forked from premiere/premiere-libtorrent
add some missing documentation. undeprecate error_file_metadata ahead of master undeprecating it
This commit is contained in:
parent
47bd25230c
commit
7878f68370
|
@ -470,3 +470,4 @@ libFuzzer
|
||||||
clang's
|
clang's
|
||||||
prev
|
prev
|
||||||
Dreik's
|
Dreik's
|
||||||
|
ctx
|
||||||
|
|
|
@ -152,6 +152,8 @@ TORRENT_VERSION_NAMESPACE_2
|
||||||
// to the session (if DHT is enabled). The hostname may be an IP address.
|
// to the session (if DHT is enabled). The hostname may be an IP address.
|
||||||
aux::noexcept_movable<std::vector<std::pair<std::string, int>>> dht_nodes;
|
aux::noexcept_movable<std::vector<std::pair<std::string, int>>> dht_nodes;
|
||||||
|
|
||||||
|
// 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.
|
||||||
std::string name;
|
std::string name;
|
||||||
|
|
||||||
// the path where the torrent is or will be stored.
|
// the path where the torrent is or will be stored.
|
||||||
|
@ -236,6 +238,8 @@ TORRENT_VERSION_NAMESPACE_2
|
||||||
int max_uploads = -1;
|
int max_uploads = -1;
|
||||||
int max_connections = -1;
|
int max_connections = -1;
|
||||||
|
|
||||||
|
// the upload and download rate limits for this torrent, specified in
|
||||||
|
// bytes per second. -1 means unlimited.
|
||||||
int upload_limit = -1;
|
int upload_limit = -1;
|
||||||
int download_limit = -1;
|
int download_limit = -1;
|
||||||
|
|
||||||
|
@ -329,6 +333,8 @@ TORRENT_VERSION_NAMESPACE_2
|
||||||
// applied before the torrent is added.
|
// applied before the torrent is added.
|
||||||
aux::noexcept_movable<std::map<file_index_t, std::string>> renamed_files;
|
aux::noexcept_movable<std::map<file_index_t, std::string>> renamed_files;
|
||||||
|
|
||||||
|
// the posix time of the last time payload was received or sent for this
|
||||||
|
// torrent, respectively.
|
||||||
std::time_t last_download = 0;
|
std::time_t last_download = 0;
|
||||||
std::time_t last_upload = 0;
|
std::time_t last_upload = 0;
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,7 @@ namespace libtorrent {
|
||||||
#endif
|
#endif
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
// hidden
|
||||||
alert(alert const& rhs) = delete;
|
alert(alert const& rhs) = delete;
|
||||||
alert& operator=(alert const&) = delete;
|
alert& operator=(alert const&) = delete;
|
||||||
alert(alert&& rhs) noexcept = default;
|
alert(alert&& rhs) noexcept = default;
|
||||||
|
|
|
@ -84,6 +84,7 @@ namespace libtorrent {
|
||||||
// this constant represents "max_alert_index" + 1
|
// this constant represents "max_alert_index" + 1
|
||||||
constexpr int num_alert_types = 96;
|
constexpr int num_alert_types = 96;
|
||||||
|
|
||||||
|
// internal
|
||||||
enum alert_priority
|
enum alert_priority
|
||||||
{
|
{
|
||||||
alert_priority_normal = 0,
|
alert_priority_normal = 0,
|
||||||
|
@ -2538,6 +2539,8 @@ TORRENT_VERSION_NAMESPACE_2
|
||||||
peer_request req;
|
peer_request req;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// debug logging of the DHT when dht_log_notification is set in the alert
|
||||||
|
// mask.
|
||||||
struct TORRENT_EXPORT dht_log_alert final : alert
|
struct TORRENT_EXPORT dht_log_alert final : alert
|
||||||
{
|
{
|
||||||
enum dht_module_t
|
enum dht_module_t
|
||||||
|
@ -2608,6 +2611,7 @@ TORRENT_VERSION_NAMESPACE_2
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Posted when we receive a response to a DHT get_peers request.
|
||||||
struct TORRENT_EXPORT dht_get_peers_reply_alert final : alert
|
struct TORRENT_EXPORT dht_get_peers_reply_alert final : alert
|
||||||
{
|
{
|
||||||
dht_get_peers_reply_alert(aux::stack_allocator& alloc
|
dht_get_peers_reply_alert(aux::stack_allocator& alloc
|
||||||
|
@ -2736,6 +2740,9 @@ TORRENT_VERSION_NAMESPACE_2
|
||||||
aux::allocation_slot m_msg_idx;
|
aux::allocation_slot m_msg_idx;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 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 TORRENT_EXPORT dht_live_nodes_alert final : alert
|
struct TORRENT_EXPORT dht_live_nodes_alert final : alert
|
||||||
{
|
{
|
||||||
dht_live_nodes_alert(aux::stack_allocator& alloc
|
dht_live_nodes_alert(aux::stack_allocator& alloc
|
||||||
|
@ -2747,8 +2754,10 @@ TORRENT_VERSION_NAMESPACE_2
|
||||||
static constexpr alert_category_t static_category = alert::dht_notification;
|
static constexpr alert_category_t static_category = alert::dht_notification;
|
||||||
std::string message() const override;
|
std::string message() const override;
|
||||||
|
|
||||||
|
// the local DHT node's node-ID this routing table belongs to
|
||||||
sha1_hash node_id;
|
sha1_hash node_id;
|
||||||
|
|
||||||
|
// the number of nodes in the routing table and the actual nodes.
|
||||||
int num_nodes() const;
|
int num_nodes() const;
|
||||||
std::vector<std::pair<sha1_hash, udp::endpoint>> nodes() const;
|
std::vector<std::pair<sha1_hash, udp::endpoint>> nodes() const;
|
||||||
|
|
||||||
|
@ -2778,6 +2787,8 @@ TORRENT_VERSION_NAMESPACE_2
|
||||||
std::string message() const override;
|
std::string message() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// posted as a response to a call to session::dht_sample_infohashes() with
|
||||||
|
// the information from the DHT response message.
|
||||||
struct TORRENT_EXPORT dht_sample_infohashes_alert final : alert
|
struct TORRENT_EXPORT dht_sample_infohashes_alert final : alert
|
||||||
{
|
{
|
||||||
dht_sample_infohashes_alert(aux::stack_allocator& alloc
|
dht_sample_infohashes_alert(aux::stack_allocator& alloc
|
||||||
|
@ -2792,8 +2803,10 @@ TORRENT_VERSION_NAMESPACE_2
|
||||||
|
|
||||||
std::string message() const override;
|
std::string message() const override;
|
||||||
|
|
||||||
|
// the node the request was sent to (and this response was received from)
|
||||||
aux::noexcept_movable<udp::endpoint> endpoint;
|
aux::noexcept_movable<udp::endpoint> endpoint;
|
||||||
|
|
||||||
|
// the interval to wait before making another request to this node
|
||||||
time_duration const interval;
|
time_duration const interval;
|
||||||
|
|
||||||
// This field indicates how many info-hash keys are currently in the node's storage.
|
// This field indicates how many info-hash keys are currently in the node's storage.
|
||||||
|
@ -2801,6 +2814,9 @@ TORRENT_VERSION_NAMESPACE_2
|
||||||
// indexer may obtain additional samples after waiting out the interval.
|
// indexer may obtain additional samples after waiting out the interval.
|
||||||
int const num_infohashes;
|
int const num_infohashes;
|
||||||
|
|
||||||
|
// 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()``.
|
||||||
int num_samples() const;
|
int num_samples() const;
|
||||||
std::vector<sha1_hash> samples() const;
|
std::vector<sha1_hash> samples() const;
|
||||||
|
|
||||||
|
|
|
@ -94,11 +94,12 @@ namespace libtorrent {
|
||||||
// view).
|
// view).
|
||||||
|
|
||||||
// if this tracker has returned scrape data, these fields are filled in
|
// if this tracker has returned scrape data, these fields are filled in
|
||||||
// with valid numbers. Otherwise they are set to -1. the number of
|
// with valid numbers. Otherwise they are set to -1. ``incomplete`` counts
|
||||||
// current downloaders
|
// 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.
|
||||||
int scrape_incomplete = -1;
|
int scrape_incomplete = -1;
|
||||||
int scrape_complete = -1;
|
int scrape_complete = -1;
|
||||||
|
|
||||||
int scrape_downloaded = -1;
|
int scrape_downloaded = -1;
|
||||||
|
|
||||||
// the number of times in a row we have failed to announce to this
|
// the number of times in a row we have failed to announce to this
|
||||||
|
@ -161,6 +162,8 @@ TORRENT_VERSION_NAMESPACE_2
|
||||||
// trackerid is sent).
|
// trackerid is sent).
|
||||||
std::string trackerid;
|
std::string trackerid;
|
||||||
|
|
||||||
|
// each local listen socket (endpoint) will announce to the tracker. This
|
||||||
|
// list contains state per endpoint.
|
||||||
std::vector<announce_endpoint> endpoints;
|
std::vector<announce_endpoint> endpoints;
|
||||||
|
|
||||||
// the tier this tracker belongs to
|
// the tier this tracker belongs to
|
||||||
|
|
|
@ -261,6 +261,7 @@ struct TORRENT_EXPORT bdecode_node
|
||||||
, int token_limit);
|
, int token_limit);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// hidden
|
||||||
TORRENT_EXPORT friend bdecode_node bdecode(span<char const> buffer
|
TORRENT_EXPORT friend bdecode_node bdecode(span<char const> buffer
|
||||||
, error_code& ec, int* error_pos, int depth_limit, int token_limit);
|
, error_code& ec, int* error_pos, int depth_limit, int token_limit);
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,6 @@ namespace libtorrent {
|
||||||
// query bit at ``index``. Returns true if bit is 1, otherwise false.
|
// query bit at ``index``. Returns true if bit is 1, otherwise false.
|
||||||
bool operator[](int index) const noexcept
|
bool operator[](int index) const noexcept
|
||||||
{ return get_bit(index); }
|
{ return get_bit(index); }
|
||||||
|
|
||||||
bool get_bit(int index) const noexcept
|
bool get_bit(int index) const noexcept
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(index >= 0);
|
TORRENT_ASSERT(index >= 0);
|
||||||
|
@ -104,6 +103,7 @@ namespace libtorrent {
|
||||||
// returns true if all bits in the bitfield are set
|
// returns true if all bits in the bitfield are set
|
||||||
bool all_set() const noexcept;
|
bool all_set() const noexcept;
|
||||||
|
|
||||||
|
// returns true if no bit in the bitfield is set
|
||||||
bool none_set() const noexcept
|
bool none_set() const noexcept
|
||||||
{
|
{
|
||||||
if(size() == 0) return true;
|
if(size() == 0) return true;
|
||||||
|
@ -125,6 +125,8 @@ namespace libtorrent {
|
||||||
return bits;
|
return bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// returns the number of 32 bit words are needed to represent all bits in
|
||||||
|
// this bitfield.
|
||||||
int num_words() const noexcept
|
int num_words() const noexcept
|
||||||
{
|
{
|
||||||
return (size() + 31) / 32;
|
return (size() + 31) / 32;
|
||||||
|
@ -133,7 +135,8 @@ namespace libtorrent {
|
||||||
// returns true if the bitfield has zero size.
|
// returns true if the bitfield has zero size.
|
||||||
bool empty() const noexcept { return size() == 0; }
|
bool empty() const noexcept { return size() == 0; }
|
||||||
|
|
||||||
// returns a pointer to the internal buffer of the bitfield.
|
// returns a pointer to the internal buffer of the bitfield, or
|
||||||
|
// ``nullptr`` if it's empty.
|
||||||
char const* data() const noexcept { return m_buf ? reinterpret_cast<char const*>(&m_buf[1]) : nullptr; }
|
char const* data() const noexcept { return m_buf ? reinterpret_cast<char const*>(&m_buf[1]) : nullptr; }
|
||||||
char* data() noexcept { return m_buf ? reinterpret_cast<char*>(&m_buf[1]) : nullptr; }
|
char* data() noexcept { return m_buf ? reinterpret_cast<char*>(&m_buf[1]) : nullptr; }
|
||||||
|
|
||||||
|
@ -142,16 +145,16 @@ namespace libtorrent {
|
||||||
char const* bytes() const { return data(); }
|
char const* bytes() const { return data(); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// assignment operator
|
// hidden
|
||||||
bitfield& operator=(bitfield const& rhs)
|
bitfield& operator=(bitfield const& rhs)
|
||||||
{
|
{
|
||||||
if (&rhs == this) return *this;
|
if (&rhs == this) return *this;
|
||||||
assign(rhs.data(), rhs.size());
|
assign(rhs.data(), rhs.size());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bitfield& operator=(bitfield&& rhs) noexcept = default;
|
bitfield& operator=(bitfield&& rhs) noexcept = default;
|
||||||
|
|
||||||
|
// swaps the bit-fields two variables refer to
|
||||||
void swap(bitfield& rhs) noexcept
|
void swap(bitfield& rhs) noexcept
|
||||||
{
|
{
|
||||||
std::swap(m_buf, rhs.m_buf);
|
std::swap(m_buf, rhs.m_buf);
|
||||||
|
@ -159,9 +162,14 @@ namespace libtorrent {
|
||||||
|
|
||||||
// count the number of bits in the bitfield that are set to 1.
|
// count the number of bits in the bitfield that are set to 1.
|
||||||
int count() const noexcept;
|
int count() const noexcept;
|
||||||
|
|
||||||
|
// returns the index of the first set bit in the bitfield, i.e. 1 bit.
|
||||||
int find_first_set() const noexcept;
|
int find_first_set() const noexcept;
|
||||||
|
|
||||||
|
// returns the index to the last cleared bit in the bitfield, i.e. 0 bit.
|
||||||
int find_last_clear() const noexcept;
|
int find_last_clear() const noexcept;
|
||||||
|
|
||||||
|
// internal
|
||||||
struct const_iterator
|
struct const_iterator
|
||||||
{
|
{
|
||||||
friend struct bitfield;
|
friend struct bitfield;
|
||||||
|
@ -220,6 +228,7 @@ namespace libtorrent {
|
||||||
std::uint32_t bit = 0x80000000;
|
std::uint32_t bit = 0x80000000;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// internal
|
||||||
const_iterator begin() const noexcept { return const_iterator(m_buf ? buf() : nullptr, 0); }
|
const_iterator begin() const noexcept { return const_iterator(m_buf ? buf() : nullptr, 0); }
|
||||||
const_iterator end() const noexcept
|
const_iterator end() const noexcept
|
||||||
{
|
{
|
||||||
|
|
|
@ -340,6 +340,7 @@ namespace aux {
|
||||||
mutable std::uint8_t m_type_queried:1;
|
mutable std::uint8_t m_type_queried:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// hidden
|
||||||
TORRENT_EXPORT bool operator==(entry const& lhs, entry const& rhs);
|
TORRENT_EXPORT bool operator==(entry const& lhs, entry const& rhs);
|
||||||
inline bool operator!=(entry const& lhs, entry const& rhs) { return !(lhs == rhs); }
|
inline bool operator!=(entry const& lhs, entry const& rhs) { return !(lhs == rhs); }
|
||||||
|
|
||||||
|
|
|
@ -514,18 +514,24 @@ namespace libtorrent {
|
||||||
// error happened on
|
// error happened on
|
||||||
struct TORRENT_EXPORT storage_error
|
struct TORRENT_EXPORT storage_error
|
||||||
{
|
{
|
||||||
|
// hidden
|
||||||
storage_error(): file_idx(-1), operation(operation_t::unknown) {}
|
storage_error(): file_idx(-1), operation(operation_t::unknown) {}
|
||||||
explicit storage_error(error_code e): ec(e), file_idx(-1), operation(operation_t::unknown) {}
|
explicit storage_error(error_code e): ec(e), file_idx(-1), operation(operation_t::unknown) {}
|
||||||
|
|
||||||
|
// explicitly converts to true if this object represents an error, and
|
||||||
|
// false if it does not.
|
||||||
explicit operator bool() const { return ec.value() != 0; }
|
explicit operator bool() const { return ec.value() != 0; }
|
||||||
|
|
||||||
// the error that occurred
|
// the error that occurred
|
||||||
error_code ec;
|
error_code ec;
|
||||||
|
|
||||||
|
// 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.
|
||||||
file_index_t file() const { return file_index_t(file_idx); }
|
file_index_t file() const { return file_index_t(file_idx); }
|
||||||
void file(file_index_t f) { file_idx = static_cast<int>(f); }
|
void file(file_index_t f) { file_idx = static_cast<int>(f); }
|
||||||
|
|
||||||
// the file the error occurred on
|
// internal
|
||||||
std::int32_t file_idx:24;
|
std::int32_t file_idx:24;
|
||||||
|
|
||||||
// A code from file_operation_t enum, indicating what
|
// A code from file_operation_t enum, indicating what
|
||||||
|
|
|
@ -383,6 +383,9 @@ namespace libtorrent {
|
||||||
piece_index_t end_piece() const
|
piece_index_t end_piece() const
|
||||||
{ return piece_index_t(m_num_pieces); }
|
{ return piece_index_t(m_num_pieces); }
|
||||||
|
|
||||||
|
// 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).
|
||||||
piece_index_t last_piece() const
|
piece_index_t last_piece() const
|
||||||
{ return piece_index_t(m_num_pieces - 1); }
|
{ return piece_index_t(m_num_pieces - 1); }
|
||||||
|
|
||||||
|
@ -481,6 +484,10 @@ namespace libtorrent {
|
||||||
// target string associated with it.
|
// target string associated with it.
|
||||||
static constexpr file_flags_t flag_symlink = 3_bit;
|
static constexpr file_flags_t flag_symlink = 3_bit;
|
||||||
|
|
||||||
|
// returns all directories used in the torrent. Files in the torrent are
|
||||||
|
// located in one of these directories. This is not a tree, it's a flat
|
||||||
|
// list of all *leaf* directories. i.e. the union of the parent paths of
|
||||||
|
// all files.
|
||||||
std::vector<std::string> const& paths() const { return m_paths; }
|
std::vector<std::string> const& paths() const { return m_paths; }
|
||||||
|
|
||||||
// returns a bitmask of flags from file_flags_t that apply
|
// returns a bitmask of flags from file_flags_t that apply
|
||||||
|
|
|
@ -44,7 +44,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <libtorrent/string_view.hpp>
|
#include <libtorrent/string_view.hpp>
|
||||||
|
|
||||||
namespace libtorrent {
|
namespace libtorrent {
|
||||||
|
|
||||||
class entry;
|
class entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,20 +74,17 @@ namespace libtorrent { namespace dht {
|
||||||
// constructor function is called dht_default_storage_constructor().
|
// constructor function is called dht_default_storage_constructor().
|
||||||
// You should know that if this storage becomes full of DHT items,
|
// You should know that if this storage becomes full of DHT items,
|
||||||
// the current implementation could degrade in performance.
|
// the current implementation could degrade in performance.
|
||||||
//
|
|
||||||
struct TORRENT_EXPORT dht_storage_interface
|
struct TORRENT_EXPORT dht_storage_interface
|
||||||
{
|
{
|
||||||
#if TORRENT_ABI_VERSION == 1
|
#if TORRENT_ABI_VERSION == 1
|
||||||
// This function returns the number of torrents tracked by
|
// This function returns the number of torrents tracked by
|
||||||
// the DHT at the moment. It's used to fill session_status.
|
// the DHT at the moment. It's used to fill session_status.
|
||||||
// It's deprecated.
|
// It's deprecated.
|
||||||
//
|
|
||||||
virtual size_t num_torrents() const = 0;
|
virtual size_t num_torrents() const = 0;
|
||||||
|
|
||||||
// This function returns the sum of all of peers per torrent
|
// This function returns the sum of all of peers per torrent
|
||||||
// tracker byt the DHT at the moment.
|
// tracker byt the DHT at the moment.
|
||||||
// It's deprecated.
|
// It's deprecated.
|
||||||
//
|
|
||||||
virtual size_t num_peers() const = 0;
|
virtual size_t num_peers() const = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -109,10 +105,12 @@ namespace libtorrent { namespace dht {
|
||||||
//
|
//
|
||||||
// If the scrape parameter is true, you should fill these keys:
|
// If the scrape parameter is true, you should fill these keys:
|
||||||
//
|
//
|
||||||
// peers["BFpe"] - with the standard bit representation of a
|
// peers["BFpe"]
|
||||||
// 256 bloom filter containing the downloaders
|
// with the standard bit representation of a
|
||||||
// peers["BFsd"] - with the standard bit representation of a
|
// 256 bloom filter containing the downloaders
|
||||||
// 256 bloom filter containing the seeders
|
// peers["BFsd"]
|
||||||
|
// with the standard bit representation of a
|
||||||
|
// 256 bloom filter containing the seeders
|
||||||
//
|
//
|
||||||
// If the scrape parameter is false, you should fill the
|
// If the scrape parameter is false, you should fill the
|
||||||
// key peers["values"] with a list containing a subset of
|
// key peers["values"] with a list containing a subset of
|
||||||
|
@ -122,7 +120,6 @@ namespace libtorrent { namespace dht {
|
||||||
//
|
//
|
||||||
// returns true if the maximum number of peers are stored
|
// returns true if the maximum number of peers are stored
|
||||||
// for this info_hash.
|
// for this info_hash.
|
||||||
//
|
|
||||||
virtual bool get_peers(sha1_hash const& info_hash
|
virtual bool get_peers(sha1_hash const& info_hash
|
||||||
, bool noseed, bool scrape, address const& requester
|
, bool noseed, bool scrape, address const& requester
|
||||||
, entry& peers) const = 0;
|
, entry& peers) const = 0;
|
||||||
|
@ -136,7 +133,6 @@ namespace libtorrent { namespace dht {
|
||||||
// the announce_peer DHT message. The length of this value should
|
// the announce_peer DHT message. The length of this value should
|
||||||
// have a maximum length in the final storage. The default
|
// have a maximum length in the final storage. The default
|
||||||
// implementation truncate the value for a maximum of 50 characters.
|
// implementation truncate the value for a maximum of 50 characters.
|
||||||
//
|
|
||||||
virtual void announce_peer(sha1_hash const& info_hash
|
virtual void announce_peer(sha1_hash const& info_hash
|
||||||
, tcp::endpoint const& endp
|
, tcp::endpoint const& endp
|
||||||
, string_view name, bool seed) = 0;
|
, string_view name, bool seed) = 0;
|
||||||
|
@ -148,7 +144,6 @@ namespace libtorrent { namespace dht {
|
||||||
//
|
//
|
||||||
// returns true if the item is found and the data is returned
|
// returns true if the item is found and the data is returned
|
||||||
// inside the (entry) out parameter item.
|
// inside the (entry) out parameter item.
|
||||||
//
|
|
||||||
virtual bool get_immutable_item(sha1_hash const& target
|
virtual bool get_immutable_item(sha1_hash const& target
|
||||||
, entry& item) const = 0;
|
, entry& item) const = 0;
|
||||||
|
|
||||||
|
@ -159,7 +154,6 @@ namespace libtorrent { namespace dht {
|
||||||
// This data can be stored only if the target is not already
|
// This data can be stored only if the target is not already
|
||||||
// present. The implementation should consider the value of
|
// present. The implementation should consider the value of
|
||||||
// dht_settings::max_dht_items.
|
// dht_settings::max_dht_items.
|
||||||
//
|
|
||||||
virtual void put_immutable_item(sha1_hash const& target
|
virtual void put_immutable_item(sha1_hash const& target
|
||||||
, span<char const> buf
|
, span<char const> buf
|
||||||
, address const& addr) = 0;
|
, address const& addr) = 0;
|
||||||
|
@ -168,7 +162,6 @@ namespace libtorrent { namespace dht {
|
||||||
//
|
//
|
||||||
// returns true if the item is found and the data is returned
|
// returns true if the item is found and the data is returned
|
||||||
// inside the out parameter seq.
|
// inside the out parameter seq.
|
||||||
//
|
|
||||||
virtual bool get_mutable_item_seq(sha1_hash const& target
|
virtual bool get_mutable_item_seq(sha1_hash const& target
|
||||||
, sequence_number& seq) const = 0;
|
, sequence_number& seq) const = 0;
|
||||||
|
|
||||||
|
@ -184,7 +177,6 @@ namespace libtorrent { namespace dht {
|
||||||
//
|
//
|
||||||
// returns true if the item is found and the data is returned
|
// returns true if the item is found and the data is returned
|
||||||
// inside the (entry) out parameter item.
|
// inside the (entry) out parameter item.
|
||||||
//
|
|
||||||
virtual bool get_mutable_item(sha1_hash const& target
|
virtual bool get_mutable_item(sha1_hash const& target
|
||||||
, sequence_number seq, bool force_fill
|
, sequence_number seq, bool force_fill
|
||||||
, entry& item) const = 0;
|
, entry& item) const = 0;
|
||||||
|
@ -196,7 +188,6 @@ namespace libtorrent { namespace dht {
|
||||||
// The sequence number should be checked if the item is already
|
// The sequence number should be checked if the item is already
|
||||||
// present. The implementation should consider the value of
|
// present. The implementation should consider the value of
|
||||||
// dht_settings::max_dht_items.
|
// dht_settings::max_dht_items.
|
||||||
//
|
|
||||||
virtual void put_mutable_item(sha1_hash const& target
|
virtual void put_mutable_item(sha1_hash const& target
|
||||||
, span<char const> buf
|
, span<char const> buf
|
||||||
, signature const& sig
|
, signature const& sig
|
||||||
|
@ -217,7 +208,6 @@ namespace libtorrent { namespace dht {
|
||||||
// and modify the actual sample to put in ``item``
|
// and modify the actual sample to put in ``item``
|
||||||
//
|
//
|
||||||
// returns the number of info-hashes in the sample.
|
// returns the number of info-hashes in the sample.
|
||||||
//
|
|
||||||
virtual int get_infohashes_sample(entry& item) = 0;
|
virtual int get_infohashes_sample(entry& item) = 0;
|
||||||
|
|
||||||
// This function is called periodically (non-constant frequency).
|
// This function is called periodically (non-constant frequency).
|
||||||
|
@ -225,17 +215,21 @@ namespace libtorrent { namespace dht {
|
||||||
// For implementers:
|
// For implementers:
|
||||||
// Use this functions for expire peers or items or any other
|
// Use this functions for expire peers or items or any other
|
||||||
// storage cleanup.
|
// storage cleanup.
|
||||||
//
|
|
||||||
virtual void tick() = 0;
|
virtual void tick() = 0;
|
||||||
|
|
||||||
|
// return stats counters for the store
|
||||||
virtual dht_storage_counters counters() const = 0;
|
virtual dht_storage_counters counters() const = 0;
|
||||||
|
|
||||||
|
// hidden
|
||||||
virtual ~dht_storage_interface() {}
|
virtual ~dht_storage_interface() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
using dht_storage_constructor_type
|
using dht_storage_constructor_type
|
||||||
= std::function<std::unique_ptr<dht_storage_interface>(dht_settings const& settings)>;
|
= std::function<std::unique_ptr<dht_storage_interface>(dht_settings 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.
|
||||||
TORRENT_EXPORT std::unique_ptr<dht_storage_interface> dht_default_storage_constructor(
|
TORRENT_EXPORT std::unique_ptr<dht_storage_interface> dht_default_storage_constructor(
|
||||||
dht_settings const& settings);
|
dht_settings const& settings);
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ namespace libtorrent {
|
||||||
// is based on the peer's IP address).
|
// is based on the peer's IP address).
|
||||||
struct TORRENT_EXPORT peer_class_type_filter
|
struct TORRENT_EXPORT peer_class_type_filter
|
||||||
{
|
{
|
||||||
|
// hidden
|
||||||
peer_class_type_filter()
|
peer_class_type_filter()
|
||||||
{
|
{
|
||||||
m_peer_class_type_mask.fill(0xffffffff);
|
m_peer_class_type_mask.fill(0xffffffff);
|
||||||
|
|
|
@ -232,6 +232,8 @@ TORRENT_VERSION_NAMESPACE_2
|
||||||
// which client the peer is using. See identify_client()_
|
// which client the peer is using. See identify_client()_
|
||||||
peer_id pid;
|
peer_id pid;
|
||||||
|
|
||||||
|
// the number of bytes we have requested from this peer, but not yet
|
||||||
|
// received.
|
||||||
int queue_bytes;
|
int queue_bytes;
|
||||||
|
|
||||||
// the number of seconds until the current front piece request will time
|
// the number of seconds until the current front piece request will time
|
||||||
|
|
|
@ -142,6 +142,7 @@ namespace aux {
|
||||||
session_params(settings_pack const& sp
|
session_params(settings_pack const& sp
|
||||||
, std::vector<std::shared_ptr<plugin>> exts);
|
, std::vector<std::shared_ptr<plugin>> exts);
|
||||||
|
|
||||||
|
// hidden
|
||||||
session_params(session_params const&) = default;
|
session_params(session_params const&) = default;
|
||||||
session_params(session_params&&) = default;
|
session_params(session_params&&) = default;
|
||||||
session_params& operator=(session_params const&) = default;
|
session_params& operator=(session_params const&) = default;
|
||||||
|
|
|
@ -71,13 +71,16 @@ namespace libtorrent {
|
||||||
friend class session;
|
friend class session;
|
||||||
friend struct aux::session_impl;
|
friend struct aux::session_impl;
|
||||||
|
|
||||||
session_handle() {}
|
// hidden
|
||||||
|
session_handle() = default;
|
||||||
session_handle(session_handle const& t) = default;
|
session_handle(session_handle const& t) = default;
|
||||||
session_handle(session_handle&& t) noexcept = default;
|
session_handle(session_handle&& t) noexcept = default;
|
||||||
session_handle& operator=(session_handle const&) = default;
|
session_handle& operator=(session_handle const&) = default;
|
||||||
session_handle& operator=(session_handle&&) noexcept = default;
|
session_handle& operator=(session_handle&&) noexcept = default;
|
||||||
|
|
||||||
|
// 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.
|
||||||
bool is_valid() const { return !m_impl.expired(); }
|
bool is_valid() const { return !m_impl.expired(); }
|
||||||
|
|
||||||
// saves settings (i.e. the settings_pack)
|
// saves settings (i.e. the settings_pack)
|
||||||
|
|
|
@ -74,6 +74,8 @@ namespace aux {
|
||||||
, std::vector<void(aux::session_impl::*)()>* callbacks = nullptr);
|
, std::vector<void(aux::session_impl::*)()>* callbacks = nullptr);
|
||||||
TORRENT_EXTRA_EXPORT void run_all_updates(aux::session_impl& ses);
|
TORRENT_EXTRA_EXPORT void run_all_updates(aux::session_impl& ses);
|
||||||
|
|
||||||
|
// converts a setting integer (from the enums string_types, int_types or
|
||||||
|
// bool_types) to a string, and vice versa.
|
||||||
TORRENT_EXPORT int setting_by_name(string_view name);
|
TORRENT_EXPORT int setting_by_name(string_view name);
|
||||||
TORRENT_EXPORT char const* name_for_setting(int s);
|
TORRENT_EXPORT char const* name_for_setting(int s);
|
||||||
|
|
||||||
|
@ -95,26 +97,38 @@ namespace aux {
|
||||||
, aux::session_settings_single_thread&
|
, aux::session_settings_single_thread&
|
||||||
, std::vector<void(aux::session_impl::*)()>*);
|
, std::vector<void(aux::session_impl::*)()>*);
|
||||||
|
|
||||||
|
// hidden
|
||||||
settings_pack() = default;
|
settings_pack() = default;
|
||||||
settings_pack(settings_pack const&) = default;
|
settings_pack(settings_pack const&) = default;
|
||||||
settings_pack(settings_pack&&) noexcept = default;
|
settings_pack(settings_pack&&) noexcept = default;
|
||||||
settings_pack& operator=(settings_pack const&) = default;
|
settings_pack& operator=(settings_pack const&) = default;
|
||||||
settings_pack& operator=(settings_pack&&) noexcept = default;
|
settings_pack& operator=(settings_pack&&) noexcept = default;
|
||||||
|
|
||||||
|
// 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.
|
||||||
void set_str(int name, std::string val);
|
void set_str(int name, std::string val);
|
||||||
void set_int(int name, int val);
|
void set_int(int name, int val);
|
||||||
void set_bool(int name, bool val);
|
void set_bool(int name, bool val);
|
||||||
bool has_val(int name) const;
|
|
||||||
template <typename Type, typename Tag>
|
template <typename Type, typename Tag>
|
||||||
void set_int(int name, flags::bitfield_flag<Type, Tag> const val)
|
void set_int(int name, flags::bitfield_flag<Type, Tag> const val)
|
||||||
{ set_int(name, static_cast<int>(static_cast<Type>(val))); }
|
{ set_int(name, static_cast<int>(static_cast<Type>(val))); }
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
bool has_val(int name) const;
|
||||||
|
|
||||||
// clear the settings pack from all settings
|
// clear the settings pack from all settings
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
// clear a specific setting from the pack
|
// clear a specific setting from the pack
|
||||||
void clear(int name);
|
void clear(int name);
|
||||||
|
|
||||||
|
// 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.
|
||||||
std::string const& get_str(int name) const;
|
std::string const& get_str(int name) const;
|
||||||
int get_int(int name) const;
|
int get_int(int name) const;
|
||||||
bool get_bool(int name) const;
|
bool get_bool(int name) const;
|
||||||
|
@ -130,6 +144,8 @@ namespace aux {
|
||||||
index_mask = 0x3fff
|
index_mask = 0x3fff
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// enumeration values naming string settings in the pack. To be used with
|
||||||
|
// get_str() and set_str().
|
||||||
enum string_types
|
enum string_types
|
||||||
{
|
{
|
||||||
// this is the client identification to the tracker. The recommended
|
// this is the client identification to the tracker. The recommended
|
||||||
|
@ -250,6 +266,8 @@ namespace aux {
|
||||||
max_string_setting_internal
|
max_string_setting_internal
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// enumeration values naming boolean settings in the pack. To be used with
|
||||||
|
// get_bool() and set_bool().
|
||||||
enum bool_types
|
enum bool_types
|
||||||
{
|
{
|
||||||
// determines if connections from the same IP address as existing
|
// determines if connections from the same IP address as existing
|
||||||
|
@ -752,6 +770,8 @@ namespace aux {
|
||||||
max_bool_setting_internal
|
max_bool_setting_internal
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// enumeration values naming integer settings in the pack. To be used with
|
||||||
|
// get_int() and set_int().
|
||||||
enum int_types
|
enum int_types
|
||||||
{
|
{
|
||||||
// ``tracker_completion_timeout`` is the number of seconds the tracker
|
// ``tracker_completion_timeout`` is the number of seconds the tracker
|
||||||
|
|
|
@ -248,6 +248,7 @@ namespace aux {
|
||||||
// i.e. is_valid() will return false.
|
// i.e. is_valid() will return false.
|
||||||
torrent_handle() noexcept = default;
|
torrent_handle() noexcept = default;
|
||||||
|
|
||||||
|
// hidden
|
||||||
torrent_handle(torrent_handle const& t) = default;
|
torrent_handle(torrent_handle const& t) = default;
|
||||||
torrent_handle(torrent_handle&& t) noexcept = default;
|
torrent_handle(torrent_handle&& t) noexcept = default;
|
||||||
torrent_handle& operator=(torrent_handle const&) = default;
|
torrent_handle& operator=(torrent_handle const&) = default;
|
||||||
|
@ -1239,6 +1240,8 @@ namespace aux {
|
||||||
bool operator<(const torrent_handle& h) const
|
bool operator<(const torrent_handle& h) const
|
||||||
{ return m_torrent.owner_before(h.m_torrent); }
|
{ return m_torrent.owner_before(h.m_torrent); }
|
||||||
|
|
||||||
|
// returns a unique identifier for this torrent. It's not a dense index.
|
||||||
|
// It's not preserved across sessions.
|
||||||
std::uint32_t id() const
|
std::uint32_t id() const
|
||||||
{
|
{
|
||||||
uintptr_t ret = reinterpret_cast<uintptr_t>(m_torrent.lock().get());
|
uintptr_t ret = reinterpret_cast<uintptr_t>(m_torrent.lock().get());
|
||||||
|
|
|
@ -74,6 +74,7 @@ namespace libtorrent {
|
||||||
|
|
||||||
using headers_t = std::vector<std::pair<std::string, std::string>>;
|
using headers_t = std::vector<std::pair<std::string, std::string>>;
|
||||||
|
|
||||||
|
// hidden
|
||||||
web_seed_entry(std::string const& url_, type_t type_
|
web_seed_entry(std::string const& url_, type_t type_
|
||||||
, std::string const& auth_ = std::string()
|
, std::string const& auth_ = std::string()
|
||||||
, headers_t const& extra_headers_ = headers_t());
|
, headers_t const& extra_headers_ = headers_t());
|
||||||
|
@ -125,6 +126,7 @@ namespace libtorrent {
|
||||||
int max_decode_tokens = 2000000;
|
int max_decode_tokens = 2000000;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// the torrent_info class holds the information found in a .torrent file.
|
||||||
class TORRENT_EXPORT torrent_info
|
class TORRENT_EXPORT torrent_info
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -141,6 +141,12 @@ TORRENT_VERSION_NAMESPACE_2
|
||||||
// the index of that file in the .torrent file.
|
// the index of that file in the .torrent file.
|
||||||
error_code errc;
|
error_code errc;
|
||||||
|
|
||||||
|
// 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;
|
||||||
file_index_t error_file = torrent_status::error_file_none;
|
file_index_t error_file = torrent_status::error_file_none;
|
||||||
|
|
||||||
// special values for error_file to describe which file or component
|
// special values for error_file to describe which file or component
|
||||||
|
@ -151,11 +157,11 @@ TORRENT_VERSION_NAMESPACE_2
|
||||||
// the error occurred setting up the SSL context
|
// the error occurred setting up the SSL context
|
||||||
static constexpr file_index_t error_file_ssl_ctx{-3};
|
static constexpr file_index_t error_file_ssl_ctx{-3};
|
||||||
|
|
||||||
#if TORRENT_ABI_VERSION == 1
|
|
||||||
// the error occurred while loading the .torrent file via the user
|
// the error occurred while loading the .torrent file via the user
|
||||||
// supplied load function
|
// supplied load function
|
||||||
static constexpr file_index_t TORRENT_DEPRECATED error_file_metadata{-4};
|
static constexpr file_index_t error_file_metadata{-4};
|
||||||
|
|
||||||
|
#if TORRENT_ABI_VERSION == 1
|
||||||
// the error occurred on m_url
|
// the error occurred on m_url
|
||||||
static constexpr file_index_t TORRENT_DEPRECATED error_file_url{-2};
|
static constexpr file_index_t TORRENT_DEPRECATED error_file_url{-2};
|
||||||
#endif
|
#endif
|
||||||
|
@ -559,9 +565,19 @@ TORRENT_VERSION_NAMESPACE_2
|
||||||
// the info-hash for this torrent
|
// the info-hash for this torrent
|
||||||
sha1_hash info_hash;
|
sha1_hash info_hash;
|
||||||
|
|
||||||
|
// the timestamps of the last time this torrent uploaded or downloaded
|
||||||
|
// payload to any peer.
|
||||||
time_point last_upload;
|
time_point last_upload;
|
||||||
time_point last_download;
|
time_point last_download;
|
||||||
|
|
||||||
|
// 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.
|
||||||
seconds active_duration;
|
seconds active_duration;
|
||||||
seconds finished_duration;
|
seconds finished_duration;
|
||||||
seconds seeding_duration;
|
seconds seeding_duration;
|
||||||
|
|
|
@ -2492,7 +2492,7 @@ namespace {
|
||||||
aux::vector<sha1_hash> samples;
|
aux::vector<sha1_hash> samples;
|
||||||
samples.resize(m_num_samples);
|
samples.resize(m_num_samples);
|
||||||
|
|
||||||
const char *ptr = m_alloc.get().ptr(m_samples_idx);
|
char const* ptr = m_alloc.get().ptr(m_samples_idx);
|
||||||
std::memcpy(samples.data(), ptr, samples.size() * 20);
|
std::memcpy(samples.data(), ptr, samples.size() * 20);
|
||||||
|
|
||||||
return std::move(samples);
|
return std::move(samples);
|
||||||
|
|
|
@ -601,7 +601,7 @@ namespace libtorrent { namespace dht {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
std::vector<udp::endpoint> save_nodes(node const& dht)
|
std::vector<udp::endpoint> save_nodes(node const& dht)
|
||||||
{
|
{
|
||||||
|
@ -613,7 +613,7 @@ namespace libtorrent { namespace dht {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
dht_state dht_tracker::state() const
|
dht_state dht_tracker::state() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -6058,13 +6058,12 @@ namespace aux {
|
||||||
void session_impl::dht_sample_infohashes(udp::endpoint const& ep, sha1_hash const& target)
|
void session_impl::dht_sample_infohashes(udp::endpoint const& ep, sha1_hash const& target)
|
||||||
{
|
{
|
||||||
if (!m_dht) return;
|
if (!m_dht) return;
|
||||||
m_dht->sample_infohashes(ep, target, [this, &ep](time_duration interval
|
m_dht->sample_infohashes(ep, target, [this, ep](time_duration const interval
|
||||||
, int num, std::vector<sha1_hash> samples
|
, int const num, std::vector<sha1_hash> samples
|
||||||
, std::vector<std::pair<sha1_hash, udp::endpoint>> nodes)
|
, std::vector<std::pair<sha1_hash, udp::endpoint>> nodes)
|
||||||
{
|
{
|
||||||
if (m_alerts.should_post<dht_sample_infohashes_alert>())
|
m_alerts.emplace_alert<dht_sample_infohashes_alert>(ep
|
||||||
m_alerts.emplace_alert<dht_sample_infohashes_alert>(ep
|
, interval, num, std::move(samples), std::move(nodes));
|
||||||
, interval, num, samples, nodes);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,10 +38,10 @@ namespace libtorrent {
|
||||||
file_index_t constexpr torrent_status::error_file_ssl_ctx;
|
file_index_t constexpr torrent_status::error_file_ssl_ctx;
|
||||||
file_index_t constexpr torrent_status::error_file_exception;
|
file_index_t constexpr torrent_status::error_file_exception;
|
||||||
file_index_t constexpr torrent_status::error_file_partfile;
|
file_index_t constexpr torrent_status::error_file_partfile;
|
||||||
|
file_index_t constexpr torrent_status::error_file_metadata;
|
||||||
|
|
||||||
#if TORRENT_ABI_VERSION == 1
|
#if TORRENT_ABI_VERSION == 1
|
||||||
file_index_t constexpr torrent_status::error_file_url;
|
file_index_t constexpr torrent_status::error_file_url;
|
||||||
file_index_t constexpr torrent_status::error_file_metadata;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
torrent_status::torrent_status() noexcept {}
|
torrent_status::torrent_status() noexcept {}
|
||||||
|
|
Loading…
Reference in New Issue