| add_torrent_params.hpp | | add_torrent_params.hpp | |
| | | | |
| skipping to change at line 150 | | skipping to change at line 150 | |
| // that the files are complete, this is a way to avo
id the initial | | // that the files are complete, this is a way to avo
id the initial | |
| // file checks, and significantly reduce the startup
time. | | // file checks, and significantly reduce the startup
time. | |
| // | | // | |
| // Setting ``flag_seed_mode`` on a torrent without m
etadata (a | | // Setting ``flag_seed_mode`` on a torrent without m
etadata (a | |
| // .torrent file) is a no-op and will be ignored. | | // .torrent file) is a no-op and will be ignored. | |
| // | | // | |
| // If resume data is passed in with this torrent, th
e seed mode saved | | // If resume data is passed in with this torrent, th
e seed mode saved | |
| // in there will override the seed mode you set here
. | | // in there will override the seed mode you set here
. | |
| flag_seed_mode = 0x001, | | flag_seed_mode = 0x001, | |
| | | | |
|
| // If ``flag_override_resume_data`` is set, the ``pa | | // If ``flag_override_resume_data`` is set, flags se | |
| used``, | | t for this torrent | |
| // ``auto_managed`` and ``save_path`` of the torrent | | // in this ``add_torrent_params`` object will take p | |
| are not loaded | | recedence over | |
| // from the resume data, but the states requested by | | // whatever states are saved in the resume data. For | |
| the flags in | | instance, the | |
| // ``add_torrent_params`` will override them. | | // ``paused``, ``auto_managed``, ``sequential_downlo | |
| // | | ad``, ``seed_mode``, | |
| // If you pass in resume data, the paused state of t | | // ``super_seeding``, ``max_uploads``, ``max_connect | |
| he torrent when | | ions``, | |
| // the resume data was saved will override the pause | | // ``upload_limit`` and ``download_limit`` are all a | |
| d state you pass | | ffected by this | |
| // in here. You can override this by setting | | // flag. The intention of this flag is to have any f | |
| // ``flag_override_resume_data``. | | ield in | |
| | | // add_torrent_params configuring the torrent overri | |
| | | de the corresponding | |
| | | // configuration from the resume file, with the one | |
| | | exception of save | |
| | | // resume data, which has its own flag (for historic | |
| | | reasons). | |
| flag_override_resume_data = 0x002, | | flag_override_resume_data = 0x002, | |
| | | | |
| // If ``flag_upload_mode`` is set, the torrent will
be initialized in | | // If ``flag_upload_mode`` is set, the torrent will
be initialized in | |
| // upload-mode, which means it will not make any pie
ce requests. This | | // upload-mode, which means it will not make any pie
ce requests. This | |
| // state is typically entered on disk I/O errors, an
d if the torrent | | // state is typically entered on disk I/O errors, an
d if the torrent | |
| // is also auto managed, it will be taken out of thi
s state | | // is also auto managed, it will be taken out of thi
s state | |
| // periodically. This mode can be used to avoid race
conditions when | | // periodically. This mode can be used to avoid race
conditions when | |
| // adjusting priorities of pieces before allowing th
e torrent to start | | // adjusting priorities of pieces before allowing th
e torrent to start | |
| // downloading. | | // downloading. | |
| // | | // | |
| | | | |
| skipping to change at line 283 | | skipping to change at line 284 | |
| | | | |
| // url seeds to be added to the torrent (`BEP 17`_). | | // url seeds to be added to the torrent (`BEP 17`_). | |
| std::vector<std::string> url_seeds; | | std::vector<std::string> url_seeds; | |
| | | | |
| // a list of hostname and port pairs, representing DHT nodes
to be added | | // a list of hostname and port pairs, representing DHT nodes
to be added | |
| // to the session (if DHT is enabled). The hostname may be a
n IP address. | | // to the session (if DHT is enabled). The hostname may be a
n IP address. | |
| std::vector<std::pair<std::string, int> > dht_nodes; | | std::vector<std::pair<std::string, int> > dht_nodes; | |
| std::string name; | | std::string name; | |
| | | | |
| // the path where the torrent is or will be stored. Note tha
t this may | | // the path where the torrent is or will be stored. Note tha
t this may | |
|
| // alos be stored in resume data. If you which the save path
saved in | | // alos be stored in resume data. If you want the save path
saved in | |
| // the resume data to be used, you need to set the | | // the resume data to be used, you need to set the | |
| // flag_use_resume_save_path flag. | | // flag_use_resume_save_path flag. | |
|
| | | // | |
| | | // .. note:: | |
| | | // On windows this path (and other paths) are interpret | |
| | | ed as UNC | |
| | | // paths. This means they must use backslashes as direc | |
| | | tory separators | |
| | | // and may not contain the special directories "." or " | |
| | | ..". | |
| std::string save_path; | | std::string save_path; | |
| | | | |
| // The optional parameter, ``resume_data`` can be given if u
p to date | | // The optional parameter, ``resume_data`` can be given if u
p to date | |
| // fast-resume data is available. The fast-resume data can b
e acquired | | // fast-resume data is available. The fast-resume data can b
e acquired | |
| // from a running torrent by calling save_resume_data() on | | // from a running torrent by calling save_resume_data() on | |
| // torrent_handle. See fast-resume_. The ``vector`` that is
passed in | | // torrent_handle. See fast-resume_. The ``vector`` that is
passed in | |
| // will be swapped into the running torrent instance with | | // will be swapped into the running torrent instance with | |
| // ``std::vector::swap()``. | | // ``std::vector::swap()``. | |
| std::vector<char> resume_data; | | std::vector<char> resume_data; | |
| | | | |
| | | | |
End of changes. 3 change blocks. |
| 15 lines changed or deleted | | 29 lines changed or added | |
|
| bencode.hpp | | bencode.hpp | |
| | | | |
| skipping to change at line 102 | | skipping to change at line 102 | |
| #include "libtorrent/entry.hpp" | | #include "libtorrent/entry.hpp" | |
| #include "libtorrent/config.hpp" | | #include "libtorrent/config.hpp" | |
| | | | |
| #include "libtorrent/assert.hpp" | | #include "libtorrent/assert.hpp" | |
| #include "libtorrent/escape_string.hpp" | | #include "libtorrent/escape_string.hpp" | |
| #include "libtorrent/io.hpp" // for write_string | | #include "libtorrent/io.hpp" // for write_string | |
| | | | |
| namespace libtorrent | | namespace libtorrent | |
| { | | { | |
| | | | |
|
| | | #ifndef TORRENT_NO_DEPRECATE | |
| // thrown by bdecode() if the provided bencoded buffer does not cont
ain | | // thrown by bdecode() if the provided bencoded buffer does not cont
ain | |
| // valid encoding. | | // valid encoding. | |
| struct TORRENT_EXPORT invalid_encoding: std::exception | | struct TORRENT_EXPORT invalid_encoding: std::exception | |
| { | | { | |
|
| | | // hidden | |
| virtual const char* what() const throw() { return "invalid b
encoding"; } | | virtual const char* what() const throw() { return "invalid b
encoding"; } | |
| }; | | }; | |
|
| | | #endif | |
| | | | |
| namespace detail | | namespace detail | |
| { | | { | |
| // this is used in the template, so it must be available to
the client | | // this is used in the template, so it must be available to
the client | |
| TORRENT_EXPORT char const* integer_to_str(char* buf, int siz
e | | TORRENT_EXPORT char const* integer_to_str(char* buf, int siz
e | |
| , entry::integer_type val); | | , entry::integer_type val); | |
| | | | |
| template <class OutIt> | | template <class OutIt> | |
| int write_integer(OutIt& out, entry::integer_type val) | | int write_integer(OutIt& out, entry::integer_type val) | |
| { | | { | |
| | | | |
| skipping to change at line 429 | | skipping to change at line 432 | |
| // | | // | |
| // Or, if you have a raw char buffer:: | | // Or, if you have a raw char buffer:: | |
| // | | // | |
| // const char* buf; | | // const char* buf; | |
| // // ... | | // // ... | |
| // entry e = bdecode(buf, buf + data_size); | | // entry e = bdecode(buf, buf + data_size); | |
| // | | // | |
| // Now we just need to know how to retrieve information from the ent
ry. | | // Now we just need to know how to retrieve information from the ent
ry. | |
| // | | // | |
| // If ``bdecode()`` encounters invalid encoded data in the range giv
en to it | | // If ``bdecode()`` encounters invalid encoded data in the range giv
en to it | |
|
| // it will throw libtorrent_exception. | | // it will return a default constructed ``entry`` object. | |
| template<class OutIt> int bencode(OutIt out, const entry& e) | | template<class OutIt> int bencode(OutIt out, const entry& e) | |
| { | | { | |
| return detail::bencode_recursive(out, e); | | return detail::bencode_recursive(out, e); | |
| } | | } | |
| template<class InIt> entry bdecode(InIt start, InIt end) | | template<class InIt> entry bdecode(InIt start, InIt end) | |
| { | | { | |
| entry e; | | entry e; | |
| bool err = false; | | bool err = false; | |
| detail::bdecode_recursive(start, end, e, err, 0); | | detail::bdecode_recursive(start, end, e, err, 0); | |
| #ifdef TORRENT_DEBUG | | #ifdef TORRENT_DEBUG | |
| | | | |
End of changes. 4 change blocks. |
| 1 lines changed or deleted | | 4 lines changed or added | |
|
| config.hpp | | config.hpp | |
| | | | |
| skipping to change at line 64 | | skipping to change at line 64 | |
| #error TORRENT_DEBUG_BUFFERS only works if you also disable pool allocators
with TORRENT_DISABLE_POOL_ALLOCATOR | | #error TORRENT_DEBUG_BUFFERS only works if you also disable pool allocators
with TORRENT_DISABLE_POOL_ALLOCATOR | |
| #endif | | #endif | |
| | | | |
| #if !defined BOOST_ASIO_SEPARATE_COMPILATION && !defined BOOST_ASIO_DYN_LIN
K | | #if !defined BOOST_ASIO_SEPARATE_COMPILATION && !defined BOOST_ASIO_DYN_LIN
K | |
| #error you must define either BOOST_ASIO_SEPARATE_COMPILATION or BOOST_ASIO
_DYN_LINK in your project in \ | | #error you must define either BOOST_ASIO_SEPARATE_COMPILATION or BOOST_ASIO
_DYN_LINK in your project in \ | |
| order for asios declarations to be correct. If you are linking dynam
ically against libtorrent, define \ | | order for asios declarations to be correct. If you are linking dynam
ically against libtorrent, define \ | |
| BOOST_ASIO_DYN_LINK otherwise BOOST_ASIO_SEPARATE_COMPILATION. You c
an also use pkg-config or boost \ | | BOOST_ASIO_DYN_LINK otherwise BOOST_ASIO_SEPARATE_COMPILATION. You c
an also use pkg-config or boost \ | |
| build, to automatically apply these defines | | build, to automatically apply these defines | |
| #endif | | #endif | |
| | | | |
|
| // some parts pulled out of stdint.h | | | |
| // to avoid C99 or C++11 dependency | | | |
| #if !defined INT64_MAX | | | |
| #define INT64_MAX 0x7fffffffffffffffLL | | | |
| #endif | | | |
| #if !defined INT16_MAX | | | |
| #define INT16_MAX 32767 | | | |
| #endif | | | |
| #if !defined INT16_MIN | | | |
| #define INT16_MIN -32768 | | | |
| #endif | | | |
| | | | |
| #ifndef _MSC_VER | | #ifndef _MSC_VER | |
| #ifndef __STDC_FORMAT_MACROS | | #ifndef __STDC_FORMAT_MACROS | |
| #define __STDC_FORMAT_MACROS 1 | | #define __STDC_FORMAT_MACROS 1 | |
| #endif | | #endif | |
| #include <inttypes.h> // for PRId64 et.al. | | #include <inttypes.h> // for PRId64 et.al. | |
| #endif | | #endif | |
| | | | |
| #ifndef PRId64 | | #ifndef PRId64 | |
| // MinGW uses microsofts runtime | | // MinGW uses microsofts runtime | |
| #if defined _MSC_VER || defined __MINGW32__ | | #if defined _MSC_VER || defined __MINGW32__ | |
| | | | |
| skipping to change at line 286 | | skipping to change at line 274 | |
| #define TORRENT_HAS_FALLOCATE 0 | | #define TORRENT_HAS_FALLOCATE 0 | |
| #define TORRENT_USE_IFCONF 1 | | #define TORRENT_USE_IFCONF 1 | |
| #define TORRENT_USE_SYSCTL 1 | | #define TORRENT_USE_SYSCTL 1 | |
| #define TORRENT_USE_MLOCK 0 | | #define TORRENT_USE_MLOCK 0 | |
| #define TORRENT_USE_IPV6 0 | | #define TORRENT_USE_IPV6 0 | |
| #define TORRENT_ICONV_ARG (const char**) | | #define TORRENT_ICONV_ARG (const char**) | |
| #define TORRENT_USE_WRITEV 0 | | #define TORRENT_USE_WRITEV 0 | |
| #define TORRENT_USE_READV 0 | | #define TORRENT_USE_READV 0 | |
| | | | |
| #else | | #else | |
|
| #warning unknown OS, assuming BSD | | | |
| | | #ifdef _MSC_VER | |
| | | #pragma message ( "unknown OS, assuming BSD" ) | |
| | | #else | |
| | | #warning "unknown OS, assuming BSD" | |
| | | #endif | |
| | | | |
| #define TORRENT_BSD | | #define TORRENT_BSD | |
| #endif | | #endif | |
| | | | |
| // on windows, NAME_MAX refers to Unicode characters | | // on windows, NAME_MAX refers to Unicode characters | |
| // on linux it refers to bytes (utf-8 encoded) | | // on linux it refers to bytes (utf-8 encoded) | |
| // TODO: Make this count Unicode characters instead of bytes on windows | | // TODO: Make this count Unicode characters instead of bytes on windows | |
| | | | |
| // windows | | // windows | |
| #if defined FILENAME_MAX | | #if defined FILENAME_MAX | |
| #define TORRENT_MAX_PATH FILENAME_MAX | | #define TORRENT_MAX_PATH FILENAME_MAX | |
| | | | |
| skipping to change at line 315 | | skipping to change at line 309 | |
| | | | |
| // posix | | // posix | |
| #elif defined NAME_MAX | | #elif defined NAME_MAX | |
| #define TORRENT_MAX_PATH NAME_MAX | | #define TORRENT_MAX_PATH NAME_MAX | |
| | | | |
| // none of the above | | // none of the above | |
| #else | | #else | |
| // this is the maximum number of characters in a | | // this is the maximum number of characters in a | |
| // path element / filename on windows | | // path element / filename on windows | |
| #define TORRENT_MAX_PATH 255 | | #define TORRENT_MAX_PATH 255 | |
|
| #warning unknown platform, assuming the longest path is 255 | | | |
| | | #ifdef _MSC_VER | |
| | | #pragma message ( "unknown platform, assuming the longest path is 255" ) | |
| | | #else | |
| | | #warning "unknown platform, assuming the longest path is 255" | |
| | | #endif | |
| | | | |
| #endif | | #endif | |
| | | | |
| #if defined TORRENT_WINDOWS && !defined TORRENT_MINGW | | #if defined TORRENT_WINDOWS && !defined TORRENT_MINGW | |
| | | | |
| #include <stdarg.h> | | #include <stdarg.h> | |
| | | | |
| // internal | | // internal | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| inline | | inline | |
| | | | |
End of changes. 3 change blocks. |
| 14 lines changed or deleted | | 13 lines changed or added | |
|
| lazy_entry.hpp | | lazy_entry.hpp | |
| | | | |
| skipping to change at line 230 | | skipping to change at line 230 | |
| // internal | | // internal | |
| lazy_entry* dict_append(char const* name); | | lazy_entry* dict_append(char const* name); | |
| // internal | | // internal | |
| void pop(); | | void pop(); | |
| | | | |
| // if this is a dictionary, look for a key ``name``, and ret
urn | | // if this is a dictionary, look for a key ``name``, and ret
urn | |
| // a pointer to its value, or NULL if there is none. | | // a pointer to its value, or NULL if there is none. | |
| lazy_entry* dict_find(char const* name); | | lazy_entry* dict_find(char const* name); | |
| lazy_entry const* dict_find(char const* name) const | | lazy_entry const* dict_find(char const* name) const | |
| { return const_cast<lazy_entry*>(this)->dict_find(name); } | | { return const_cast<lazy_entry*>(this)->dict_find(name); } | |
|
| | | lazy_entry* dict_find(std::string const& name); | |
| | | lazy_entry const* dict_find(std::string const& name) const | |
| | | { return const_cast<lazy_entry*>(this)->dict_find(name); } | |
| lazy_entry const* dict_find_string(char const* name) const; | | lazy_entry const* dict_find_string(char const* name) const; | |
| | | | |
| // if this is a dictionary, look for a key ``name`` whose va
lue | | // if this is a dictionary, look for a key ``name`` whose va
lue | |
| // is a string. If such key exist, return a pointer to | | // is a string. If such key exist, return a pointer to | |
| // its value, otherwise NULL. | | // its value, otherwise NULL. | |
| std::string dict_find_string_value(char const* name) const; | | std::string dict_find_string_value(char const* name) const; | |
| pascal_string dict_find_pstr(char const* name) const; | | pascal_string dict_find_pstr(char const* name) const; | |
| | | | |
| // if this is a dictionary, look for a key ``name`` whose va
lue | | // if this is a dictionary, look for a key ``name`` whose va
lue | |
| // is an int. If such key exist, return a pointer to its val
ue, | | // is an int. If such key exist, return a pointer to its val
ue, | |
| | | | |
| skipping to change at line 251 | | skipping to change at line 254 | |
| boost::int64_t dict_find_int_value(char const* name, boost::
int64_t default_val = 0) const; | | boost::int64_t dict_find_int_value(char const* name, boost::
int64_t default_val = 0) const; | |
| lazy_entry const* dict_find_int(char const* name) const; | | lazy_entry const* dict_find_int(char const* name) const; | |
| | | | |
| // these functions require that ``this`` is a dictionary. | | // these functions require that ``this`` is a dictionary. | |
| // (this->type() == dict_t). They look for an element with t
he | | // (this->type() == dict_t). They look for an element with t
he | |
| // specified name in the dictionary. ``dict_find_dict`` only | | // specified name in the dictionary. ``dict_find_dict`` only | |
| // finds dictionaries and ``dict_find_list`` only finds list
s. | | // finds dictionaries and ``dict_find_list`` only finds list
s. | |
| // if no key with the corresponding value of the right type
is | | // if no key with the corresponding value of the right type
is | |
| // found, NULL is returned. | | // found, NULL is returned. | |
| lazy_entry const* dict_find_dict(char const* name) const; | | lazy_entry const* dict_find_dict(char const* name) const; | |
|
| | | lazy_entry const* dict_find_dict(std::string const& name) co
nst; | |
| lazy_entry const* dict_find_list(char const* name) const; | | lazy_entry const* dict_find_list(char const* name) const; | |
| | | | |
| // if this is a dictionary, return the key value pair at | | // if this is a dictionary, return the key value pair at | |
| // position ``i`` from the dictionary. | | // position ``i`` from the dictionary. | |
| std::pair<std::string, lazy_entry const*> dict_at(int i) con
st; | | std::pair<std::string, lazy_entry const*> dict_at(int i) con
st; | |
| | | | |
| // requires that ``this`` is a dictionary. return the | | // requires that ``this`` is a dictionary. return the | |
| // number of items in it | | // number of items in it | |
| int dict_size() const | | int dict_size() const | |
| { | | { | |
| | | | |
| skipping to change at line 316 | | skipping to change at line 320 | |
| { | | { | |
| TORRENT_ASSERT(m_type == list_t); | | TORRENT_ASSERT(m_type == list_t); | |
| return int(m_size); | | return int(m_size); | |
| } | | } | |
| | | | |
| // internal: end points one byte passed last byte in the sou
rce | | // internal: end points one byte passed last byte in the sou
rce | |
| // buffer backing the bencoded structure. | | // buffer backing the bencoded structure. | |
| void set_end(char const* end) | | void set_end(char const* end) | |
| { | | { | |
| TORRENT_ASSERT(end > m_begin); | | TORRENT_ASSERT(end > m_begin); | |
|
| m_len = end - m_begin; | | TORRENT_ASSERT(end - m_begin < INT_MAX); | |
| | | m_len = int(end - m_begin); | |
| } | | } | |
| | | | |
| // internal | | // internal | |
| void clear(); | | void clear(); | |
| | | | |
| // internal: releases ownership of any memory allocated | | // internal: releases ownership of any memory allocated | |
| void release() | | void release() | |
| { | | { | |
| m_data.start = 0; | | m_data.start = 0; | |
| m_size = 0; | | m_size = 0; | |
| | | | |
End of changes. 3 change blocks. |
| 1 lines changed or deleted | | 6 lines changed or added | |
|
| node.hpp | | node.hpp | |
| | | | |
| skipping to change at line 204 | | skipping to change at line 204 | |
| typedef std::map<node_id, dht_mutable_item> dht_mutable_table_t; | | typedef std::map<node_id, dht_mutable_item> dht_mutable_table_t; | |
| | | | |
| public: | | public: | |
| node_impl(alert_dispatcher* alert_disp, udp_socket_interface* sock | | node_impl(alert_dispatcher* alert_disp, udp_socket_interface* sock | |
| , libtorrent::dht_settings const& settings, node_id nid, add
ress const& external_address | | , libtorrent::dht_settings const& settings, node_id nid, add
ress const& external_address | |
| , dht_observer* observer); | | , dht_observer* observer); | |
| | | | |
| virtual ~node_impl() {} | | virtual ~node_impl() {} | |
| | | | |
| void tick(); | | void tick(); | |
|
| void refresh(node_id const& id, find_data::nodes_callback const& f); | | | |
| void bootstrap(std::vector<udp::endpoint> const& nodes | | void bootstrap(std::vector<udp::endpoint> const& nodes | |
| , find_data::nodes_callback const& f); | | , find_data::nodes_callback const& f); | |
| void add_router_node(udp::endpoint router); | | void add_router_node(udp::endpoint router); | |
| | | | |
| void unreachable(udp::endpoint const& ep); | | void unreachable(udp::endpoint const& ep); | |
| void incoming(msg const& m); | | void incoming(msg const& m); | |
| | | | |
| int num_torrents() const { return m_map.size(); } | | int num_torrents() const { return m_map.size(); } | |
| int num_peers() const | | int num_peers() const | |
| { | | { | |
| int ret = 0; | | int ret = 0; | |
| std::for_each(m_map.begin(), m_map.end(), count_peers(ret)); | | std::for_each(m_map.begin(), m_map.end(), count_peers(ret)); | |
| return ret; | | return ret; | |
| } | | } | |
| | | | |
| int bucket_size(int bucket); | | int bucket_size(int bucket); | |
| | | | |
| node_id const& nid() const { return m_id; } | | node_id const& nid() const { return m_id; } | |
| | | | |
|
| boost::tuple<int, int> size() const{ return m_table.size(); } | | boost::tuple<int, int, int> size() const { return m_table.size(); } | |
| size_type num_global_nodes() const | | size_type num_global_nodes() const | |
| { return m_table.num_global_nodes(); } | | { return m_table.num_global_nodes(); } | |
| | | | |
| int data_size() const { return int(m_map.size()); } | | int data_size() const { return int(m_map.size()); } | |
| | | | |
| #ifdef TORRENT_DHT_VERBOSE_LOGGING | | #ifdef TORRENT_DHT_VERBOSE_LOGGING | |
| void print_state(std::ostream& os) const | | void print_state(std::ostream& os) const | |
| { m_table.print_state(os); } | | { m_table.print_state(os); } | |
| #endif | | #endif | |
| | | | |
| | | | |
| skipping to change at line 282 | | skipping to change at line 281 | |
| mutex_t::scoped_lock l(m_mutex); | | mutex_t::scoped_lock l(m_mutex); | |
| m_running_requests.erase(a); | | m_running_requests.erase(a); | |
| } | | } | |
| | | | |
| void status(libtorrent::session_status& s); | | void status(libtorrent::session_status& s); | |
| | | | |
| libtorrent::dht_settings const& settings() const { return m_settings
; } | | libtorrent::dht_settings const& settings() const { return m_settings
; } | |
| | | | |
| protected: | | protected: | |
| | | | |
|
| void lookup_peers(sha1_hash const& info_hash, int prefix, entry& rep | | void send_single_refresh(udp::endpoint const& ep, int bucket | |
| ly | | , node_id const& id = node_id()); | |
| | | void lookup_peers(sha1_hash const& info_hash, entry& reply | |
| , bool noseed, bool scrape) const; | | , bool noseed, bool scrape) const; | |
| bool lookup_torrents(sha1_hash const& target, entry& reply | | bool lookup_torrents(sha1_hash const& target, entry& reply | |
| , char* tags) const; | | , char* tags) const; | |
| | | | |
| libtorrent::dht_settings const& m_settings; | | libtorrent::dht_settings const& m_settings; | |
| | | | |
| private: | | private: | |
| typedef libtorrent::mutex mutex_t; | | typedef libtorrent::mutex mutex_t; | |
| mutex_t m_mutex; | | mutex_t m_mutex; | |
| | | | |
| | | | |
| skipping to change at line 314 | | skipping to change at line 315 | |
| | | | |
| private: | | private: | |
| dht_observer* m_observer; | | dht_observer* m_observer; | |
| | | | |
| table_t m_map; | | table_t m_map; | |
| dht_immutable_table_t m_immutable_table; | | dht_immutable_table_t m_immutable_table; | |
| dht_mutable_table_t m_mutable_table; | | dht_mutable_table_t m_mutable_table; | |
| | | | |
| ptime m_last_tracker_tick; | | ptime m_last_tracker_tick; | |
| | | | |
|
| | | // the last time we issued a bootstrap or a refresh on our own ID, t | |
| | | o expand | |
| | | // the routing table buckets close to us. | |
| | | ptime m_last_self_refresh; | |
| | | | |
| // secret random numbers used to create write tokens | | // secret random numbers used to create write tokens | |
| int m_secret[2]; | | int m_secret[2]; | |
| | | | |
| alert_dispatcher* m_post_alert; | | alert_dispatcher* m_post_alert; | |
| udp_socket_interface* m_sock; | | udp_socket_interface* m_sock; | |
| }; | | }; | |
| | | | |
| } } // namespace libtorrent::dht | | } } // namespace libtorrent::dht | |
| | | | |
| #endif // NODE_HPP | | #endif // NODE_HPP | |
| | | | |
End of changes. 4 change blocks. |
| 4 lines changed or deleted | | 9 lines changed or added | |
|
| node_entry.hpp | | node_entry.hpp | |
| | | | |
| skipping to change at line 40 | | skipping to change at line 40 | |
| | | | |
| */ | | */ | |
| | | | |
| #ifndef KADEMLIA_NODE_ENTRY_HPP | | #ifndef KADEMLIA_NODE_ENTRY_HPP | |
| #define KADEMLIA_NODE_ENTRY_HPP | | #define KADEMLIA_NODE_ENTRY_HPP | |
| | | | |
| #include "libtorrent/kademlia/node_id.hpp" | | #include "libtorrent/kademlia/node_id.hpp" | |
| #include "libtorrent/socket.hpp" | | #include "libtorrent/socket.hpp" | |
| #include "libtorrent/address.hpp" | | #include "libtorrent/address.hpp" | |
| #include "libtorrent/union_endpoint.hpp" | | #include "libtorrent/union_endpoint.hpp" | |
|
| | | #include "libtorrent/time.hpp" // for time_now() | |
| | | | |
| #ifdef TORRENT_DHT_VERBOSE_LOGGING | | #ifdef TORRENT_DHT_VERBOSE_LOGGING | |
| #include "libtorrent/time.hpp" | | #include "libtorrent/time.hpp" | |
| #endif | | #endif | |
| | | | |
| namespace libtorrent { namespace dht | | namespace libtorrent { namespace dht | |
| { | | { | |
| | | | |
| struct node_entry | | struct node_entry | |
| { | | { | |
|
| node_entry(node_id const& id_, udp::endpoint ep, int roundtriptime = | | node_entry(node_id const& id_, udp::endpoint ep, int roundtriptime = | |
| 0xffff, bool pinged = false) | | 0xffff | |
| : id(id_) | | , bool pinged = false) | |
| , endpoint(ep) | | : last_queried(pinged ? time_now() : min_time()) | |
| | | , id(id_) | |
| | | , a(ep.address().to_v4().to_bytes()) | |
| | | , p(ep.port()) | |
| , rtt(roundtriptime & 0xffff) | | , rtt(roundtriptime & 0xffff) | |
| , timeout_count(pinged ? 0 : 0xff) | | , timeout_count(pinged ? 0 : 0xff) | |
| { | | { | |
| #ifdef TORRENT_DHT_VERBOSE_LOGGING | | #ifdef TORRENT_DHT_VERBOSE_LOGGING | |
| first_seen = time_now(); | | first_seen = time_now(); | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| node_entry(udp::endpoint ep) | | node_entry(udp::endpoint ep) | |
|
| : id(0) | | : last_queried(min_time()) | |
| , endpoint(ep) | | , id(0) | |
| | | , a(ep.address().to_v4().to_bytes()) | |
| | | , p(ep.port()) | |
| , rtt(0xffff) | | , rtt(0xffff) | |
| , timeout_count(0xff) | | , timeout_count(0xff) | |
| { | | { | |
| #ifdef TORRENT_DHT_VERBOSE_LOGGING | | #ifdef TORRENT_DHT_VERBOSE_LOGGING | |
| first_seen = time_now(); | | first_seen = time_now(); | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| node_entry() | | node_entry() | |
|
| : id(0) | | : last_queried(min_time()) | |
| | | , id(0) | |
| | | , p(0) | |
| , rtt(0xffff) | | , rtt(0xffff) | |
| , timeout_count(0xff) | | , timeout_count(0xff) | |
| { | | { | |
| #ifdef TORRENT_DHT_VERBOSE_LOGGING | | #ifdef TORRENT_DHT_VERBOSE_LOGGING | |
| first_seen = time_now(); | | first_seen = time_now(); | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| bool pinged() const { return timeout_count != 0xff; } | | bool pinged() const { return timeout_count != 0xff; } | |
| void set_pinged() { if (timeout_count == 0xff) timeout_count = 0; } | | void set_pinged() { if (timeout_count == 0xff) timeout_count = 0; } | |
| void timed_out() { if (pinged() && timeout_count < 0xfe) ++timeout_c
ount; } | | void timed_out() { if (pinged() && timeout_count < 0xfe) ++timeout_c
ount; } | |
| int fail_count() const { return pinged() ? timeout_count : 0; } | | int fail_count() const { return pinged() ? timeout_count : 0; } | |
| void reset_fail_count() { if (pinged()) timeout_count = 0; } | | void reset_fail_count() { if (pinged()) timeout_count = 0; } | |
|
| udp::endpoint ep() const { return udp::endpoint(endpoint); } | | udp::endpoint ep() const { return udp::endpoint(address_v4(a), p); } | |
| bool confirmed() const { return timeout_count == 0; } | | bool confirmed() const { return timeout_count == 0; } | |
| void update_rtt(int new_rtt) | | void update_rtt(int new_rtt) | |
| { | | { | |
|
| | | TORRENT_ASSERT(new_rtt <= 0xffff); | |
| | | TORRENT_ASSERT(new_rtt >= 0); | |
| | | if (new_rtt == 0xffff) return; | |
| if (rtt == 0xffff) rtt = new_rtt; | | if (rtt == 0xffff) rtt = new_rtt; | |
|
| else rtt = int(rtt) / 3 + int(new_rtt) * 2 / 3; | | else rtt = int(rtt) * 2 / 3 + int(new_rtt) / 3; | |
| } | | } | |
|
| address addr() const { return endpoint.address(); } | | address addr() const { return address_v4(a); } | |
| int port() const { return endpoint.port; } | | int port() const { return p; } | |
| | | | |
| #ifdef TORRENT_DHT_VERBOSE_LOGGING | | #ifdef TORRENT_DHT_VERBOSE_LOGGING | |
| ptime first_seen; | | ptime first_seen; | |
| #endif | | #endif | |
| | | | |
|
| | | // the time we last received a response for a request to this peer | |
| | | ptime last_queried; | |
| | | | |
| node_id id; | | node_id id; | |
| | | | |
|
| union_endpoint endpoint; | | address_v4::bytes_type a; | |
| | | boost::uint16_t p; | |
| | | | |
| // the average RTT of this node | | // the average RTT of this node | |
| boost::uint16_t rtt; | | boost::uint16_t rtt; | |
| | | | |
| // the number of times this node has failed to | | // the number of times this node has failed to | |
| // respond in a row | | // respond in a row | |
| boost::uint8_t timeout_count; | | boost::uint8_t timeout_count; | |
| }; | | }; | |
| | | | |
| } } // namespace libtorrent::dht | | } } // namespace libtorrent::dht | |
| | | | |
End of changes. 10 change blocks. |
| 12 lines changed or deleted | | 27 lines changed or added | |
|
| routing_table.hpp | | routing_table.hpp | |
| | | | |
| skipping to change at line 42 | | skipping to change at line 42 | |
| | | | |
| #ifndef ROUTING_TABLE_HPP | | #ifndef ROUTING_TABLE_HPP | |
| #define ROUTING_TABLE_HPP | | #define ROUTING_TABLE_HPP | |
| | | | |
| #include <vector> | | #include <vector> | |
| #include <boost/cstdint.hpp> | | #include <boost/cstdint.hpp> | |
| | | | |
| #include <boost/utility.hpp> | | #include <boost/utility.hpp> | |
| #include <boost/tuple/tuple.hpp> | | #include <boost/tuple/tuple.hpp> | |
| #include <boost/array.hpp> | | #include <boost/array.hpp> | |
|
| | | #include <boost/noncopyable.hpp> | |
| #include <set> | | #include <set> | |
| | | | |
| #include <libtorrent/kademlia/logging.hpp> | | #include <libtorrent/kademlia/logging.hpp> | |
| | | | |
| #include <libtorrent/kademlia/node_id.hpp> | | #include <libtorrent/kademlia/node_id.hpp> | |
| #include <libtorrent/kademlia/node_entry.hpp> | | #include <libtorrent/kademlia/node_entry.hpp> | |
| #include <libtorrent/session_settings.hpp> | | #include <libtorrent/session_settings.hpp> | |
| #include <libtorrent/size_type.hpp> | | #include <libtorrent/size_type.hpp> | |
| #include <libtorrent/assert.hpp> | | #include <libtorrent/assert.hpp> | |
| #include <libtorrent/ptime.hpp> | | #include <libtorrent/ptime.hpp> | |
| | | | |
| skipping to change at line 71 | | skipping to change at line 72 | |
| #ifdef TORRENT_DHT_VERBOSE_LOGGING | | #ifdef TORRENT_DHT_VERBOSE_LOGGING | |
| TORRENT_DECLARE_LOG(table); | | TORRENT_DECLARE_LOG(table); | |
| #endif | | #endif | |
| | | | |
| typedef std::vector<node_entry> bucket_t; | | typedef std::vector<node_entry> bucket_t; | |
| | | | |
| struct routing_table_node | | struct routing_table_node | |
| { | | { | |
| bucket_t replacements; | | bucket_t replacements; | |
| bucket_t live_nodes; | | bucket_t live_nodes; | |
|
| ptime last_active; | | | |
| }; | | }; | |
| | | | |
| // differences in the implementation from the description in | | // differences in the implementation from the description in | |
| // the paper: | | // the paper: | |
| // | | // | |
| // * Nodes are not marked as being stale, they keep a counter | | // * Nodes are not marked as being stale, they keep a counter | |
| // that tells how many times in a row they have failed. When | | // that tells how many times in a row they have failed. When | |
| // a new node is to be inserted, the node that has failed | | // a new node is to be inserted, the node that has failed | |
| // the most times is replaced. If none of the nodes in the | | // the most times is replaced. If none of the nodes in the | |
| // bucket has failed, then it is put in the replacement | | // bucket has failed, then it is put in the replacement | |
| // cache (just like in the paper). | | // cache (just like in the paper). | |
| | | | |
|
| class TORRENT_EXTRA_EXPORT routing_table | | class TORRENT_EXTRA_EXPORT routing_table : boost::noncopyable | |
| { | | { | |
| public: | | public: | |
| typedef std::vector<routing_table_node> table_t; | | typedef std::vector<routing_table_node> table_t; | |
| | | | |
| routing_table(node_id const& id, int bucket_size | | routing_table(node_id const& id, int bucket_size | |
| , dht_settings const& settings); | | , dht_settings const& settings); | |
| | | | |
| void status(session_status& s) const; | | void status(session_status& s) const; | |
| | | | |
| void node_failed(node_id const& id, udp::endpoint const& ep); | | void node_failed(node_id const& id, udp::endpoint const& ep); | |
| | | | |
| // adds an endpoint that will never be added to | | // adds an endpoint that will never be added to | |
| // the routing table | | // the routing table | |
| void add_router_node(udp::endpoint router); | | void add_router_node(udp::endpoint router); | |
| | | | |
| // iterates over the router nodes added | | // iterates over the router nodes added | |
| typedef std::set<udp::endpoint>::const_iterator router_iterator; | | typedef std::set<udp::endpoint>::const_iterator router_iterator; | |
| router_iterator router_begin() const { return m_router_nodes.begin()
; } | | router_iterator router_begin() const { return m_router_nodes.begin()
; } | |
| router_iterator router_end() const { return m_router_nodes.end(); } | | router_iterator router_end() const { return m_router_nodes.end(); } | |
| | | | |
|
| | | enum add_node_status_t { | |
| | | failed_to_add = 0, | |
| | | node_added, | |
| | | need_bucket_split | |
| | | }; | |
| | | add_node_status_t add_node_impl(node_entry e); | |
| | | | |
| bool add_node(node_entry e); | | bool add_node(node_entry e); | |
| | | | |
| // this function is called every time the node sees | | // this function is called every time the node sees | |
| // a sign of a node being alive. This node will either | | // a sign of a node being alive. This node will either | |
| // be inserted in the k-buckets or be moved to the top | | // be inserted in the k-buckets or be moved to the top | |
| // of its bucket. | | // of its bucket. | |
| bool node_seen(node_id const& id, udp::endpoint ep, int rtt); | | bool node_seen(node_id const& id, udp::endpoint ep, int rtt); | |
| | | | |
| // this may add a node to the routing table and mark it as | | // this may add a node to the routing table and mark it as | |
| // not pinged. If the bucket the node falls into is full, | | // not pinged. If the bucket the node falls into is full, | |
| // the node will be ignored. | | // the node will be ignored. | |
| void heard_about(node_id const& id, udp::endpoint const& ep); | | void heard_about(node_id const& id, udp::endpoint const& ep); | |
| | | | |
|
| // if any bucket in the routing table needs to be refreshed | | node_entry const* next_refresh(); | |
| // this function will return true and set the target to an | | | |
| // appropriate target inside that bucket | | | |
| bool need_refresh(node_id& target) const; | | | |
| | | | |
| enum | | enum | |
| { | | { | |
|
| | | // nodes that have not been pinged are considered failed by
this flag | |
| include_failed = 1 | | include_failed = 1 | |
| }; | | }; | |
|
| | | | |
| // fills the vector with the count nodes from our buckets that | | // fills the vector with the count nodes from our buckets that | |
| // are nearest to the given id. | | // are nearest to the given id. | |
| void find_node(node_id const& id, std::vector<node_entry>& l | | void find_node(node_id const& id, std::vector<node_entry>& l | |
| , int options, int count = 0); | | , int options, int count = 0); | |
| void remove_node(node_entry* n | | void remove_node(node_entry* n | |
| , table_t::iterator bucket) ; | | , table_t::iterator bucket) ; | |
| | | | |
| int bucket_size(int bucket) const | | int bucket_size(int bucket) const | |
| { | | { | |
| int num_buckets = m_buckets.size(); | | int num_buckets = m_buckets.size(); | |
| | | | |
| skipping to change at line 149 | | skipping to change at line 155 | |
| table_t::const_iterator i = m_buckets.begin(); | | table_t::const_iterator i = m_buckets.begin(); | |
| std::advance(i, bucket); | | std::advance(i, bucket); | |
| return (int)i->live_nodes.size(); | | return (int)i->live_nodes.size(); | |
| } | | } | |
| | | | |
| void for_each_node(void (*)(void*, node_entry const&) | | void for_each_node(void (*)(void*, node_entry const&) | |
| , void (*)(void*, node_entry const&), void* userdata) const; | | , void (*)(void*, node_entry const&), void* userdata) const; | |
| | | | |
| int bucket_size() const { return m_bucket_size; } | | int bucket_size() const { return m_bucket_size; } | |
| | | | |
|
| boost::tuple<int, int> size() const; | | // returns the number of nodes in the main buckets, number of nodes | |
| | | in the | |
| | | // replacement buckets and the number of nodes in the main buckets t | |
| | | hat have | |
| | | // been pinged and confirmed up | |
| | | boost::tuple<int, int, int> size() const; | |
| | | | |
| size_type num_global_nodes() const; | | size_type num_global_nodes() const; | |
| | | | |
| // the number of bits down we have full buckets | | // the number of bits down we have full buckets | |
| // i.e. essentially the number of full buckets | | // i.e. essentially the number of full buckets | |
| // we have | | // we have | |
| int depth() const; | | int depth() const; | |
| | | | |
|
| // returns true if there are no working nodes | | | |
| // in the routing table | | | |
| bool need_bootstrap() const; | | | |
| int num_active_buckets() const { return m_buckets.size(); } | | int num_active_buckets() const { return m_buckets.size(); } | |
| | | | |
| void replacement_cache(bucket_t& nodes) const; | | void replacement_cache(bucket_t& nodes) const; | |
| | | | |
| #if defined TORRENT_DHT_VERBOSE_LOGGING || defined TORRENT_DEBUG | | #if defined TORRENT_DHT_VERBOSE_LOGGING || defined TORRENT_DEBUG | |
| // used for debug and monitoring purposes. This will print out | | // used for debug and monitoring purposes. This will print out | |
| // the state of the routing table to the given stream | | // the state of the routing table to the given stream | |
| void print_state(std::ostream& os) const; | | void print_state(std::ostream& os) const; | |
| #endif | | #endif | |
| | | | |
|
| void touch_bucket(node_id const& target); | | | |
| | | | |
| int bucket_limit(int bucket) const; | | int bucket_limit(int bucket) const; | |
| | | | |
| #if TORRENT_USE_INVARIANT_CHECKS | | #if TORRENT_USE_INVARIANT_CHECKS | |
| void check_invariant() const; | | void check_invariant() const; | |
| #endif | | #endif | |
| | | | |
| private: | | private: | |
| | | | |
| table_t::iterator find_bucket(node_id const& id); | | table_t::iterator find_bucket(node_id const& id); | |
| | | | |
| | | | |
| skipping to change at line 209 | | skipping to change at line 214 | |
| // bucket size nodes in it, another bucket is | | // bucket size nodes in it, another bucket is | |
| // added to the end and it's split up between them | | // added to the end and it's split up between them | |
| table_t m_buckets; | | table_t m_buckets; | |
| | | | |
| node_id m_id; // our own node id | | node_id m_id; // our own node id | |
| | | | |
| // the last seen depth (i.e. levels in the routing table) | | // the last seen depth (i.e. levels in the routing table) | |
| // it's mutable because it's updated by depth(), which is const | | // it's mutable because it's updated by depth(), which is const | |
| mutable int m_depth; | | mutable int m_depth; | |
| | | | |
|
| // the last time need_bootstrap() returned true | | | |
| mutable ptime m_last_bootstrap; | | | |
| | | | |
| // the last time the routing table was refreshed. | | | |
| // this is used to stagger buckets needing refresh | | | |
| // to be at least 45 seconds apart. | | | |
| mutable ptime m_last_refresh; | | | |
| | | | |
| // the last time we refreshed our own bucket | | // the last time we refreshed our own bucket | |
| // refreshed every 15 minutes | | // refreshed every 15 minutes | |
| mutable ptime m_last_self_refresh; | | mutable ptime m_last_self_refresh; | |
| | | | |
| // this is a set of all the endpoints that have | | // this is a set of all the endpoints that have | |
| // been identified as router nodes. They will | | // been identified as router nodes. They will | |
| // be used in searches, but they will never | | // be used in searches, but they will never | |
| // be added to the routing table. | | // be added to the routing table. | |
| std::set<udp::endpoint> m_router_nodes; | | std::set<udp::endpoint> m_router_nodes; | |
| | | | |
| | | | |
End of changes. 11 change blocks. |
| 20 lines changed or deleted | | 19 lines changed or added | |
|
| session.hpp | | session.hpp | |
| | | | |
| skipping to change at line 212 | | skipping to change at line 212 | |
| } | | } | |
| | | | |
| // The destructor of session will notify all trackers that o
ur torrents | | // The destructor of session will notify all trackers that o
ur torrents | |
| // have been shut down. If some trackers are down, they will
time out. | | // have been shut down. If some trackers are down, they will
time out. | |
| // All this before the destructor of session returns. So, it
's advised | | // All this before the destructor of session returns. So, it
's advised | |
| // that any kind of interface (such as windows) are closed b
efore | | // that any kind of interface (such as windows) are closed b
efore | |
| // destructing the session object. Because it can take a few
second for | | // destructing the session object. Because it can take a few
second for | |
| // it to finish. The timeout can be set with ``set_settings(
)``. | | // it to finish. The timeout can be set with ``set_settings(
)``. | |
| ~session(); | | ~session(); | |
| | | | |
|
| | | // TODO: 2 the ip filter should probably be saved here too | |
| | | | |
| // flags that determines which aspects of the session should
be | | // flags that determines which aspects of the session should
be | |
| // saved when calling save_state(). | | // saved when calling save_state(). | |
| enum save_state_flags_t | | enum save_state_flags_t | |
| { | | { | |
| // saves settings (i.e. the session_settings) | | // saves settings (i.e. the session_settings) | |
| save_settings = 0x001, | | save_settings = 0x001, | |
| | | | |
| // saves dht_settings | | // saves dht_settings | |
| save_dht_settings = 0x002, | | save_dht_settings = 0x002, | |
| | | | |
| | | | |
| skipping to change at line 523 | | skipping to change at line 525 | |
| // posted. | | // posted. | |
| void dht_get_item(boost::array<char, 32> key | | void dht_get_item(boost::array<char, 32> key | |
| , std::string salt = std::string()); | | , std::string salt = std::string()); | |
| | | | |
| // store the given bencoded data as an immutable item in the
DHT. | | // store the given bencoded data as an immutable item in the
DHT. | |
| // the returned hash is the key that is to be used to look t
he item | | // the returned hash is the key that is to be used to look t
he item | |
| // up agan. It's just the sha-1 hash of the bencoded form of
the | | // up agan. It's just the sha-1 hash of the bencoded form of
the | |
| // structure. | | // structure. | |
| sha1_hash dht_put_item(entry data); | | sha1_hash dht_put_item(entry data); | |
| | | | |
|
| // store an immutable item. The ``key`` is the public key th
e blob is | | // store a mutable item. The ``key`` is the public key the b
lob is | |
| // to be stored under. The optional ``salt`` argument is a s
tring that | | // to be stored under. The optional ``salt`` argument is a s
tring that | |
| // is to be mixed in with the key when determining where in
the DHT | | // is to be mixed in with the key when determining where in
the DHT | |
| // the value is to be stored. The callback function is calle
d from within | | // the value is to be stored. The callback function is calle
d from within | |
| // the libtorrent network thread once we've found where to s
tore the blob, | | // the libtorrent network thread once we've found where to s
tore the blob, | |
| // possibly with the current value stored under the key. | | // possibly with the current value stored under the key. | |
| // The values passed to the callback functions are: | | // The values passed to the callback functions are: | |
| // | | // | |
| // entry& value | | // entry& value | |
| // the current value stored under the key (may be empty
). Also expected | | // the current value stored under the key (may be empty
). Also expected | |
| // to be set to the value to be stored by the function. | | // to be set to the value to be stored by the function. | |
| | | | |
End of changes. 2 change blocks. |
| 1 lines changed or deleted | | 3 lines changed or added | |
|
| torrent.hpp | | torrent.hpp | |
| | | | |
| skipping to change at line 153 | | skipping to change at line 153 | |
| torrent(aux::session_impl& ses, tcp::endpoint const& net_int
erface | | torrent(aux::session_impl& ses, tcp::endpoint const& net_int
erface | |
| , int block_size, int seq, add_torrent_params const&
p | | , int block_size, int seq, add_torrent_params const&
p | |
| , sha1_hash const& info_hash); | | , sha1_hash const& info_hash); | |
| ~torrent(); | | ~torrent(); | |
| | | | |
| #ifndef TORRENT_DISABLE_ENCRYPTION | | #ifndef TORRENT_DISABLE_ENCRYPTION | |
| sha1_hash const& obfuscated_hash() const | | sha1_hash const& obfuscated_hash() const | |
| { return m_obfuscated_hash; } | | { return m_obfuscated_hash; } | |
| #endif | | #endif | |
| | | | |
|
| sha1_hash const& info_hash() const | | // This may be called from multiple threads | |
| { | | sha1_hash const& info_hash() const { return m_info_hash; } | |
| static sha1_hash empty; | | | |
| return m_torrent_file ? m_torrent_file->info_hash() | | | |
| : empty; | | | |
| } | | | |
| | | | |
| bool is_deleted() const { return m_deleted; } | | bool is_deleted() const { return m_deleted; } | |
| | | | |
| // starts the announce timer | | // starts the announce timer | |
| void start(); | | void start(); | |
| | | | |
| void start_download_url(); | | void start_download_url(); | |
| | | | |
| #ifndef TORRENT_DISABLE_EXTENSIONS | | #ifndef TORRENT_DISABLE_EXTENSIONS | |
| void add_extension(boost::shared_ptr<torrent_plugin>); | | void add_extension(boost::shared_ptr<torrent_plugin>); | |
| | | | |
| skipping to change at line 552 | | skipping to change at line 549 | |
| return m_super_seeding && is_seed(); | | return m_super_seeding && is_seed(); | |
| } | | } | |
| | | | |
| void super_seeding(bool on); | | void super_seeding(bool on); | |
| int get_piece_to_super_seed(bitfield const&); | | int get_piece_to_super_seed(bitfield const&); | |
| | | | |
| // returns true if we have downloaded the given piece | | // returns true if we have downloaded the given piece | |
| bool have_piece(int index) const | | bool have_piece(int index) const | |
| { | | { | |
| if (!valid_metadata()) return false; | | if (!valid_metadata()) return false; | |
|
| if (!has_picker()) return true; | | if (!has_picker()) return is_seed(); | |
| return m_picker->have_piece(index); | | return m_picker->have_piece(index); | |
| } | | } | |
| | | | |
| // called when we learn that we have a piece | | // called when we learn that we have a piece | |
| // only once per piece | | // only once per piece | |
| void we_have(int index); | | void we_have(int index); | |
| | | | |
| int num_have() const | | int num_have() const | |
| { | | { | |
| // pretend we have every piece when in seed mode | | // pretend we have every piece when in seed mode | |
| | | | |
| skipping to change at line 1116 | | skipping to change at line 1113 | |
| | | | |
| // m_num_verified = m_verified.count() | | // m_num_verified = m_verified.count() | |
| boost::uint32_t m_num_verified; | | boost::uint32_t m_num_verified; | |
| | | | |
| #ifndef TORRENT_DISABLE_ENCRYPTION | | #ifndef TORRENT_DISABLE_ENCRYPTION | |
| // this is SHA1("req2" + info-hash), used for | | // this is SHA1("req2" + info-hash), used for | |
| // encrypted hand shakes | | // encrypted hand shakes | |
| sha1_hash m_obfuscated_hash; | | sha1_hash m_obfuscated_hash; | |
| #endif | | #endif | |
| | | | |
|
| | | // keep a copy if the info-hash here, so it can be accessed | |
| | | from multiple | |
| | | // threads, and be cheap to access from the client | |
| | | sha1_hash m_info_hash; | |
| | | | |
| // the average time it takes to download one time critical p
iece | | // the average time it takes to download one time critical p
iece | |
| boost::uint32_t m_average_piece_time; | | boost::uint32_t m_average_piece_time; | |
| // the average piece download time deviation | | // the average piece download time deviation | |
| boost::uint32_t m_piece_time_deviation; | | boost::uint32_t m_piece_time_deviation; | |
| | | | |
| // the number of bytes that has been | | // the number of bytes that has been | |
| // downloaded that failed the hash-test | | // downloaded that failed the hash-test | |
| boost::uint32_t m_total_failed_bytes; | | boost::uint32_t m_total_failed_bytes; | |
| boost::uint32_t m_total_redundant_bytes; | | boost::uint32_t m_total_redundant_bytes; | |
| | | | |
| | | | |
End of changes. 3 change blocks. |
| 7 lines changed or deleted | | 8 lines changed or added | |
|
| torrent_handle.hpp | | torrent_handle.hpp | |
| | | | |
| skipping to change at line 1149 | | skipping to change at line 1149 | |
| // all wstring APIs are deprecated since 0.16.11 | | // all wstring APIs are deprecated since 0.16.11 | |
| // instead, use the wchar -> utf8 conversion functions | | // instead, use the wchar -> utf8 conversion functions | |
| // and pass in utf8 strings | | // and pass in utf8 strings | |
| TORRENT_DEPRECATED_PREFIX | | TORRENT_DEPRECATED_PREFIX | |
| void move_storage(std::wstring const& save_path, int flags =
0) const TORRENT_DEPRECATED; | | void move_storage(std::wstring const& save_path, int flags =
0) const TORRENT_DEPRECATED; | |
| TORRENT_DEPRECATED_PREFIX | | TORRENT_DEPRECATED_PREFIX | |
| void rename_file(int index, std::wstring const& new_name) co
nst TORRENT_DEPRECATED; | | void rename_file(int index, std::wstring const& new_name) co
nst TORRENT_DEPRECATED; | |
| #endif // TORRENT_USE_WSTRING | | #endif // TORRENT_USE_WSTRING | |
| #endif // TORRENT_NO_DEPRECATE | | #endif // TORRENT_NO_DEPRECATE | |
| | | | |
|
| // Enables or disabled super seeding/initial seeding for thi | | // Enables or disabled super seeding/initial seeding for thi | |
| s torrent. The torrent | | s torrent. | |
| // needs to be a seed for this to take effect. | | // The torrent needs to be a seed for this to take effect. | |
| void super_seeding(bool on) const; | | void super_seeding(bool on) const; | |
| | | | |
|
| // ``info_hash()`` returns the info-hash for the torrent. | | // ``info_hash()`` returns the info-hash of the torrent. If | |
| | | this handle | |
| | | // is to a torrent that hasn't loaded yet (for instance by b | |
| | | eing added) | |
| | | // by a URL, the returned value is undefined. | |
| sha1_hash info_hash() const; | | sha1_hash info_hash() const; | |
| | | | |
| // comparison operators. The order of the torrents is unspec
ified | | // comparison operators. The order of the torrents is unspec
ified | |
| // but stable. | | // but stable. | |
| bool operator==(const torrent_handle& h) const | | bool operator==(const torrent_handle& h) const | |
| { return m_torrent.lock() == h.m_torrent.lock(); } | | { return m_torrent.lock() == h.m_torrent.lock(); } | |
| bool operator!=(const torrent_handle& h) const | | bool operator!=(const torrent_handle& h) const | |
| { return m_torrent.lock() != h.m_torrent.lock(); } | | { return m_torrent.lock() != h.m_torrent.lock(); } | |
| bool operator<(const torrent_handle& h) const | | bool operator<(const torrent_handle& h) const | |
| { return m_torrent.lock() < h.m_torrent.lock(); } | | { return m_torrent.lock() < h.m_torrent.lock(); } | |
| | | | |
End of changes. 2 change blocks. |
| 4 lines changed or deleted | | 8 lines changed or added | |
|
| torrent_info.hpp | | torrent_info.hpp | |
| | | | |
| skipping to change at line 312 | | skipping to change at line 312 | |
| #ifndef BOOST_NO_EXCEPTIONS | | #ifndef BOOST_NO_EXCEPTIONS | |
| // for backwards compatibility with 0.14 | | // for backwards compatibility with 0.14 | |
| typedef libtorrent_exception invalid_torrent_file; | | typedef libtorrent_exception invalid_torrent_file; | |
| #endif | | #endif | |
| | | | |
| // This class represents the information stored in a .torrent file | | // This class represents the information stored in a .torrent file | |
| class TORRENT_EXPORT torrent_info : public intrusive_ptr_base<torren
t_info> | | class TORRENT_EXPORT torrent_info : public intrusive_ptr_base<torren
t_info> | |
| { | | { | |
| public: | | public: | |
| | | | |
|
| // The constructor that takes an info-hash will initialize | | // The constructor that takes an info-hash will initialize | |
| the info-hash to the given value, | | the info-hash | |
| // but leave all other fields empty. This is used internally | | // to the given value, but leave all other fields empty. Thi | |
| when downloading torrents without | | s is used | |
| // the metadata. The metadata will be created by libtorrent | | // internally when downloading torrents without the metadata | |
| as soon as it has been downloaded | | . The | |
| // from the swarm. | | // metadata will be created by libtorrent as soon as it has | |
| // | | been | |
| // The constructor that takes a lazy_entry will create a tor | | // downloaded from the swarm. | |
| rent_info object from the | | // | |
| // information found in the given torrent_file. The lazy_ent | | // The constructor that takes a lazy_entry will create a tor | |
| ry represents a tree node in | | rent_info | |
| // an bencoded file. To load an ordinary .torrent file | | // object from the information found in the given torrent_fi | |
| // into a lazy_entry, use lazy_bdecode(). | | le. The | |
| // | | // lazy_entry represents a tree node in an bencoded file. To | |
| // The version that takes a buffer pointer and a size will d | | load an | |
| ecode it as a .torrent file and | | // ordinary .torrent file into a lazy_entry, use lazy_bdecod | |
| // initialize the torrent_info object for you. | | e(). | |
| // | | // | |
| // The version that takes a filename will simply load the to | | // The version that takes a buffer pointer and a size will d | |
| rrent file and decode it inside | | ecode it as a | |
| // the constructor, for convenience. This might not be the m | | // .torrent file and initialize the torrent_info object for | |
| ost suitable for applications that | | you. | |
| // want to be able to report detailed errors on what might g | | // | |
| o wrong. | | // The version that takes a filename will simply load the to | |
| // | | rrent file | |
| // The overloads that takes an ``error_code const&`` never t | | // and decode it inside the constructor, for convenience. Th | |
| hrows if an error occur, they | | is might not | |
| // will simply set the error code to describe what went wron | | // be the most suitable for applications that want to be abl | |
| g and not fully initialize the | | e to report | |
| // torrent_info object. The overloads that do not take the e | | // detailed errors on what might go wrong. | |
| xtra error_code parameter will | | // | |
| // always throw if an error occurs. These overloads are not | | // There is an upper limit on the size of the torrent file t | |
| available when building without | | hat will be | |
| // exception support. | | // loaded by the overload taking a filename. If it's importa | |
| | | nt that even | |
| | | // very large torrent files are loaded, use one of the other | |
| | | overloads. | |
| | | // | |
| | | // The overloads that takes an ``error_code const&`` never t | |
| | | hrows if an | |
| | | // error occur, they will simply set the error code to descr | |
| | | ibe what went | |
| | | // wrong and not fully initialize the torrent_info object. T | |
| | | he overloads | |
| | | // that do not take the extra error_code parameter will alwa | |
| | | ys throw if | |
| | | // an error occurs. These overloads are not available when b | |
| | | uilding | |
| | | // without exception support. | |
| // | | // | |
| // The ``flags`` argument is currently unused. | | // The ``flags`` argument is currently unused. | |
| #ifndef BOOST_NO_EXCEPTIONS | | #ifndef BOOST_NO_EXCEPTIONS | |
| torrent_info(lazy_entry const& torrent_file, int flags = 0); | | torrent_info(lazy_entry const& torrent_file, int flags = 0); | |
| torrent_info(char const* buffer, int size, int flags = 0); | | torrent_info(char const* buffer, int size, int flags = 0); | |
| torrent_info(std::string const& filename, int flags = 0); | | torrent_info(std::string const& filename, int flags = 0); | |
| #ifndef TORRENT_NO_DEPRECATE | | #ifndef TORRENT_NO_DEPRECATE | |
| #if TORRENT_USE_WSTRING | | #if TORRENT_USE_WSTRING | |
| // all wstring APIs are deprecated since 0.16.11 | | // all wstring APIs are deprecated since 0.16.11 | |
| // instead, use the wchar -> utf8 conversion functions | | // instead, use the wchar -> utf8 conversion functions | |
| | | | |
End of changes. 1 change blocks. |
| 35 lines changed or deleted | | 50 lines changed or added | |
|