| alert.hpp | | alert.hpp | |
| | | | |
| skipping to change at line 183 | | skipping to change at line 183 | |
| virtual ~alert(); | | virtual ~alert(); | |
| | | | |
| // a timestamp is automatically created in the constructor | | // a timestamp is automatically created in the constructor | |
| ptime timestamp() const; | | ptime timestamp() const; | |
| | | | |
| // returns an integer that is unique to this alert type. It
can be | | // returns an integer that is unique to this alert type. It
can be | |
| // compared against a specific alert by querying a static co
nstant called ``alert_type`` | | // compared against a specific alert by querying a static co
nstant called ``alert_type`` | |
| // in the alert. It can be used to determine the run-time ty
pe of an alert* in | | // in the alert. It can be used to determine the run-time ty
pe of an alert* in | |
| // order to cast to that alert type and access specific memb
ers. | | // order to cast to that alert type and access specific memb
ers. | |
| // | | // | |
|
| // e.g:: | | // e.g: | |
| | | // | |
| | | // .. code:: c++ | |
| // | | // | |
| // std::auto_ptr<alert> a = ses.pop_alert(); | | // std::auto_ptr<alert> a = ses.pop_alert(); | |
| // switch (a->type()) | | // switch (a->type()) | |
| // { | | // { | |
| // case read_piece_alert::alert_type: | | // case read_piece_alert::alert_type: | |
| // { | | // { | |
| // read_piece_alert* p = (read_piece_al
ert*)a.get(); | | // read_piece_alert* p = (read_piece_al
ert*)a.get(); | |
| // if (p->ec) { | | // if (p->ec) { | |
| // // read_piece failed | | // // read_piece failed | |
| // break; | | // break; | |
| | | | |
| skipping to change at line 236 | | skipping to change at line 238 | |
| severity_t severity() const TORRENT_DEPRECATED { return warn
ing; } | | severity_t severity() const TORRENT_DEPRECATED { return warn
ing; } | |
| #endif | | #endif | |
| | | | |
| // returns a pointer to a copy of the alert. | | // returns a pointer to a copy of the alert. | |
| virtual std::auto_ptr<alert> clone() const = 0; | | virtual std::auto_ptr<alert> clone() const = 0; | |
| | | | |
| private: | | private: | |
| ptime m_timestamp; | | ptime m_timestamp; | |
| }; | | }; | |
| | | | |
|
| | | #ifndef BOOST_NO_EXCEPTIONS | |
| #ifndef TORRENT_NO_DEPRECATE | | #ifndef TORRENT_NO_DEPRECATE | |
| struct TORRENT_EXPORT unhandled_alert : std::exception | | struct TORRENT_EXPORT unhandled_alert : std::exception | |
| { | | { | |
| unhandled_alert() {} | | unhandled_alert() {} | |
| }; | | }; | |
| | | | |
| #ifndef BOOST_NO_TYPEID | | #ifndef BOOST_NO_TYPEID | |
| | | | |
| namespace detail { | | namespace detail { | |
| | | | |
| | | | |
| skipping to change at line 294 | | skipping to change at line 297 | |
| | | | |
| detail::handle_alert_dispatch(alert_, handler, typei
d(*alert_) | | detail::handle_alert_dispatch(alert_, handler, typei
d(*alert_) | |
| , BOOST_PP_ENUM(TORRENT_MAX_ALERT_TYPES, ALE
RT_POINTER_TYPE, _)); | | , BOOST_PP_ENUM(TORRENT_MAX_ALERT_TYPES, ALE
RT_POINTER_TYPE, _)); | |
| | | | |
| #undef ALERT_POINTER_TYPE | | #undef ALERT_POINTER_TYPE | |
| } | | } | |
| }; | | }; | |
| | | | |
| #endif // BOOST_NO_TYPEID | | #endif // BOOST_NO_TYPEID | |
| #endif // TORRENT_NO_DEPRECATE | | #endif // TORRENT_NO_DEPRECATE | |
|
| | | #endif // BOOST_NO_EXCEPTIONS | |
| | | | |
| // When you get an alert, you can use ``alert_cast<>`` to attempt to cast t
he pointer to a | | // When you get an alert, you can use ``alert_cast<>`` to attempt to cast t
he pointer to a | |
| // more specific alert type, in order to query it for more information. | | // more specific alert type, in order to query it for more information. | |
| template <class T> | | template <class T> | |
| T* alert_cast(alert* a) | | T* alert_cast(alert* a) | |
| { | | { | |
| if (a == 0) return 0; | | if (a == 0) return 0; | |
| if (a->type() == T::alert_type) return static_cast<T*>(a); | | if (a->type() == T::alert_type) return static_cast<T*>(a); | |
| return 0; | | return 0; | |
| } | | } | |
| | | | |
End of changes. 3 change blocks. |
| 1 lines changed or deleted | | 5 lines changed or added | |
|
| config.hpp | | config.hpp | |
| | | | |
| skipping to change at line 562 | | skipping to change at line 562 | |
| && !defined TORRENT_DISABLE_INVARIANT_CHECKS | | && !defined TORRENT_DISABLE_INVARIANT_CHECKS | |
| #define TORRENT_USE_INVARIANT_CHECKS 1 | | #define TORRENT_USE_INVARIANT_CHECKS 1 | |
| #else | | #else | |
| #define TORRENT_USE_INVARIANT_CHECKS 0 | | #define TORRENT_USE_INVARIANT_CHECKS 0 | |
| #endif | | #endif | |
| | | | |
| // for non-exception builds | | // for non-exception builds | |
| #ifdef BOOST_NO_EXCEPTIONS | | #ifdef BOOST_NO_EXCEPTIONS | |
| #define TORRENT_TRY if (true) | | #define TORRENT_TRY if (true) | |
| #define TORRENT_CATCH(x) else if (false) | | #define TORRENT_CATCH(x) else if (false) | |
|
| | | #define TORRENT_CATCH_ALL else if (false) | |
| #define TORRENT_DECLARE_DUMMY(x, y) x y | | #define TORRENT_DECLARE_DUMMY(x, y) x y | |
| #else | | #else | |
| #define TORRENT_TRY try | | #define TORRENT_TRY try | |
| #define TORRENT_CATCH(x) catch(x) | | #define TORRENT_CATCH(x) catch(x) | |
|
| | | #define TORRENT_CATCH_ALL catch(...) | |
| #define TORRENT_DECLARE_DUMMY(x, y) | | #define TORRENT_DECLARE_DUMMY(x, y) | |
| #endif // BOOST_NO_EXCEPTIONS | | #endif // BOOST_NO_EXCEPTIONS | |
| | | | |
| #endif // TORRENT_CONFIG_HPP_INCLUDED | | #endif // TORRENT_CONFIG_HPP_INCLUDED | |
| | | | |
End of changes. 2 change blocks. |
| 0 lines changed or deleted | | 2 lines changed or added | |
|
| create_torrent.hpp | | create_torrent.hpp | |
| | | | |
| skipping to change at line 84 | | skipping to change at line 84 | |
| // | | // | |
| // If there are a lot of files and or deep directoy hierarchies to | | // If there are a lot of files and or deep directoy hierarchies to | |
| // traverse, step one can be time consuming. | | // traverse, step one can be time consuming. | |
| // | | // | |
| // Typically step 3 is by far the most time consuming step, since it | | // Typically step 3 is by far the most time consuming step, since it | |
| // requires to read all the bytes from all the files in the torrent. | | // requires to read all the bytes from all the files in the torrent. | |
| // | | // | |
| // All of these classes and functions are declared by including | | // All of these classes and functions are declared by including | |
| // ``libtorrent/create_torrent.hpp``. | | // ``libtorrent/create_torrent.hpp``. | |
| // | | // | |
|
| // example:: | | // example: | |
| | | // | |
| | | // .. code:: c++ | |
| // | | // | |
| // file_storage fs; | | // file_storage fs; | |
| // | | // | |
| // // recursively adds files in directories | | // // recursively adds files in directories | |
| // add_files(fs, "./my_torrent"); | | // add_files(fs, "./my_torrent"); | |
| // | | // | |
| // create_torrent t(fs); | | // create_torrent t(fs); | |
| // t.add_tracker("http://my.tracker.com/announce"); | | // t.add_tracker("http://my.tracker.com/announce"); | |
| // t.set_creator("libtorrent example"); | | // t.set_creator("libtorrent example"); | |
| // | | // | |
| | | | |
| skipping to change at line 187 | | skipping to change at line 189 | |
| ~create_torrent(); | | ~create_torrent(); | |
| | | | |
| // This function will generate the .torrent file as a bencod
e tree. In order to | | // This function will generate the .torrent file as a bencod
e tree. In order to | |
| // generate the flat file, use the bencode() function. | | // generate the flat file, use the bencode() function. | |
| // | | // | |
| // It may be useful to add custom entries to the torrent fil
e before bencoding it | | // It may be useful to add custom entries to the torrent fil
e before bencoding it | |
| // and saving it to disk. | | // and saving it to disk. | |
| // | | // | |
| // If anything goes wrong during torrent generation, this fu
nction will return | | // If anything goes wrong during torrent generation, this fu
nction will return | |
| // an empty ``entry`` structure. You can test for this condi
tion by querying the | | // an empty ``entry`` structure. You can test for this condi
tion by querying the | |
|
| // type of the entry:: | | // type of the entry: | |
| | | // | |
| | | // .. code:: c++ | |
| // | | // | |
| // file_storage fs; | | // file_storage fs; | |
| // // add file ... | | // // add file ... | |
| // create_torrent t(fs); | | // create_torrent t(fs); | |
| // // add trackers and piece hashes ... | | // // add trackers and piece hashes ... | |
| // e = t.generate(); | | // e = t.generate(); | |
| // | | // | |
| // if (e.type() == entry::undefined_t) | | // if (e.type() == entry::undefined_t) | |
| // { | | // { | |
| // // something went wrong | | // // something went wrong | |
| | | | |
End of changes. 2 change blocks. |
| 2 lines changed or deleted | | 6 lines changed or added | |
|
| entry.hpp | | entry.hpp | |
| | | | |
| skipping to change at line 162 | | skipping to change at line 162 | |
| // isn't of the type you request, the accessor will throw | | // isn't of the type you request, the accessor will throw | |
| // libtorrent_exception (which derives from ``std::runtime_e
rror``). You | | // libtorrent_exception (which derives from ``std::runtime_e
rror``). You | |
| // can ask an ``entry`` for its type through the ``type()``
function. | | // can ask an ``entry`` for its type through the ``type()``
function. | |
| // | | // | |
| // If you want to create an ``entry`` you give it the type y
ou want it to | | // If you want to create an ``entry`` you give it the type y
ou want it to | |
| // have in its constructor, and then use one of the non-cons
t accessors | | // have in its constructor, and then use one of the non-cons
t accessors | |
| // to get a reference which you then can assign the value yo
u want it to | | // to get a reference which you then can assign the value yo
u want it to | |
| // have. | | // have. | |
| // | | // | |
| // The typical code to get info from a torrent file will the
n look like | | // The typical code to get info from a torrent file will the
n look like | |
|
| // this:: | | // this: | |
| | | // | |
| | | // .. code:: c++ | |
| // | | // | |
| // entry torrent_file; | | // entry torrent_file; | |
| // // ... | | // // ... | |
| // | | // | |
| // // throws if this is not a dictionary | | // // throws if this is not a dictionary | |
| // entry::dictionary_type const& dict = torrent_file.di
ct(); | | // entry::dictionary_type const& dict = torrent_file.di
ct(); | |
| // entry::dictionary_type::const_iterator i; | | // entry::dictionary_type::const_iterator i; | |
| // i = dict.find("announce"); | | // i = dict.find("announce"); | |
| // if (i != dict.end()) | | // if (i != dict.end()) | |
| // { | | // { | |
| // std::string tracker_url = i->second.string()
; | | // std::string tracker_url = i->second.string()
; | |
| // std::cout << tracker_url << "\n"; | | // std::cout << tracker_url << "\n"; | |
| // } | | // } | |
| // | | // | |
| // | | // | |
|
| // The following code is equivalent, but a little bit shorte | | // The following code is equivalent, but a little bit shorte | |
| r:: | | r: | |
| | | // | |
| | | // .. code:: c++ | |
| // | | // | |
| // entry torrent_file; | | // entry torrent_file; | |
| // // ... | | // // ... | |
| // | | // | |
| // // throws if this is not a dictionary | | // // throws if this is not a dictionary | |
| // if (entry* i = torrent_file.find_key("announce")) | | // if (entry* i = torrent_file.find_key("announce")) | |
| // { | | // { | |
| // std::string tracker_url = i->string(); | | // std::string tracker_url = i->string(); | |
| // std::cout << tracker_url << "\n"; | | // std::cout << tracker_url << "\n"; | |
| // } | | // } | |
| | | | |
End of changes. 2 change blocks. |
| 3 lines changed or deleted | | 7 lines changed or added | |
|
| http_parser.hpp | | http_parser.hpp | |
| | | | |
| skipping to change at line 65 | | skipping to change at line 65 | |
| | | | |
| namespace libtorrent | | namespace libtorrent | |
| { | | { | |
| | | | |
| // return true if the status code is 200, 206, or in the 300-400 ran
ge | | // return true if the status code is 200, 206, or in the 300-400 ran
ge | |
| bool is_ok_status(int http_status); | | bool is_ok_status(int http_status); | |
| | | | |
| // return true if the status code is a redirect | | // return true if the status code is a redirect | |
| bool is_redirect(int http_status); | | bool is_redirect(int http_status); | |
| | | | |
|
| std::string resolve_redirect_location(std::string referrer | | TORRENT_EXTRA_EXPORT std::string resolve_redirect_location(std::stri
ng referrer | |
| , std::string location); | | , std::string location); | |
| | | | |
| class TORRENT_EXTRA_EXPORT http_parser | | class TORRENT_EXTRA_EXPORT http_parser | |
| { | | { | |
| public: | | public: | |
| enum flags_t { dont_parse_chunks = 1 }; | | enum flags_t { dont_parse_chunks = 1 }; | |
| http_parser(int flags = 0); | | http_parser(int flags = 0); | |
| ~http_parser(); | | ~http_parser(); | |
| std::string const& header(char const* key) const | | std::string const& header(char const* key) const | |
| { | | { | |
| | | | |
End of changes. 1 change blocks. |
| 1 lines changed or deleted | | 1 lines changed or added | |
|
| i2p_stream.hpp | | i2p_stream.hpp | |
| | | | |
| skipping to change at line 194 | | skipping to change at line 194 | |
| private: | | private: | |
| | | | |
| void on_sam_connect(error_code const& ec, i2p_stream::handler_type c
onst& h | | void on_sam_connect(error_code const& ec, i2p_stream::handler_type c
onst& h | |
| , boost::shared_ptr<i2p_stream>); | | , boost::shared_ptr<i2p_stream>); | |
| void do_name_lookup(std::string const& name | | void do_name_lookup(std::string const& name | |
| , name_lookup_handler const& h); | | , name_lookup_handler const& h); | |
| void on_name_lookup(error_code const& ec | | void on_name_lookup(error_code const& ec | |
| , name_lookup_handler handler | | , name_lookup_handler handler | |
| , boost::shared_ptr<i2p_stream>); | | , boost::shared_ptr<i2p_stream>); | |
| | | | |
|
| void set_local_endpoint(error_code const& ec, char const* dest); | | void set_local_endpoint(error_code const& ec, char const* dest | |
| | | , i2p_stream::handler_type const& h); | |
| | | | |
| // to talk to i2p SAM bridge | | // to talk to i2p SAM bridge | |
| boost::shared_ptr<i2p_stream> m_sam_socket; | | boost::shared_ptr<i2p_stream> m_sam_socket; | |
| proxy_settings m_sam_router; | | proxy_settings m_sam_router; | |
| | | | |
| // our i2p endpoint key | | // our i2p endpoint key | |
| std::string m_i2p_local_endpoint; | | std::string m_i2p_local_endpoint; | |
| std::string m_session_id; | | std::string m_session_id; | |
| | | | |
| std::list<std::pair<std::string, name_lookup_handler> > m_name_looku
p; | | std::list<std::pair<std::string, name_lookup_handler> > m_name_looku
p; | |
| | | | |
End of changes. 1 change blocks. |
| 1 lines changed or deleted | | 2 lines changed or added | |
|
| invariant_check.hpp | | invariant_check.hpp | |
| // Copyright Daniel Wallin 2004. Use, modification and distribution is | | // Copyright Daniel Wallin 2004. Use, modification and distribution is | |
| // subject to the Boost Software License, Version 1.0. (See accompanying | | // subject to the Boost Software License, Version 1.0. (See accompanying | |
| // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
| | | | |
| #ifndef TORRENT_INVARIANT_ACCESS_HPP_INCLUDED | | #ifndef TORRENT_INVARIANT_ACCESS_HPP_INCLUDED | |
| #define TORRENT_INVARIANT_ACCESS_HPP_INCLUDED | | #define TORRENT_INVARIANT_ACCESS_HPP_INCLUDED | |
| | | | |
| #include "libtorrent/config.hpp" | | #include "libtorrent/config.hpp" | |
| #include "libtorrent/assert.hpp" | | #include "libtorrent/assert.hpp" | |
|
| | | #include "libtorrent/config.hpp" | |
| | | | |
| #if TORRENT_USE_INVARIANT_CHECKS | | #if TORRENT_USE_INVARIANT_CHECKS | |
| | | | |
| namespace libtorrent | | namespace libtorrent | |
| { | | { | |
| | | | |
| class invariant_access | | class invariant_access | |
| { | | { | |
| public: | | public: | |
| template<class T> | | template<class T> | |
| | | | |
| skipping to change at line 40 | | skipping to change at line 41 | |
| } | | } | |
| | | | |
| struct invariant_checker {}; | | struct invariant_checker {}; | |
| | | | |
| template<class T> | | template<class T> | |
| struct invariant_checker_impl : invariant_checker | | struct invariant_checker_impl : invariant_checker | |
| { | | { | |
| invariant_checker_impl(T const& self_) | | invariant_checker_impl(T const& self_) | |
| : self(self_) | | : self(self_) | |
| { | | { | |
|
| try | | TORRENT_TRY | |
| { | | { | |
| check_invariant(self); | | check_invariant(self); | |
| } | | } | |
|
| catch (...) | | TORRENT_CATCH_ALL | |
| { | | { | |
| TORRENT_ASSERT(false); | | TORRENT_ASSERT(false); | |
| } | | } | |
| } | | } | |
| | | | |
| ~invariant_checker_impl() | | ~invariant_checker_impl() | |
| { | | { | |
|
| try | | TORRENT_TRY | |
| { | | { | |
| check_invariant(self); | | check_invariant(self); | |
| } | | } | |
|
| catch (...) | | TORRENT_CATCH_ALL | |
| { | | { | |
| TORRENT_ASSERT(false); | | TORRENT_ASSERT(false); | |
| } | | } | |
| } | | } | |
| | | | |
| T const& self; | | T const& self; | |
| }; | | }; | |
| | | | |
| template<class T> | | template<class T> | |
| invariant_checker_impl<T> make_invariant_checker(T const& x) | | invariant_checker_impl<T> make_invariant_checker(T const& x) | |
| | | | |
End of changes. 5 change blocks. |
| 4 lines changed or deleted | | 5 lines changed or added | |
|
| item.hpp | | item.hpp | |
| | | | |
| skipping to change at line 78 | | skipping to change at line 78 | |
| // is responsible for allocating the destination buffer that's passed in | | // is responsible for allocating the destination buffer that's passed in | |
| // as the ``sig`` argument. Typically it would be allocated on the stack. | | // as the ``sig`` argument. Typically it would be allocated on the stack. | |
| void TORRENT_EXPORT sign_mutable_item( | | void TORRENT_EXPORT sign_mutable_item( | |
| std::pair<char const*, int> v | | std::pair<char const*, int> v | |
| , std::pair<char const*, int> salt | | , std::pair<char const*, int> salt | |
| , boost::uint64_t seq | | , boost::uint64_t seq | |
| , char const* pk | | , char const* pk | |
| , char const* sk | | , char const* sk | |
| , char* sig); | | , char* sig); | |
| | | | |
|
| sha1_hash TORRENT_EXTRA_EXPORT mutable_item_cas( | | | |
| std::pair<char const*, int> v | | | |
| , std::pair<char const*, int> salt | | | |
| , boost::uint64_t seq); | | | |
| | | | |
| struct TORRENT_EXTRA_EXPORT invalid_item : std::exception | | | |
| { | | | |
| virtual const char* what() const throw() { return "invalid DHT item" | | | |
| ; } | | | |
| }; | | | |
| | | | |
| enum | | enum | |
| { | | { | |
| item_pk_len = 32, | | item_pk_len = 32, | |
| item_sk_len = 64, | | item_sk_len = 64, | |
| item_sig_len = 64 | | item_sig_len = 64 | |
| }; | | }; | |
| | | | |
| class TORRENT_EXTRA_EXPORT item | | class TORRENT_EXTRA_EXPORT item | |
| { | | { | |
| public: | | public: | |
| item() : m_seq(0), m_mutable(false) {} | | item() : m_seq(0), m_mutable(false) {} | |
| item(char const* pk, std::string const& salt); | | item(char const* pk, std::string const& salt); | |
| item(entry const& v) { assign(v); } | | item(entry const& v) { assign(v); } | |
| item(entry const& v | | item(entry const& v | |
| , std::pair<char const*, int> salt | | , std::pair<char const*, int> salt | |
| , boost::uint64_t seq, char const* pk, char const* sk); | | , boost::uint64_t seq, char const* pk, char const* sk); | |
| item(lazy_entry const* v) { assign(v); } | | item(lazy_entry const* v) { assign(v); } | |
|
| item(lazy_entry const* v, std::pair<char const*, int> salt | | | |
| , boost::uint64_t seq, char const* pk, char const* sig); | | | |
| | | | |
| void assign(entry const& v) | | void assign(entry const& v) | |
| { | | { | |
| assign(v, std::pair<char const*, int>(static_cast<char const
*>(NULL) | | assign(v, std::pair<char const*, int>(static_cast<char const
*>(NULL) | |
| , 0), 0, NULL, NULL); | | , 0), 0, NULL, NULL); | |
| } | | } | |
| void assign(entry const& v, std::pair<char const*, int> salt | | void assign(entry const& v, std::pair<char const*, int> salt | |
| , boost::uint64_t seq, char const* pk, char const* sk); | | , boost::uint64_t seq, char const* pk, char const* sk); | |
| void assign(lazy_entry const* v) | | void assign(lazy_entry const* v) | |
| { | | { | |
| | | | |
| skipping to change at line 130 | | skipping to change at line 118 | |
| bool assign(lazy_entry const* v, std::pair<char const*, int> salt | | bool assign(lazy_entry const* v, std::pair<char const*, int> salt | |
| , boost::uint64_t seq, char const* pk, char const* sig); | | , boost::uint64_t seq, char const* pk, char const* sig); | |
| void assign(entry const& v, std::string salt, boost::uint64_t seq | | void assign(entry const& v, std::string salt, boost::uint64_t seq | |
| , char const* pk, char const* sig); | | , char const* pk, char const* sig); | |
| | | | |
| void clear() { m_value = entry(); } | | void clear() { m_value = entry(); } | |
| bool empty() const { return m_value.type() == entry::undefined_t; } | | bool empty() const { return m_value.type() == entry::undefined_t; } | |
| | | | |
| bool is_mutable() const { return m_mutable; } | | bool is_mutable() const { return m_mutable; } | |
| | | | |
|
| sha1_hash cas(); | | | |
| | | | |
| entry const& value() const { return m_value; } | | entry const& value() const { return m_value; } | |
| boost::array<char, item_pk_len> const& pk() const | | boost::array<char, item_pk_len> const& pk() const | |
| { return m_pk; } | | { return m_pk; } | |
| boost::array<char, item_sig_len> const& sig() const | | boost::array<char, item_sig_len> const& sig() const | |
| { return m_sig; } | | { return m_sig; } | |
| boost::uint64_t seq() const { return m_seq; } | | boost::uint64_t seq() const { return m_seq; } | |
| std::string const& salt() const { return m_salt; } | | std::string const& salt() const { return m_salt; } | |
| | | | |
| private: | | private: | |
| entry m_value; | | entry m_value; | |
| | | | |
End of changes. 3 change blocks. |
| 15 lines changed or deleted | | 0 lines changed or added | |
|
| lsd.hpp | | lsd.hpp | |
| | | | |
| skipping to change at line 69 | | skipping to change at line 69 | |
| , peer_callback_t const& cb); | | , peer_callback_t const& cb); | |
| ~lsd(); | | ~lsd(); | |
| | | | |
| // void rebind(address const& listen_interface); | | // void rebind(address const& listen_interface); | |
| | | | |
| void announce(sha1_hash const& ih, int listen_port, bool broadcast =
false); | | void announce(sha1_hash const& ih, int listen_port, bool broadcast =
false); | |
| void close(); | | void close(); | |
| | | | |
| private: | | private: | |
| | | | |
|
| void resend_announce(error_code const& e, std::string msg); | | void announce_impl(sha1_hash const& ih, int listen_port | |
| | | , bool broadcast, int retry_count); | |
| | | void resend_announce(error_code const& e, sha1_hash const& ih | |
| | | , int listen_port, int retry_count); | |
| void on_announce(udp::endpoint const& from, char* buffer | | void on_announce(udp::endpoint const& from, char* buffer | |
| , std::size_t bytes_transferred); | | , std::size_t bytes_transferred); | |
|
| // void setup_receive(); | | | |
| | | | |
| peer_callback_t m_callback; | | peer_callback_t m_callback; | |
| | | | |
| // the udp socket used to send and receive | | // the udp socket used to send and receive | |
| // multicast messages on | | // multicast messages on | |
| broadcast_socket m_socket; | | broadcast_socket m_socket; | |
|
| | | #if TORRENT_USE_IPV6 | |
| | | broadcast_socket m_socket6; | |
| | | #endif | |
| | | | |
| // used to resend udp packets in case | | // used to resend udp packets in case | |
| // they time out | | // they time out | |
| deadline_timer m_broadcast_timer; | | deadline_timer m_broadcast_timer; | |
| | | | |
|
| // current retry count | | | |
| boost::uint32_t m_retry_count; | | | |
| | | | |
| // this is a random (presumably unique) | | // this is a random (presumably unique) | |
| // ID for this LSD node. It is used to | | // ID for this LSD node. It is used to | |
| // ignore our own broadcast messages. | | // ignore our own broadcast messages. | |
| // There's no point in adding ourselves | | // There's no point in adding ourselves | |
| // as a peer | | // as a peer | |
| int m_cookie; | | int m_cookie; | |
| | | | |
| bool m_disabled; | | bool m_disabled; | |
|
| | | #if TORRENT_USE_IPV6 | |
| | | bool m_disabled6; | |
| | | #endif | |
| #if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING) | | #if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING) | |
| FILE* m_log; | | FILE* m_log; | |
| #endif | | #endif | |
| }; | | }; | |
| | | | |
| } | | } | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 5 change blocks. |
| 5 lines changed or deleted | | 10 lines changed or added | |
|
| peer_connection.hpp | | peer_connection.hpp | |
| | | | |
| skipping to change at line 432 | | skipping to change at line 432 | |
| bool ignore_unchoke_slots() const; | | bool ignore_unchoke_slots() const; | |
| void ignore_unchoke_slots(bool i) | | void ignore_unchoke_slots(bool i) | |
| { m_ignore_unchoke_slots = i; } | | { m_ignore_unchoke_slots = i; } | |
| | | | |
| bool failed() const { return m_failed; } | | bool failed() const { return m_failed; } | |
| | | | |
| int desired_queue_size() const | | int desired_queue_size() const | |
| { | | { | |
| // this peer is in end-game mode we only want | | // this peer is in end-game mode we only want | |
| // one outstanding request | | // one outstanding request | |
|
| return m_endgame_mode ? 1: m_desired_queue_size; | | return (m_endgame_mode || m_snubbed) ? 1 : m_desired
_queue_size; | |
| } | | } | |
| | | | |
| bool bittyrant_unchoke_compare( | | bool bittyrant_unchoke_compare( | |
| boost::intrusive_ptr<peer_connection const> const& p
) const; | | boost::intrusive_ptr<peer_connection const> const& p
) const; | |
| // compares this connection against the given connection | | // compares this connection against the given connection | |
| // for which one is more eligible for an unchoke. | | // for which one is more eligible for an unchoke. | |
| // returns true if this is more eligible | | // returns true if this is more eligible | |
| bool unchoke_compare(boost::intrusive_ptr<peer_connection co
nst> const& p) const; | | bool unchoke_compare(boost::intrusive_ptr<peer_connection co
nst> const& p) const; | |
| bool upload_rate_compare(peer_connection const* p) const; | | bool upload_rate_compare(peer_connection const* p) const; | |
| | | | |
| | | | |
| skipping to change at line 1150 | | skipping to change at line 1150 | |
| // we need to send to this peer for it to unchoke | | // we need to send to this peer for it to unchoke | |
| // us | | // us | |
| int m_est_reciprocation_rate; | | int m_est_reciprocation_rate; | |
| | | | |
| // estimated round trip time to this peer | | // estimated round trip time to this peer | |
| // based on the time from when async_connect | | // based on the time from when async_connect | |
| // was called to when on_connection_complete | | // was called to when on_connection_complete | |
| // was called. The rtt is specified in milliseconds | | // was called. The rtt is specified in milliseconds | |
| boost::uint16_t m_rtt; | | boost::uint16_t m_rtt; | |
| | | | |
|
| | | // the number of request we should queue up | |
| | | // at the remote end. | |
| | | boost::uint16_t m_desired_queue_size; | |
| | | | |
| #ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES | | #ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES | |
| // in case the session settings is set | | // in case the session settings is set | |
| // to resolve countries, this is set to | | // to resolve countries, this is set to | |
| // the two character country code this | | // the two character country code this | |
| // peer resides in. | | // peer resides in. | |
| char m_country[2]; | | char m_country[2]; | |
| #endif | | #endif | |
| | | | |
| // if set to non-zero, this peer will always prefer | | // if set to non-zero, this peer will always prefer | |
| // to request entire n pieces, rather than blocks. | | // to request entire n pieces, rather than blocks. | |
| // where n is the value of this variable. | | // where n is the value of this variable. | |
| // if it is 0, the download rate limit setting | | // if it is 0, the download rate limit setting | |
| // will be used to determine if whole pieces | | // will be used to determine if whole pieces | |
| // are preferred. | | // are preferred. | |
| boost::uint8_t m_prefer_whole_pieces; | | boost::uint8_t m_prefer_whole_pieces; | |
| | | | |
|
| // the number of request we should queue up | | | |
| // at the remote end. | | | |
| boost::uint8_t m_desired_queue_size; | | | |
| | | | |
| // if this is true, the disconnection | | // if this is true, the disconnection | |
| // timestamp is not updated when the connection | | // timestamp is not updated when the connection | |
| // is closed. This means the time until we can | | // is closed. This means the time until we can | |
| // reconnect to this peer is shorter, and likely | | // reconnect to this peer is shorter, and likely | |
| // immediate. | | // immediate. | |
| bool m_fast_reconnect:1; | | bool m_fast_reconnect:1; | |
| | | | |
| // is true if it was we that connected to the peer | | // is true if it was we that connected to the peer | |
| // and false if we got an incoming connection | | // and false if we got an incoming connection | |
| // could be considered: true = local, false = remote | | // could be considered: true = local, false = remote | |
| | | | |
End of changes. 3 change blocks. |
| 5 lines changed or deleted | | 5 lines changed or added | |
|
| sliding_average.hpp | | sliding_average.hpp | |
| | | | |
| skipping to change at line 36 | | skipping to change at line 36 | |
| INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
| CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
| POSSIBILITY OF SUCH DAMAGE. | | POSSIBILITY OF SUCH DAMAGE. | |
| | | | |
| */ | | */ | |
| | | | |
| #ifndef TORRENT_SLIDING_AVERAGE_HPP_INCLUDED | | #ifndef TORRENT_SLIDING_AVERAGE_HPP_INCLUDED | |
| #define TORRENT_SLIDING_AVERAGE_HPP_INCLUDED | | #define TORRENT_SLIDING_AVERAGE_HPP_INCLUDED | |
| | | | |
|
| | | #include <boost/cstdint.hpp> | |
| | | | |
| namespace libtorrent | | namespace libtorrent | |
| { | | { | |
|
| // a sliding average accumulator. Add samples to it and it | | | |
| // keeps track of a sliding mean value and an average deviation | | // an exponential moving average accumulator. Add samples to it and it keep | |
| // from that average. | | s | |
| template <int history_size> | | // track of a moving mean value and an average deviation | |
| | | template <int inverted_gain> | |
| struct sliding_average | | struct sliding_average | |
| { | | { | |
|
| sliding_average(): m_mean(-1), m_average_deviation(-1) {} | | sliding_average(): m_mean(0), m_average_deviation(0), m_num_samples(
0) {} | |
| | | | |
| void add_sample(int s) | | void add_sample(int s) | |
| { | | { | |
|
| if (m_mean == -1) | | // fixed point | |
| { | | s *= 64; | |
| m_mean = s; | | int deviation; | |
| return; | | | |
| } | | if (m_num_samples > 0) | |
| int deviation = abs(m_mean - s); | | deviation = abs(m_mean - s); | |
| | | | |
| m_mean = m_mean - m_mean / history_size + s / history_size; | | if (m_num_samples < inverted_gain) | |
| | | ++m_num_samples; | |
| if (m_average_deviation == -1) | | | |
| { | | m_mean += (s - m_mean) / m_num_samples; | |
| m_average_deviation = deviation; | | | |
| return; | | if (m_num_samples > 1) { | |
| | | // the the exact same thing for deviation off the me | |
| | | an except -1 on | |
| | | // the samples, because the number of deviation samp | |
| | | les always lags | |
| | | // behind by 1 (you need to actual samples to have a | |
| | | single deviation | |
| | | // sample). | |
| | | m_average_deviation += (deviation - m_average_deviat | |
| | | ion) / (m_num_samples - 1); | |
| } | | } | |
|
| m_average_deviation = m_average_deviation - m_average_deviat | | | |
| ion | | | |
| / history_size + deviation / history_size; | | | |
| } | | } | |
| | | | |
|
| int mean() const { return m_mean != -1 ? m_mean : 0; } | | int mean() const { return m_num_samples > 0 ? (m_mean + 32) / 64 : 0 | |
| int avg_deviation() const { return m_average_deviation != -1 ? m_ave | | ; } | |
| rage_deviation : 0; } | | int avg_deviation() const { return m_num_samples > 1 ? (m_average_de | |
| | | viation + 32) / 64 : 0; } | |
| | | | |
| private: | | private: | |
|
| | | // both of these are fixed point values (* 64) | |
| int m_mean; | | int m_mean; | |
| int m_average_deviation; | | int m_average_deviation; | |
|
| | | // the number of samples we have received, but no more than inverted | |
| | | _gain | |
| | | // this is the effective inverted_gain | |
| | | int m_num_samples; | |
| }; | | }; | |
| | | | |
| struct average_accumulator | | struct average_accumulator | |
| { | | { | |
| average_accumulator() | | average_accumulator() | |
| : m_num_samples(0) | | : m_num_samples(0) | |
| , m_sample_sum(0) | | , m_sample_sum(0) | |
| {} | | {} | |
| | | | |
| void add_sample(int s) | | void add_sample(int s) | |
| | | | |
| skipping to change at line 98 | | skipping to change at line 107 | |
| { | | { | |
| int ret; | | int ret; | |
| if (m_num_samples == 0) ret = 0; | | if (m_num_samples == 0) ret = 0; | |
| else ret = int(m_sample_sum / m_num_samples); | | else ret = int(m_sample_sum / m_num_samples); | |
| m_num_samples = 0; | | m_num_samples = 0; | |
| m_sample_sum = 0; | | m_sample_sum = 0; | |
| return ret; | | return ret; | |
| } | | } | |
| | | | |
| int m_num_samples; | | int m_num_samples; | |
|
| size_type m_sample_sum; | | boost::uint64_t m_sample_sum; | |
| }; | | }; | |
| | | | |
| } | | } | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 9 change blocks. |
| 25 lines changed or deleted | | 40 lines changed or added | |
|
| storage.hpp | | storage.hpp | |
| | | | |
| skipping to change at line 84 | | skipping to change at line 84 | |
| // A custom storage implementation must derive from and implement the | | // A custom storage implementation must derive from and implement the | |
| // storage_interface. You must also provide a function that constructs the | | // storage_interface. You must also provide a function that constructs the | |
| // custom storage object and provide this function to the add_torrent() cal
l | | // custom storage object and provide this function to the add_torrent() cal
l | |
| // via add_torrent_params. Either passed in to the constructor or by settin
g | | // via add_torrent_params. Either passed in to the constructor or by settin
g | |
| // the add_torrent_params::storage field. | | // the add_torrent_params::storage field. | |
| // | | // | |
| // This is an example storage implementation that stores all pieces in a | | // This is an example storage implementation that stores all pieces in a | |
| // ``std::map``, i.e. in RAM. It's not necessarily very useful in practice,
but | | // ``std::map``, i.e. in RAM. It's not necessarily very useful in practice,
but | |
| // illustrates the basics of implementing a custom storage. | | // illustrates the basics of implementing a custom storage. | |
| // | | // | |
|
| //:: | | // .. code:: c++ | |
| // | | // | |
| // struct temp_storage : storage_interface | | // struct temp_storage : storage_interface | |
| // { | | // { | |
| // temp_storage(file_storage const& fs) : m_files(fs) {} | | // temp_storage(file_storage const& fs) : m_files(fs) {} | |
| // void set_file_priority(std::vector<boost::uint8_t> const& pr
io) {} | | // void set_file_priority(std::vector<boost::uint8_t> const& pr
io) {} | |
| // virtual bool initialize(bool allocate_files) { return false;
} | | // virtual bool initialize(bool allocate_files) { return false;
} | |
| // virtual bool has_any_file() { return false; } | | // virtual bool has_any_file() { return false; } | |
| // virtual int read(char* buf, int slot, int offset, int size) | | // virtual int read(char* buf, int slot, int offset, int size) | |
| // { | | // { | |
| // std::map<int, std::vector<char> >::const_iterator i
= m_file_data.find(slot); | | // std::map<int, std::vector<char> >::const_iterator i
= m_file_data.find(slot); | |
| | | | |
End of changes. 1 change blocks. |
| 1 lines changed or deleted | | 1 lines changed or added | |
|
| torrent_handle.hpp | | torrent_handle.hpp | |
| | | | |
| skipping to change at line 659 | | skipping to change at line 659 | |
| // | | // | |
| // It also means that if the resume data is out dated, libto
rrent will | | // It also means that if the resume data is out dated, libto
rrent will | |
| // not re-check the files, but assume that it is fairly rece
nt. The | | // not re-check the files, but assume that it is fairly rece
nt. The | |
| // assumption is that it's better to loose a little bit than
to re-check | | // assumption is that it's better to loose a little bit than
to re-check | |
| // the entire file. | | // the entire file. | |
| // | | // | |
| // It is still a good idea to save resume data periodically
during | | // It is still a good idea to save resume data periodically
during | |
| // download as well as when closing down. | | // download as well as when closing down. | |
| // | | // | |
| // Example code to pause and save resume data for all torren
ts and wait | | // Example code to pause and save resume data for all torren
ts and wait | |
|
| // for the alerts:: | | // for the alerts: | |
| | | // | |
| | | // .. code:: c++ | |
| // | | // | |
| // extern int outstanding_resume_data; // global counte
r of outstanding resume data | | // extern int outstanding_resume_data; // global counte
r of outstanding resume data | |
| // std::vector<torrent_handle> handles = ses.get_torren
ts(); | | // std::vector<torrent_handle> handles = ses.get_torren
ts(); | |
| // ses.pause(); | | // ses.pause(); | |
| // for (std::vector<torrent_handle>::iterator i = handl
es.begin(); | | // for (std::vector<torrent_handle>::iterator i = handl
es.begin(); | |
| // i != handles.end(); ++i) | | // i != handles.end(); ++i) | |
| // { | | // { | |
| // torrent_handle& h = *i; | | // torrent_handle& h = *i; | |
| // if (!h.is_valid()) continue; | | // if (!h.is_valid()) continue; | |
| // torrent_status s = h.status(); | | // torrent_status s = h.status(); | |
| | | | |
End of changes. 1 change blocks. |
| 1 lines changed or deleted | | 3 lines changed or added | |
|
| version.hpp | | version.hpp | |
| | | | |
| skipping to change at line 38 | | skipping to change at line 38 | |
| ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
| POSSIBILITY OF SUCH DAMAGE. | | POSSIBILITY OF SUCH DAMAGE. | |
| | | | |
| */ | | */ | |
| | | | |
| #ifndef TORRENT_VERSION_HPP_INCLUDED | | #ifndef TORRENT_VERSION_HPP_INCLUDED | |
| #define TORRENT_VERSION_HPP_INCLUDED | | #define TORRENT_VERSION_HPP_INCLUDED | |
| | | | |
| #define LIBTORRENT_VERSION_MAJOR 1 | | #define LIBTORRENT_VERSION_MAJOR 1 | |
| #define LIBTORRENT_VERSION_MINOR 0 | | #define LIBTORRENT_VERSION_MINOR 0 | |
|
| #define LIBTORRENT_VERSION_TINY 1 | | #define LIBTORRENT_VERSION_TINY 2 | |
| | | | |
| // the format of this version is: MMmmtt | | // the format of this version is: MMmmtt | |
| // M = Major version, m = minor version, t = tiny version | | // M = Major version, m = minor version, t = tiny version | |
| #define LIBTORRENT_VERSION_NUM ((LIBTORRENT_VERSION_MAJOR * 10000) + (LIBTO
RRENT_VERSION_MINOR * 100) + LIBTORRENT_VERSION_TINY) | | #define LIBTORRENT_VERSION_NUM ((LIBTORRENT_VERSION_MAJOR * 10000) + (LIBTO
RRENT_VERSION_MINOR * 100) + LIBTORRENT_VERSION_TINY) | |
| | | | |
|
| #define LIBTORRENT_VERSION "1.0.1.0" | | #define LIBTORRENT_VERSION "1.0.2.0" | |
| #define LIBTORRENT_REVISION "$Rev: 10111 $" | | #define LIBTORRENT_REVISION "$Rev: 10260 $" | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 2 change blocks. |
| 3 lines changed or deleted | | 3 lines changed or added | |
|