2006-08-28 02:36:00 +02:00
|
|
|
|
============================
|
|
|
|
|
libtorrent API Documentation
|
|
|
|
|
============================
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2005-10-13 09:59:05 +02:00
|
|
|
|
:Author: Arvid Norberg, arvid@rasterbar.com
|
2009-01-29 01:35:57 +01:00
|
|
|
|
:Version: 0.15.0
|
2005-05-03 15:13:57 +02:00
|
|
|
|
|
2005-08-17 19:19:20 +02:00
|
|
|
|
.. contents:: Table of contents
|
2005-08-10 20:04:39 +02:00
|
|
|
|
:depth: 2
|
2005-08-17 19:19:20 +02:00
|
|
|
|
:backlinks: none
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2005-08-17 19:19:20 +02:00
|
|
|
|
overview
|
|
|
|
|
========
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
|
|
|
|
The interface of libtorrent consists of a few classes. The main class is
|
|
|
|
|
the ``session``, it contains the main loop that serves all torrents.
|
|
|
|
|
|
|
|
|
|
The basic usage is as follows:
|
|
|
|
|
|
2006-01-24 01:47:27 +01:00
|
|
|
|
* construct a session
|
2009-12-03 06:11:57 +01:00
|
|
|
|
* load session state from settings file (see `load_state() save_state()`_)
|
2008-09-17 17:25:12 +02:00
|
|
|
|
* start extensions (see `add_extension()`_).
|
2009-11-01 04:13:50 +01:00
|
|
|
|
* start DHT, LSD, UPnP, NAT-PMP etc (see `start_dht() stop_dht() set_dht_settings() dht_state() is_dht_running()`_
|
2008-04-07 02:15:36 +02:00
|
|
|
|
`start_lsd() stop_lsd()`_, `start_upnp() stop_upnp()`_ and `start_natpmp() stop_natpmp()`_)
|
2007-11-24 21:48:51 +01:00
|
|
|
|
* parse .torrent-files and add them to the session (see `bdecode() bencode()`_ and `add_torrent()`_)
|
2004-04-17 17:17:43 +02:00
|
|
|
|
* main loop (see session_)
|
2005-09-18 12:18:23 +02:00
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
* query the torrent_handles for progress (see torrent_handle_)
|
2004-01-07 01:48:02 +01:00
|
|
|
|
* query the session for information
|
|
|
|
|
* add and remove torrents from the session at run-time
|
2005-09-18 12:18:23 +02:00
|
|
|
|
|
2005-08-17 19:19:20 +02:00
|
|
|
|
* save resume data for all torrent_handles (optional, see
|
2008-04-13 20:54:36 +02:00
|
|
|
|
`save_resume_data()`_)
|
2009-12-03 06:11:57 +01:00
|
|
|
|
* save session state (see `load_state() save_state()`_)
|
2004-01-07 01:48:02 +01:00
|
|
|
|
* destruct session object
|
|
|
|
|
|
|
|
|
|
Each class and function is described in this manual.
|
|
|
|
|
|
2008-05-28 10:44:40 +02:00
|
|
|
|
For a description on how to create torrent files, see make_torrent_.
|
|
|
|
|
|
|
|
|
|
.. _make_torrent: make_torrent.html
|
|
|
|
|
|
2009-06-19 00:32:55 +02:00
|
|
|
|
things to keep in mind
|
|
|
|
|
======================
|
|
|
|
|
|
|
|
|
|
A common problem developers are facing is torrents stopping without explanation.
|
|
|
|
|
Here is a description on which conditions libtorrent will stop your torrents,
|
|
|
|
|
how to find out about it and what to do about it.
|
|
|
|
|
|
|
|
|
|
Make sure to keep track of the paused state, the error state and the upload
|
|
|
|
|
mode of your torrents. By default, torrents are auto-managed, which means
|
|
|
|
|
libtorrent will pause them, unpause them, scrape them and take them out
|
|
|
|
|
of upload-mode automatically.
|
|
|
|
|
|
|
|
|
|
Whenever a torrent encounters a fatal error, it will be stopped, and the
|
|
|
|
|
``session_status::error`` will describe the error that caused it. If a torrent
|
|
|
|
|
is auto managed, it is scraped periodically and paused or resumed based on
|
|
|
|
|
the number of downloaders per seed. This will effectively seed torrents that
|
|
|
|
|
are in the greatest need of seeds.
|
|
|
|
|
|
|
|
|
|
If a torrent hits a disk write error, it will be put into upload mode. This
|
|
|
|
|
means it will not download anything, but only upload. The assumption is that
|
|
|
|
|
the write error is caused by a full disk or write permission errors. If the
|
|
|
|
|
torrent is auto-managed, it will periodically be taken out of the upload
|
|
|
|
|
mode, trying to write things to the disk again. This means torrent will recover
|
|
|
|
|
from certain disk errors if the problem is resolved. If the torrent is not
|
|
|
|
|
auto managed, you have to call `set_upload_mode()`_ to turn
|
|
|
|
|
downloading back on again.
|
|
|
|
|
|
|
|
|
|
|
2007-11-24 21:48:51 +01:00
|
|
|
|
network primitives
|
|
|
|
|
==================
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2006-09-01 05:06:00 +02:00
|
|
|
|
There are a few typedefs in the ``libtorrent`` namespace which pulls
|
|
|
|
|
in network types from the ``asio`` namespace. These are::
|
|
|
|
|
|
|
|
|
|
typedef asio::ip::address address;
|
|
|
|
|
typedef asio::ip::address_v4 address_v4;
|
|
|
|
|
typedef asio::ip::address_v6 address_v6;
|
|
|
|
|
using asio::ip::tcp;
|
|
|
|
|
using asio::ip::udp;
|
|
|
|
|
|
|
|
|
|
These are declared in the ``<libtorrent/socket.hpp>`` header.
|
|
|
|
|
|
|
|
|
|
The ``using`` statements will give easy access to::
|
|
|
|
|
|
|
|
|
|
tcp::endpoint
|
|
|
|
|
udp::endpoint
|
|
|
|
|
|
|
|
|
|
Which are the endpoint types used in libtorrent. An endpoint is an address
|
|
|
|
|
with an associated port.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2007-11-24 21:48:51 +01:00
|
|
|
|
For documentation on these types, please refer to the `asio documentation`_.
|
|
|
|
|
|
|
|
|
|
.. _`asio documentation`: http://asio.sourceforge.net/asio-0.3.8/doc/asio/reference.html
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
session
|
|
|
|
|
=======
|
|
|
|
|
|
|
|
|
|
The ``session`` class has the following synopsis::
|
|
|
|
|
|
|
|
|
|
class session: public boost::noncopyable
|
|
|
|
|
{
|
2004-02-26 01:27:06 +01:00
|
|
|
|
|
2006-05-21 12:41:37 +02:00
|
|
|
|
session(fingerprint const& print
|
2006-08-28 02:36:00 +02:00
|
|
|
|
= libtorrent::fingerprint(
|
2008-09-22 01:19:58 +02:00
|
|
|
|
"LT", 0, 1, 0, 0)
|
2009-02-09 04:48:27 +01:00
|
|
|
|
, int flags = start_default_features
|
|
|
|
|
| add_default_plugins
|
2008-11-16 03:09:53 +01:00
|
|
|
|
, int alert_mask = alert::error_notification);
|
2004-03-29 00:44:40 +02:00
|
|
|
|
|
2004-02-26 01:27:06 +01:00
|
|
|
|
session(
|
2006-05-21 12:41:37 +02:00
|
|
|
|
fingerprint const& print
|
2004-03-29 00:44:40 +02:00
|
|
|
|
, std::pair<int, int> listen_port_range
|
2008-09-22 01:19:58 +02:00
|
|
|
|
, char const* listen_interface = 0
|
2009-02-09 04:48:27 +01:00
|
|
|
|
, int flags = start_default_features
|
|
|
|
|
| add_default_plugins
|
2008-11-16 03:09:53 +01:00
|
|
|
|
, int alert_mask = alert::error_notification);
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2009-12-03 06:11:57 +01:00
|
|
|
|
void load_state(lazy_entry const& e);
|
|
|
|
|
void save_state(entry& e) const;
|
|
|
|
|
|
2009-02-09 04:48:27 +01:00
|
|
|
|
torrent_handle add_torrent(
|
|
|
|
|
add_torrent_params const& params);
|
2009-02-26 08:09:56 +01:00
|
|
|
|
torrent_handle add_torrent(
|
|
|
|
|
add_torrent_params const& params
|
|
|
|
|
, error_code& ec);
|
2004-06-17 22:56:49 +02:00
|
|
|
|
|
2008-06-29 21:08:30 +02:00
|
|
|
|
void pause();
|
|
|
|
|
void resume();
|
|
|
|
|
bool is_paused() const;
|
|
|
|
|
|
2006-10-11 16:02:21 +02:00
|
|
|
|
session_proxy abort();
|
|
|
|
|
|
2007-11-23 23:45:59 +01:00
|
|
|
|
enum options_t
|
|
|
|
|
{
|
|
|
|
|
none = 0,
|
|
|
|
|
delete_files = 1
|
|
|
|
|
};
|
|
|
|
|
|
2008-09-22 01:19:58 +02:00
|
|
|
|
enum session_flags_t
|
|
|
|
|
{
|
|
|
|
|
add_default_plugins = 1,
|
|
|
|
|
start_default_features = 2
|
|
|
|
|
};
|
|
|
|
|
|
2009-02-09 04:48:27 +01:00
|
|
|
|
void remove_torrent(torrent_handle const& h
|
|
|
|
|
, int options = none);
|
2006-12-04 13:15:49 +01:00
|
|
|
|
torrent_handle find_torrent(sha_hash const& ih);
|
|
|
|
|
std::vector<torrent_handle> get_torrents() const;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2007-06-06 02:41:20 +02:00
|
|
|
|
void set_settings(session_settings const& settings);
|
|
|
|
|
void set_pe_settings(pe_settings const& settings);
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
void set_upload_rate_limit(int bytes_per_second);
|
2007-01-03 12:42:10 +01:00
|
|
|
|
int upload_rate_limit() const;
|
2004-03-28 19:45:37 +02:00
|
|
|
|
void set_download_rate_limit(int bytes_per_second);
|
2007-01-03 12:42:10 +01:00
|
|
|
|
int download_rate_limit() const;
|
2009-05-14 19:23:00 +02:00
|
|
|
|
|
|
|
|
|
void set_local_upload_rate_limit(int bytes_per_second);
|
|
|
|
|
int local_upload_rate_limit() const;
|
|
|
|
|
void set_local_download_rate_limit(int bytes_per_second);
|
|
|
|
|
int local_download_rate_limit() const;
|
|
|
|
|
|
2004-10-29 15:21:09 +02:00
|
|
|
|
void set_max_uploads(int limit);
|
|
|
|
|
void set_max_connections(int limit);
|
2008-11-08 08:40:55 +01:00
|
|
|
|
int max_connections() const;
|
2005-11-03 13:23:09 +01:00
|
|
|
|
void set_max_half_open_connections(int limit);
|
2007-09-10 03:57:40 +02:00
|
|
|
|
int max_half_open_connections() const;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2007-04-26 01:38:25 +02:00
|
|
|
|
void set_peer_proxy(proxy_settings const& s);
|
|
|
|
|
void set_web_seed_proxy(proxy_settings const& s);
|
|
|
|
|
void set_tracker_proxy(proxy_settings const& s);
|
|
|
|
|
|
|
|
|
|
proxy_settings const& peer_proxy() const;
|
|
|
|
|
proxy_settings const& web_seed_proxy() const;
|
|
|
|
|
proxy_settings const& tracker_proxy() const;
|
|
|
|
|
|
2007-01-03 12:42:10 +01:00
|
|
|
|
int num_uploads() const;
|
|
|
|
|
int num_connections() const;
|
|
|
|
|
|
2008-04-05 06:53:22 +02:00
|
|
|
|
bool load_asnum_db(char const* file);
|
2008-12-21 09:48:06 +01:00
|
|
|
|
bool load_asnum_db(wchar_t const* file);
|
2008-04-11 10:46:43 +02:00
|
|
|
|
bool load_country_db(char const* file);
|
2008-12-21 09:48:06 +01:00
|
|
|
|
bool load_country_db(wchar_t const* file);
|
2008-04-22 02:05:23 +02:00
|
|
|
|
int as_for_ip(address const& adr);
|
2008-04-05 06:53:22 +02:00
|
|
|
|
|
|
|
|
|
void load_state(entry const& ses_state);
|
|
|
|
|
entry state() const;
|
|
|
|
|
|
2005-08-10 20:04:39 +02:00
|
|
|
|
void set_ip_filter(ip_filter const& f);
|
2009-07-21 03:52:37 +02:00
|
|
|
|
ip_filter const& get_ip_filter() const;
|
|
|
|
|
|
2004-04-18 15:41:08 +02:00
|
|
|
|
session_status status() const;
|
2008-02-08 11:22:05 +01:00
|
|
|
|
cache_status get_cache_status() const;
|
2004-04-18 15:41:08 +02:00
|
|
|
|
|
2004-02-26 13:59:01 +01:00
|
|
|
|
bool is_listening() const;
|
|
|
|
|
unsigned short listen_port() const;
|
|
|
|
|
bool listen_on(
|
|
|
|
|
std::pair<int, int> const& port_range
|
2004-04-17 17:17:43 +02:00
|
|
|
|
, char const* interface = 0);
|
2004-02-26 13:59:01 +01:00
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
std::auto_ptr<alert> pop_alert();
|
2008-05-15 02:45:01 +02:00
|
|
|
|
alert const* wait_for_alert(time_duration max_wait);
|
2008-07-06 14:22:56 +02:00
|
|
|
|
void set_alert_mask(int m);
|
2009-02-09 04:48:27 +01:00
|
|
|
|
size_t set_alert_queue_size_limit(
|
|
|
|
|
size_t queue_size_limit_);
|
2006-08-01 17:27:08 +02:00
|
|
|
|
|
2006-12-04 13:15:49 +01:00
|
|
|
|
void add_extension(boost::function<
|
|
|
|
|
boost::shared_ptr<torrent_plugin>(torrent*)> ext);
|
|
|
|
|
|
|
|
|
|
void start_dht();
|
2006-08-01 17:27:08 +02:00
|
|
|
|
void stop_dht();
|
2006-08-28 02:36:00 +02:00
|
|
|
|
void set_dht_settings(
|
|
|
|
|
dht_settings const& settings);
|
2006-08-01 17:27:08 +02:00
|
|
|
|
entry dht_state() const;
|
2006-08-28 02:36:00 +02:00
|
|
|
|
void add_dht_node(std::pair<std::string
|
|
|
|
|
, int> const& node);
|
2006-09-27 19:20:18 +02:00
|
|
|
|
void add_dht_router(std::pair<std::string
|
|
|
|
|
, int> const& node);
|
2009-10-24 23:55:16 +02:00
|
|
|
|
bool is_dht_running() const;
|
2008-04-06 21:17:58 +02:00
|
|
|
|
|
|
|
|
|
void start_lsd();
|
|
|
|
|
void stop_lsd();
|
|
|
|
|
|
2008-04-07 01:18:35 +02:00
|
|
|
|
upnp* start_upnp();
|
2008-04-06 21:17:58 +02:00
|
|
|
|
void stop_upnp();
|
|
|
|
|
|
2008-04-07 01:18:35 +02:00
|
|
|
|
natpmp* start_natpmp();
|
2008-04-06 21:17:58 +02:00
|
|
|
|
void stop_natpmp();
|
2004-01-07 01:48:02 +01:00
|
|
|
|
};
|
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
Once it's created, the session object will spawn the main thread that will do all the work.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
The main thread will be idle as long it doesn't have any torrents to participate in.
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
|
|
|
|
session()
|
|
|
|
|
---------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2006-08-28 02:36:00 +02:00
|
|
|
|
session(fingerprint const& print
|
2008-09-22 01:19:58 +02:00
|
|
|
|
= libtorrent::fingerprint("LT", 0, 1, 0, 0)
|
2009-02-09 04:48:27 +01:00
|
|
|
|
, int flags = start_default_features
|
|
|
|
|
| add_default_plugins
|
2008-11-16 03:09:53 +01:00
|
|
|
|
, int alert_mask = alert::error_notification);
|
2008-09-22 01:19:58 +02:00
|
|
|
|
|
2005-07-06 02:58:23 +02:00
|
|
|
|
session(fingerprint const& print
|
2004-04-17 17:17:43 +02:00
|
|
|
|
, std::pair<int, int> listen_port_range
|
2008-09-22 01:19:58 +02:00
|
|
|
|
, char const* listen_interface = 0
|
2009-02-09 04:48:27 +01:00
|
|
|
|
, int flags = start_default_features
|
|
|
|
|
| add_default_plugins
|
2008-11-16 03:09:53 +01:00
|
|
|
|
, int alert_mask = alert::error_notification);
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
2006-05-21 12:41:37 +02:00
|
|
|
|
If the fingerprint in the first overload is omited, the client will get a default
|
2004-04-17 17:17:43 +02:00
|
|
|
|
fingerprint stating the version of libtorrent. The fingerprint is a short string that will be
|
|
|
|
|
used in the peer-id to identify the client and the client's version. For more details see the
|
|
|
|
|
fingerprint_ class. The constructor that only takes a fingerprint will not open a
|
|
|
|
|
listen port for the session, to get it running you'll have to call ``session::listen_on()``.
|
|
|
|
|
The other constructor, that takes a port range and an interface as well as the fingerprint
|
|
|
|
|
will automatically try to listen on a port on the given interface. For more information about
|
|
|
|
|
the parameters, see ``listen_on()`` function.
|
|
|
|
|
|
2008-09-22 01:19:58 +02:00
|
|
|
|
The flags paramater can be used to start default features (upnp & nat-pmp) and default plugins
|
|
|
|
|
(ut_metadata, ut_pex and smart_ban). The default is to start those things. If you do not want
|
|
|
|
|
them to start, pass 0 as the flags parameter.
|
|
|
|
|
|
2008-12-14 20:47:02 +01:00
|
|
|
|
The ``alert_mask`` is the same mask that you would send to `set_alert_mask()`_.
|
2008-11-16 03:09:53 +01:00
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
~session()
|
|
|
|
|
----------
|
|
|
|
|
|
2004-06-14 01:30:42 +02:00
|
|
|
|
The destructor of session will notify all trackers that our torrents have been shut down.
|
2004-07-01 21:01:19 +02:00
|
|
|
|
If some trackers are down, they will time out. All this before the destructor of session
|
2006-05-21 12:41:37 +02:00
|
|
|
|
returns. So, it's advised that any kind of interface (such as windows) are closed before
|
|
|
|
|
destructing the session object. Because it can take a few second for it to finish. The
|
2006-05-21 01:58:09 +02:00
|
|
|
|
timeout can be set with ``set_settings()``.
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
2009-12-03 06:11:57 +01:00
|
|
|
|
load_state() save_state()
|
|
|
|
|
-------------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void load_state(lazy_entry const& e);
|
|
|
|
|
void save_state(entry& e) const;
|
|
|
|
|
|
|
|
|
|
loads and saves all session settings, including dht_settings, encryption settings and proxy
|
|
|
|
|
settings. ``save_state`` writes all keys to the ``entry`` that's passed in, which needs to
|
|
|
|
|
either not be initialized, or initialized as a dictionary.
|
|
|
|
|
|
|
|
|
|
``load_state`` expects a ``lazy_entry`` which can be built from a bencoded buffer with
|
|
|
|
|
``lazy_bdecode``.
|
|
|
|
|
|
|
|
|
|
|
2008-06-29 21:08:30 +02:00
|
|
|
|
pause() resume() is_paused()
|
|
|
|
|
----------------------------
|
|
|
|
|
|
|
|
|
|
::
|
2008-10-17 19:31:20 +02:00
|
|
|
|
|
2008-06-29 21:08:30 +02:00
|
|
|
|
void pause();
|
|
|
|
|
void resume();
|
|
|
|
|
bool is_paused() const;
|
|
|
|
|
|
2009-01-22 04:02:16 +01:00
|
|
|
|
Pausing the session has the same effect as pausing every torrent in it, except that
|
|
|
|
|
torrents will not be resumed by the auto-manage mechanism. Resuming will restore the
|
|
|
|
|
torrents to their previous paused state. i.e. the session pause state is separate from
|
|
|
|
|
the torrent pause state. A torrent is inactive if it is paused or if the session is
|
|
|
|
|
paused.
|
2008-06-29 21:08:30 +02:00
|
|
|
|
|
2006-10-11 16:02:21 +02:00
|
|
|
|
abort()
|
|
|
|
|
-------
|
|
|
|
|
|
2008-06-29 21:08:30 +02:00
|
|
|
|
::
|
2006-10-12 00:03:24 +02:00
|
|
|
|
|
|
|
|
|
session_proxy abort();
|
|
|
|
|
|
2006-10-11 16:02:21 +02:00
|
|
|
|
In case you want to destruct the session asynchrounously, you can request a session
|
|
|
|
|
destruction proxy. If you don't do this, the destructor of the session object will
|
|
|
|
|
block while the trackers are contacted. If you keep one ``session_proxy`` to the
|
|
|
|
|
session when destructing it, the destructor will not block, but start to close down
|
|
|
|
|
the session, the destructor of the proxy will then synchronize the threads. So, the
|
|
|
|
|
destruction of the session is performed from the ``session`` destructor call until the
|
|
|
|
|
``session_proxy`` destructor call. The ``session_proxy`` does not have any operations
|
|
|
|
|
on it (since the session is being closed down, no operations are allowed on it). The
|
|
|
|
|
only valid operation is calling the destructor::
|
|
|
|
|
|
2006-10-15 15:46:52 +02:00
|
|
|
|
class session_proxy
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
session_proxy();
|
|
|
|
|
~session_proxy()
|
|
|
|
|
};
|
2006-10-11 16:02:21 +02:00
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
|
|
|
|
add_torrent()
|
|
|
|
|
-------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2007-11-22 10:27:22 +01:00
|
|
|
|
typedef storage_interface* (&storage_constructor_type)(
|
2009-06-22 02:52:57 +02:00
|
|
|
|
file_storage const&, file_storage const*, fs::path const&, file_pool&);
|
2007-11-22 10:27:22 +01:00
|
|
|
|
|
2008-04-24 05:28:48 +02:00
|
|
|
|
struct add_torrent_params
|
|
|
|
|
{
|
|
|
|
|
add_torrent_params(storage_constructor_type s);
|
|
|
|
|
|
|
|
|
|
boost::intrusive_ptr<torrent_info> ti;
|
|
|
|
|
char const* tracker_url;
|
|
|
|
|
sha1_hash info_hash;
|
|
|
|
|
char const* name;
|
|
|
|
|
fs::path save_path;
|
2008-07-01 01:14:31 +02:00
|
|
|
|
std::vector<char>* resume_data;
|
2008-04-24 05:28:48 +02:00
|
|
|
|
storage_mode_t storage_mode;
|
|
|
|
|
bool paused;
|
|
|
|
|
bool auto_managed;
|
|
|
|
|
bool duplicate_is_error;
|
|
|
|
|
storage_constructor_type storage;
|
|
|
|
|
void* userdata;
|
2009-02-03 08:46:24 +01:00
|
|
|
|
bool seed_mode;
|
2009-03-21 05:33:53 +01:00
|
|
|
|
bool override_resume_data;
|
2009-06-19 00:32:55 +02:00
|
|
|
|
bool upload_mode;
|
2008-04-24 05:28:48 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
torrent_handle add_torrent(add_torrent_params const& params);
|
2009-02-26 08:09:56 +01:00
|
|
|
|
torrent_handle add_torrent(add_torrent_params const& params
|
|
|
|
|
, error_code& ec);
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
|
|
|
|
You add torrents through the ``add_torrent()`` function where you give an
|
2008-04-24 05:28:48 +02:00
|
|
|
|
object with all the parameters.
|
|
|
|
|
|
2009-02-26 08:09:56 +01:00
|
|
|
|
The overload that does not take an ``error_code`` throws an exception on
|
|
|
|
|
error and is not available when building without exception support.
|
|
|
|
|
|
2008-04-24 05:28:48 +02:00
|
|
|
|
The only mandatory parameter is ``save_path`` which is the directory where you
|
|
|
|
|
want the files to be saved. You also need to specify either the ``ti`` (the
|
|
|
|
|
torrent file) or ``info_hash`` (the info hash of the torrent). If you specify the
|
|
|
|
|
info-hash, the torrent file will be downloaded from peers, which requires them to
|
|
|
|
|
support the metadata extension. For the metadata extension to work, libtorrent must
|
|
|
|
|
be built with extensions enabled (``TORRENT_DISABLE_EXTENSIONS`` must not be
|
|
|
|
|
defined). It also takes an optional ``name`` argument. This may be 0 in case no
|
|
|
|
|
name should be assigned to the torrent. In case it's not 0, the name is used for
|
|
|
|
|
the torrent as long as it doesn't have metadata. See ``torrent_handle::name``.
|
|
|
|
|
|
|
|
|
|
If the torrent doesn't have a tracker, but relies on the DHT to find peers, the
|
|
|
|
|
``tracker_url`` can be 0, otherwise you might specify a tracker url that tracks this
|
|
|
|
|
torrent.
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
|
|
|
|
If the torrent you are trying to add already exists in the session (is either queued
|
|
|
|
|
for checking, being checked or downloading) ``add_torrent()`` will throw
|
2009-03-21 05:33:53 +01:00
|
|
|
|
libtorrent_exception_ which derives from ``std::exception`` unless ``duplicate_is_error``
|
2008-04-24 05:28:48 +02:00
|
|
|
|
is set to false. In that case, ``add_torrent`` will return the handle to the existing
|
|
|
|
|
torrent.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2005-05-13 02:39:39 +02:00
|
|
|
|
The optional parameter, ``resume_data`` can be given if up to date fast-resume data
|
2004-01-07 01:48:02 +01:00
|
|
|
|
is available. The fast-resume data can be acquired from a running torrent by calling
|
2008-07-01 01:14:31 +02:00
|
|
|
|
`save_resume_data()`_ on `torrent_handle`_. See `fast resume`_. The ``vector`` that is
|
|
|
|
|
passed in will be swapped into the running torrent instance with ``std::vector::swap()``.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2007-11-20 08:54:51 +01:00
|
|
|
|
The ``storage_mode`` parameter refers to the layout of the storage for this torrent.
|
|
|
|
|
There are 3 different modes:
|
|
|
|
|
|
|
|
|
|
storage_mode_sparse
|
|
|
|
|
All pieces will be written to the place where they belong and sparse files
|
|
|
|
|
will be used. This is the recommended, and default mode.
|
|
|
|
|
|
|
|
|
|
storage_mode_allocate
|
2008-10-19 00:12:31 +02:00
|
|
|
|
Same as ``storage_mode_sparse`` except that files will be ftruncated on
|
|
|
|
|
startup (SetEndOfFile() on windows). For filesystem that supports sparse
|
|
|
|
|
files, this is in all practical aspects identical to sparse mode. For
|
|
|
|
|
filesystems that don't, it will allocate the data for the files. The mac
|
|
|
|
|
filesystem HFS+ doesn't support sparse files, it will allocate the files
|
|
|
|
|
with zeroes.
|
2007-11-20 08:54:51 +01:00
|
|
|
|
|
|
|
|
|
storage_mode_compact
|
|
|
|
|
The storage will grow as more pieces are downloaded, and pieces
|
|
|
|
|
are rearranged to finally be in their correct places once the entire torrent has been
|
|
|
|
|
downloaded.
|
|
|
|
|
|
|
|
|
|
For more information, see `storage allocation`_.
|
2005-05-13 02:39:39 +02:00
|
|
|
|
|
2007-08-22 07:31:42 +02:00
|
|
|
|
``paused`` is a boolean that specifies whether or not the torrent is to be started in
|
|
|
|
|
a paused state. I.e. it won't connect to the tracker or any of the peers until it's
|
|
|
|
|
resumed. This is typically a good way of avoiding race conditions when setting
|
|
|
|
|
configuration options on torrents before starting them.
|
2005-07-10 12:42:00 +02:00
|
|
|
|
|
2009-03-21 05:33:53 +01:00
|
|
|
|
If you pass in resume data, the paused state of the torrent when the resume data
|
|
|
|
|
was saved will override the paused state you pass in here. You can override this
|
|
|
|
|
by setting ``override_resume_data``.
|
|
|
|
|
|
2008-04-24 05:28:48 +02:00
|
|
|
|
If ``auto_managed`` is true, this torrent will be queued, started and seeded
|
|
|
|
|
automatically by libtorrent. When this is set, the torrent should also be started
|
|
|
|
|
as paused. The default queue order is the order the torrents were added. They
|
|
|
|
|
are all downloaded in that order. For more details, see queuing_.
|
|
|
|
|
|
2009-03-21 05:33:53 +01:00
|
|
|
|
If you pass in resume data, the auto_managed state of the torrent when the resume data
|
|
|
|
|
was saved will override the auto_managed state you pass in here. You can override this
|
|
|
|
|
by setting ``override_resume_data``.
|
|
|
|
|
|
2008-04-24 05:28:48 +02:00
|
|
|
|
``storage`` can be used to customize how the data is stored. The default
|
2007-11-22 10:27:22 +01:00
|
|
|
|
storage will simply write the data to the files it belongs to, but it could be
|
|
|
|
|
overridden to save everything to a single file at a specific location or encrypt the
|
|
|
|
|
content on disk for instance. For more information about the ``storage_interface``
|
|
|
|
|
that needs to be implemented for a custom storage, see `storage_interface`_.
|
|
|
|
|
|
2007-11-24 22:13:19 +01:00
|
|
|
|
The ``userdata`` parameter is optional and will be passed on to the extension
|
|
|
|
|
constructor functions, if any (see `add_extension()`_).
|
|
|
|
|
|
2009-02-03 08:46:24 +01:00
|
|
|
|
If ``seed_mode`` is set to true, libtorrent will assume that all files are present
|
|
|
|
|
for this torrent and that they all match the hashes in the torrent file. Each time
|
|
|
|
|
a peer requests to download a block, the piece is verified against the hash, unless
|
|
|
|
|
it has been verified already. If a hash fails, the torrent will automatically leave
|
|
|
|
|
the seed mode and recheck all the files. The use case for this mode is if a torrent
|
|
|
|
|
is created and seeded, or if the user already know that the files are complete, this
|
|
|
|
|
is a way to avoid the initial file checks, and significantly reduce the startup time.
|
|
|
|
|
|
|
|
|
|
Setting ``seed_mode`` on a torrent without metadata (a .torrent file) is a no-op
|
|
|
|
|
and will be ignored.
|
|
|
|
|
|
2009-03-21 05:33:53 +01:00
|
|
|
|
If resume data is passed in with this torrent, the seed mode saved in there will
|
|
|
|
|
override the seed mode you set here.
|
|
|
|
|
|
2008-04-24 05:28:48 +02:00
|
|
|
|
The torrent_handle_ returned by ``add_torrent()`` can be used to retrieve information
|
|
|
|
|
about the torrent's progress, its peers etc. It is also used to abort a torrent.
|
2007-11-20 08:54:51 +01:00
|
|
|
|
|
2009-03-21 05:33:53 +01:00
|
|
|
|
If ``override_resume_data`` is set to true, the ``paused`` and ``auto_managed``
|
|
|
|
|
state of the torrent are not loaded from the resume data, but the states requested
|
|
|
|
|
by this ``add_torrent_params`` will override it.
|
|
|
|
|
|
2009-06-19 00:32:55 +02:00
|
|
|
|
If ``upload_mode`` is set to true, the torrent will be initialized in upload-mode,
|
|
|
|
|
which means it will not make any piece requests. This state is typically entered
|
|
|
|
|
on disk I/O errors, and if the torrent is also auto managed, it will be taken out
|
|
|
|
|
of this state periodically. This mode can be used to avoid race conditions when
|
|
|
|
|
adjusting priorities of pieces before allowing the torrent to start downloading.
|
2007-11-20 08:54:51 +01:00
|
|
|
|
|
2007-11-24 21:48:51 +01:00
|
|
|
|
remove_torrent()
|
|
|
|
|
----------------
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2007-11-23 23:45:59 +01:00
|
|
|
|
void remove_torrent(torrent_handle const& h, int options = none);
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
``remove_torrent()`` will close all peer connections associated with the torrent and tell
|
2007-11-23 23:45:59 +01:00
|
|
|
|
the tracker that we've stopped participating in the swarm. The optional second argument
|
|
|
|
|
``options`` can be used to delete all the files downloaded by this torrent. To do this, pass
|
|
|
|
|
in the value ``session::delete_files``. The removal of the torrent is asyncronous, there is
|
|
|
|
|
no guarantee that adding the same torrent immediately after it was removed will not throw
|
2009-03-21 05:33:53 +01:00
|
|
|
|
a libtorrent_exception_ exception.
|
2007-11-24 21:48:51 +01:00
|
|
|
|
|
|
|
|
|
find_torrent() get_torrents()
|
|
|
|
|
-----------------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
torrent_handle find_torrent(sha_hash const& ih);
|
|
|
|
|
std::vector<torrent_handle> get_torrents() const;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2006-12-04 13:15:49 +01:00
|
|
|
|
``find_torrent()`` looks for a torrent with the given info-hash. In case there
|
|
|
|
|
is such a torrent in the session, a torrent_handle to that torrent is returned.
|
|
|
|
|
In case the torrent cannot be found, an invalid torrent_handle is returned.
|
|
|
|
|
|
|
|
|
|
See ``torrent_handle::is_valid()`` to know if the torrent was found or not.
|
|
|
|
|
|
|
|
|
|
``get_torrents()`` returns a vector of torrent_handles to all the torrents
|
|
|
|
|
currently in the session.
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2007-01-03 12:42:10 +01:00
|
|
|
|
set_upload_rate_limit() set_download_rate_limit() upload_rate_limit() download_rate_limit()
|
|
|
|
|
-------------------------------------------------------------------------------------------
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void set_upload_rate_limit(int bytes_per_second);
|
|
|
|
|
void set_download_rate_limit(int bytes_per_second);
|
2007-01-03 12:42:10 +01:00
|
|
|
|
int upload_rate_limit() const;
|
|
|
|
|
int download_rate_limit() const;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
|
|
|
|
``set_upload_rate_limit()`` set the maximum number of bytes allowed to be
|
|
|
|
|
sent to peers per second. This bandwidth is distributed among all the peers. If
|
2009-05-14 19:23:00 +02:00
|
|
|
|
you don't want to limit upload rate, you can set this to 0 (the default).
|
2004-03-28 19:45:37 +02:00
|
|
|
|
``set_download_rate_limit()`` works the same way but for download rate instead
|
|
|
|
|
of upload rate.
|
2007-01-03 12:42:10 +01:00
|
|
|
|
``download_rate_limit()`` and ``upload_rate_limit()`` returns the previously
|
|
|
|
|
set limits.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2009-05-14 19:23:00 +02:00
|
|
|
|
A rate limit of 0 means infinite.
|
|
|
|
|
|
2009-04-09 21:20:53 +02:00
|
|
|
|
Upload and download rate limits are not applied to peers on the local network
|
|
|
|
|
by default. To change that, see ``session_settings::ignore_limits_on_local_network``.
|
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
2009-05-14 19:23:00 +02:00
|
|
|
|
set_local_upload_rate_limit() set_local_download_rate_limit() local_upload_rate_limit() local_download_rate_limit()
|
|
|
|
|
-------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void set_local_upload_rate_limit(int bytes_per_second);
|
|
|
|
|
void set_local_download_rate_limit(int bytes_per_second);
|
|
|
|
|
int local_upload_rate_limit() const;
|
|
|
|
|
int local_download_rate_limit() const;
|
|
|
|
|
|
|
|
|
|
These rate limits are only used for local peers (peers within the same subnet as
|
|
|
|
|
the client itself) and it is only used when ``session_settings::ignore_limits_on_local_network``
|
|
|
|
|
is set to true (which it is by default). These rate limits default to unthrottled,
|
|
|
|
|
but can be useful in case you want to treat local peers preferentially, but not
|
|
|
|
|
quite unthrottled.
|
|
|
|
|
|
|
|
|
|
A rate limit of 0 means infinite.
|
|
|
|
|
|
|
|
|
|
|
2009-04-07 17:55:05 +02:00
|
|
|
|
set_max_uploads() set_max_connections() max_uploads() max_connections()
|
|
|
|
|
-----------------------------------------------------------------------
|
2004-10-29 15:21:09 +02:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void set_max_uploads(int limit);
|
|
|
|
|
void set_max_connections(int limit);
|
2009-04-07 17:55:05 +02:00
|
|
|
|
int max_uploads() const;
|
2008-11-08 08:40:55 +01:00
|
|
|
|
int max_connections() const;
|
2004-10-29 15:21:09 +02:00
|
|
|
|
|
|
|
|
|
These functions will set a global limit on the number of unchoked peers (uploads)
|
|
|
|
|
and the number of connections opened. The number of connections is set to a hard
|
|
|
|
|
minimum of at least two connections per torrent, so if you set a too low
|
|
|
|
|
connections limit, and open too many torrents, the limit will not be met. The
|
|
|
|
|
number of uploads is at least one per torrent.
|
|
|
|
|
|
2009-04-07 17:55:05 +02:00
|
|
|
|
``max_uploads()`` and ``max_connections()`` returns the current settings.
|
2008-11-08 08:40:55 +01:00
|
|
|
|
|
2009-04-04 09:55:34 +02:00
|
|
|
|
The number of unchoke slots may be ignored. In order to make this setting
|
|
|
|
|
take effect, disable ``session_settings::auto_upload_slots_rate_based``.
|
|
|
|
|
|
2004-10-29 15:21:09 +02:00
|
|
|
|
|
2007-01-03 12:42:10 +01:00
|
|
|
|
num_uploads() num_connections()
|
|
|
|
|
-------------------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
int num_uploads() const;
|
|
|
|
|
int num_connections() const;
|
|
|
|
|
|
|
|
|
|
Returns the number of currently unchoked peers and the number of connections
|
|
|
|
|
(including half-open ones) respectively.
|
|
|
|
|
|
|
|
|
|
|
2007-09-10 03:57:40 +02:00
|
|
|
|
set_max_half_open_connections() max_half_open_connections()
|
|
|
|
|
-----------------------------------------------------------
|
2005-11-03 13:23:09 +01:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void set_max_half_open_connections(int limit);
|
2007-09-10 03:57:40 +02:00
|
|
|
|
int max_half_open_connections() const;
|
2005-11-03 13:23:09 +01:00
|
|
|
|
|
|
|
|
|
Sets the maximum number of half-open connections libtorrent will have when
|
|
|
|
|
connecting to peers. A half-open connection is one where connect() has been
|
2006-09-26 00:37:48 +02:00
|
|
|
|
called, but the connection still hasn't been established (nor failed). Windows
|
2006-05-21 12:41:37 +02:00
|
|
|
|
XP Service Pack 2 sets a default, system wide, limit of the number of half-open
|
2005-11-03 13:23:09 +01:00
|
|
|
|
connections to 10. So, this limit can be used to work nicer together with
|
|
|
|
|
other network applications on that system. The default is to have no limit,
|
|
|
|
|
and passing -1 as the limit, means to have no limit. When limiting the number
|
|
|
|
|
of simultaneous connection attempts, peers will be put in a queue waiting for
|
|
|
|
|
their turn to get connected.
|
|
|
|
|
|
2007-09-10 03:57:40 +02:00
|
|
|
|
``max_half_open_connections()`` returns the set limit. This limit defaults
|
|
|
|
|
to 8 on windows.
|
|
|
|
|
|
2008-04-22 02:05:23 +02:00
|
|
|
|
load_asnum_db() load_country_db() int as_for_ip()
|
|
|
|
|
-------------------------------------------------
|
2008-04-05 06:53:22 +02:00
|
|
|
|
|
|
|
|
|
::
|
2005-11-03 13:23:09 +01:00
|
|
|
|
|
2008-04-05 06:53:22 +02:00
|
|
|
|
bool load_asnum_db(char const* file);
|
2008-12-21 09:48:06 +01:00
|
|
|
|
bool load_asnum_db(wchar_t const* file);
|
2008-04-11 10:46:43 +02:00
|
|
|
|
bool load_country_db(char const* file);
|
2008-12-21 09:48:06 +01:00
|
|
|
|
bool load_country_db(wchar_t const* file);
|
2008-04-22 02:05:23 +02:00
|
|
|
|
int as_for_ip(address const& adr);
|
2008-04-05 06:53:22 +02:00
|
|
|
|
|
2008-04-11 10:46:43 +02:00
|
|
|
|
These functions are not available if ``TORRENT_DISABLE_GEO_IP`` is defined. They
|
|
|
|
|
expects a path to the `MaxMind ASN database`_ and `MaxMind GeoIP database`_
|
|
|
|
|
respectively. This will be used to look up which AS and country peers belong to.
|
2008-04-05 06:53:22 +02:00
|
|
|
|
|
2008-04-22 02:05:23 +02:00
|
|
|
|
``as_for_ip`` returns the AS number for the IP address specified. If the IP is not
|
|
|
|
|
in the database or the ASN database is not loaded, 0 is returned.
|
|
|
|
|
|
2008-12-21 09:48:06 +01:00
|
|
|
|
The ``wchar_t`` overloads are for wide character paths.
|
|
|
|
|
|
2008-04-05 06:53:22 +02:00
|
|
|
|
.. _`MaxMind ASN database`: http://www.maxmind.com/app/asnum
|
2008-04-11 10:46:43 +02:00
|
|
|
|
.. _`MaxMind GeoIP database`: http://www.maxmind.com/app/geolitecountry
|
2008-04-05 06:53:22 +02:00
|
|
|
|
|
|
|
|
|
load_state() state()
|
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void load_state(entry const& ses_state);
|
|
|
|
|
entry state() const;
|
|
|
|
|
|
|
|
|
|
These functions loads and save session state. Currently, the only state
|
|
|
|
|
that's stored is peak download rates for ASes. This map is used to
|
|
|
|
|
determine which order to connect to peers.
|
|
|
|
|
|
2005-07-06 02:58:23 +02:00
|
|
|
|
set_ip_filter()
|
|
|
|
|
---------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void set_ip_filter(ip_filter const& filter);
|
|
|
|
|
|
|
|
|
|
Sets a filter that will be used to reject and accept incoming as well as outgoing
|
|
|
|
|
connections based on their originating ip address. The default filter will allow
|
|
|
|
|
connections to any ip address. To build a set of rules for which addresses are
|
|
|
|
|
accepted and not, see ip_filter_.
|
|
|
|
|
|
2007-04-17 07:56:43 +02:00
|
|
|
|
Each time a peer is blocked because of the IP filter, a peer_blocked_alert_ is
|
|
|
|
|
generated.
|
|
|
|
|
|
2009-07-21 03:52:37 +02:00
|
|
|
|
get_ip_filter()
|
|
|
|
|
---------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
ip_filter const& get_ip_filter() const;
|
|
|
|
|
|
|
|
|
|
Returns the ip_filter currently in the session. See ip_filter_.
|
|
|
|
|
|
2005-07-06 02:58:23 +02:00
|
|
|
|
|
2004-04-18 15:41:08 +02:00
|
|
|
|
status()
|
|
|
|
|
--------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
session_status status() const;
|
|
|
|
|
|
2004-06-14 01:30:42 +02:00
|
|
|
|
``status()`` returns session wide-statistics and status. The ``session_status``
|
2004-04-18 15:41:08 +02:00
|
|
|
|
struct has the following members::
|
|
|
|
|
|
2008-09-20 19:42:25 +02:00
|
|
|
|
struct dht_lookup
|
|
|
|
|
{
|
|
|
|
|
char const* type;
|
|
|
|
|
int outstanding_requests;
|
|
|
|
|
int timeouts;
|
|
|
|
|
int responses;
|
|
|
|
|
int branch_factor;
|
|
|
|
|
};
|
|
|
|
|
|
2004-04-18 15:41:08 +02:00
|
|
|
|
struct session_status
|
|
|
|
|
{
|
|
|
|
|
bool has_incoming_connections;
|
|
|
|
|
|
2009-07-19 06:59:27 +02:00
|
|
|
|
int upload_rate;
|
|
|
|
|
int download_rate;
|
2008-09-20 19:42:25 +02:00
|
|
|
|
size_type total_download;
|
|
|
|
|
size_type total_upload;
|
2004-04-18 15:41:08 +02:00
|
|
|
|
|
2009-07-19 06:59:27 +02:00
|
|
|
|
int payload_upload_rate;
|
|
|
|
|
int payload_download_rate;
|
2008-09-20 19:42:25 +02:00
|
|
|
|
size_type total_payload_download;
|
|
|
|
|
size_type total_payload_upload;
|
2004-04-18 15:41:08 +02:00
|
|
|
|
|
2009-07-19 06:59:27 +02:00
|
|
|
|
int ip_overhead_upload_rate;
|
|
|
|
|
int ip_overhead_download_rate;
|
2008-09-20 19:42:25 +02:00
|
|
|
|
size_type total_ip_overhead_download;
|
|
|
|
|
size_type total_ip_overhead_upload;
|
|
|
|
|
|
2009-07-19 06:59:27 +02:00
|
|
|
|
int dht_upload_rate;
|
|
|
|
|
int dht_download_rate;
|
2008-09-20 19:42:25 +02:00
|
|
|
|
size_type total_dht_download;
|
|
|
|
|
size_type total_dht_upload;
|
2004-04-18 15:41:08 +02:00
|
|
|
|
|
2009-07-19 06:59:27 +02:00
|
|
|
|
int tracker_upload_rate;
|
|
|
|
|
int tracker_download_rate;
|
2008-09-22 02:15:05 +02:00
|
|
|
|
size_type total_tracker_download;
|
|
|
|
|
size_type total_tracker_upload;
|
|
|
|
|
|
2008-07-11 09:30:04 +02:00
|
|
|
|
size_type total_redundant_bytes;
|
|
|
|
|
size_type total_failed_bytes;
|
|
|
|
|
|
2004-04-18 15:41:08 +02:00
|
|
|
|
int num_peers;
|
2008-01-13 12:18:18 +01:00
|
|
|
|
int num_unchoked;
|
|
|
|
|
int allowed_upload_slots;
|
2006-09-05 01:22:21 +02:00
|
|
|
|
|
2008-10-19 00:35:10 +02:00
|
|
|
|
int optimistic_unchoke_counter;
|
|
|
|
|
int unchoke_counter;
|
|
|
|
|
|
2006-09-05 01:22:21 +02:00
|
|
|
|
int dht_nodes;
|
2009-11-11 06:28:28 +01:00
|
|
|
|
int dht_node_cache;
|
2006-09-05 01:22:21 +02:00
|
|
|
|
int dht_torrents;
|
2007-05-12 03:52:25 +02:00
|
|
|
|
int dht_global_nodes;
|
2008-09-20 19:42:25 +02:00
|
|
|
|
std::vector<dht_lookup> active_requests;
|
2004-04-18 15:41:08 +02:00
|
|
|
|
};
|
|
|
|
|
|
2004-06-14 01:30:42 +02:00
|
|
|
|
``has_incoming_connections`` is false as long as no incoming connections have been
|
2004-04-18 15:41:08 +02:00
|
|
|
|
established on the listening socket. Every time you change the listen port, this will
|
|
|
|
|
be reset to false.
|
|
|
|
|
|
2008-09-20 19:42:25 +02:00
|
|
|
|
``upload_rate``, ``download_rate`` are the total download and upload rates accumulated
|
|
|
|
|
from all torrents. This includes bittorrent protocol, DHT and an estimated TCP/IP
|
|
|
|
|
protocol overhead.
|
2004-04-18 15:41:08 +02:00
|
|
|
|
|
|
|
|
|
``total_download`` and ``total_upload`` are the total number of bytes downloaded and
|
2008-09-20 19:42:25 +02:00
|
|
|
|
uploaded to and from all torrents. This also includes all the protocol overhead.
|
|
|
|
|
|
|
|
|
|
``payload_download_rate`` and ``payload_upload_rate`` is the rate of the payload
|
|
|
|
|
down- and upload only.
|
|
|
|
|
|
|
|
|
|
``total_payload_download`` and ``total_payload_upload`` is the total transfers of payload
|
|
|
|
|
only. The payload does not include the bittorrent protocol overhead, but only parts of the
|
|
|
|
|
actual files to be downloaded.
|
|
|
|
|
|
|
|
|
|
``ip_overhead_upload_rate``, ``ip_overhead_download_rate``, ``total_ip_overhead_download``
|
|
|
|
|
and ``total_ip_overhead_upload`` is the estimated TCP/IP overhead in each direction.
|
|
|
|
|
|
|
|
|
|
``dht_upload_rate``, ``dht_download_rate``, ``total_dht_download`` and ``total_dht_upload``
|
|
|
|
|
is the DHT bandwidth usage.
|
2004-04-18 15:41:08 +02:00
|
|
|
|
|
2008-07-11 09:30:04 +02:00
|
|
|
|
``total_redundant_bytes`` is the number of bytes that has been received more than once.
|
|
|
|
|
This can happen if a request from a peer times out and is requested from a different
|
|
|
|
|
peer, and then received again from the first one. To make this lower, increase the
|
|
|
|
|
``request_timeout`` and the ``piece_timeout`` in the session settings.
|
|
|
|
|
|
|
|
|
|
``total_failed_bytes`` is the number of bytes that was downloaded which later failed
|
|
|
|
|
the hash-check.
|
|
|
|
|
|
2007-08-22 19:49:29 +02:00
|
|
|
|
``num_peers`` is the total number of peer connections this session has. This includes
|
|
|
|
|
incoming connections that still hasn't sent their handshake or outgoing connections
|
|
|
|
|
that still hasn't completed the TCP connection. This number may be slightly higher
|
|
|
|
|
than the sum of all peers of all torrents because the incoming connections may not
|
|
|
|
|
be assigned a torrent yet.
|
2004-04-18 15:41:08 +02:00
|
|
|
|
|
2008-01-13 12:18:18 +01:00
|
|
|
|
``num_unchoked`` is the current number of unchoked peers.
|
|
|
|
|
``allowed_upload_slots`` is the current allowed number of unchoked peers.
|
|
|
|
|
|
2008-10-19 00:35:10 +02:00
|
|
|
|
``optimistic_unchoke_counter`` and ``unchoke_counter`` tells the number of
|
|
|
|
|
seconds until the next optimistic unchoke change and the start of the next
|
|
|
|
|
unchoke interval. These numbers may be reset prematurely if a peer that is
|
|
|
|
|
unchoked disconnects or becomes notinterested.
|
|
|
|
|
|
2009-11-11 06:28:28 +01:00
|
|
|
|
``dht_nodes``, ``dht_node_cache`` and ``dht_torrents`` are only available when
|
2006-09-05 01:22:21 +02:00
|
|
|
|
built with DHT support. They are all set to 0 if the DHT isn't running. When
|
|
|
|
|
the DHT is running, ``dht_nodes`` is set to the number of nodes in the routing
|
|
|
|
|
table. This number only includes *active* nodes, not cache nodes. The
|
2009-11-11 06:28:28 +01:00
|
|
|
|
``dht_node_cache`` is set to the number of nodes in the node cache. These nodes
|
2006-09-05 01:22:21 +02:00
|
|
|
|
are used to replace the regular nodes in the routing table in case any of them
|
|
|
|
|
becomes unresponsive.
|
|
|
|
|
|
|
|
|
|
``dht_torrents`` are the number of torrents tracked by the DHT at the moment.
|
|
|
|
|
|
2007-05-12 03:52:25 +02:00
|
|
|
|
``dht_global_nodes`` is an estimation of the total number of nodes in the DHT
|
|
|
|
|
network.
|
2004-04-18 15:41:08 +02:00
|
|
|
|
|
2008-09-20 19:42:25 +02:00
|
|
|
|
``active_requests`` is a vector of the currently running DHT lookups.
|
|
|
|
|
|
|
|
|
|
|
2008-02-08 11:22:05 +01:00
|
|
|
|
get_cache_status()
|
|
|
|
|
------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
cache_status get_cache_status() const;
|
|
|
|
|
|
|
|
|
|
Returns status of the disk cache for this session.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct cache_status
|
|
|
|
|
{
|
|
|
|
|
size_type blocks_written;
|
|
|
|
|
size_type writes;
|
2008-02-22 05:11:04 +01:00
|
|
|
|
size_type blocks_read;
|
|
|
|
|
size_type blocks_read_hit;
|
|
|
|
|
size_type reads;
|
|
|
|
|
int cache_size;
|
|
|
|
|
int read_cache_size;
|
2009-05-02 08:52:57 +02:00
|
|
|
|
int total_used_buffers;
|
2008-02-08 11:22:05 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
``blocks_written`` is the total number of 16 KiB blocks written to disk
|
|
|
|
|
since this session was started.
|
|
|
|
|
|
|
|
|
|
``writes`` is the total number of write operations performed since this
|
|
|
|
|
session was started.
|
|
|
|
|
|
|
|
|
|
The ratio (``blocks_written`` - ``writes``) / ``blocks_written`` represents
|
|
|
|
|
the number of saved write operations per total write operations. i.e. a kind
|
|
|
|
|
of cache hit ratio for the write cahe.
|
|
|
|
|
|
2008-02-22 05:11:04 +01:00
|
|
|
|
``blocks_read`` is the number of blocks that were requested from the
|
|
|
|
|
bittorrent engine (from peers), that were served from disk or cache.
|
|
|
|
|
|
|
|
|
|
``blocks_read_hit`` is the number of blocks that were served from cache.
|
|
|
|
|
|
|
|
|
|
The ratio ``blocks_read_hit`` / ``blocks_read`` is the cache hit ratio
|
|
|
|
|
for the read cache.
|
|
|
|
|
|
|
|
|
|
``cache_size`` is the number of 16 KiB blocks currently in the disk cache.
|
|
|
|
|
This includes both read and write cache.
|
|
|
|
|
|
|
|
|
|
``read_cache_size`` is the number of 16KiB blocks in the read cache.
|
2008-02-08 11:22:05 +01:00
|
|
|
|
|
2009-05-02 08:52:57 +02:00
|
|
|
|
``total_used_buffers`` is the total number of buffers currently in use.
|
|
|
|
|
This includes the read/write disk cache as well as send and receive buffers
|
|
|
|
|
used in peer connections.
|
|
|
|
|
|
2008-02-08 11:22:05 +01:00
|
|
|
|
get_cache_info()
|
|
|
|
|
----------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void get_cache_info(sha1_hash const& ih
|
|
|
|
|
, std::vector<cached_piece_info>& ret) const;
|
|
|
|
|
|
|
|
|
|
``get_cache_info()`` fills out the supplied vector with information for
|
|
|
|
|
each piece that is currently in the disk cache for the torrent with the
|
|
|
|
|
specified info-hash (``ih``).
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct cached_piece_info
|
|
|
|
|
{
|
|
|
|
|
int piece;
|
|
|
|
|
std::vector<bool> blocks;
|
2008-02-22 05:11:04 +01:00
|
|
|
|
ptime last_use;
|
2008-07-11 12:29:26 +02:00
|
|
|
|
enum kind_t { read_cache = 0, write_cache = 1 };
|
|
|
|
|
kind_t kind;
|
2008-02-08 11:22:05 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
``piece`` is the piece index for this cache entry.
|
|
|
|
|
|
|
|
|
|
``blocks`` has one entry for each block in this piece. ``true`` represents
|
|
|
|
|
the data for that block being in the disk cache and ``false`` means it's not.
|
|
|
|
|
|
2008-02-22 05:11:04 +01:00
|
|
|
|
``last_use`` is the time when a block was last written to this piece. The older
|
2008-02-08 11:22:05 +01:00
|
|
|
|
a piece is, the more likely it is to be flushed to disk.
|
|
|
|
|
|
2008-07-11 12:29:26 +02:00
|
|
|
|
``kind`` specifies if this piece is part of the read cache or the write cache.
|
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
is_listening() listen_port() listen_on()
|
|
|
|
|
----------------------------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
bool is_listening() const;
|
|
|
|
|
unsigned short listen_port() const;
|
|
|
|
|
bool listen_on(
|
|
|
|
|
std::pair<int, int> const& port_range
|
|
|
|
|
, char const* interface = 0);
|
|
|
|
|
|
2006-05-21 12:41:37 +02:00
|
|
|
|
``is_listening()`` will tell you whether or not the session has successfully
|
2004-02-26 13:59:01 +01:00
|
|
|
|
opened a listening port. If it hasn't, this function will return false, and
|
|
|
|
|
then you can use ``listen_on()`` to make another try.
|
|
|
|
|
|
|
|
|
|
``listen_port()`` returns the port we ended up listening on. Since you just pass
|
|
|
|
|
a port-range to the constructor and to ``listen_on()``, to know which port it
|
|
|
|
|
ended up using, you have to ask the session using this function.
|
|
|
|
|
|
|
|
|
|
``listen_on()`` will change the listen port and/or the listen interface. If the
|
|
|
|
|
session is already listening on a port, this socket will be closed and a new socket
|
|
|
|
|
will be opened with these new settings. The port range is the ports it will try
|
|
|
|
|
to listen on, if the first port fails, it will continue trying the next port within
|
|
|
|
|
the range and so on. The interface parameter can be left as 0, in that case the
|
|
|
|
|
os will decide which interface to listen on, otherwise it should be the ip-address
|
|
|
|
|
of the interface you want the listener socket bound to. ``listen_on()`` returns true
|
|
|
|
|
if it managed to open the socket, and false if it failed. If it fails, it will also
|
|
|
|
|
generate an appropriate alert (listen_failed_alert_).
|
|
|
|
|
|
2004-03-29 00:44:40 +02:00
|
|
|
|
The interface parameter can also be a hostname that will resolve to the device you
|
|
|
|
|
want to listen on.
|
|
|
|
|
|
2007-03-16 22:45:29 +01:00
|
|
|
|
If you're also starting the DHT, it is a good idea to do that after you've called
|
|
|
|
|
``listen_on()``, since the default listen port for the DHT is the same as the tcp
|
|
|
|
|
listen socket. If you start the DHT first, it will assume the tcp port is free and
|
|
|
|
|
open the udp socket on that port, then later, when ``listen_on()`` is called, it
|
|
|
|
|
may turn out that the tcp port is in use. That results in the DHT and the bittorrent
|
|
|
|
|
socket listening on different ports. If the DHT is active when ``listen_on`` is
|
|
|
|
|
called, the udp port will be rebound to the new port, if it was configured to use
|
|
|
|
|
the same port as the tcp socket, and if the listen_on call failed to bind to the
|
|
|
|
|
same port that the udp uses.
|
|
|
|
|
|
|
|
|
|
The reason why it's a good idea to run the DHT and the bittorrent socket on the same
|
|
|
|
|
port is because that is an assumption that may be used to increase performance. One
|
|
|
|
|
way to accelerate the connecting of peers on windows may be to first ping all peers
|
|
|
|
|
with a DHT ping packet, and connect to those that responds first. On windows one
|
|
|
|
|
can only connect to a few peers at a time because of a built in limitation (in XP
|
|
|
|
|
Service pack 2).
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2008-12-14 20:47:02 +01:00
|
|
|
|
set_alert_mask()
|
|
|
|
|
----------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void set_alert_mask(int m);
|
|
|
|
|
|
|
|
|
|
Changes the mask of which alerts to receive. By default only errors are reported.
|
|
|
|
|
``m`` is a bitmask where each bit represents a category of alerts.
|
|
|
|
|
|
|
|
|
|
See alerts_ for mor information on the alert categories.
|
|
|
|
|
|
|
|
|
|
pop_alert() wait_for_alert() set_alert_queue_size_limit()
|
|
|
|
|
---------------------------------------------------------
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
::
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
std::auto_ptr<alert> pop_alert();
|
2008-05-15 02:45:01 +02:00
|
|
|
|
alert const* wait_for_alert(time_duration max_wait);
|
2008-10-07 07:46:42 +02:00
|
|
|
|
size_t set_alert_queue_size_limit(size_t queue_size_limit_);
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2006-05-21 12:41:37 +02:00
|
|
|
|
``pop_alert()`` is used to ask the session if any errors or events has occurred. With
|
2008-12-14 20:47:02 +01:00
|
|
|
|
`set_alert_mask()`_ you can filter which alerts to receive through ``pop_alert()``.
|
2008-07-06 14:22:56 +02:00
|
|
|
|
For information about the alert categories, see alerts_.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2008-05-15 02:45:01 +02:00
|
|
|
|
``wait_for_alert`` blocks until an alert is available, or for no more than ``max_wait``
|
|
|
|
|
time. If ``wait_for_alert`` returns because of the time-out, and no alerts are available,
|
|
|
|
|
it returns 0. If at least one alert was generated, a pointer to that alert is returned.
|
|
|
|
|
The alert is not popped, any subsequent calls to ``wait_for_alert`` will return the
|
|
|
|
|
same pointer until the alert is popped by calling ``pop_alert``. This is useful for
|
|
|
|
|
leaving any alert dispatching mechanism independent of this blocking call, the dispatcher
|
|
|
|
|
can be called and it can pop the alert independently.
|
|
|
|
|
|
2009-09-25 16:35:28 +02:00
|
|
|
|
In the python binding, ``wait_for_alert`` takes the number of milliseconds to wait as an integer.
|
|
|
|
|
|
2008-10-07 07:46:42 +02:00
|
|
|
|
``set_alert_queue_size_limit()`` you can specify how many alerts can be awaiting for dispatching.
|
|
|
|
|
If this limit is reached, new incoming alerts can not be received until alerts are popped
|
|
|
|
|
by calling ``pop_alert``. Default value is 1000.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2009-09-23 20:44:21 +02:00
|
|
|
|
``save_resume_data_alert`` and ``save_resume_data_failed_alert`` are always posted, regardelss
|
|
|
|
|
of the alert mask.
|
|
|
|
|
|
2006-12-04 13:15:49 +01:00
|
|
|
|
add_extension()
|
|
|
|
|
---------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void add_extension(boost::function<
|
2007-11-24 22:13:19 +01:00
|
|
|
|
boost::shared_ptr<torrent_plugin>(torrent*, void*)> ext);
|
2006-12-04 13:15:49 +01:00
|
|
|
|
|
|
|
|
|
This function adds an extension to this session. The argument is a function
|
|
|
|
|
object that is called with a ``torrent*`` and which should return a
|
|
|
|
|
``boost::shared_ptr<torrent_plugin>``. To write custom plugins, see
|
2008-09-17 17:25:12 +02:00
|
|
|
|
`libtorrent plugins`_. For the typical bittorrent client all of these
|
|
|
|
|
extensions should be added. The main plugins implemented in libtorrent are:
|
2006-12-04 13:15:49 +01:00
|
|
|
|
|
|
|
|
|
metadata extension
|
|
|
|
|
Allows peers to download the metadata (.torren files) from the swarm
|
|
|
|
|
directly. Makes it possible to join a swarm with just a tracker and
|
|
|
|
|
info-hash.
|
|
|
|
|
|
2007-12-18 07:04:54 +01:00
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
#include <libtorrent/extensions/metadata_transfer.hpp>
|
|
|
|
|
ses.add_extension(&libtorrent::create_metadata_plugin);
|
|
|
|
|
|
|
|
|
|
uTorrent metadata
|
|
|
|
|
Same as ``metadata extension`` but compatible with uTorrent.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
#include <libtorrent/extensions/ut_metadata.hpp>
|
|
|
|
|
ses.add_extension(&libtorrent::create_ut_metadata_plugin);
|
|
|
|
|
|
2006-12-04 13:15:49 +01:00
|
|
|
|
uTorrent peer exchange
|
|
|
|
|
Exchanges peers between clients.
|
|
|
|
|
|
2007-12-18 07:04:54 +01:00
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
#include <libtorrent/extensions/ut_pex.hpp>
|
|
|
|
|
ses.add_extension(&libtorrent::create_ut_pex_plugin);
|
2006-12-04 13:15:49 +01:00
|
|
|
|
|
2007-12-18 07:04:54 +01:00
|
|
|
|
smart ban plugin
|
|
|
|
|
A plugin that, with a small overhead, can ban peers
|
|
|
|
|
that sends bad data with very high accuracy. Should
|
|
|
|
|
eliminate most problems on poisoned torrents.
|
2007-01-03 12:42:10 +01:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2007-12-18 07:04:54 +01:00
|
|
|
|
#include <libtorrent/extensions/smart_ban.hpp>
|
|
|
|
|
ses.add_extension(&libtorrent::create_smart_ban_plugin);
|
|
|
|
|
|
2007-01-03 12:42:10 +01:00
|
|
|
|
|
2006-12-04 13:15:49 +01:00
|
|
|
|
.. _`libtorrent plugins`: libtorrent_plugins.html
|
|
|
|
|
|
2007-06-06 02:41:20 +02:00
|
|
|
|
set_settings() set_pe_settings()
|
|
|
|
|
--------------------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void set_settings(session_settings const& settings);
|
|
|
|
|
void set_pe_settings(pe_settings const& settings);
|
|
|
|
|
|
|
|
|
|
Sets the session settings and the packet encryption settings respectively.
|
|
|
|
|
See session_settings_ and pe_settings_ for more information on available
|
|
|
|
|
options.
|
|
|
|
|
|
|
|
|
|
|
2007-04-26 01:38:25 +02:00
|
|
|
|
set_peer_proxy() set_web_seed_proxy() set_tracker_proxy() set_dht_proxy()
|
|
|
|
|
-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void set_peer_proxy(proxy_settings const& s);
|
|
|
|
|
void set_web_seed_proxy(proxy_settings const& s);
|
|
|
|
|
void set_tracker_proxy(proxy_settings const& s);
|
|
|
|
|
void set_dht_proxy(proxy_settings const& s);
|
|
|
|
|
|
|
|
|
|
The ``set_dht_proxy`` is not available when DHT is disabled. These functions
|
|
|
|
|
sets the proxy settings for different kinds of connections, bittorrent peers,
|
|
|
|
|
web seeds, trackers and the DHT traffic.
|
|
|
|
|
|
|
|
|
|
``set_peer_proxy`` affects regular bittorrent peers. ``set_web_seed_proxy``
|
|
|
|
|
affects only web seeds. see `HTTP seeding`_.
|
|
|
|
|
|
2007-04-26 02:35:28 +02:00
|
|
|
|
``set_tracker_proxy`` only affects HTTP tracker connections (UDP tracker
|
|
|
|
|
connections are affected if the given proxy supports UDP, e.g. SOCKS5).
|
|
|
|
|
|
|
|
|
|
``set_dht_proxy`` affects the DHT messages. Since they are sent over UDP,
|
|
|
|
|
it only has any effect if the proxy supports UDP.
|
|
|
|
|
|
|
|
|
|
For more information on what settings are available for proxies, see
|
|
|
|
|
`proxy_settings`_.
|
|
|
|
|
|
2007-04-26 01:38:25 +02:00
|
|
|
|
|
|
|
|
|
peer_proxy() web_seed_proxy() tracker_proxy() dht_proxy()
|
|
|
|
|
---------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
proxy_settings const& peer_proxy() const;
|
|
|
|
|
proxy_settings const& web_seed_proxy() const;
|
|
|
|
|
proxy_settings const& tracker_proxy() const;
|
|
|
|
|
proxy_settings const& dht_proxy() const;
|
|
|
|
|
|
2007-04-26 02:35:28 +02:00
|
|
|
|
These functions returns references to their respective current settings.
|
2007-04-26 01:38:25 +02:00
|
|
|
|
|
2007-04-26 02:35:28 +02:00
|
|
|
|
The ``dht_proxy`` is not available when DHT is disabled.
|
2007-04-26 01:38:25 +02:00
|
|
|
|
|
2007-06-06 02:41:20 +02:00
|
|
|
|
|
2009-08-20 05:19:12 +02:00
|
|
|
|
set_i2p_proxy() i2p_proxy()
|
|
|
|
|
---------------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void set_i2p_proxy(proxy_settings const&);
|
|
|
|
|
proxy_settings const& i2p_proxy();
|
|
|
|
|
|
|
|
|
|
``set_i2p_proxy`` sets the i2p_ proxy, and tries to open a persistant
|
|
|
|
|
connection to it. The only used fields in the proxy settings structs
|
|
|
|
|
are ``hostname`` and ``port``.
|
|
|
|
|
|
|
|
|
|
``i2p_proxy`` returns the current i2p proxy in use.
|
|
|
|
|
|
2009-08-24 05:42:41 +02:00
|
|
|
|
.. _i2p: http://www.i2p2.de
|
|
|
|
|
|
2009-08-20 05:19:12 +02:00
|
|
|
|
|
2009-10-24 23:55:16 +02:00
|
|
|
|
start_dht() stop_dht() set_dht_settings() dht_state() is_dht_running()
|
|
|
|
|
----------------------------------------------------------------------
|
2006-08-01 17:27:08 +02:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void start_dht(entry const& startup_state);
|
|
|
|
|
void stop_dht();
|
|
|
|
|
void set_dht_settings(dht_settings const& settings);
|
|
|
|
|
entry dht_state() const;
|
2009-10-24 23:55:16 +02:00
|
|
|
|
bool is_dht_running() const;
|
2006-08-01 17:27:08 +02:00
|
|
|
|
|
|
|
|
|
These functions are not available in case ``TORRENT_DISABLE_DHT`` is
|
|
|
|
|
defined. ``start_dht`` starts the dht node and makes the trackerless service
|
|
|
|
|
available to torrents. The startup state is optional and can contain nodes
|
|
|
|
|
and the node id from the previous session. The dht node state is a bencoded
|
|
|
|
|
dictionary with the following entries:
|
|
|
|
|
|
|
|
|
|
``nodes``
|
2006-09-02 09:33:01 +02:00
|
|
|
|
A list of strings, where each string is a node endpoint encoded in binary. If
|
|
|
|
|
the string is 6 bytes long, it is an IPv4 address of 4 bytes, encoded in
|
|
|
|
|
network byte order (big endian), followed by a 2 byte port number (also
|
|
|
|
|
network byte order). If the string is 18 bytes long, it is 16 bytes of IPv6
|
|
|
|
|
address followed by a 2 bytes port number (also network byte order).
|
2006-08-01 17:27:08 +02:00
|
|
|
|
|
|
|
|
|
``node-id``
|
|
|
|
|
The node id written as a readable string as a hexadecimal number.
|
|
|
|
|
|
|
|
|
|
``dht_state`` will return the current state of the dht node, this can be used
|
|
|
|
|
to start up the node again, passing this entry to ``start_dht``. It is a good
|
|
|
|
|
idea to save this to disk when the session is closed, and read it up again
|
|
|
|
|
when starting.
|
|
|
|
|
|
2006-11-14 01:08:16 +01:00
|
|
|
|
If the port the DHT is supposed to listen on is already in use, and exception
|
|
|
|
|
is thrown, ``asio::error``.
|
|
|
|
|
|
2006-08-01 17:27:08 +02:00
|
|
|
|
``stop_dht`` stops the dht node.
|
|
|
|
|
|
|
|
|
|
``add_dht_node`` adds a node to the routing table. This can be used if your
|
|
|
|
|
client has its own source of bootstrapping nodes.
|
|
|
|
|
|
|
|
|
|
``set_dht_settings`` sets some parameters availavle to the dht node. The
|
|
|
|
|
struct has the following members::
|
|
|
|
|
|
|
|
|
|
struct dht_settings
|
|
|
|
|
{
|
|
|
|
|
int max_peers_reply;
|
|
|
|
|
int search_branching;
|
|
|
|
|
int service_port;
|
|
|
|
|
int max_fail_count;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
``max_peers_reply`` is the maximum number of peers the node will send in
|
|
|
|
|
response to a ``get_peers`` message from another node.
|
|
|
|
|
|
|
|
|
|
``search_branching`` is the number of concurrent search request the node will
|
|
|
|
|
send when announcing and refreshing the routing table. This parameter is
|
|
|
|
|
called alpha in the kademlia paper.
|
|
|
|
|
|
2007-03-15 23:03:56 +01:00
|
|
|
|
``service_port`` is the udp port the node will listen to. This will default
|
|
|
|
|
to 0, which means the udp listen port will be the same as the tcp listen
|
|
|
|
|
port. This is in general a good idea, since some NAT implementations
|
|
|
|
|
reserves the udp port for any mapped tcp port, and vice versa. NAT-PMP
|
|
|
|
|
guarantees this for example.
|
2006-08-01 17:27:08 +02:00
|
|
|
|
|
|
|
|
|
``max_fail_count`` is the maximum number of failed tries to contact a node
|
|
|
|
|
before it is removed from the routing table. If there are known working nodes
|
|
|
|
|
that are ready to replace a failing node, it will be replaced immediately,
|
|
|
|
|
this limit is only used to clear out nodes that don't have any node that can
|
|
|
|
|
replace them.
|
|
|
|
|
|
2009-10-24 23:55:16 +02:00
|
|
|
|
``is_dht_running`` returns true if the DHT support has been started and false
|
|
|
|
|
otherwise.
|
|
|
|
|
|
2006-11-14 01:08:16 +01:00
|
|
|
|
|
2006-09-27 19:20:18 +02:00
|
|
|
|
add_dht_node() add_dht_router()
|
|
|
|
|
-------------------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void add_dht_node(std::pair<std::string, int> const& node);
|
|
|
|
|
void add_dht_router(std::pair<std::string, int> const& node);
|
|
|
|
|
|
|
|
|
|
``add_dht_node`` takes a host name and port pair. That endpoint will be
|
|
|
|
|
pinged, and if a valid DHT reply is received, the node will be added to
|
|
|
|
|
the routing table.
|
|
|
|
|
|
|
|
|
|
``add_dht_router`` adds the given endpoint to a list of DHT router nodes.
|
|
|
|
|
If a search is ever made while the routing table is empty, those nodes will
|
|
|
|
|
be used as backups. Nodes in the router node list will also never be added
|
|
|
|
|
to the regular routing table, which effectively means they are only used
|
|
|
|
|
for bootstrapping, to keep the load off them.
|
|
|
|
|
|
|
|
|
|
An example routing node that you could typically add is
|
|
|
|
|
``router.bittorrent.com``.
|
2006-08-01 17:27:08 +02:00
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2008-04-06 21:17:58 +02:00
|
|
|
|
start_lsd() stop_lsd()
|
|
|
|
|
----------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void start_lsd();
|
|
|
|
|
void stop_lsd();
|
|
|
|
|
|
|
|
|
|
Starts and stops Local Service Discovery. This service will broadcast
|
|
|
|
|
the infohashes of all the non-private torrents on the local network to
|
|
|
|
|
look for peers on the same swarm within multicast reach.
|
|
|
|
|
|
|
|
|
|
It is turned off by default.
|
|
|
|
|
|
|
|
|
|
start_upnp() stop_upnp()
|
|
|
|
|
------------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2008-04-07 01:18:35 +02:00
|
|
|
|
upnp* start_upnp();
|
2008-04-06 21:17:58 +02:00
|
|
|
|
void stop_upnp();
|
|
|
|
|
|
|
|
|
|
Starts and stops the UPnP service. When started, the listen port and the DHT
|
|
|
|
|
port are attempted to be forwarded on local UPnP router devices.
|
|
|
|
|
|
2008-04-07 01:18:35 +02:00
|
|
|
|
The upnp object returned by ``start_upnp()`` can be used to add and remove
|
|
|
|
|
arbitrary port mappings. Mapping status is returned through the
|
|
|
|
|
portmap_alert_ and the portmap_error_alert_. The object will be valid until
|
2008-04-07 02:15:36 +02:00
|
|
|
|
``stop_upnp()`` is called. See `UPnP and NAT-PMP`_.
|
2008-04-07 01:18:35 +02:00
|
|
|
|
|
2008-04-06 21:17:58 +02:00
|
|
|
|
It is off by default.
|
|
|
|
|
|
|
|
|
|
start_natpmp() stop_natpmp()
|
|
|
|
|
----------------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2008-04-07 01:18:35 +02:00
|
|
|
|
natpmp* start_natpmp();
|
2008-04-06 21:17:58 +02:00
|
|
|
|
void stop_natpmp();
|
|
|
|
|
|
|
|
|
|
Starts and stops the NAT-PMP service. When started, the listen port and the DHT
|
|
|
|
|
port are attempted to be forwarded on the router through NAT-PMP.
|
|
|
|
|
|
2008-04-07 01:18:35 +02:00
|
|
|
|
The natpmp object returned by ``start_natpmp()`` can be used to add and remove
|
|
|
|
|
arbitrary port mappings. Mapping status is returned through the
|
|
|
|
|
portmap_alert_ and the portmap_error_alert_. The object will be valid until
|
2008-04-07 02:15:36 +02:00
|
|
|
|
``stop_natpmp()`` is called. See `UPnP and NAT-PMP`_.
|
2008-04-07 01:18:35 +02:00
|
|
|
|
|
2008-04-06 21:17:58 +02:00
|
|
|
|
It is off by default.
|
|
|
|
|
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
entry
|
|
|
|
|
=====
|
|
|
|
|
|
|
|
|
|
The ``entry`` class represents one node in a bencoded hierarchy. It works as a
|
|
|
|
|
variant type, it can be either a list, a dictionary (``std::map``), an integer
|
|
|
|
|
or a string. This is its synopsis::
|
|
|
|
|
|
|
|
|
|
class entry
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
2005-09-11 11:58:34 +02:00
|
|
|
|
typedef std::map<std::string, entry> dictionary_type;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
typedef std::string string_type;
|
2004-03-28 19:45:37 +02:00
|
|
|
|
typedef std::list<entry> list_type;
|
|
|
|
|
typedef size_type integer_type;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
|
|
|
|
enum data_type
|
|
|
|
|
{
|
|
|
|
|
int_t,
|
|
|
|
|
string_t,
|
|
|
|
|
list_t,
|
|
|
|
|
dictionary_t,
|
|
|
|
|
undefined_t
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
data_type type() const;
|
|
|
|
|
|
2005-07-06 02:58:23 +02:00
|
|
|
|
entry(dictionary_type const&);
|
|
|
|
|
entry(string_type const&);
|
|
|
|
|
entry(list_type const&);
|
|
|
|
|
entry(integer_type const&);
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
|
|
|
|
entry();
|
|
|
|
|
entry(data_type t);
|
2005-07-06 02:58:23 +02:00
|
|
|
|
entry(entry const& e);
|
2004-01-07 01:48:02 +01:00
|
|
|
|
~entry();
|
|
|
|
|
|
2005-07-06 02:58:23 +02:00
|
|
|
|
void operator=(entry const& e);
|
|
|
|
|
void operator=(dictionary_type const&);
|
|
|
|
|
void operator=(string_type const&);
|
|
|
|
|
void operator=(list_type const&);
|
|
|
|
|
void operator=(integer_type const&);
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2004-03-28 19:45:37 +02:00
|
|
|
|
integer_type& integer();
|
2004-04-17 17:17:43 +02:00
|
|
|
|
integer_type const& integer() const;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
string_type& string();
|
2004-04-17 17:17:43 +02:00
|
|
|
|
string_type const& string() const;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
list_type& list();
|
2004-04-17 17:17:43 +02:00
|
|
|
|
list_type const& list() const;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
dictionary_type& dict();
|
2004-04-17 17:17:43 +02:00
|
|
|
|
dictionary_type const& dict() const;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2004-03-28 19:45:37 +02:00
|
|
|
|
// these functions requires that the entry
|
|
|
|
|
// is a dictionary, otherwise they will throw
|
|
|
|
|
entry& operator[](char const* key);
|
|
|
|
|
entry& operator[](std::string const& key);
|
2005-07-06 02:58:23 +02:00
|
|
|
|
entry const& operator[](char const* key) const;
|
|
|
|
|
entry const& operator[](std::string const& key) const;
|
2004-03-28 19:45:37 +02:00
|
|
|
|
entry* find_key(char const* key);
|
|
|
|
|
entry const* find_key(char const* key) const;
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
void print(std::ostream& os, int indent = 0) const;
|
|
|
|
|
};
|
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
*TODO: finish documentation of entry.*
|
|
|
|
|
|
|
|
|
|
integer() string() list() dict() type()
|
|
|
|
|
---------------------------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
integer_type& integer();
|
|
|
|
|
integer_type const& integer() const;
|
|
|
|
|
string_type& string();
|
|
|
|
|
string_type const& string() const;
|
|
|
|
|
list_type& list();
|
|
|
|
|
list_type const& list() const;
|
|
|
|
|
dictionary_type& dict();
|
|
|
|
|
dictionary_type const& dict() const;
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
The ``integer()``, ``string()``, ``list()`` and ``dict()`` functions
|
2006-05-21 12:41:37 +02:00
|
|
|
|
are accessors that return the respective type. If the ``entry`` object isn't of the
|
2009-03-21 05:33:53 +01:00
|
|
|
|
type you request, the accessor will throw libtorrent_exception_ (which derives from
|
2004-01-07 01:48:02 +01:00
|
|
|
|
``std::runtime_error``). You can ask an ``entry`` for its type through the
|
|
|
|
|
``type()`` function.
|
|
|
|
|
|
|
|
|
|
The ``print()`` function is there for debug purposes only.
|
|
|
|
|
|
|
|
|
|
If you want to create an ``entry`` you give it the type you want it to have in its
|
|
|
|
|
constructor, and then use one of the non-const accessors to get a reference which you then
|
|
|
|
|
can assign the value you want it to have.
|
|
|
|
|
|
|
|
|
|
The typical code to get info from a torrent file will then look like this::
|
|
|
|
|
|
|
|
|
|
entry torrent_file;
|
|
|
|
|
// ...
|
|
|
|
|
|
2005-10-13 09:59:05 +02:00
|
|
|
|
// throws if this is not a dictionary
|
2005-07-06 02:58:23 +02:00
|
|
|
|
entry::dictionary_type const& dict = torrent_file.dict();
|
2004-01-07 01:48:02 +01:00
|
|
|
|
entry::dictionary_type::const_iterator i;
|
|
|
|
|
i = dict.find("announce");
|
|
|
|
|
if (i != dict.end())
|
|
|
|
|
{
|
2005-10-13 09:59:05 +02:00
|
|
|
|
std::string tracker_url = i->second.string();
|
|
|
|
|
std::cout << tracker_url << "\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The following code is equivalent, but a little bit shorter::
|
|
|
|
|
|
|
|
|
|
entry torrent_file;
|
|
|
|
|
// ...
|
|
|
|
|
|
|
|
|
|
// throws if this is not a dictionary
|
|
|
|
|
if (entry* i = torrent_file.find_key("announce"))
|
|
|
|
|
{
|
|
|
|
|
std::string tracker_url = i->string();
|
2004-01-07 01:48:02 +01:00
|
|
|
|
std::cout << tracker_url << "\n";
|
|
|
|
|
}
|
|
|
|
|
|
2005-10-13 09:59:05 +02:00
|
|
|
|
|
|
|
|
|
To make it easier to extract information from a torrent file, the class torrent_info_
|
2004-01-07 01:48:02 +01:00
|
|
|
|
exists.
|
|
|
|
|
|
|
|
|
|
|
2005-10-13 09:59:05 +02:00
|
|
|
|
operator[]
|
|
|
|
|
----------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
entry& operator[](char const* key);
|
|
|
|
|
entry& operator[](std::string const& key);
|
|
|
|
|
entry const& operator[](char const* key) const;
|
|
|
|
|
entry const& operator[](std::string const& key) const;
|
|
|
|
|
|
|
|
|
|
All of these functions requires the entry to be a dictionary, if it isn't they
|
|
|
|
|
will throw ``libtorrent::type_error``.
|
|
|
|
|
|
|
|
|
|
The non-const versions of the ``operator[]`` will return a reference to either
|
|
|
|
|
the existing element at the given key or, if there is no element with the
|
|
|
|
|
given key, a reference to a newly inserted element at that key.
|
|
|
|
|
|
|
|
|
|
The const version of ``operator[]`` will only return a reference to an
|
|
|
|
|
existing element at the given key. If the key is not found, it will throw
|
|
|
|
|
``libtorrent::type_error``.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
find_key()
|
|
|
|
|
----------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
entry* find_key(char const* key);
|
|
|
|
|
entry const* find_key(char const* key) const;
|
|
|
|
|
|
|
|
|
|
These functions requires the entry to be a dictionary, if it isn't they
|
|
|
|
|
will throw ``libtorrent::type_error``.
|
|
|
|
|
|
|
|
|
|
They will look for an element at the given key in the dictionary, if the
|
|
|
|
|
element cannot be found, they will return 0. If an element with the given
|
|
|
|
|
key is found, the return a pointer to it.
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
|
|
|
|
torrent_info
|
|
|
|
|
============
|
|
|
|
|
|
2008-05-28 10:44:40 +02:00
|
|
|
|
In previous versions of libtorrent, this class was also used for creating
|
|
|
|
|
torrent files. This functionality has been moved to ``create_torrent``, see
|
|
|
|
|
make_torrent_.
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
The ``torrent_info`` has the following synopsis::
|
|
|
|
|
|
|
|
|
|
class torrent_info
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
2009-02-23 02:21:19 +01:00
|
|
|
|
// these constructors throws exceptions on error
|
2004-10-14 03:17:04 +02:00
|
|
|
|
torrent_info(sha1_hash const& info_hash);
|
2008-05-20 11:49:40 +02:00
|
|
|
|
torrent_info(lazy_entry const& torrent_file);
|
|
|
|
|
torrent_info(char const* buffer, int size);
|
2008-07-01 13:00:00 +02:00
|
|
|
|
torrent_info(boost::filesystem::path const& filename);
|
2008-12-01 08:52:59 +01:00
|
|
|
|
torrent_info(boost::filesystem::wpath const& filename);
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2009-02-23 02:21:19 +01:00
|
|
|
|
// these constructors sets the error code on error
|
|
|
|
|
torrent_info(sha1_hash const& info_hash, error_code& ec);
|
|
|
|
|
torrent_info(lazy_entry const& torrent_file, error_code& ec);
|
|
|
|
|
torrent_info(char const* buffer, int size, error_code& ec);
|
|
|
|
|
torrent_info(fs::path const& filename, error_code& ec);
|
|
|
|
|
torrent_info(fs::wpath const& filename, error_code& ec);
|
|
|
|
|
|
2004-03-23 23:58:18 +01:00
|
|
|
|
void add_tracker(std::string const& url, int tier = 0);
|
2008-05-28 10:44:40 +02:00
|
|
|
|
std::vector<announce_entry> const& trackers() const;
|
2004-03-05 12:58:38 +01:00
|
|
|
|
|
2008-05-28 10:44:40 +02:00
|
|
|
|
file_storage const& files() const;
|
2008-12-24 21:07:34 +01:00
|
|
|
|
file_storage const& orig_files() const;
|
|
|
|
|
|
2009-11-27 23:15:34 +01:00
|
|
|
|
void remap_files(file_storage const& f);
|
|
|
|
|
|
2008-12-24 21:07:34 +01:00
|
|
|
|
void rename_file(int index, std::string const& new_filename);
|
|
|
|
|
void rename_file(int index, std::wstring const& new_filename);
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2008-05-28 10:44:40 +02:00
|
|
|
|
typedef file_storage::iterator file_iterator;
|
|
|
|
|
typedef file_storage::reverse_iterator reverse_file_iterator;
|
2007-08-25 22:01:53 +02:00
|
|
|
|
|
2008-05-28 10:44:40 +02:00
|
|
|
|
file_iterator begin_files() const;
|
|
|
|
|
file_iterator end_files() const;
|
|
|
|
|
reverse_file_iterator rbegin_files() const;
|
|
|
|
|
reverse_file_iterator rend_files() const;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2008-05-28 10:44:40 +02:00
|
|
|
|
int num_files() const;
|
|
|
|
|
file_entry const& file_at(int index) const;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2006-04-25 23:04:48 +02:00
|
|
|
|
std::vector<file_slice> map_block(int piece, size_type offset
|
2008-05-28 10:44:40 +02:00
|
|
|
|
, int size) const;
|
2006-04-25 23:04:48 +02:00
|
|
|
|
peer_request map_file(int file_index, size_type file_offset
|
2008-05-28 10:44:40 +02:00
|
|
|
|
, int size) const;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2006-08-01 17:27:08 +02:00
|
|
|
|
bool priv() const;
|
|
|
|
|
|
2006-04-25 23:04:48 +02:00
|
|
|
|
std::vector<std::string> const& url_seeds() const;
|
2008-12-30 04:54:07 +01:00
|
|
|
|
void add_url_seed(std::string const& url);
|
|
|
|
|
std::vector<std::string> const& http_seeds() const;
|
|
|
|
|
void add_http_seed(std::string const& url);
|
2006-04-25 23:04:48 +02:00
|
|
|
|
|
2004-02-20 16:22:23 +01:00
|
|
|
|
size_type total_size() const;
|
2008-02-25 11:28:53 +01:00
|
|
|
|
int piece_length() const;
|
2004-01-31 18:13:40 +01:00
|
|
|
|
int num_pieces() const;
|
2005-07-06 02:58:23 +02:00
|
|
|
|
sha1_hash const& info_hash() const;
|
2006-05-21 12:41:37 +02:00
|
|
|
|
std::string const& name() const;
|
2005-07-06 02:58:23 +02:00
|
|
|
|
std::string const& comment() const;
|
2005-08-18 00:59:21 +02:00
|
|
|
|
std::string const& creator() const;
|
2004-03-05 12:58:38 +01:00
|
|
|
|
|
2006-08-01 17:27:08 +02:00
|
|
|
|
std::vector<std::pair<std::string, int> > const& nodes() const;
|
|
|
|
|
void add_node(std::pair<std::string, int> const& node);
|
|
|
|
|
|
2004-03-05 12:58:38 +01:00
|
|
|
|
boost::optional<boost::posix_time::ptime>
|
|
|
|
|
creation_date() const;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2008-02-25 11:28:53 +01:00
|
|
|
|
int piece_size(unsigned int index) const;
|
2005-07-06 02:58:23 +02:00
|
|
|
|
sha1_hash const& hash_for_piece(unsigned int index) const;
|
2008-05-14 07:29:42 +02:00
|
|
|
|
char const* hash_for_piece_ptr(unsigned int index) const;
|
|
|
|
|
|
|
|
|
|
boost::shared_array<char> metadata() const;
|
|
|
|
|
int metadata_size() const;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
};
|
|
|
|
|
|
2005-07-06 02:58:23 +02:00
|
|
|
|
torrent_info()
|
|
|
|
|
--------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
torrent_info(sha1_hash const& info_hash);
|
2008-05-20 11:49:40 +02:00
|
|
|
|
torrent_info(lazy_entry const& torrent_file);
|
|
|
|
|
torrent_info(char const* buffer, int size);
|
2008-07-01 13:00:00 +02:00
|
|
|
|
torrent_info(boost::filesystem::path const& filename);
|
2008-12-01 08:52:59 +01:00
|
|
|
|
torrent_info(boost::filesystem::wpath const& filename);
|
2005-07-06 02:58:23 +02:00
|
|
|
|
|
2009-02-23 02:21:19 +01:00
|
|
|
|
torrent_info(sha1_hash const& info_hash, error_code& ec);
|
|
|
|
|
torrent_info(lazy_entry const& torrent_file, error_code& ec);
|
|
|
|
|
torrent_info(char const* buffer, int size, error_code& ec);
|
|
|
|
|
torrent_info(fs::path const& filename, error_code& ec);
|
|
|
|
|
torrent_info(fs::wpath const& filename, error_code& ec);
|
|
|
|
|
|
2008-05-20 11:49:40 +02:00
|
|
|
|
The constructor that takes an info-hash will initialize the info-hash to the given value,
|
|
|
|
|
but leave all other fields empty. This is used internally when downloading torrents without
|
|
|
|
|
the metadata. The metadata will be created by libtorrent as soon as it has been downloaded
|
|
|
|
|
from the swarm.
|
2005-07-06 02:58:23 +02:00
|
|
|
|
|
2008-05-20 11:49:40 +02:00
|
|
|
|
The constructor that takes a ``lazy_entry`` will create a ``torrent_info`` object from the
|
|
|
|
|
information found in the given torrent_file. The ``lazy_entry`` represents a tree node in
|
|
|
|
|
an bencoded file. To load an ordinary .torrent file
|
|
|
|
|
into a ``lazy_entry``, use lazy_bdecode(), see `bdecode() bencode()`_.
|
2005-07-06 02:58:23 +02:00
|
|
|
|
|
2008-05-20 11:49:40 +02:00
|
|
|
|
The version that takes a buffer pointer and a size will decode it as a .torrent file and
|
|
|
|
|
initialize the torrent_info object for you.
|
2008-05-12 08:35:24 +02:00
|
|
|
|
|
|
|
|
|
The version that takes a filename will simply load the torrent file and decode it inside
|
|
|
|
|
the constructor, for convenience. This might not be the most suitable for applications that
|
|
|
|
|
want to be able to report detailed errors on what might go wrong.
|
|
|
|
|
|
2009-02-23 02:21:19 +01:00
|
|
|
|
The overloads that takes an ``error_code const&`` never throws if an error occur, they
|
|
|
|
|
will simply set the error code to describe what went wrong and not fully initialize the
|
|
|
|
|
torrent_info object. The overloads that do not take the extra error_code_ parameter will
|
|
|
|
|
always throw if an error occurs. These overloads are not available when building without
|
|
|
|
|
exception support.
|
|
|
|
|
|
2005-07-06 02:58:23 +02:00
|
|
|
|
|
2008-05-14 07:29:42 +02:00
|
|
|
|
add_tracker()
|
|
|
|
|
-------------
|
2005-07-06 02:58:23 +02:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void add_tracker(std::string const& url, int tier = 0);
|
|
|
|
|
|
|
|
|
|
``add_tracker()`` adds a tracker to the announce-list. The ``tier`` determines the order in
|
2006-05-21 12:41:37 +02:00
|
|
|
|
which the trackers are to be tried. For more information see `trackers()`_.
|
2005-07-06 02:58:23 +02:00
|
|
|
|
|
2008-12-24 21:07:34 +01:00
|
|
|
|
files() orig_files()
|
|
|
|
|
--------------------
|
2007-08-25 20:26:43 +02:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2008-05-28 10:44:40 +02:00
|
|
|
|
file_storage const& file() const;
|
2008-12-24 21:07:34 +01:00
|
|
|
|
file_storage const& orig_files() const;
|
2007-08-25 20:26:43 +02:00
|
|
|
|
|
2008-05-28 10:44:40 +02:00
|
|
|
|
The ``file_storage`` object contains the information on how to map the pieces to
|
|
|
|
|
files. It is separated from the ``torrent_info`` object because when creating torrents
|
|
|
|
|
a storage object needs to be created without having a torrent file. When renaming files
|
|
|
|
|
in a storage, the storage needs to make its own copy of the ``file_storage`` in order
|
|
|
|
|
to make its mapping differ from the one in the torrent file.
|
2007-11-22 10:27:22 +01:00
|
|
|
|
|
2008-12-24 21:07:34 +01:00
|
|
|
|
``orig_files()`` returns the original (unmodified) file storage for this torrent. This
|
|
|
|
|
is used by the web server connection, which needs to request files with the original
|
2009-03-21 05:33:53 +01:00
|
|
|
|
names. Filename may be chaged using ``torrent_info::rename_file()``.
|
2008-12-24 21:07:34 +01:00
|
|
|
|
|
2008-05-28 10:44:40 +02:00
|
|
|
|
For more information on the ``file_storage`` object, see the separate document on how
|
|
|
|
|
to create torrents.
|
2007-08-25 20:26:43 +02:00
|
|
|
|
|
2009-11-27 23:15:34 +01:00
|
|
|
|
remap_files()
|
|
|
|
|
-------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void remap_files(file_storage const& f);
|
|
|
|
|
|
|
|
|
|
Remaps the file storage to a new file layout. This can be used to, for instance,
|
|
|
|
|
download all data in a torrent to a single file, or to a number of fixed size
|
|
|
|
|
sector aligned files, regardless of the number and sizes of the files in the torrent.
|
|
|
|
|
|
|
|
|
|
The new specified ``file_storage`` must have the exact same size as the current one.
|
|
|
|
|
|
2009-02-28 21:14:51 +01:00
|
|
|
|
rename_file()
|
|
|
|
|
-------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void rename_file(int index, std::string const& new_filename);
|
|
|
|
|
void rename_file(int index, std::wstring const& new_filename);
|
|
|
|
|
|
|
|
|
|
Renames a the file with the specified index to the new name. The new filename is
|
|
|
|
|
reflected by the ``file_storage`` returned by ``files()`` but not by the one
|
|
|
|
|
returned by ``orig_files()``.
|
|
|
|
|
|
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
begin_files() end_files() rbegin_files() rend_files()
|
|
|
|
|
-----------------------------------------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2008-05-28 10:44:40 +02:00
|
|
|
|
file_iterator begin_files() const;
|
|
|
|
|
file_iterator end_files() const;
|
|
|
|
|
reverse_file_iterator rbegin_files() const;
|
|
|
|
|
reverse_file_iterator rend_files() const;
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
This class will need some explanation. First of all, to get a list of all files
|
|
|
|
|
in the torrent, you can use ``begin_files()``, ``end_files()``,
|
|
|
|
|
``rbegin_files()`` and ``rend_files()``. These will give you standard vector
|
2004-01-16 00:57:11 +01:00
|
|
|
|
iterators with the type ``file_entry``.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2007-08-25 20:26:43 +02:00
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct file_entry
|
|
|
|
|
{
|
|
|
|
|
boost::filesystem::path path;
|
|
|
|
|
size_type offset;
|
|
|
|
|
size_type size;
|
2007-11-25 11:47:05 +01:00
|
|
|
|
size_type file_base;
|
2009-01-11 23:27:43 +01:00
|
|
|
|
bool pad_file:1;
|
|
|
|
|
bool hidden_attribute:1;
|
|
|
|
|
bool executable_attribute:1;
|
2007-08-25 20:26:43 +02:00
|
|
|
|
};
|
|
|
|
|
|
2005-05-12 01:03:12 +02:00
|
|
|
|
The ``path`` is the full (relative) path of each file. i.e. if it is a multi-file
|
|
|
|
|
torrent, all the files starts with a directory with the same name as ``torrent_info::name()``.
|
2005-10-13 09:59:05 +02:00
|
|
|
|
The filenames are encoded with UTF-8.
|
2005-05-12 01:03:12 +02:00
|
|
|
|
|
2006-06-18 00:04:25 +02:00
|
|
|
|
``size`` is the size of the file (in bytes) and ``offset`` is the byte offset
|
|
|
|
|
of the file within the torrent. i.e. the sum of all the sizes of the files
|
2007-08-25 22:01:53 +02:00
|
|
|
|
before it in the list.
|
2006-10-13 01:51:10 +02:00
|
|
|
|
|
2007-11-25 11:47:05 +01:00
|
|
|
|
``file_base`` is the offset in the file where the storage should start. The normal
|
|
|
|
|
case is to have this set to 0, so that the storage starts saving data at the start
|
|
|
|
|
if the file. In cases where multiple files are mapped into the same file though,
|
|
|
|
|
the ``file_base`` should be set to an offset so that the different regions do
|
|
|
|
|
not overlap. This is used when mapping "unselected" files into a so-called part
|
|
|
|
|
file.
|
|
|
|
|
|
2009-01-11 23:27:43 +01:00
|
|
|
|
``pad_file`` is set to true for files that are not part of the data of the torrent.
|
|
|
|
|
They are just there to make sure the next file is aligned to a particular byte offset
|
|
|
|
|
or piece boundry. These files should typically be hidden from an end user. They are
|
|
|
|
|
not written to disk.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
|
|
|
|
num_files() file_at()
|
|
|
|
|
---------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2008-05-28 10:44:40 +02:00
|
|
|
|
int num_files() const;
|
|
|
|
|
file_entry const& file_at(int index) const;
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
If you need index-access to files you can use the ``num_files()`` and ``file_at()``
|
|
|
|
|
to access files using indices.
|
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
2006-04-25 23:04:48 +02:00
|
|
|
|
map_block()
|
|
|
|
|
-----------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
std::vector<file_slice> map_block(int piece, size_type offset
|
2008-05-28 10:44:40 +02:00
|
|
|
|
, int size) const;
|
2006-04-25 23:04:48 +02:00
|
|
|
|
|
|
|
|
|
This function will map a piece index, a byte offset within that piece and
|
|
|
|
|
a size (in bytes) into the corresponding files with offsets where that data
|
|
|
|
|
for that piece is supposed to be stored.
|
|
|
|
|
|
|
|
|
|
The file slice struct looks like this::
|
|
|
|
|
|
|
|
|
|
struct file_slice
|
|
|
|
|
{
|
|
|
|
|
int file_index;
|
|
|
|
|
size_type offset;
|
|
|
|
|
size_type size;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The ``file_index`` refers to the index of the file (in the torrent_info).
|
|
|
|
|
To get the path and filename, use ``file_at()`` and give the ``file_index``
|
|
|
|
|
as argument. The ``offset`` is the byte offset in the file where the range
|
|
|
|
|
starts, and ``size`` is the number of bytes this range is. The size + offset
|
|
|
|
|
will never be greater than the file size.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
map_file()
|
|
|
|
|
----------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
peer_request map_file(int file_index, size_type file_offset
|
2008-05-28 10:44:40 +02:00
|
|
|
|
, int size) const;
|
2006-04-25 23:04:48 +02:00
|
|
|
|
|
|
|
|
|
This function will map a range in a specific file into a range in the torrent.
|
|
|
|
|
The ``file_offset`` parameter is the offset in the file, given in bytes, where
|
|
|
|
|
0 is the start of the file.
|
|
|
|
|
The ``peer_request`` structure looks like this::
|
|
|
|
|
|
|
|
|
|
struct peer_request
|
|
|
|
|
{
|
|
|
|
|
int piece;
|
|
|
|
|
int start;
|
|
|
|
|
int length;
|
|
|
|
|
bool operator==(peer_request const& r) const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
``piece`` is the index of the piece in which the range starts.
|
|
|
|
|
``start`` is the offset within that piece where the range starts.
|
|
|
|
|
``length`` is the size of the range, in bytes.
|
|
|
|
|
|
|
|
|
|
The input range is assumed to be valid within the torrent. ``file_offset``
|
|
|
|
|
+ ``size`` is not allowed to be greater than the file size. ``file_index``
|
|
|
|
|
must refer to a valid file, i.e. it cannot be >= ``num_files()``.
|
|
|
|
|
|
|
|
|
|
|
2008-12-30 04:54:07 +01:00
|
|
|
|
url_seeds() add_url_seed() http_seeds() add_http_seed()
|
|
|
|
|
-------------------------------------------------------
|
2006-04-25 23:04:48 +02:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
std::vector<std::string> const& url_seeds() const;
|
|
|
|
|
void add_url_seed(std::string const& url);
|
2008-12-30 04:54:07 +01:00
|
|
|
|
std::vector<std::string> const& http_seeds() const;
|
|
|
|
|
void add_http_seed(std::string const& url);
|
2006-04-25 23:04:48 +02:00
|
|
|
|
|
2008-12-30 04:54:07 +01:00
|
|
|
|
If there are any url-seeds or http seeds in this torrent, ``url_seeds()``
|
|
|
|
|
and ``http_seeds()`` will return a vector of those urls.
|
|
|
|
|
``add_url_seed()`` and ``add_http_seed()`` adds one url to the list of
|
|
|
|
|
url/http seeds. Currently, the only transport protocol
|
2006-04-25 23:04:48 +02:00
|
|
|
|
supported for the url is http.
|
|
|
|
|
|
|
|
|
|
See `HTTP seeding`_ for more information.
|
|
|
|
|
|
|
|
|
|
|
2004-09-12 12:12:16 +02:00
|
|
|
|
trackers()
|
|
|
|
|
----------
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2005-07-06 02:58:23 +02:00
|
|
|
|
std::vector<announce_entry> const& trackers() const;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
|
|
|
|
The ``trackers()`` function will return a sorted vector of ``announce_entry``.
|
|
|
|
|
Each announce entry contains a string, which is the tracker url, and a tier index. The
|
|
|
|
|
tier index is the high-level priority. No matter which trackers that works or not, the
|
|
|
|
|
ones with lower tier will always be tried before the one with higher tier number.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct announce_entry
|
|
|
|
|
{
|
2004-09-12 12:12:16 +02:00
|
|
|
|
announce_entry(std::string const& url);
|
2004-01-07 01:48:02 +01:00
|
|
|
|
std::string url;
|
2009-12-02 05:05:24 +01:00
|
|
|
|
|
|
|
|
|
int next_announce_in() const;
|
|
|
|
|
int min_announce_in() const;
|
|
|
|
|
|
2008-11-27 21:51:59 +01:00
|
|
|
|
boost::uint8_t tier;
|
|
|
|
|
boost::uint8_t fail_limit;
|
2008-11-29 09:38:40 +01:00
|
|
|
|
boost::uint8_t fails;
|
|
|
|
|
|
|
|
|
|
enum tracker_source
|
|
|
|
|
{
|
|
|
|
|
source_torrent = 1,
|
|
|
|
|
source_client = 2,
|
|
|
|
|
source_magnet_link = 4,
|
|
|
|
|
source_tex = 8
|
|
|
|
|
};
|
|
|
|
|
boost::uint8_t source;
|
|
|
|
|
|
|
|
|
|
bool verified:1;
|
|
|
|
|
bool updating:1;
|
|
|
|
|
bool start_sent:1;
|
|
|
|
|
bool complete_sent:1;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
};
|
|
|
|
|
|
2009-12-02 05:05:24 +01:00
|
|
|
|
``next_announce_in()`` returns the number of seconds to the next announce on
|
|
|
|
|
this tracker. ``min_announce_in()`` returns the number of seconds until we are
|
|
|
|
|
allowed to force another tracker update with this tracker.
|
|
|
|
|
|
2008-11-27 21:51:59 +01:00
|
|
|
|
``fail_limit`` is the max number of failures to announce to this tracker in
|
|
|
|
|
a row, before this tracker is not used anymore.
|
|
|
|
|
|
2008-11-29 09:38:40 +01:00
|
|
|
|
``fails`` is the number of times in a row we have failed to announce to this
|
|
|
|
|
tracker.
|
|
|
|
|
|
|
|
|
|
``source`` is a bitmask specifying which sources we got this tracker from.
|
|
|
|
|
|
|
|
|
|
``verified`` is set to true the first time we receive a valid response
|
|
|
|
|
from this tracker.
|
|
|
|
|
|
|
|
|
|
``updating`` is true while we're waiting for a response from the tracker.
|
|
|
|
|
|
|
|
|
|
``start_sent`` is set to true when we get a valid response from an announce
|
|
|
|
|
with event=started. If it is set, we won't send start in the subsequent
|
|
|
|
|
announces.
|
|
|
|
|
|
|
|
|
|
``complete_sent`` is set to true when we send a event=completed.
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
total_size() piece_length() piece_size() num_pieces()
|
|
|
|
|
-----------------------------------------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
size_type total_size() const;
|
2008-02-25 11:28:53 +01:00
|
|
|
|
int piece_length() const;
|
|
|
|
|
int piece_size(unsigned int index) const;
|
2004-04-17 17:17:43 +02:00
|
|
|
|
int num_pieces() const;
|
|
|
|
|
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
``total_size()``, ``piece_length()`` and ``num_pieces()`` returns the total
|
|
|
|
|
number of bytes the torrent-file represents (all the files in it), the number of byte for
|
|
|
|
|
each piece and the total number of pieces, respectively. The difference between
|
|
|
|
|
``piece_size()`` and ``piece_length()`` is that ``piece_size()`` takes
|
|
|
|
|
the piece index as argument and gives you the exact size of that piece. It will always
|
|
|
|
|
be the same as ``piece_length()`` except in the case of the last piece, which may
|
|
|
|
|
be smaller.
|
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
2008-05-14 07:29:42 +02:00
|
|
|
|
hash_for_piece() hash_for_piece_ptr() info_hash()
|
|
|
|
|
-------------------------------------------------
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
size_type piece_size(unsigned int index) const;
|
2005-07-06 02:58:23 +02:00
|
|
|
|
sha1_hash const& hash_for_piece(unsigned int index) const;
|
2008-05-14 07:29:42 +02:00
|
|
|
|
char const* hash_for_piece_ptr(unsigned int index) const;
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
``hash_for_piece()`` takes a piece-index and returns the 20-bytes sha1-hash for that
|
|
|
|
|
piece and ``info_hash()`` returns the 20-bytes sha1-hash for the info-section of the
|
|
|
|
|
torrent file. For more information on the ``sha1_hash``, see the big_number_ class.
|
2008-05-14 07:29:42 +02:00
|
|
|
|
``hash_for_piece_ptr()`` returns a pointer to the 20 byte sha1 digest for the piece.
|
|
|
|
|
Note that the string is not null-terminated.
|
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
2005-08-18 00:59:21 +02:00
|
|
|
|
name() comment() creation_date() creator()
|
|
|
|
|
------------------------------------------
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2005-07-06 02:58:23 +02:00
|
|
|
|
std::string const& name() const;
|
|
|
|
|
std::string const& comment() const;
|
2004-04-17 17:17:43 +02:00
|
|
|
|
boost::optional<boost::posix_time::ptime> creation_date() const;
|
|
|
|
|
|
|
|
|
|
``name()`` returns the name of the torrent.
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
``comment()`` returns the comment associated with the torrent. If there's no comment,
|
|
|
|
|
it will return an empty string. ``creation_date()`` returns a `boost::posix_time::ptime`__
|
2006-05-21 12:41:37 +02:00
|
|
|
|
object, representing the time when this torrent file was created. If there's no time stamp
|
|
|
|
|
in the torrent file, this will return a date of January 1:st 1970.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2005-10-13 09:59:05 +02:00
|
|
|
|
Both the name and the comment is UTF-8 encoded strings.
|
|
|
|
|
|
2005-08-18 01:04:26 +02:00
|
|
|
|
``creator()`` returns the creator string in the torrent. If there is no creator string
|
2005-08-18 00:59:21 +02:00
|
|
|
|
it will return an empty string.
|
|
|
|
|
|
2007-03-24 19:46:27 +01:00
|
|
|
|
__ http://www.boost.org/doc/html/date_time/posix_time.html#date_time.posix_time.ptime_class
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
|
|
|
|
|
2008-05-14 07:29:42 +02:00
|
|
|
|
priv()
|
|
|
|
|
------
|
2006-08-01 17:27:08 +02:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
bool priv() const;
|
|
|
|
|
|
|
|
|
|
``priv()`` returns true if this torrent is private. i.e., it should not be
|
|
|
|
|
distributed on the trackerless network (the kademlia DHT).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nodes()
|
|
|
|
|
-------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
std::vector<std::pair<std::string, int> > const& nodes() const;
|
|
|
|
|
|
|
|
|
|
If this torrent contains any DHT nodes, they are put in this vector in their original
|
|
|
|
|
form (host name and port number).
|
|
|
|
|
|
2008-05-15 09:37:34 +02:00
|
|
|
|
add_node()
|
|
|
|
|
----------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void add_node(std::pair<std::string, int> const& node);
|
|
|
|
|
|
|
|
|
|
This is used when creating torrent. Use this to add a known DHT node. It may
|
|
|
|
|
be used, by the client, to bootstrap into the DHT network.
|
|
|
|
|
|
2006-08-01 17:27:08 +02:00
|
|
|
|
|
2008-05-14 07:29:42 +02:00
|
|
|
|
metadata() metadata_size()
|
|
|
|
|
--------------------------
|
2006-08-01 17:27:08 +02:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2008-05-14 07:29:42 +02:00
|
|
|
|
boost::shared_array<char> metadata() const;
|
|
|
|
|
int metadata_size() const;
|
2006-08-01 17:27:08 +02:00
|
|
|
|
|
2008-05-14 07:29:42 +02:00
|
|
|
|
``metadata()`` returns a the raw info section of the torrent file. The size
|
|
|
|
|
of the metadata is returned by ``metadata_size()``.
|
2006-08-01 17:27:08 +02:00
|
|
|
|
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
torrent_handle
|
|
|
|
|
==============
|
|
|
|
|
|
|
|
|
|
You will usually have to store your torrent handles somewhere, since it's the
|
2006-05-21 12:41:37 +02:00
|
|
|
|
object through which you retrieve information about the torrent and aborts the torrent.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
Its declaration looks like this::
|
|
|
|
|
|
|
|
|
|
struct torrent_handle
|
|
|
|
|
{
|
|
|
|
|
torrent_handle();
|
|
|
|
|
|
|
|
|
|
torrent_status status();
|
2009-07-04 06:58:24 +02:00
|
|
|
|
void file_progress(std::vector<size_type>& fp, int flags = 0);
|
2005-10-19 16:02:58 +02:00
|
|
|
|
void get_download_queue(std::vector<partial_piece_info>& queue) const;
|
|
|
|
|
void get_peer_info(std::vector<peer_info>& v) const;
|
|
|
|
|
torrent_info const& get_torrent_info() const;
|
|
|
|
|
bool is_valid() const;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2006-11-14 01:08:16 +01:00
|
|
|
|
std::string name() const;
|
|
|
|
|
|
2008-04-13 20:54:36 +02:00
|
|
|
|
void save_resume_data() const;
|
2005-10-19 16:02:58 +02:00
|
|
|
|
void force_reannounce() const;
|
2009-10-25 03:37:45 +01:00
|
|
|
|
void force_dht_announce() const;
|
2007-11-24 04:10:20 +01:00
|
|
|
|
void force_reannounce(boost::posix_time::time_duration) const;
|
|
|
|
|
void scrape_tracker() const;
|
2007-04-10 23:23:13 +02:00
|
|
|
|
void connect_peer(asio::ip::tcp::endpoint const& adr, int source = 0) const;
|
2004-03-23 23:58:18 +01:00
|
|
|
|
|
2005-10-13 09:59:05 +02:00
|
|
|
|
void set_tracker_login(std::string const& username
|
2005-10-19 16:02:58 +02:00
|
|
|
|
, std::string const& password) const;
|
2004-03-28 19:45:37 +02:00
|
|
|
|
|
2009-11-01 03:35:22 +01:00
|
|
|
|
std::vector<announce_entry> trackers() const;
|
2004-09-12 12:12:16 +02:00
|
|
|
|
void replace_trackers(std::vector<announce_entry> const&);
|
2009-11-01 03:35:22 +01:00
|
|
|
|
void add_tracker(announce_entry const& url);
|
2004-09-12 12:12:16 +02:00
|
|
|
|
|
2006-04-25 23:04:48 +02:00
|
|
|
|
void add_url_seed(std::string const& url);
|
2007-08-17 18:40:55 +02:00
|
|
|
|
void remove_url_seed(std::string const& url);
|
|
|
|
|
std::set<std::string> url_seeds() const;
|
2006-04-25 23:04:48 +02:00
|
|
|
|
|
2008-12-30 04:54:07 +01:00
|
|
|
|
void add_http_seed(std::string const& url);
|
|
|
|
|
void remove_http_seed(std::string const& url);
|
|
|
|
|
std::set<std::string> http_seeds() const;
|
|
|
|
|
|
2005-10-19 16:02:58 +02:00
|
|
|
|
void set_ratio(float ratio) const;
|
2009-04-07 17:55:05 +02:00
|
|
|
|
int max_uploads() const;
|
2005-10-19 16:02:58 +02:00
|
|
|
|
void set_max_uploads(int max_uploads) const;
|
|
|
|
|
void set_max_connections(int max_connections) const;
|
2008-11-08 08:40:55 +01:00
|
|
|
|
int max_connections() const;
|
2005-10-19 16:02:58 +02:00
|
|
|
|
void set_upload_limit(int limit) const;
|
2007-04-10 11:25:17 +02:00
|
|
|
|
int upload_limit() const;
|
2005-10-19 16:02:58 +02:00
|
|
|
|
void set_download_limit(int limit) const;
|
2007-04-10 11:25:17 +02:00
|
|
|
|
int download_limit() const;
|
2008-01-31 18:52:29 +01:00
|
|
|
|
void set_sequential_download(bool sd) const;
|
2008-06-17 10:30:04 +02:00
|
|
|
|
bool is_sequential_download() const;
|
2006-04-25 23:04:48 +02:00
|
|
|
|
|
2006-05-20 19:59:17 +02:00
|
|
|
|
void set_peer_upload_limit(asio::ip::tcp::endpoint ip, int limit) const;
|
|
|
|
|
void set_peer_download_limit(asio::ip::tcp::endpoint ip, int limit) const;
|
2006-04-25 23:04:48 +02:00
|
|
|
|
|
2008-05-29 05:37:19 +02:00
|
|
|
|
int queue_position() const;
|
|
|
|
|
void queue_position_up() const;
|
|
|
|
|
void queue_position_down() const;
|
|
|
|
|
void queue_position_top() const;
|
|
|
|
|
void queue_position_bottom() const;
|
|
|
|
|
|
2009-09-13 04:24:25 +02:00
|
|
|
|
void set_priority(int prio) const;
|
|
|
|
|
|
2005-10-19 16:02:58 +02:00
|
|
|
|
void use_interface(char const* net_interface) const;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2005-10-19 16:02:58 +02:00
|
|
|
|
void pause() const;
|
|
|
|
|
void resume() const;
|
2004-03-21 03:03:37 +01:00
|
|
|
|
bool is_paused() const;
|
2004-09-08 01:16:11 +02:00
|
|
|
|
bool is_seed() const;
|
2008-06-07 18:24:56 +02:00
|
|
|
|
void force_recheck() const;
|
2008-07-12 19:00:52 +02:00
|
|
|
|
void clear_error() const;
|
2009-06-19 00:32:55 +02:00
|
|
|
|
void set_upload_mode(bool m) const;
|
2004-03-21 03:03:37 +01:00
|
|
|
|
|
2007-01-29 08:39:33 +01:00
|
|
|
|
void resolve_countries(bool r);
|
|
|
|
|
bool resolve_countries() const;
|
|
|
|
|
|
2009-03-17 10:34:44 +01:00
|
|
|
|
enum deadline_flags { alert_when_available = 1 };
|
2009-12-05 08:24:22 +01:00
|
|
|
|
void set_piece_deadline(int index, int deadline, int flags = 0) const;
|
2009-03-17 10:34:44 +01:00
|
|
|
|
|
2009-11-14 19:25:19 +01:00
|
|
|
|
void piece_availability(std::vector<int>& avail) const;
|
2007-03-20 02:59:00 +01:00
|
|
|
|
void piece_priority(int index, int priority) const;
|
|
|
|
|
int piece_priority(int index) const;
|
|
|
|
|
void prioritize_pieces(std::vector<int> const& pieces) const;
|
|
|
|
|
std::vector<int> piece_priorities() const;
|
|
|
|
|
|
2008-07-20 18:00:08 +02:00
|
|
|
|
void file_priority(int index, int priority) const;
|
|
|
|
|
int file_priority(int index) const;
|
2007-03-20 02:59:00 +01:00
|
|
|
|
void prioritize_files(std::vector<int> const& files) const;
|
2008-07-20 18:00:08 +02:00
|
|
|
|
std::vector<int> file_priorities() const;
|
2007-03-20 02:59:00 +01:00
|
|
|
|
|
2008-04-24 05:28:48 +02:00
|
|
|
|
bool is_auto_managed() const;
|
|
|
|
|
void auto_managed(bool m) const;
|
|
|
|
|
|
2004-09-10 02:47:30 +02:00
|
|
|
|
bool has_metadata() const;
|
2008-09-24 04:32:33 +02:00
|
|
|
|
bool set_metadata(char const* buf, int size) const;
|
2004-09-10 02:47:30 +02:00
|
|
|
|
|
2006-05-21 12:41:37 +02:00
|
|
|
|
boost::filesystem::path save_path() const;
|
2007-06-11 23:24:14 +02:00
|
|
|
|
void move_storage(boost::filesystem::path const& save_path) const;
|
2008-11-30 09:12:26 +01:00
|
|
|
|
void move_storage(boost::filesystem::wpath const& save_path) const;
|
2008-11-30 08:04:21 +01:00
|
|
|
|
void rename_file(int index, boost::filesystem::path) const;
|
2008-11-30 09:12:26 +01:00
|
|
|
|
void rename_file(int index, boost::filesystem::wpath) const;
|
2008-09-04 18:20:19 +02:00
|
|
|
|
storage_interface* get_storage_impl() const;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2008-12-08 07:36:22 +01:00
|
|
|
|
bool super_seeding() const;
|
|
|
|
|
void super_seeding(bool on) const;
|
|
|
|
|
|
2008-12-07 22:04:19 +01:00
|
|
|
|
enum flags_t { overwrite_existing = 1 };
|
|
|
|
|
void add_piece(int piece, char const* data, int flags = 0) const;
|
2008-12-14 20:47:02 +01:00
|
|
|
|
void read_piece(int piece) const;
|
2008-12-07 22:04:19 +01:00
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
sha1_hash info_hash() const;
|
|
|
|
|
|
2005-07-06 02:58:23 +02:00
|
|
|
|
bool operator==(torrent_handle const&) const;
|
|
|
|
|
bool operator!=(torrent_handle const&) const;
|
|
|
|
|
bool operator<(torrent_handle const&) const;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
};
|
|
|
|
|
|
2007-03-20 02:59:00 +01:00
|
|
|
|
The default constructor will initialize the handle to an invalid state. Which
|
|
|
|
|
means you cannot perform any operation on it, unless you first assign it a
|
|
|
|
|
valid handle. If you try to perform any operation on an uninitialized handle,
|
|
|
|
|
it will throw ``invalid_handle``.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2009-03-21 05:33:53 +01:00
|
|
|
|
.. warning:: All operations on a ``torrent_handle`` may throw libtorrent_exception_
|
2008-04-24 05:28:48 +02:00
|
|
|
|
exception, in case the handle is no longer refering to a torrent. There is
|
|
|
|
|
one exception ``is_valid()`` will never throw.
|
2006-10-14 19:18:41 +02:00
|
|
|
|
Since the torrents are processed by a background thread, there is no
|
|
|
|
|
guarantee that a handle will remain valid between two calls.
|
|
|
|
|
|
2009-03-17 10:34:44 +01:00
|
|
|
|
set_piece_deadline()
|
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
enum deadline_flags { alert_when_available = 1 };
|
2009-12-05 08:24:22 +01:00
|
|
|
|
void set_piece_deadline(int index, int deadline, int flags = 0) const;
|
2009-03-17 10:34:44 +01:00
|
|
|
|
|
|
|
|
|
This function sets or resets the deadline associated with a specific piece
|
|
|
|
|
index (``index``). libtorrent will attempt to download this entire piece before
|
|
|
|
|
the deadline expires. This is not necessarily possible, but pieces with a more
|
|
|
|
|
recent deadline will always be prioritized over pieces with a deadline further
|
|
|
|
|
ahead in time. The deadline (and flags) of a piece can be changed by calling this
|
|
|
|
|
function again.
|
|
|
|
|
|
|
|
|
|
The ``flags`` parameter can be used to ask libtorrent to send an alert once the
|
|
|
|
|
piece has been downloaded, by passing ``alert_when_available``. When set, the
|
|
|
|
|
read_piece_alert_ alert will be delivered, with the piece data, when it's downloaded.
|
|
|
|
|
|
|
|
|
|
If the piece is already downloaded when this call is made, nothing happens, unless
|
|
|
|
|
the ``alert_when_available`` flag is set, in which case it will do the same thing
|
2009-03-21 05:33:53 +01:00
|
|
|
|
as calling `read_piece()`_ for ``index``.
|
2009-03-17 10:34:44 +01:00
|
|
|
|
|
2009-12-05 08:24:22 +01:00
|
|
|
|
``deadline`` is the number of milliseconds until this piece should be completed.
|
2009-09-25 17:03:24 +02:00
|
|
|
|
|
2007-03-20 02:59:00 +01:00
|
|
|
|
|
2009-11-14 19:25:19 +01:00
|
|
|
|
piece_availability()
|
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void piece_availability(std::vector<int>& avail) const;
|
|
|
|
|
|
|
|
|
|
Fills the specified ``std::vector<int>`` with the availability for each
|
|
|
|
|
piece in this torrent. libtorrent does not keep track of availability for
|
|
|
|
|
seeds, so if the torrent is seeding the availability for all pieces is
|
|
|
|
|
reported as 0.
|
|
|
|
|
|
|
|
|
|
The piece availability is the number of peers that we are connected that has
|
|
|
|
|
advertized having a particular piece. This is the information that libtorrent
|
|
|
|
|
uses in order to prefer picking rare pieces.
|
|
|
|
|
|
|
|
|
|
|
2008-07-20 18:00:08 +02:00
|
|
|
|
piece_priority() prioritize_pieces() piece_priorities()
|
|
|
|
|
-------------------------------------------------------
|
2007-03-20 02:59:00 +01:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void piece_priority(int index, int priority) const;
|
|
|
|
|
int piece_priority(int index) const;
|
|
|
|
|
void prioritize_pieces(std::vector<int> const& pieces) const;
|
|
|
|
|
std::vector<int> piece_priorities() const;
|
|
|
|
|
|
|
|
|
|
These functions are used to set and get the prioritiy of individual pieces.
|
|
|
|
|
By default all pieces have priority 1. That means that the random rarest
|
|
|
|
|
first algorithm is effectively active for all pieces. You may however
|
|
|
|
|
change the priority of individual pieces. There are 8 different priority
|
|
|
|
|
levels:
|
|
|
|
|
|
2007-04-26 01:38:25 +02:00
|
|
|
|
0. piece is not downloaded at all
|
|
|
|
|
1. normal priority. Download order is dependent on availability
|
|
|
|
|
2. higher than normal priority. Pieces are preferred over pieces with
|
|
|
|
|
the same availability, but not over pieces with lower availability
|
|
|
|
|
3. pieces are as likely to be picked as partial pieces.
|
|
|
|
|
4. pieces are preferred over partial pieces, but not over pieces with
|
|
|
|
|
lower availability
|
|
|
|
|
5. *currently the same as 4*
|
|
|
|
|
6. piece is as likely to be picked as any piece with availability 1
|
|
|
|
|
7. maximum priority, availability is disregarded, the piece is preferred
|
|
|
|
|
over any other piece with lower priority
|
2007-03-20 02:59:00 +01:00
|
|
|
|
|
|
|
|
|
The exact definitions of these priorities are implementation details, and
|
|
|
|
|
subject to change. The interface guarantees that higher number means higher
|
|
|
|
|
priority, and that 0 means do not download.
|
|
|
|
|
|
|
|
|
|
``piece_priority`` sets or gets the priority for an individual piece,
|
|
|
|
|
specified by ``index``.
|
|
|
|
|
|
|
|
|
|
``prioritize_pieces`` takes a vector of integers, one integer per piece in
|
|
|
|
|
the torrent. All the piece priorities will be updated with the priorities
|
|
|
|
|
in the vector.
|
|
|
|
|
|
|
|
|
|
``piece_priorities`` returns a vector with one element for each piece in the
|
|
|
|
|
torrent. Each element is the current priority of that piece.
|
|
|
|
|
|
2008-07-20 18:00:08 +02:00
|
|
|
|
|
|
|
|
|
file_priority() prioritize_files() file_priorities()
|
|
|
|
|
----------------------------------------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void file_priority(int index, int priority) const;
|
|
|
|
|
int file_priority(int index) const;
|
|
|
|
|
void prioritize_files(std::vector<int> const& files) const;
|
|
|
|
|
std::vector<int> file_priorities() const;
|
|
|
|
|
|
|
|
|
|
``index`` must be in the range [0, number_of_files).
|
|
|
|
|
|
|
|
|
|
``file_priority`` queries or sets the priority of file ``index``.
|
|
|
|
|
|
2007-03-20 02:59:00 +01:00
|
|
|
|
``prioritize_files`` takes a vector that has at as many elements as there are
|
|
|
|
|
files in the torrent. Each entry is the priority of that file. The function
|
|
|
|
|
sets the priorities of all the pieces in the torrent based on the vector.
|
|
|
|
|
|
2008-07-20 18:00:08 +02:00
|
|
|
|
``file_priorities`` returns a vector with the priorities of all files.
|
|
|
|
|
|
|
|
|
|
The priority values are the same as for ``piece_priority``.
|
|
|
|
|
|
|
|
|
|
Whenever a file priority is changed, all other piece priorities are reset
|
|
|
|
|
to match the file priorities. In order to maintain sepcial priorities for
|
|
|
|
|
particular pieces, ``piece_priority`` has to be called again for those pieces.
|
2005-05-25 12:01:01 +02:00
|
|
|
|
|
2009-11-26 01:09:49 +01:00
|
|
|
|
You cannot set the file priorities on a torrent that does not yet
|
|
|
|
|
have metadata or a torrent that is a seed. ``file_priority(int, int)`` and
|
|
|
|
|
``prioritize_files()`` are both no-ops for such torrents.
|
|
|
|
|
|
2006-06-11 15:48:39 +02:00
|
|
|
|
file_progress()
|
|
|
|
|
---------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2009-07-04 06:58:24 +02:00
|
|
|
|
void file_progress(std::vector<size_type>& fp, int flags = 0);
|
2006-06-11 15:48:39 +02:00
|
|
|
|
|
2008-07-12 15:38:22 +02:00
|
|
|
|
This function fills in the supplied vector with the the number of bytes downloaded
|
|
|
|
|
of each file in this torrent. The progress values are ordered the same as the files
|
2008-07-12 15:40:21 +02:00
|
|
|
|
in the `torrent_info`_. This operation is not very cheap. Its complexity is *O(n + mj)*.
|
|
|
|
|
Where *n* is the number of files, *m* is the number of downloading pieces and *j*
|
2008-07-12 15:38:22 +02:00
|
|
|
|
is the number of blocks in a piece.
|
2006-06-11 15:48:39 +02:00
|
|
|
|
|
2009-07-04 06:58:24 +02:00
|
|
|
|
The ``flags`` parameter can be used to specify the granularity of the file progress. If
|
|
|
|
|
left at the default value of 0, the progress will be as accurate as possible, but also
|
|
|
|
|
more expensive to calculate. If ``torrent_handle::piece_granularity`` is specified,
|
|
|
|
|
the progress will be specified in piece granularity. i.e. only pieces that have been
|
|
|
|
|
fully downloaded and passed the hash check count. When specifying piece granularity,
|
|
|
|
|
the operation is a lot cheaper, since libtorrent already keeps track of this internally
|
|
|
|
|
and no calculation is required.
|
|
|
|
|
|
2006-06-11 15:48:39 +02:00
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
save_path()
|
|
|
|
|
-----------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2006-05-21 12:41:37 +02:00
|
|
|
|
boost::filesystem::path save_path() const;
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
|
|
|
|
``save_path()`` returns the path that was given to `add_torrent()`_ when this torrent
|
2004-01-07 01:48:02 +01:00
|
|
|
|
was started.
|
|
|
|
|
|
2004-07-18 02:39:58 +02:00
|
|
|
|
move_storage()
|
|
|
|
|
--------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2007-06-11 23:24:14 +02:00
|
|
|
|
void move_storage(boost::filesystem::path const& save_path) const;
|
2008-11-30 09:12:26 +01:00
|
|
|
|
void move_storage(boost::filesystem::wpath const& save_path) const;
|
2004-07-18 02:39:58 +02:00
|
|
|
|
|
2008-11-03 02:42:19 +01:00
|
|
|
|
Moves the file(s) that this torrent are currently seeding from or downloading to. If
|
|
|
|
|
the given ``save_path`` is not located on the same drive as the original save path,
|
|
|
|
|
The files will be copied to the new drive and removed from their original location.
|
|
|
|
|
This will block all other disk IO, and other torrents download and upload rates may
|
|
|
|
|
drop while copying the file.
|
|
|
|
|
|
|
|
|
|
Since disk IO is performed in a separate thread, this operation is also asynchronous.
|
|
|
|
|
Once the operation completes, the ``storage_moved_alert`` is generated, with the new
|
2009-05-11 23:18:09 +02:00
|
|
|
|
path as the message. If the move fails for some reason, ``storage_moved_failed_alert``
|
|
|
|
|
is generated instead, containing the error message.
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
2008-11-30 08:04:21 +01:00
|
|
|
|
rename_file()
|
|
|
|
|
-------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void rename_file(int index, boost::filesystem::path) const;
|
2008-11-30 09:12:26 +01:00
|
|
|
|
void rename_file(int index, boost::filesystem::wpath) const;
|
2008-11-30 08:04:21 +01:00
|
|
|
|
|
|
|
|
|
Renames the file with the given index asynchronously. The rename operation is complete
|
|
|
|
|
when either a ``file_renamed_alert`` or ``file_rename_failed_alert`` is posted.
|
|
|
|
|
|
2008-09-04 18:20:19 +02:00
|
|
|
|
get_storage_impl()
|
|
|
|
|
------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
storage_interface* get_storage_impl() const;
|
|
|
|
|
|
|
|
|
|
Returns the storage implementation for this torrent. This depends on the
|
|
|
|
|
storage contructor function that was passed to ``session::add_torrent``.
|
|
|
|
|
|
2008-12-08 07:36:22 +01:00
|
|
|
|
super_seeding()
|
|
|
|
|
---------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
bool super_seeding() const;
|
|
|
|
|
void super_seeding(bool on) const;
|
|
|
|
|
|
|
|
|
|
Enables or disabled super seeding/initial seeding for this torrent. The torrent
|
|
|
|
|
needs to be a seed for this to take effect. The overload that returns a bool
|
|
|
|
|
tells you of super seeding is enabled or not.
|
|
|
|
|
|
2008-12-07 22:04:19 +01:00
|
|
|
|
add_piece()
|
|
|
|
|
-----------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
enum flags_t { overwrite_existing = 1 };
|
|
|
|
|
void add_piece(int piece, char const* data, int flags = 0) const;
|
|
|
|
|
|
|
|
|
|
This function will write ``data`` to the storage as piece ``piece``, as if it had
|
|
|
|
|
been downloaded from a peer. ``data`` is expected to point to a buffer of as many
|
|
|
|
|
bytes as the size of the specified piece. The data in the buffer is copied and
|
|
|
|
|
passed on to the disk IO thread to be written at a later point.
|
|
|
|
|
|
|
|
|
|
By default, data that's already been downloaded is not overwritten by this buffer. If
|
|
|
|
|
you trust this data to be correct (and pass the piece hash check) you may pass the
|
|
|
|
|
``overwrite_existing`` flag. This will instruct libtorrent to overwrite any data that
|
|
|
|
|
may already have been downloaded with this data.
|
|
|
|
|
|
|
|
|
|
Since the data is written asynchronously, you may know that is passed or failed the
|
|
|
|
|
hash check by waiting for ``piece_finished_alert`` or ``has_failed_alert``.
|
|
|
|
|
|
2008-12-14 20:47:02 +01:00
|
|
|
|
read_piece()
|
|
|
|
|
------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void read_piece(int piece) const;
|
|
|
|
|
|
|
|
|
|
This function starts an asynchronous read operation of the specified piece from
|
|
|
|
|
this torrent. You must have completed the download of the specified piece before
|
|
|
|
|
calling this function.
|
|
|
|
|
|
|
|
|
|
When the read operation is completed, it is passed back through an alert,
|
|
|
|
|
read_piece_alert_. In order to receive this alert, you must enable
|
|
|
|
|
``alert::storage_notification`` in your alert mask (see `set_alert_mask()`_).
|
|
|
|
|
|
|
|
|
|
Note that if you read multiple pieces, the read operations are not guaranteed to
|
|
|
|
|
finish in the same order as you initiated them.
|
|
|
|
|
|
2009-10-25 03:37:45 +01:00
|
|
|
|
force_reannounce() force_dht_announce()
|
|
|
|
|
---------------------------------------
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2005-10-19 16:02:58 +02:00
|
|
|
|
void force_reannounce() const;
|
2007-11-24 04:10:20 +01:00
|
|
|
|
void force_reannounce(boost::posix_time::time_duration) const;
|
2009-10-25 03:37:45 +01:00
|
|
|
|
void force_dht_announce() const;
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
2004-01-08 18:03:04 +01:00
|
|
|
|
``force_reannounce()`` will force this torrent to do another tracker request, to receive new
|
2007-11-24 04:10:20 +01:00
|
|
|
|
peers. The second overload of ``force_reannounce`` that takes a ``time_duration`` as
|
|
|
|
|
argument will schedule a reannounce in that amount of time from now.
|
2004-01-08 18:03:04 +01:00
|
|
|
|
|
2009-10-25 03:37:45 +01:00
|
|
|
|
``force_dht_announce`` will announce the torrent to the DHT immediately.
|
|
|
|
|
|
2007-11-24 04:10:20 +01:00
|
|
|
|
scrape_tracker()
|
|
|
|
|
----------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void scrape_tracker() const;
|
|
|
|
|
|
|
|
|
|
``scrape_tracker()`` will send a scrape request to the tracker. A scrape request queries the
|
|
|
|
|
tracker for statistics such as total number of incomplete peers, complete peers, number of
|
|
|
|
|
downloads etc.
|
|
|
|
|
|
|
|
|
|
This request will specifically update the ``num_complete`` and ``num_incomplete`` fields in
|
|
|
|
|
the torrent_status_ struct once it completes. When it completes, it will generate a
|
|
|
|
|
scrape_reply_alert_. If it fails, it will generate a scrape_failed_alert_.
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
|
|
|
|
connect_peer()
|
|
|
|
|
--------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2007-04-10 23:23:13 +02:00
|
|
|
|
void connect_peer(asio::ip::tcp::endpoint const& adr, int source = 0) const;
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
2004-01-08 18:03:04 +01:00
|
|
|
|
``connect_peer()`` is a way to manually connect to peers that one believe is a part of the
|
|
|
|
|
torrent. If the peer does not respond, or is not a member of this torrent, it will simply
|
|
|
|
|
be disconnected. No harm can be done by using this other than an unnecessary connection
|
|
|
|
|
attempt is made. If the torrent is uninitialized or in queued or checking mode, this
|
2009-03-21 05:33:53 +01:00
|
|
|
|
will throw libtorrent_exception_. The second (optional) argument will be bitwised ORed into
|
2007-04-10 23:23:13 +02:00
|
|
|
|
the source mask of this peer. Typically this is one of the source flags in peer_info_.
|
|
|
|
|
i.e. ``tracker``, ``pex``, ``dht`` etc.
|
2004-01-08 18:03:04 +01:00
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
2006-11-14 01:08:16 +01:00
|
|
|
|
name()
|
|
|
|
|
------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
std::string name() const;
|
|
|
|
|
|
|
|
|
|
Returns the name of the torrent. i.e. the name from the metadata associated with it. In
|
|
|
|
|
case the torrent was started without metadata, and hasn't completely received it yet,
|
|
|
|
|
it returns the name given to it when added to the session. See ``session::add_torrent``.
|
|
|
|
|
|
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
set_ratio()
|
|
|
|
|
-----------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2005-10-19 16:02:58 +02:00
|
|
|
|
void set_ratio(float ratio) const;
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
2004-01-12 04:05:10 +01:00
|
|
|
|
``set_ratio()`` sets the desired download / upload ratio. If set to 0, it is considered being
|
|
|
|
|
infinite. i.e. the client will always upload as much as it can, no matter how much it gets back
|
|
|
|
|
in return. With this setting it will work much like the standard clients.
|
|
|
|
|
|
2004-02-22 23:40:45 +01:00
|
|
|
|
Besides 0, the ratio can be set to any number greater than or equal to 1. It means how much to
|
2004-01-12 04:05:10 +01:00
|
|
|
|
attempt to upload in return for each download. e.g. if set to 2, the client will try to upload
|
|
|
|
|
2 bytes for every byte received. The default setting for this is 0, which will make it work
|
|
|
|
|
as a standard client.
|
2004-01-08 18:03:04 +01:00
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
2007-04-10 11:25:17 +02:00
|
|
|
|
set_upload_limit() set_download_limit() upload_limit() download_limit()
|
|
|
|
|
-----------------------------------------------------------------------
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2005-10-19 16:02:58 +02:00
|
|
|
|
void set_upload_limit(int limit) const;
|
|
|
|
|
void set_download_limit(int limit) const;
|
2007-04-10 11:25:17 +02:00
|
|
|
|
int upload_limit() const;
|
|
|
|
|
int download_limit() const;
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
2004-03-23 23:58:18 +01:00
|
|
|
|
``set_upload_limit`` will limit the upload bandwidth used by this particular torrent to the
|
|
|
|
|
limit you set. It is given as the number of bytes per second the torrent is allowed to upload.
|
2004-03-28 19:45:37 +02:00
|
|
|
|
``set_download_limit`` works the same way but for download bandwidth instead of upload bandwidth.
|
2004-07-02 09:52:14 +02:00
|
|
|
|
Note that setting a higher limit on a torrent then the global limit (``session::set_upload_rate_limit``)
|
2004-03-28 19:45:37 +02:00
|
|
|
|
will not override the global rate limit. The torrent can never upload more than the global rate
|
|
|
|
|
limit.
|
2004-03-23 23:58:18 +01:00
|
|
|
|
|
2007-04-10 11:25:17 +02:00
|
|
|
|
``upload_limit`` and ``download_limit`` will return the current limit setting, for upload and
|
|
|
|
|
download, respectively.
|
|
|
|
|
|
2006-09-04 19:17:45 +02:00
|
|
|
|
|
2008-06-17 10:30:04 +02:00
|
|
|
|
set_sequential_download() is_sequential_download()
|
|
|
|
|
--------------------------------------------------
|
2006-09-04 19:17:45 +02:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2008-01-31 18:52:29 +01:00
|
|
|
|
void set_sequential_download(bool sd);
|
2008-06-17 10:30:04 +02:00
|
|
|
|
bool is_sequential_download() const;
|
2006-09-04 19:17:45 +02:00
|
|
|
|
|
2008-06-17 10:30:04 +02:00
|
|
|
|
``set_sequential_download()`` enables or disables *sequential download*. When enabled, the piece
|
|
|
|
|
picker will pick pieces in sequence instead of rarest first.
|
2006-09-04 19:17:45 +02:00
|
|
|
|
|
2008-01-31 18:52:29 +01:00
|
|
|
|
Enabling sequential download will affect the piece distribution negatively in the swarm. It should be
|
|
|
|
|
used sparingly.
|
2006-09-04 19:17:45 +02:00
|
|
|
|
|
2008-06-17 10:30:04 +02:00
|
|
|
|
``is_sequential_download()`` returns true if this torrent is downloading in sequence, and false
|
|
|
|
|
otherwise.
|
|
|
|
|
|
2006-09-04 19:17:45 +02:00
|
|
|
|
|
2006-04-25 23:04:48 +02:00
|
|
|
|
set_peer_upload_limit() set_peer_download_limit()
|
|
|
|
|
-------------------------------------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2006-05-20 19:59:17 +02:00
|
|
|
|
void set_peer_upload_limit(asio::ip::tcp::endpoint ip, int limit) const;
|
|
|
|
|
void set_peer_download_limit(asio::ip::tcp::endpoint ip, int limit) const;
|
2006-04-25 23:04:48 +02:00
|
|
|
|
|
|
|
|
|
Works like ``set_upload_limit`` and ``set_download_limit`` respectively, but controls individual
|
|
|
|
|
peer instead of the whole torrent.
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
|
|
|
|
pause() resume() is_paused()
|
|
|
|
|
----------------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2005-10-19 16:02:58 +02:00
|
|
|
|
void pause() const;
|
|
|
|
|
void resume() const;
|
2004-04-17 17:17:43 +02:00
|
|
|
|
bool is_paused() const;
|
|
|
|
|
|
2004-03-21 03:03:37 +01:00
|
|
|
|
``pause()``, and ``resume()`` will disconnect all peers and reconnect all peers respectively.
|
|
|
|
|
When a torrent is paused, it will however remember all share ratios to all peers and remember
|
|
|
|
|
all potential (not connected) peers. You can use ``is_paused()`` to determine if a torrent
|
2006-05-21 12:41:37 +02:00
|
|
|
|
is currently paused. Torrents may be paused automatically if there is a file error (e.g. disk full)
|
2004-03-21 03:03:37 +01:00
|
|
|
|
or something similar. See file_error_alert_.
|
|
|
|
|
|
2009-01-22 04:02:16 +01:00
|
|
|
|
torrents that are auto-managed may be automatically resumed again. It does not make sense to
|
|
|
|
|
pause an auto-managed torrent without making it not automanaged first. Torrents are auto-managed
|
|
|
|
|
by default when added to the session. For more information, see queuing_.
|
|
|
|
|
|
2008-08-21 13:24:24 +02:00
|
|
|
|
``is_paused()`` only returns true if the torrent itself is paused. If the torrent
|
2008-08-21 13:25:10 +02:00
|
|
|
|
is not running because the session is paused, this still returns false. To know if a
|
2008-08-21 13:24:24 +02:00
|
|
|
|
torrent is active or not, you need to inspect both ``torrent_handle::is_paused()``
|
|
|
|
|
and ``session::is_paused()``.
|
|
|
|
|
|
2008-06-07 18:24:56 +02:00
|
|
|
|
force_recheck()
|
|
|
|
|
---------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void force_recheck() const;
|
|
|
|
|
|
|
|
|
|
``force_recheck`` puts the torrent back in a state where it assumes to have no resume data.
|
|
|
|
|
All peers will be disconnected and the torrent will stop announcing to the tracker. The torrent
|
|
|
|
|
will be added to the checking queue, and will be checked (all the files will be read and
|
|
|
|
|
compared to the piece hashes). Once the check is complete, the torrent will start connecting
|
|
|
|
|
to peers again, as normal.
|
|
|
|
|
|
2008-07-12 19:00:52 +02:00
|
|
|
|
clear_error()
|
|
|
|
|
-------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void clear_error() const;
|
|
|
|
|
|
|
|
|
|
If the torrent is in an error state (i.e. ``torrent_status::error`` is non-empty), this
|
|
|
|
|
will clear the error and start the torrent again.
|
2008-06-07 18:24:56 +02:00
|
|
|
|
|
2009-06-19 00:32:55 +02:00
|
|
|
|
set_upload_mode()
|
|
|
|
|
-----------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void set_upload_mode(bool m) const;
|
|
|
|
|
|
|
|
|
|
Explicitly sets the upload mode of the torrent. In upload mode, the torrent will not
|
|
|
|
|
request any pieces. If the torrent is auto managed, it will automatically be taken out
|
|
|
|
|
of upload mode periodically (see ``session_settings::optimistic_disk_retry``). Torrents
|
|
|
|
|
are automatically put in upload mode whenever they encounter a disk write error.
|
|
|
|
|
|
|
|
|
|
``m`` should be true to enter upload mode, and false to leave it.
|
|
|
|
|
|
|
|
|
|
To test if a torrent is in upload mode, call ``torrent_handle::status()`` and inspect
|
|
|
|
|
``torrent_status::upload_mode``.
|
|
|
|
|
|
2007-01-29 08:39:33 +01:00
|
|
|
|
resolve_countries()
|
|
|
|
|
-------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void resolve_countries(bool r);
|
|
|
|
|
bool resolve_countries() const;
|
|
|
|
|
|
|
|
|
|
Sets or gets the flag that derermines if countries should be resolved for the peers of this
|
|
|
|
|
torrent. It defaults to false. If it is set to true, the peer_info_ structure for the peers
|
|
|
|
|
in this torrent will have their ``country`` member set. See peer_info_ for more information
|
|
|
|
|
on how to interpret this field.
|
|
|
|
|
|
2004-09-08 01:16:11 +02:00
|
|
|
|
is_seed()
|
|
|
|
|
---------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
bool is_seed() const;
|
|
|
|
|
|
|
|
|
|
Returns true if the torrent is in seed mode (i.e. if it has finished downloading).
|
|
|
|
|
|
2008-04-24 05:28:48 +02:00
|
|
|
|
is_auto_managed() auto_managed()
|
|
|
|
|
--------------------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
bool is_auto_managed() const;
|
|
|
|
|
void auto_managed(bool m) const;
|
|
|
|
|
|
|
|
|
|
``is_auto_managed()`` returns true if this torrent is currently *auto managed*.
|
|
|
|
|
``auto_managed()`` changes whether the torrent is auto managed or not. For more info,
|
|
|
|
|
see queuing_.
|
2005-02-23 09:57:54 +01:00
|
|
|
|
|
2008-09-24 04:32:33 +02:00
|
|
|
|
has_metadata() set_metadata()
|
|
|
|
|
-----------------------------
|
2004-09-10 02:47:30 +02:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
bool has_metadata() const;
|
2008-09-24 04:32:33 +02:00
|
|
|
|
bool set_metadata(char const* buf, int size) const;
|
|
|
|
|
|
|
|
|
|
``has_metadata`` returns true if this torrent has metadata (either it was started from a
|
|
|
|
|
.torrent file or the metadata has been downloaded). The only scenario where this can return
|
|
|
|
|
false is when the torrent was started torrent-less (i.e. with just an info-hash and tracker
|
|
|
|
|
ip). Note that if the torrent doesn't have metadata, the member `get_torrent_info()`_ will
|
|
|
|
|
throw.
|
|
|
|
|
|
|
|
|
|
``set_metadata`` expects the *info* section of metadata. i.e. The buffer passed in will be
|
|
|
|
|
hashed and verified against the info-hash. If it fails, a ``metadata_failed_alert`` will be
|
|
|
|
|
generated. If it passes, a ``metadata_received_alert`` is generated. The function returns
|
|
|
|
|
true if the metadata is successfully set on the torrent, and false otherwise. If the torrent
|
|
|
|
|
already has metadata, this function will not affect the torrent, and false will be returned.
|
2004-09-10 02:47:30 +02:00
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
|
|
|
|
set_tracker_login()
|
|
|
|
|
-------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2005-10-19 16:02:58 +02:00
|
|
|
|
void set_tracker_login(std::string const& username
|
|
|
|
|
, std::string const& password) const;
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
2004-02-22 23:40:45 +01:00
|
|
|
|
``set_tracker_login()`` sets a username and password that will be sent along in the HTTP-request
|
|
|
|
|
of the tracker announce. Set this if the tracker requires authorization.
|
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
2008-11-26 02:42:14 +01:00
|
|
|
|
trackers() replace_trackers() add_tracker()
|
|
|
|
|
-------------------------------------------
|
2005-08-16 13:45:37 +02:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2009-11-01 03:35:22 +01:00
|
|
|
|
std::vector<announce_entry> trackers() const;
|
2005-10-19 16:02:58 +02:00
|
|
|
|
void replace_trackers(std::vector<announce_entry> const&) const;
|
2008-11-26 02:42:14 +01:00
|
|
|
|
void add_tracker(announc_entry const& url);
|
2005-08-16 13:45:37 +02:00
|
|
|
|
|
|
|
|
|
``trackers()`` will return the list of trackers for this torrent. The
|
2006-05-21 12:41:37 +02:00
|
|
|
|
announce entry contains both a string ``url`` which specify the announce url
|
2005-08-16 13:45:37 +02:00
|
|
|
|
for the tracker as well as an int ``tier``, which is specifies the order in
|
|
|
|
|
which this tracker is tried. If you want libtorrent to use another list of
|
|
|
|
|
trackers for this torrent, you can use ``replace_trackers()`` which takes
|
|
|
|
|
a list of the same form as the one returned from ``trackers()`` and will
|
|
|
|
|
replace it. If you want an immediate effect, you have to call
|
2009-11-01 04:13:50 +01:00
|
|
|
|
`force_reannounce() force_dht_announce()`_. See `trackers()`_ for the definition of ``announce_entry``.
|
2005-08-16 13:45:37 +02:00
|
|
|
|
|
2008-11-26 02:42:14 +01:00
|
|
|
|
``add_tracker()`` will look if the specified tracker is already in the set.
|
|
|
|
|
If it is, it doesn't do anything. If it's not in the current set of trackers,
|
|
|
|
|
it will insert it in the tier specified in the announce_entry.
|
|
|
|
|
|
2005-08-16 13:45:37 +02:00
|
|
|
|
|
2007-08-17 18:40:55 +02:00
|
|
|
|
add_url_seed() remove_url_seed() url_seeds()
|
|
|
|
|
--------------------------------------------
|
2006-04-25 23:04:48 +02:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void add_url_seed(std::string const& url);
|
2007-08-17 18:40:55 +02:00
|
|
|
|
void remove_url_seed(std::string const& url);
|
|
|
|
|
std::set<std::string> url_seeds() const;
|
2006-04-25 23:04:48 +02:00
|
|
|
|
|
|
|
|
|
``add_url_seed()`` adds another url to the torrent's list of url seeds. If the
|
|
|
|
|
given url already exists in that list, the call has no effect. The torrent
|
|
|
|
|
will connect to the server and try to download pieces from it, unless it's
|
2007-08-17 18:40:55 +02:00
|
|
|
|
paused, queued, checking or seeding. ``remove_url_seed()`` removes the given
|
|
|
|
|
url if it exists already. ``url_seeds()`` return a set of the url seeds
|
|
|
|
|
currently in this torrent. Note that urls that fails may be removed
|
|
|
|
|
automatically from the list.
|
2006-04-25 23:04:48 +02:00
|
|
|
|
|
|
|
|
|
See `HTTP seeding`_ for more information.
|
|
|
|
|
|
2008-12-30 04:54:07 +01:00
|
|
|
|
add_http_seed() remove_http_seed() http_seeds()
|
|
|
|
|
-----------------------------------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void add_http_seed(std::string const& url);
|
|
|
|
|
void remove_http_seed(std::string const& url);
|
|
|
|
|
std::set<std::string> http_seeds() const;
|
|
|
|
|
|
|
|
|
|
These functions are identical as the ``*_url_seed()`` variants, but they
|
|
|
|
|
operate on BEP 17 web seeds instead of BEP 19.
|
|
|
|
|
|
|
|
|
|
See `HTTP seeding`_ for more information.
|
2006-04-25 23:04:48 +02:00
|
|
|
|
|
2008-05-29 05:37:19 +02:00
|
|
|
|
queue_position() queue_position_up() queue_position_down() queue_position_top() queue_position_bottom()
|
|
|
|
|
-------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
int queue_position() const;
|
|
|
|
|
void queue_position_up() const;
|
|
|
|
|
void queue_position_down() const;
|
|
|
|
|
void queue_position_top() const;
|
|
|
|
|
void queue_position_bottom() const;
|
|
|
|
|
|
|
|
|
|
Every torrent that is added is assigned a queue position exactly one greater than
|
|
|
|
|
the greatest queue position of all existing torrents. Torrents that are being
|
|
|
|
|
seeded have -1 as their queue position, since they're no longer in line to be downloaded.
|
|
|
|
|
|
|
|
|
|
When a torrent is removed or turns into a seed, all torrents with greater queue positions
|
|
|
|
|
have their positions decreased to fill in the space in the sequence.
|
|
|
|
|
|
|
|
|
|
``queue_position()`` returns the torrent's position in the download queue. The torrents
|
|
|
|
|
with the smallest numbers are the ones that are being downloaded. The smaller number,
|
|
|
|
|
the closer the torrent is to the front of the line to be started.
|
|
|
|
|
|
|
|
|
|
The ``queue_position_*()`` functions adjust the torrents position in the queue. Up means
|
|
|
|
|
closer to the front and down means closer to the back of the queue. Top and bottom refers
|
|
|
|
|
to the front and the back of the queue respectively.
|
|
|
|
|
|
2009-09-13 04:24:25 +02:00
|
|
|
|
set_priority()
|
|
|
|
|
--------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void set_priority(int prio) const;
|
|
|
|
|
|
|
|
|
|
This sets the bandwidth priority of this torrent. The priority of a torrent determines
|
|
|
|
|
how much bandwidth its peers are assigned when distributing upload and download rate quotas.
|
|
|
|
|
A high number gives more bandwidth. The priority must be within the range [0, 255].
|
|
|
|
|
|
2009-09-13 18:51:27 +02:00
|
|
|
|
The default priority is 0, which is the lowest priority.
|
2009-09-13 04:24:25 +02:00
|
|
|
|
|
2009-10-20 04:53:07 +02:00
|
|
|
|
To query the priority of a torrent, use the ``torrent_handle::status()`` call.
|
2009-09-13 04:24:25 +02:00
|
|
|
|
|
|
|
|
|
Torrents with higher priority will not nececcarily get as much bandwidth as they can
|
|
|
|
|
consume, even if there's is more quota. Other peers will still be weighed in when
|
|
|
|
|
bandwidth is being distributed. With other words, bandwidth is not distributed strictly
|
|
|
|
|
in order of priority, but the priority is used as a weight.
|
2008-05-29 05:37:19 +02:00
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
use_interface()
|
|
|
|
|
---------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2005-10-19 16:02:58 +02:00
|
|
|
|
void use_interface(char const* net_interface) const;
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
2004-02-26 01:27:06 +01:00
|
|
|
|
``use_interface()`` sets the network interface this torrent will use when it opens outgoing
|
2004-04-17 17:17:43 +02:00
|
|
|
|
connections. By default, it uses the same interface as the session_ uses to listen on. The
|
2007-03-07 19:50:38 +01:00
|
|
|
|
parameter must be a string containing an ip-address (either an IPv4 or IPv6 address). If
|
|
|
|
|
the string does not conform to this format and exception is thrown.
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
info_hash()
|
|
|
|
|
-----------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
sha1_hash info_hash() const;
|
|
|
|
|
|
|
|
|
|
``info_hash()`` returns the info-hash for the torrent.
|
|
|
|
|
|
2004-02-26 01:27:06 +01:00
|
|
|
|
|
2009-04-07 17:55:05 +02:00
|
|
|
|
set_max_uploads() max_uploads() set_max_connections() max_connections()
|
|
|
|
|
-----------------------------------------------------------------------
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2005-10-19 16:02:58 +02:00
|
|
|
|
void set_max_uploads(int max_uploads) const;
|
2009-04-07 17:55:05 +02:00
|
|
|
|
int max_uploads() const;
|
2005-10-19 16:02:58 +02:00
|
|
|
|
void set_max_connections(int max_connections) const;
|
2008-11-08 08:40:55 +01:00
|
|
|
|
int max_connections() const;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
|
|
|
|
``set_max_uploads()`` sets the maximum number of peers that's unchoked at the same time on this
|
|
|
|
|
torrent. If you set this to -1, there will be no limit.
|
|
|
|
|
|
2004-01-22 23:45:52 +01:00
|
|
|
|
``set_max_connections()`` sets the maximum number of connection this torrent will open. If all
|
|
|
|
|
connections are used up, incoming connections may be refused or poor connections may be closed.
|
|
|
|
|
This must be at least 2. The default is unlimited number of connections. If -1 is given to the
|
|
|
|
|
function, it means unlimited.
|
|
|
|
|
|
2009-04-07 17:55:05 +02:00
|
|
|
|
``max_uploads()`` and ``max_connections()`` returns the current settings.
|
2008-11-08 08:40:55 +01:00
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
2008-04-13 20:54:36 +02:00
|
|
|
|
save_resume_data()
|
|
|
|
|
------------------
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2008-04-13 20:54:36 +02:00
|
|
|
|
void save_resume_data() const;
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
2008-04-13 20:54:36 +02:00
|
|
|
|
``save_resume_data()`` generates fast-resume data and returns it as an entry_. This entry_
|
2004-01-07 01:48:02 +01:00
|
|
|
|
is suitable for being bencoded. For more information about how fast-resume works, see `fast resume`_.
|
2004-09-16 03:14:16 +02:00
|
|
|
|
|
2008-04-13 20:54:36 +02:00
|
|
|
|
This operation is asynchronous, ``save_resume_data`` will return immediately. The resume data
|
|
|
|
|
is delivered when it's done through an `save_resume_data_alert`_.
|
|
|
|
|
|
|
|
|
|
The fast resume data will be empty in the following cases:
|
2004-09-16 03:14:16 +02:00
|
|
|
|
|
|
|
|
|
1. The torrent handle is invalid.
|
|
|
|
|
2. The torrent is checking (or is queued for checking) its storage, it will obviously
|
|
|
|
|
not be ready to write resume data.
|
|
|
|
|
3. The torrent hasn't received valid metadata and was started without metadata
|
|
|
|
|
(see libtorrent's `metadata from peers`_ extension)
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2008-04-13 20:54:36 +02:00
|
|
|
|
Note that by the time you receive the fast resume data, it may already be invalid if the torrent
|
2008-10-17 04:26:08 +02:00
|
|
|
|
is still downloading! The recommended practice is to first pause the session, then generate the
|
2008-04-13 20:54:36 +02:00
|
|
|
|
fast resume data, and then close it down. Make sure to not `remove_torrent()`_ before you receive
|
2008-10-17 04:26:08 +02:00
|
|
|
|
the `save_resume_data_alert`_ though. There's no need to pause when saving intermittent resume data.
|
2004-04-18 14:28:02 +02:00
|
|
|
|
|
2008-10-17 04:26:08 +02:00
|
|
|
|
.. warning:: If you pause every torrent individually instead of pausing the session, every torrent
|
|
|
|
|
will have its paused state saved in the resume data!
|
|
|
|
|
|
|
|
|
|
.. note:: It is typically a good idea to save resume data whenever a torrent is completed or paused. In those
|
|
|
|
|
cases you don't need to pause the torrent or the session, since the torrent will do no more writing
|
|
|
|
|
to its files. If you save resume data for torrents when they are paused, you can accelerate the
|
2009-01-07 03:32:08 +01:00
|
|
|
|
shutdown process by not saving resume data again for paused torrents. Completed torrents should
|
|
|
|
|
have their resume data saved when they complete and on exit, since their statistics might be updated.
|
2008-10-17 04:26:08 +02:00
|
|
|
|
|
|
|
|
|
In full allocation mode the reume data is never invalidated by subsequent
|
|
|
|
|
writes to the files, since pieces won't move around. This means that you don't need to
|
|
|
|
|
pause before writing resume data in full or sparse mode. If you don't, however, any data written to
|
|
|
|
|
disk after you saved resume data and before the session_ closed is lost.
|
2007-11-20 11:00:49 +01:00
|
|
|
|
|
|
|
|
|
It also means that if the resume data is out dated, libtorrent will not re-check the files, but assume
|
|
|
|
|
that it is fairly recent. The assumption is that it's better to loose a little bit than to re-check
|
|
|
|
|
the entire file.
|
|
|
|
|
|
2007-04-17 23:54:40 +02:00
|
|
|
|
It is still a good idea to save resume data periodically during download as well as when
|
2007-11-20 11:00:49 +01:00
|
|
|
|
closing down.
|
2007-04-17 23:54:40 +02:00
|
|
|
|
|
2008-04-13 20:54:36 +02:00
|
|
|
|
Example code to pause and save resume data for all torrents and wait for the alerts::
|
|
|
|
|
|
|
|
|
|
int num_resume_data = 0;
|
|
|
|
|
std::vector<torrent_handle> handles = ses.get_torrents();
|
2008-10-17 04:26:08 +02:00
|
|
|
|
ses.pause();
|
2008-04-13 20:54:36 +02:00
|
|
|
|
for (std::vector<torrent_handle>::iterator i = handles.begin();
|
|
|
|
|
i != handles.end(); ++i)
|
|
|
|
|
{
|
|
|
|
|
torrent_handle& h = *i;
|
|
|
|
|
if (!h.has_metadata()) continue;
|
2008-10-17 04:26:08 +02:00
|
|
|
|
if (!h.is_valid()) continue;
|
2008-04-13 20:54:36 +02:00
|
|
|
|
|
|
|
|
|
h.save_resume_data();
|
|
|
|
|
++num_resume_data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (num_resume_data > 0)
|
|
|
|
|
{
|
|
|
|
|
alert const* a = ses.wait_for_alert(seconds(10));
|
|
|
|
|
|
|
|
|
|
// if we don't get an alert within 10 seconds, abort
|
|
|
|
|
if (a == 0) break;
|
|
|
|
|
|
|
|
|
|
std::auto_ptr<alert> holder = ses.pop_alert();
|
2008-11-18 11:30:57 +01:00
|
|
|
|
|
2009-11-02 04:34:16 +01:00
|
|
|
|
if (alert_cast<save_resume_data_failed_alert>(a))
|
2008-11-18 11:30:57 +01:00
|
|
|
|
{
|
|
|
|
|
process_alert(a);
|
|
|
|
|
--num_resume_data;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-02 04:34:16 +01:00
|
|
|
|
save_resume_data_alert const* rd = alert_cast<save_resume_data_alert>(a);
|
2008-04-13 20:54:36 +02:00
|
|
|
|
if (rd == 0)
|
|
|
|
|
{
|
|
|
|
|
process_alert(a);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
torrent_handle h = rd->handle;
|
|
|
|
|
boost::filesystem::ofstream out(h.save_path()
|
|
|
|
|
/ (h.get_torrent_info().name() + ".fastresume"), std::ios_base::binary);
|
|
|
|
|
out.unsetf(std::ios_base::skipws);
|
|
|
|
|
bencode(std::ostream_iterator<char>(out), *rd->resume_data);
|
|
|
|
|
--num_resume_data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
status()
|
|
|
|
|
--------
|
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
::
|
|
|
|
|
|
2005-10-19 16:02:58 +02:00
|
|
|
|
torrent_status status() const;
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
``status()`` will return a structure with information about the status of this
|
2009-03-21 05:33:53 +01:00
|
|
|
|
torrent. If the torrent_handle_ is invalid, it will throw libtorrent_exception_ exception.
|
2004-04-17 17:17:43 +02:00
|
|
|
|
See torrent_status_.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get_download_queue()
|
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2005-10-19 16:02:58 +02:00
|
|
|
|
void get_download_queue(std::vector<partial_piece_info>& queue) const;
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
|
|
|
|
``get_download_queue()`` takes a non-const reference to a vector which it will fill with
|
|
|
|
|
information about pieces that are partially downloaded or not downloaded at all but partially
|
|
|
|
|
requested. The entry in the vector (``partial_piece_info``) looks like this::
|
|
|
|
|
|
|
|
|
|
struct partial_piece_info
|
|
|
|
|
{
|
|
|
|
|
int piece_index;
|
|
|
|
|
int blocks_in_piece;
|
2007-06-11 05:28:07 +02:00
|
|
|
|
enum state_t { none, slow, medium, fast };
|
2007-04-27 02:27:37 +02:00
|
|
|
|
state_t piece_state;
|
2009-05-03 11:45:07 +02:00
|
|
|
|
block_info* blocks;
|
2004-04-17 17:17:43 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
``piece_index`` is the index of the piece in question. ``blocks_in_piece`` is the
|
|
|
|
|
number of blocks in this particular piece. This number will be the same for most pieces, but
|
|
|
|
|
the last piece may have fewer blocks than the standard pieces.
|
|
|
|
|
|
2007-04-27 02:27:37 +02:00
|
|
|
|
``piece_state`` is set to either ``fast``, ``medium``, ``slow`` or ``none``. It tells which
|
|
|
|
|
download rate category the peers downloading this piece falls into. ``none`` means that no
|
|
|
|
|
peer is currently downloading any part of the piece. Peers prefer picking pieces from
|
|
|
|
|
the same category as themselves. The reason for this is to keep the number of partially
|
|
|
|
|
downloaded pieces down. Pieces set to ``none`` can be converted into any of ``fast``,
|
|
|
|
|
``medium`` or ``slow`` as soon as a peer want to download from it.
|
|
|
|
|
|
2007-06-11 05:28:07 +02:00
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct block_info
|
|
|
|
|
{
|
|
|
|
|
enum block_state_t
|
|
|
|
|
{ none, requested, writing, finished };
|
|
|
|
|
|
2009-05-03 11:45:07 +02:00
|
|
|
|
void set_peer(tcp::endpoint const& ep);
|
|
|
|
|
tcp::endpoint peer() const;
|
|
|
|
|
|
|
|
|
|
unsigned bytes_progress:15;
|
|
|
|
|
unsigned block_size:15;
|
2007-06-11 05:28:07 +02:00
|
|
|
|
unsigned state:2;
|
2007-07-06 19:15:35 +02:00
|
|
|
|
unsigned num_peers:14;
|
2007-06-11 05:28:07 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2009-05-03 11:45:07 +02:00
|
|
|
|
The ``blocks`` field points to an array of ``blocks_in_piece`` elements. This pointer is
|
|
|
|
|
only valid until the next call to ``get_download_queue()`` for any torrent in the same session.
|
|
|
|
|
They all share the storaga for the block arrays in their session object.
|
|
|
|
|
|
2007-06-11 05:28:07 +02:00
|
|
|
|
The ``block_info`` array contains data for each individual block in the piece. Each block has
|
|
|
|
|
a state (``state``) which is any of:
|
|
|
|
|
|
|
|
|
|
* ``none`` - This block has not been downloaded or requested form any peer.
|
|
|
|
|
* ``requested`` - The block has been requested, but not completely downloaded yet.
|
|
|
|
|
* ``writing`` - The block has been downloaded and is currently queued for being written to disk.
|
|
|
|
|
* ``finished`` - The block has been written to disk.
|
|
|
|
|
|
|
|
|
|
The ``peer`` field is the ip address of the peer this block was downloaded from.
|
2007-07-06 19:15:35 +02:00
|
|
|
|
``num_peers`` is the number of peers that is currently requesting this block. Typically this
|
|
|
|
|
is 0 or 1, but at the end of the torrent blocks may be requested by more peers in parallel to
|
|
|
|
|
speed things up.
|
2009-05-03 11:45:07 +02:00
|
|
|
|
``bytes_progress`` is the number of bytes that have been received for this block, and
|
|
|
|
|
``block_size`` is the total number of bytes in this block.
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
|
|
|
|
get_peer_info()
|
|
|
|
|
---------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2005-10-19 16:02:58 +02:00
|
|
|
|
void get_peer_info(std::vector<peer_info>&) const;
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
|
|
|
|
``get_peer_info()`` takes a reference to a vector that will be cleared and filled
|
|
|
|
|
with one entry for each peer connected to this torrent, given the handle is valid. If the
|
2009-03-21 05:33:53 +01:00
|
|
|
|
torrent_handle_ is invalid, it will throw libtorrent_exception_ exception. Each entry in
|
2004-04-17 17:17:43 +02:00
|
|
|
|
the vector contains information about that particular peer. See peer_info_.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get_torrent_info()
|
|
|
|
|
------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2005-10-19 16:02:58 +02:00
|
|
|
|
torrent_info const& get_torrent_info() const;
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
|
|
|
|
Returns a const reference to the torrent_info_ object associated with this torrent.
|
|
|
|
|
This reference is valid as long as the torrent_handle_ is valid, no longer. If the
|
2009-03-21 05:33:53 +01:00
|
|
|
|
torrent_handle_ is invalid or if it doesn't have any metadata, libtorrent_exception_
|
2004-09-10 02:47:30 +02:00
|
|
|
|
exception will be thrown. The torrent may be in a state without metadata only if
|
|
|
|
|
it was started without a .torrent file, i.e. by using the libtorrent extension of
|
|
|
|
|
just supplying a tracker and info-hash.
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
is_valid()
|
|
|
|
|
----------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
bool is_valid() const;
|
|
|
|
|
|
|
|
|
|
Returns true if this handle refers to a valid torrent and false if it hasn't been initialized
|
|
|
|
|
or if the torrent it refers to has been aborted. Note that a handle may become invalid after
|
|
|
|
|
it has been added to the session. Usually this is because the storage for the torrent is
|
|
|
|
|
somehow invalid or if the filenames are not allowed (and hence cannot be opened/created) on
|
|
|
|
|
your filesystem. If such an error occurs, a file_error_alert_ is generated and all handles
|
|
|
|
|
that refers to that torrent will become invalid.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
torrent_status
|
|
|
|
|
==============
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
It contains the following fields::
|
|
|
|
|
|
|
|
|
|
struct torrent_status
|
|
|
|
|
{
|
|
|
|
|
enum state_t
|
|
|
|
|
{
|
|
|
|
|
queued_for_checking,
|
|
|
|
|
checking_files,
|
2007-11-24 05:19:21 +01:00
|
|
|
|
downloading_metadata,
|
2004-01-07 01:48:02 +01:00
|
|
|
|
downloading,
|
2005-07-06 20:40:01 +02:00
|
|
|
|
finished,
|
2005-10-17 15:45:53 +02:00
|
|
|
|
seeding,
|
2008-11-19 01:46:48 +01:00
|
|
|
|
allocating,
|
|
|
|
|
checking_resume_data
|
2004-01-07 01:48:02 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
state_t state;
|
2004-03-22 15:56:32 +01:00
|
|
|
|
bool paused;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
float progress;
|
2009-07-19 06:59:27 +02:00
|
|
|
|
int progress_ppm;
|
2008-05-20 09:57:44 +02:00
|
|
|
|
std::string error;
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
boost::posix_time::time_duration next_announce;
|
2004-01-17 21:04:19 +01:00
|
|
|
|
boost::posix_time::time_duration announce_interval;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2004-01-31 11:20:19 +01:00
|
|
|
|
std::string current_tracker;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2004-01-31 11:20:19 +01:00
|
|
|
|
size_type total_download;
|
|
|
|
|
size_type total_upload;
|
|
|
|
|
|
|
|
|
|
size_type total_payload_download;
|
|
|
|
|
size_type total_payload_upload;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2004-04-18 14:28:02 +02:00
|
|
|
|
size_type total_failed_bytes;
|
2006-04-25 23:04:48 +02:00
|
|
|
|
size_type total_redundant_bytes;
|
2004-04-18 14:28:02 +02:00
|
|
|
|
|
2009-07-19 06:59:27 +02:00
|
|
|
|
int download_rate;
|
|
|
|
|
int upload_rate;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2009-07-19 06:59:27 +02:00
|
|
|
|
int download_payload_rate;
|
|
|
|
|
int upload_payload_rate;
|
2004-04-18 14:28:02 +02:00
|
|
|
|
|
2004-01-15 02:01:09 +01:00
|
|
|
|
int num_peers;
|
|
|
|
|
|
2005-02-23 21:38:29 +01:00
|
|
|
|
int num_complete;
|
|
|
|
|
int num_incomplete;
|
|
|
|
|
|
2008-03-30 17:48:45 +02:00
|
|
|
|
int list_seeds;
|
|
|
|
|
int list_peers;
|
|
|
|
|
|
2008-03-29 19:47:24 +01:00
|
|
|
|
int connect_candidates;
|
|
|
|
|
|
2008-06-07 04:58:28 +02:00
|
|
|
|
bitfield pieces;
|
2006-04-25 23:04:48 +02:00
|
|
|
|
int num_pieces;
|
|
|
|
|
|
2004-01-31 11:20:19 +01:00
|
|
|
|
size_type total_done;
|
2005-05-30 19:43:03 +02:00
|
|
|
|
size_type total_wanted_done;
|
|
|
|
|
size_type total_wanted;
|
2004-08-05 15:56:26 +02:00
|
|
|
|
|
|
|
|
|
int num_seeds;
|
2009-07-19 06:59:27 +02:00
|
|
|
|
|
|
|
|
|
int distributed_full_copies;
|
|
|
|
|
int distributed_fraction;
|
|
|
|
|
|
2004-08-05 15:56:26 +02:00
|
|
|
|
float distributed_copies;
|
2004-08-11 19:22:58 +02:00
|
|
|
|
|
|
|
|
|
int block_size;
|
2007-08-23 19:34:59 +02:00
|
|
|
|
|
|
|
|
|
int num_uploads;
|
|
|
|
|
int num_connections;
|
|
|
|
|
int uploads_limit;
|
|
|
|
|
int connections_limit;
|
|
|
|
|
|
2008-04-16 08:31:05 +02:00
|
|
|
|
storage_mode_t storage_mode;
|
|
|
|
|
|
|
|
|
|
int up_bandwidth_queue;
|
|
|
|
|
int down_bandwidth_queue;
|
|
|
|
|
|
|
|
|
|
size_type all_time_upload;
|
|
|
|
|
size_type all_time_download;
|
|
|
|
|
|
|
|
|
|
int active_time;
|
2009-09-30 19:21:59 +02:00
|
|
|
|
int finished_time;
|
2008-04-16 08:31:05 +02:00
|
|
|
|
int seeding_time;
|
2008-04-24 05:28:48 +02:00
|
|
|
|
|
2008-05-06 20:03:41 +02:00
|
|
|
|
int seed_rank;
|
2008-05-19 06:06:25 +02:00
|
|
|
|
|
|
|
|
|
int last_scrape;
|
2008-06-05 20:19:03 +02:00
|
|
|
|
|
|
|
|
|
bool has_incoming;
|
2009-01-05 02:08:09 +01:00
|
|
|
|
|
|
|
|
|
int sparse_regions;
|
2009-02-03 08:46:24 +01:00
|
|
|
|
|
|
|
|
|
bool seed_mode;
|
2009-06-19 00:32:55 +02:00
|
|
|
|
|
|
|
|
|
bool upload_mode;
|
2009-09-13 04:24:25 +02:00
|
|
|
|
|
|
|
|
|
int priority;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
``progress`` is a value in the range [0, 1], that represents the progress of the
|
2009-07-19 06:59:27 +02:00
|
|
|
|
torrent's current task. It may be checking files or downloading.
|
|
|
|
|
|
|
|
|
|
``progress_ppm`` reflects the same value as ``progress``, but instead in a range
|
|
|
|
|
[0, 1000000] (ppm = parts per million). When floating point operations are disabled,
|
|
|
|
|
this is the only alternative to the floating point value in ``progress``.
|
|
|
|
|
|
|
|
|
|
The torrent's current task is in the ``state`` member, it will be one of the following:
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2008-11-19 01:46:48 +01:00
|
|
|
|
+--------------------------+----------------------------------------------------------+
|
|
|
|
|
|``checking_resume_data`` |The torrent is currently checking the fastresume data and |
|
|
|
|
|
| |comparing it to the files on disk. This is typically |
|
|
|
|
|
| |completed in a fraction of a second, but if you add a |
|
|
|
|
|
| |large number of torrents at once, they will queue up. |
|
2004-01-07 01:48:02 +01:00
|
|
|
|
+--------------------------+----------------------------------------------------------+
|
|
|
|
|
|``queued_for_checking`` |The torrent is in the queue for being checked. But there |
|
|
|
|
|
| |currently is another torrent that are being checked. |
|
|
|
|
|
| |This torrent will wait for its turn. |
|
|
|
|
|
+--------------------------+----------------------------------------------------------+
|
|
|
|
|
|``checking_files`` |The torrent has not started its download yet, and is |
|
|
|
|
|
| |currently checking existing files. |
|
|
|
|
|
+--------------------------+----------------------------------------------------------+
|
2007-11-24 05:19:21 +01:00
|
|
|
|
|``downloading_metadata`` |The torrent is trying to download metadata from peers. |
|
|
|
|
|
| |This assumes the metadata_transfer extension is in use. |
|
|
|
|
|
+--------------------------+----------------------------------------------------------+
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|``downloading`` |The torrent is being downloaded. This is the state |
|
|
|
|
|
| |most torrents will be in most of the time. The progress |
|
|
|
|
|
| |meter will tell how much of the files that has been |
|
|
|
|
|
| |downloaded. |
|
2005-05-30 19:43:03 +02:00
|
|
|
|
+--------------------------+----------------------------------------------------------+
|
|
|
|
|
|``finished`` |In this state the torrent has finished downloading but |
|
|
|
|
|
| |still doesn't have the entire torrent. i.e. some pieces |
|
|
|
|
|
| |are filtered and won't get downloaded. |
|
2004-01-07 01:48:02 +01:00
|
|
|
|
+--------------------------+----------------------------------------------------------+
|
|
|
|
|
|``seeding`` |In this state the torrent has finished downloading and |
|
|
|
|
|
| |is a pure seeder. |
|
|
|
|
|
+--------------------------+----------------------------------------------------------+
|
2005-10-17 15:45:53 +02:00
|
|
|
|
|``allocating`` |If the torrent was started in full allocation mode, this |
|
|
|
|
|
| |indicates that the (disk) storage for the torrent is |
|
|
|
|
|
| |allocated. |
|
|
|
|
|
+--------------------------+----------------------------------------------------------+
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2005-05-30 19:43:03 +02:00
|
|
|
|
When downloading, the progress is ``total_wanted_done`` / ``total_wanted``.
|
|
|
|
|
|
2004-03-22 15:56:32 +01:00
|
|
|
|
``paused`` is set to true if the torrent is paused and false otherwise.
|
|
|
|
|
|
2008-05-20 09:57:44 +02:00
|
|
|
|
``error`` may be set to an error message describing why the torrent was paused, in
|
|
|
|
|
case it was paused by an error. If the torrent is not paused or if it's paused but
|
|
|
|
|
not because of an error, this string is empty.
|
|
|
|
|
|
2004-01-17 21:04:19 +01:00
|
|
|
|
``next_announce`` is the time until the torrent will announce itself to the tracker. And
|
|
|
|
|
``announce_interval`` is the time the tracker want us to wait until we announce ourself
|
|
|
|
|
again the next time.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2004-01-31 11:20:19 +01:00
|
|
|
|
``current_tracker`` is the URL of the last working tracker. If no tracker request has
|
|
|
|
|
been successful yet, it's set to an empty string.
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
``total_download`` and ``total_upload`` is the number of bytes downloaded and
|
2009-01-11 03:07:45 +01:00
|
|
|
|
uploaded to all peers, accumulated, *this session* only. The session is considered
|
|
|
|
|
to restart when a torrent is paused and restarted again. When a torrent is paused,
|
|
|
|
|
these counters are reset to 0. If you want complete, persistent, stats, see
|
|
|
|
|
``all_time_upload`` and ``all_time_download``.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
|
|
|
|
``total_payload_download`` and ``total_payload_upload`` counts the amount of bytes
|
2006-05-15 00:46:19 +02:00
|
|
|
|
send and received this session, but only the actual payload data (i.e the interesting
|
2004-01-07 01:48:02 +01:00
|
|
|
|
data), these counters ignore any protocol overhead.
|
|
|
|
|
|
2004-04-18 14:28:02 +02:00
|
|
|
|
``total_failed_bytes`` is the number of bytes that has been downloaded and that
|
|
|
|
|
has failed the piece hash test. In other words, this is just how much crap that
|
|
|
|
|
has been downloaded.
|
|
|
|
|
|
2006-04-25 23:04:48 +02:00
|
|
|
|
``total_redundant_bytes`` is the number of bytes that has been downloaded even
|
|
|
|
|
though that data already was downloaded. The reason for this is that in some
|
|
|
|
|
situations the same data can be downloaded by mistake. When libtorrent sends
|
|
|
|
|
requests to a peer, and the peer doesn't send a response within a certain
|
|
|
|
|
timeout, libtorrent will re-request that block. Another situation when
|
2006-05-21 12:41:37 +02:00
|
|
|
|
libtorrent may re-request blocks is when the requests it sends out are not
|
|
|
|
|
replied in FIFO-order (it will re-request blocks that are skipped by an out of
|
2006-04-25 23:04:48 +02:00
|
|
|
|
order block). This is supposed to be as low as possible.
|
|
|
|
|
|
2004-01-15 17:45:34 +01:00
|
|
|
|
``pieces`` is the bitmask that represents which pieces we have (set to true) and
|
|
|
|
|
the pieces we don't have. It's a pointer and may be set to 0 if the torrent isn't
|
|
|
|
|
downloading or seeding.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2006-04-25 23:04:48 +02:00
|
|
|
|
``num_pieces`` is the number of pieces that has been downloaded. It is equivalent
|
|
|
|
|
to: ``std::accumulate(pieces->begin(), pieces->end())``. So you don't have to
|
|
|
|
|
count yourself. This can be used to see if anything has updated since last time
|
|
|
|
|
if you want to keep a graph of the pieces up to date.
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
``download_rate`` and ``upload_rate`` are the total rates for all peers for this
|
|
|
|
|
torrent. These will usually have better precision than summing the rates from
|
2004-04-18 14:28:02 +02:00
|
|
|
|
all peers. The rates are given as the number of bytes per second. The
|
|
|
|
|
``download_payload_rate`` and ``upload_payload_rate`` respectively is the
|
|
|
|
|
total transfer rate of payload only, not counting protocol chatter. This might
|
|
|
|
|
be slightly smaller than the other rates, but if projected over a long time
|
2006-05-21 12:41:37 +02:00
|
|
|
|
(e.g. when calculating ETA:s) the difference may be noticeable.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2004-01-15 02:01:09 +01:00
|
|
|
|
``num_peers`` is the number of peers this torrent currently is connected to.
|
2005-11-05 11:56:47 +01:00
|
|
|
|
Peer connections that are in the half-open state (is attempting to connect)
|
|
|
|
|
or are queued for later connection attempt do not count. Although they are
|
|
|
|
|
visible in the peer list when you call `get_peer_info()`_.
|
2004-01-15 02:01:09 +01:00
|
|
|
|
|
2005-02-23 21:38:29 +01:00
|
|
|
|
``num_complete`` and ``num_incomplete`` are set to -1 if the tracker did not
|
|
|
|
|
send any scrape data in its announce reply. This data is optional and may
|
|
|
|
|
not be available from all trackers. If these are not -1, they are the total
|
|
|
|
|
number of peers that are seeding (complete) and the total number of peers
|
|
|
|
|
that are still downloading (incomplete) this torrent.
|
|
|
|
|
|
2008-03-30 17:48:45 +02:00
|
|
|
|
``list_seeds`` and ``list_peers`` are the number of seeds in our peer list
|
|
|
|
|
and the total number of peers (including seeds) respectively. We are not
|
|
|
|
|
necessarily connected to all the peers in our peer list. This is the number
|
|
|
|
|
of peers we know of in total, including banned peers and peers that we have
|
|
|
|
|
failed to connect to.
|
|
|
|
|
|
2008-03-29 19:47:24 +01:00
|
|
|
|
``connect_candidates`` is the number of peers in this torrent's peer list
|
|
|
|
|
that is a candidate to be connected to. i.e. It has fewer connect attempts
|
|
|
|
|
than the max fail count, it is not a seed if we are a seed, it is not banned
|
|
|
|
|
etc. If this is 0, it means we don't know of any more peers that we can try.
|
|
|
|
|
|
2004-04-18 14:28:02 +02:00
|
|
|
|
``total_done`` is the total number of bytes of the file(s) that we have. All
|
|
|
|
|
this does not necessarily has to be downloaded during this session (that's
|
2007-11-25 09:38:25 +01:00
|
|
|
|
``total_payload_download``).
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2006-05-21 12:41:37 +02:00
|
|
|
|
``total_wanted_done`` is the number of bytes we have downloaded, only counting the
|
2005-05-30 19:43:03 +02:00
|
|
|
|
pieces that we actually want to download. i.e. excluding any pieces that we have but
|
|
|
|
|
are filtered as not wanted.
|
|
|
|
|
|
|
|
|
|
``total_wanted`` is the total number of bytes we want to download. This is also
|
|
|
|
|
excluding pieces that have been filtered.
|
|
|
|
|
|
2004-08-08 23:26:40 +02:00
|
|
|
|
``num_seeds`` is the number of peers that are seeding that this client is
|
|
|
|
|
currently connected to.
|
2004-08-05 15:56:26 +02:00
|
|
|
|
|
2009-07-19 06:59:27 +02:00
|
|
|
|
``distributed_full_copies`` is the number of distributed copies of the torrent.
|
|
|
|
|
Note that one copy may be spread out among many peers. It tells how many copies
|
|
|
|
|
there are currently of the rarest piece(s) among the peers this client is
|
|
|
|
|
connected to.
|
|
|
|
|
|
|
|
|
|
``distributed_fraction`` tells the share of pieces that have more copies than
|
|
|
|
|
the rarest piece(s). Divide this number by 1000 to get the fraction.
|
|
|
|
|
|
|
|
|
|
For example, if ``distributed_full_copies`` is 2 and ``distrbuted_fraction``
|
|
|
|
|
is 500, it means that the rarest pieces have only 2 copies among the peers
|
|
|
|
|
this torrent is connected to, and that 50% of all the pieces have more than
|
|
|
|
|
two copies.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2007-04-12 12:25:10 +02:00
|
|
|
|
If we are a seed, the piece picker is deallocated as an optimization, and
|
|
|
|
|
piece availability is no longer tracked. In this case the distributed
|
2009-07-19 06:59:27 +02:00
|
|
|
|
copies members are set to -1.
|
|
|
|
|
|
|
|
|
|
``distributed_copies`` is a floating point representation of the
|
|
|
|
|
``distributed_full_copies`` as the integer part and ``distributed_fraction``
|
|
|
|
|
/ 1000 as the fraction part. If floating point operations are disabled
|
|
|
|
|
this value is always -1.
|
2006-07-16 02:08:50 +02:00
|
|
|
|
|
2004-08-11 19:22:58 +02:00
|
|
|
|
``block_size`` is the size of a block, in bytes. A block is a sub piece, it
|
|
|
|
|
is the number of bytes that each piece request asks for and the number of
|
|
|
|
|
bytes that each bit in the ``partial_piece_info``'s bitset represents
|
|
|
|
|
(see `get_download_queue()`_). This is typically 16 kB, but it may be
|
|
|
|
|
larger if the pieces are larger.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2007-08-23 19:34:59 +02:00
|
|
|
|
``num_uploads`` is the number of unchoked peers in this torrent.
|
|
|
|
|
|
|
|
|
|
``num_connections`` is the number of peer connections this torrent has, including
|
|
|
|
|
half-open connections that hasn't completed the bittorrent handshake yet. This is
|
2009-11-26 16:36:32 +01:00
|
|
|
|
always >= ``num_peers``.
|
2007-08-23 19:34:59 +02:00
|
|
|
|
|
|
|
|
|
``uploads_limit`` is the set limit of upload slots (unchoked peers) for this torrent.
|
|
|
|
|
|
|
|
|
|
``connections_limit`` is the set limit of number of connections for this torrent.
|
|
|
|
|
|
2008-04-16 08:31:05 +02:00
|
|
|
|
``storage_mode`` is one of ``storage_mode_allocate``, ``storage_mode_sparse`` or
|
|
|
|
|
``storage_mode_compact``. Identifies which storage mode this torrent is being saved
|
|
|
|
|
with. See `Storage allocation`_.
|
|
|
|
|
|
|
|
|
|
``up_bandwidth_queue`` and ``down_bandwidth_queue`` are the number of peers in this
|
|
|
|
|
torrent that are waiting for more bandwidth quota from the torrent rate limiter.
|
|
|
|
|
This can determine if the rate you get from this torrent is bound by the torrents
|
|
|
|
|
limit or not. If there is no limit set on this torrent, the peers might still be
|
|
|
|
|
waiting for bandwidth quota from the global limiter, but then they are counted in
|
|
|
|
|
the ``session_status`` object.
|
|
|
|
|
|
|
|
|
|
``all_time_upload`` and ``all_time_download`` are accumulated upload and download
|
2008-10-15 19:55:44 +02:00
|
|
|
|
payload byte counters. They are saved in and restored from resume data to keep totals
|
2008-04-16 08:31:05 +02:00
|
|
|
|
across sessions.
|
|
|
|
|
|
2009-09-30 19:21:59 +02:00
|
|
|
|
``active_time``, ``finished_time`` and ``seeding_time`` are second counters.
|
|
|
|
|
They keep track of the number of seconds this torrent has been active (not
|
|
|
|
|
paused) and the number of seconds it has been active while being finished and
|
|
|
|
|
active while being a seed. ``seeding_time`` should be >= ``finished_time`` which
|
|
|
|
|
should be >= ``active_time``. They are all saved in and restored from resume data,
|
|
|
|
|
to keep totals across sessions.
|
2007-08-23 19:34:59 +02:00
|
|
|
|
|
2008-05-06 20:03:41 +02:00
|
|
|
|
``seed_rank`` is a rank of how important it is to seed the torrent, it is used
|
|
|
|
|
to determine which torrents to seed and which to queue. It is based on the peer
|
|
|
|
|
to seed ratio from the tracker scrape. For more information, see queuing_.
|
2008-04-24 05:28:48 +02:00
|
|
|
|
|
2008-05-19 06:06:25 +02:00
|
|
|
|
``last_scrape`` is the number of seconds since this torrent acquired scrape data.
|
|
|
|
|
If it has never done that, this value is -1.
|
|
|
|
|
|
2008-06-05 20:19:03 +02:00
|
|
|
|
``has_incoming`` is true if there has ever been an incoming connection attempt
|
|
|
|
|
to this torrent.'
|
|
|
|
|
|
2009-01-05 02:08:09 +01:00
|
|
|
|
``sparse_regions`` the number of regions of non-downloaded pieces in the
|
|
|
|
|
torrent. This is an interesting metric on windows vista, since there is
|
|
|
|
|
a limit on the number of sparse regions in a single file there.
|
2008-04-24 05:28:48 +02:00
|
|
|
|
|
2009-02-03 08:46:24 +01:00
|
|
|
|
``seed_mode`` is true if the torrent is in seed_mode. If the torrent was
|
|
|
|
|
started in seed mode, it will leave seed mode once all pieces have been
|
|
|
|
|
checked or as soon as one piece fails the hash check.
|
|
|
|
|
|
2009-06-19 00:32:55 +02:00
|
|
|
|
``upload_mode`` is true if the torrent is blocked from downloading. This
|
|
|
|
|
typically happens when a disk write operation fails. If the torrent is
|
|
|
|
|
auto-managed, it will periodically be taken out of this state, in the
|
|
|
|
|
hope that the disk condition (be it disk full or permission errors) has
|
|
|
|
|
been resolved. If the torrent is not auto-managed, you have to explicitly
|
|
|
|
|
take it out of the upload mode by calling `set_upload_mode()`_ on the
|
|
|
|
|
torrent_handle_.
|
2009-02-03 08:46:24 +01:00
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
peer_info
|
|
|
|
|
=========
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
It contains the following fields::
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
|
|
|
|
struct peer_info
|
|
|
|
|
{
|
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
interesting = 0x1,
|
|
|
|
|
choked = 0x2,
|
|
|
|
|
remote_interested = 0x4,
|
|
|
|
|
remote_choked = 0x8,
|
2004-01-09 11:50:22 +01:00
|
|
|
|
supports_extensions = 0x10,
|
2005-11-02 17:28:39 +01:00
|
|
|
|
local_connection = 0x20,
|
2006-04-25 23:04:48 +02:00
|
|
|
|
handshake = 0x40,
|
|
|
|
|
connecting = 0x80,
|
2007-06-09 03:06:10 +02:00
|
|
|
|
queued = 0x100,
|
|
|
|
|
on_parole = 0x200,
|
|
|
|
|
seed = 0x400,
|
2007-08-22 07:31:42 +02:00
|
|
|
|
optimistic_unchoke = 0x800,
|
2008-06-29 11:50:42 +02:00
|
|
|
|
snubbed = 0x1000,
|
2008-07-19 09:57:43 +02:00
|
|
|
|
upload_only = 0x2000,
|
2007-08-22 07:31:42 +02:00
|
|
|
|
rc4_encrypted = 0x100000,
|
|
|
|
|
plaintext_encrypted = 0x200000
|
2004-01-07 01:48:02 +01:00
|
|
|
|
};
|
2007-04-10 23:23:13 +02:00
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
unsigned int flags;
|
2007-04-10 23:23:13 +02:00
|
|
|
|
|
|
|
|
|
enum peer_source_flags
|
|
|
|
|
{
|
|
|
|
|
tracker = 0x1,
|
|
|
|
|
dht = 0x2,
|
|
|
|
|
pex = 0x4,
|
|
|
|
|
lsd = 0x8
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
int source;
|
|
|
|
|
|
2009-06-10 10:30:55 +02:00
|
|
|
|
enum bw_state { bw_idle, bw_limit, bw_network, bw_disk };
|
2008-01-14 00:46:43 +01:00
|
|
|
|
|
|
|
|
|
char read_state;
|
|
|
|
|
char write_state;
|
|
|
|
|
|
2006-05-20 19:59:17 +02:00
|
|
|
|
asio::ip::tcp::endpoint ip;
|
2009-07-19 06:59:27 +02:00
|
|
|
|
int up_speed;
|
|
|
|
|
int down_speed;
|
|
|
|
|
int payload_up_speed;
|
|
|
|
|
int payload_down_speed;
|
2004-01-25 19:18:36 +01:00
|
|
|
|
size_type total_download;
|
|
|
|
|
size_type total_upload;
|
2006-04-25 23:04:48 +02:00
|
|
|
|
peer_id pid;
|
2008-06-07 04:58:28 +02:00
|
|
|
|
bitfield pieces;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
int upload_limit;
|
2006-04-25 23:04:48 +02:00
|
|
|
|
int download_limit;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2008-01-10 23:13:23 +01:00
|
|
|
|
time_duration last_request;
|
|
|
|
|
time_duration last_active;
|
2008-06-29 11:50:42 +02:00
|
|
|
|
int request_timeout;
|
2008-01-10 23:13:23 +01:00
|
|
|
|
|
|
|
|
|
int send_buffer_size;
|
|
|
|
|
int used_send_buffer;
|
|
|
|
|
|
2008-04-10 12:03:23 +02:00
|
|
|
|
int receive_buffer_size;
|
|
|
|
|
int used_receive_buffer;
|
|
|
|
|
|
2008-01-10 23:13:23 +01:00
|
|
|
|
int num_hashfails;
|
|
|
|
|
|
2007-01-29 08:39:33 +01:00
|
|
|
|
char country[2];
|
|
|
|
|
|
2008-04-05 06:53:22 +02:00
|
|
|
|
std::string inet_as_name;
|
|
|
|
|
int inet_as;
|
|
|
|
|
|
2004-01-25 19:18:36 +01:00
|
|
|
|
size_type load_balancing;
|
|
|
|
|
|
2008-07-08 02:03:08 +02:00
|
|
|
|
int requests_in_buffer;
|
2004-01-12 21:31:27 +01:00
|
|
|
|
int download_queue_length;
|
2004-01-14 17:22:49 +01:00
|
|
|
|
int upload_queue_length;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2008-01-10 23:13:23 +01:00
|
|
|
|
int failcount;
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
int downloading_piece_index;
|
|
|
|
|
int downloading_block_index;
|
|
|
|
|
int downloading_progress;
|
|
|
|
|
int downloading_total;
|
2006-04-25 23:04:48 +02:00
|
|
|
|
|
|
|
|
|
std::string client;
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
standard_bittorrent = 0,
|
|
|
|
|
web_seed = 1
|
|
|
|
|
};
|
|
|
|
|
int connection_type;
|
2008-01-07 05:47:20 +01:00
|
|
|
|
|
|
|
|
|
int remote_dl_rate;
|
|
|
|
|
|
|
|
|
|
int pending_disk_bytes;
|
|
|
|
|
|
|
|
|
|
int send_quota;
|
|
|
|
|
int receive_quota;
|
2008-02-09 23:42:56 +01:00
|
|
|
|
|
|
|
|
|
int rtt;
|
2008-04-03 08:11:21 +02:00
|
|
|
|
|
2008-10-24 02:15:39 +02:00
|
|
|
|
int num_pieces;
|
|
|
|
|
|
2008-04-03 08:11:21 +02:00
|
|
|
|
int download_rate_peak;
|
|
|
|
|
int upload_rate_peak;
|
|
|
|
|
|
2008-09-25 22:39:06 +02:00
|
|
|
|
float progress;
|
2009-07-19 06:59:27 +02:00
|
|
|
|
int progress_ppm;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
The ``flags`` attribute tells you in which state the peer is. It is set to
|
2004-01-09 11:50:22 +01:00
|
|
|
|
any combination of the enums above. The following table describes each flag:
|
|
|
|
|
|
|
|
|
|
+-------------------------+-------------------------------------------------------+
|
2005-05-30 19:43:03 +02:00
|
|
|
|
| ``interesting`` | **we** are interested in pieces from this peer. |
|
2004-01-09 11:50:22 +01:00
|
|
|
|
+-------------------------+-------------------------------------------------------+
|
|
|
|
|
| ``choked`` | **we** have choked this peer. |
|
|
|
|
|
+-------------------------+-------------------------------------------------------+
|
2005-05-30 19:43:03 +02:00
|
|
|
|
| ``remote_interested`` | the peer is interested in **us** |
|
|
|
|
|
+-------------------------+-------------------------------------------------------+
|
|
|
|
|
| ``remote_choked`` | the peer has choked **us**. |
|
2004-01-09 11:50:22 +01:00
|
|
|
|
+-------------------------+-------------------------------------------------------+
|
2004-06-17 22:56:49 +02:00
|
|
|
|
| ``support_extensions`` | means that this peer supports the |
|
|
|
|
|
| | `extension protocol`__. |
|
2004-01-09 11:50:22 +01:00
|
|
|
|
+-------------------------+-------------------------------------------------------+
|
|
|
|
|
| ``local_connection`` | The connection was initiated by us, the peer has a |
|
2005-05-30 19:43:03 +02:00
|
|
|
|
| | listen port open, and that port is the same as in the |
|
2006-04-25 23:04:48 +02:00
|
|
|
|
| | address of this peer. If this flag is not set, this |
|
2004-01-09 11:50:22 +01:00
|
|
|
|
| | peer connection was opened by this peer connecting to |
|
|
|
|
|
| | us. |
|
|
|
|
|
+-------------------------+-------------------------------------------------------+
|
2006-04-25 23:04:48 +02:00
|
|
|
|
| ``handshake`` | The connection is opened, and waiting for the |
|
|
|
|
|
| | handshake. Until the handshake is done, the peer |
|
|
|
|
|
| | cannot be identified. |
|
|
|
|
|
+-------------------------+-------------------------------------------------------+
|
2005-11-02 17:28:39 +01:00
|
|
|
|
| ``connecting`` | The connection is in a half-open state (i.e. it is |
|
|
|
|
|
| | being connected). |
|
|
|
|
|
+-------------------------+-------------------------------------------------------+
|
|
|
|
|
| ``queued`` | The connection is currently queued for a connection |
|
|
|
|
|
| | attempt. This may happen if there is a limit set on |
|
|
|
|
|
| | the number of half-open TCP connections. |
|
|
|
|
|
+-------------------------+-------------------------------------------------------+
|
2007-08-22 07:31:42 +02:00
|
|
|
|
| ``on_parole`` | The peer has participated in a piece that failed the |
|
|
|
|
|
| | hash check, and is now "on parole", which means we're |
|
|
|
|
|
| | only requesting whole pieces from this peer until |
|
|
|
|
|
| | it either fails that piece or proves that it doesn't |
|
|
|
|
|
| | send bad data. |
|
|
|
|
|
+-------------------------+-------------------------------------------------------+
|
|
|
|
|
| ``seed`` | This peer is a seed (it has all the pieces). |
|
|
|
|
|
+-------------------------+-------------------------------------------------------+
|
|
|
|
|
| ``optimistic_unchoke`` | This peer is subject to an optimistic unchoke. It has |
|
|
|
|
|
| | been unchoked for a while to see if it might unchoke |
|
|
|
|
|
| | us in return an earn an upload/unchoke slot. If it |
|
|
|
|
|
| | doesn't within some period of time, it will be choked |
|
|
|
|
|
| | and another peer will be optimistically unchoked. |
|
|
|
|
|
+-------------------------+-------------------------------------------------------+
|
2008-06-29 11:50:42 +02:00
|
|
|
|
| ``snubbed`` | This peer has recently failed to send a block within |
|
|
|
|
|
| | the request timeout from when the request was sent. |
|
|
|
|
|
| | We're currently picking one block at a time from this |
|
|
|
|
|
| | peer. |
|
2008-01-10 23:44:53 +01:00
|
|
|
|
+-------------------------+-------------------------------------------------------+
|
2008-07-19 09:57:43 +02:00
|
|
|
|
| ``upload_only`` | This peer has either explicitly (with an extension) |
|
|
|
|
|
| | or implicitly (by becoming a seed) told us that it |
|
|
|
|
|
| | will not downloading anything more, regardless of |
|
|
|
|
|
| | which pieces we have. |
|
|
|
|
|
+-------------------------+-------------------------------------------------------+
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2005-11-01 19:30:39 +01:00
|
|
|
|
__ extension_protocol.html
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2007-04-10 23:23:13 +02:00
|
|
|
|
``source`` is a combination of flags describing from which sources this peer
|
|
|
|
|
was received. The flags are:
|
|
|
|
|
|
|
|
|
|
+------------------------+--------------------------------------------------------+
|
|
|
|
|
| ``tracker`` | The peer was received from the tracker. |
|
|
|
|
|
+------------------------+--------------------------------------------------------+
|
|
|
|
|
| ``dht`` | The peer was received from the kademlia DHT. |
|
|
|
|
|
+------------------------+--------------------------------------------------------+
|
|
|
|
|
| ``pex`` | The peer was received from the peer exchange |
|
|
|
|
|
| | extension. |
|
|
|
|
|
+------------------------+--------------------------------------------------------+
|
|
|
|
|
| ``lsd`` | The peer was received from the local service |
|
|
|
|
|
| | discovery (The peer is on the local network). |
|
|
|
|
|
+------------------------+--------------------------------------------------------+
|
|
|
|
|
| ``resume_data`` | The peer was added from the fast resume data. |
|
|
|
|
|
+------------------------+--------------------------------------------------------+
|
|
|
|
|
|
2008-01-14 00:46:43 +01:00
|
|
|
|
``read_state`` and ``write_state`` indicates what state this peer is in with regards
|
|
|
|
|
to sending and receiving data. The states are declared in the ``bw_state`` enum and
|
|
|
|
|
defines as follows:
|
|
|
|
|
|
|
|
|
|
+------------------------+--------------------------------------------------------+
|
|
|
|
|
| ``bw_idle`` | The peer is not waiting for any external events to |
|
|
|
|
|
| | send or receive data. |
|
|
|
|
|
| | |
|
|
|
|
|
+------------------------+--------------------------------------------------------+
|
2009-06-10 10:30:55 +02:00
|
|
|
|
| ``bw_limit`` | The peer is waiting for the rate limiter. |
|
2008-01-14 00:46:43 +01:00
|
|
|
|
| | |
|
|
|
|
|
+------------------------+--------------------------------------------------------+
|
|
|
|
|
| ``bw_network`` | The peer has quota and is currently waiting for a |
|
|
|
|
|
| | network read or write operation to complete. This is |
|
|
|
|
|
| | the state all peers are in if there are no bandwidth |
|
|
|
|
|
| | limits. |
|
|
|
|
|
| | |
|
|
|
|
|
+------------------------+--------------------------------------------------------+
|
2009-06-10 10:30:55 +02:00
|
|
|
|
| ``bw_disk`` | The peer is waiting for the disk I/O thread to catch |
|
|
|
|
|
| | up writing buffers to disk before downloading more. |
|
|
|
|
|
| | |
|
|
|
|
|
+------------------------+--------------------------------------------------------+
|
2008-01-14 00:46:43 +01:00
|
|
|
|
|
2006-04-25 23:04:48 +02:00
|
|
|
|
The ``ip`` field is the IP-address to this peer. The type is an asio endpoint. For
|
|
|
|
|
more info, see the asio_ documentation.
|
|
|
|
|
|
|
|
|
|
.. _asio: http://asio.sf.net
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2005-05-25 12:01:01 +02:00
|
|
|
|
``up_speed`` and ``down_speed`` contains the current upload and download speed
|
|
|
|
|
we have to and from this peer (including any protocol messages). The transfer rates
|
|
|
|
|
of payload data only are found in ``payload_up_speed`` and ``payload_down_speed``.
|
2006-05-21 12:41:37 +02:00
|
|
|
|
These figures are updated approximately once every second.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
|
|
|
|
``total_download`` and ``total_upload`` are the total number of bytes downloaded
|
|
|
|
|
from and uploaded to this peer. These numbers do not include the protocol chatter, but only
|
|
|
|
|
the payload data.
|
|
|
|
|
|
2006-04-25 23:04:48 +02:00
|
|
|
|
``pid`` is the peer's id as used in the bit torrent protocol. This id can be used to
|
2004-01-07 01:48:02 +01:00
|
|
|
|
extract 'fingerprints' from the peer. Sometimes it can tell you which client the peer
|
2004-04-17 17:17:43 +02:00
|
|
|
|
is using. See identify_client()_
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2008-06-07 04:58:28 +02:00
|
|
|
|
``pieces`` is a bitfield, with one bit per piece in the torrent.
|
|
|
|
|
Each bit tells you if the peer has that piece (if it's set to 1)
|
|
|
|
|
or if the peer miss that piece (set to 0).
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2004-10-18 00:23:08 +02:00
|
|
|
|
``seed`` is true if this peer is a seed.
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
``upload_limit`` is the number of bytes per second we are allowed to send to this
|
2007-01-16 06:05:52 +01:00
|
|
|
|
peer every second. It may be -1 if there's no local limit on the peer. The global
|
|
|
|
|
limit and the torrent limit is always enforced anyway.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2006-04-25 23:04:48 +02:00
|
|
|
|
``download_limit`` is the number of bytes per second this peer is allowed to
|
|
|
|
|
receive. -1 means it's unlimited.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2008-01-10 23:13:23 +01:00
|
|
|
|
``last_request`` and ``last_active`` is the time since we last sent a request
|
|
|
|
|
to this peer and since any transfer occurred with this peer, respectively.
|
|
|
|
|
|
2008-06-29 11:50:42 +02:00
|
|
|
|
``request_timeout`` is the number of seconds until the current front piece request
|
|
|
|
|
will time out. This timeout can be adjusted through ``session_settings::request_timeout``.
|
|
|
|
|
-1 means that there is not outstanding request.
|
|
|
|
|
|
2008-01-10 23:13:23 +01:00
|
|
|
|
``send_buffer_size`` and ``used_send_buffer`` is the number of bytes allocated
|
|
|
|
|
and used for the peer's send buffer, respectively.
|
|
|
|
|
|
2008-04-10 12:03:23 +02:00
|
|
|
|
``receive_buffer_size`` and ``used_receive_buffer`` are the number of bytes
|
|
|
|
|
allocated and used as receive buffer, respectively.
|
|
|
|
|
|
2008-01-10 23:13:23 +01:00
|
|
|
|
``num_hashfails`` is the number of pieces this peer has participated in
|
|
|
|
|
sending us that turned out to fail the hash check.
|
|
|
|
|
|
2007-01-29 08:39:33 +01:00
|
|
|
|
``country`` is the two letter `ISO 3166 country code`__ for the country the peer
|
|
|
|
|
is connected from. If the country hasn't been resolved yet, both chars are set
|
|
|
|
|
to 0. If the resolution failed for some reason, the field is set to "--". If the
|
|
|
|
|
resolution service returns an invalid country code, it is set to "!!".
|
|
|
|
|
The ``countries.nerd.dk`` service is used to look up countries. This field will
|
|
|
|
|
remain set to 0 unless the torrent is set to resolve countries, see `resolve_countries()`_.
|
|
|
|
|
|
|
|
|
|
__ http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html
|
|
|
|
|
|
2008-04-05 06:53:22 +02:00
|
|
|
|
``inet_as_name`` is the name of the AS this peer is located in. This might be
|
|
|
|
|
an empty string if there is no name in the geo ip database.
|
|
|
|
|
|
|
|
|
|
``inet_as`` is the AS number the peer is located in.
|
|
|
|
|
|
2006-05-21 12:41:37 +02:00
|
|
|
|
``load_balancing`` is a measurement of the balancing of free download (that we get)
|
2004-01-07 01:48:02 +01:00
|
|
|
|
and free upload that we give. Every peer gets a certain amount of free upload, but
|
|
|
|
|
this member says how much *extra* free upload this peer has got. If it is a negative
|
|
|
|
|
number it means that this was a peer from which we have got this amount of free
|
|
|
|
|
download.
|
|
|
|
|
|
2008-07-08 02:03:08 +02:00
|
|
|
|
``requests_in_buffer`` is the number of requests messages that are currently in the
|
|
|
|
|
send buffer waiting to be sent.
|
|
|
|
|
|
2004-01-14 17:22:49 +01:00
|
|
|
|
``download_queue_length`` is the number of piece-requests we have sent to this peer
|
2004-01-12 21:31:27 +01:00
|
|
|
|
that hasn't been answered with a piece yet.
|
|
|
|
|
|
2004-01-14 17:22:49 +01:00
|
|
|
|
``upload_queue_length`` is the number of piece-requests we have received from this peer
|
|
|
|
|
that we haven't answered with a piece yet.
|
|
|
|
|
|
2008-01-10 23:13:23 +01:00
|
|
|
|
``failcount`` is the number of times this peer has "failed". i.e. failed to connect
|
|
|
|
|
or disconnected us. The failcount is decremented when we see this peer in a tracker
|
|
|
|
|
response or peer exchange message.
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
You can know which piece, and which part of that piece, that is currently being
|
|
|
|
|
downloaded from a specific peer by looking at the next four members.
|
|
|
|
|
``downloading_piece_index`` is the index of the piece that is currently being downloaded.
|
|
|
|
|
This may be set to -1 if there's currently no piece downloading from this peer. If it is
|
|
|
|
|
>= 0, the other three members are valid. ``downloading_block_index`` is the index of the
|
|
|
|
|
block (or sub-piece) that is being downloaded. ``downloading_progress`` is the number
|
|
|
|
|
of bytes of this block we have received from the peer, and ``downloading_total`` is
|
|
|
|
|
the total number of bytes in this block.
|
|
|
|
|
|
2006-04-25 23:04:48 +02:00
|
|
|
|
``client`` is a string describing the software at the other end of the connection.
|
|
|
|
|
In some cases this information is not available, then it will contain a string
|
|
|
|
|
that may give away something about which software is running in the other end.
|
|
|
|
|
In the case of a web seed, the server type and version will be a part of this
|
|
|
|
|
string.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2006-04-25 23:04:48 +02:00
|
|
|
|
``connection_type`` can currently be one of ``standard_bittorrent`` or
|
|
|
|
|
``web_seed``. These are currently the only implemented protocols.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2008-01-07 05:47:20 +01:00
|
|
|
|
``remote_dl_rate`` is an estimate of the rate this peer is downloading at, in
|
|
|
|
|
bytes per second.
|
|
|
|
|
|
|
|
|
|
``pending_disk_bytes`` is the number of bytes this peer has pending in the
|
|
|
|
|
disk-io thread. Downloaded and waiting to be written to disk. This is what
|
2009-07-20 02:23:16 +02:00
|
|
|
|
is capped by ``session_settings::max_queued_disk_bytes``.
|
2008-01-07 05:47:20 +01:00
|
|
|
|
|
|
|
|
|
``send_quota`` and ``receive_quota`` are the number of bytes this peer has been
|
|
|
|
|
assigned to be allowed to send and receive until it has to request more quota
|
|
|
|
|
from the bandwidth manager.
|
|
|
|
|
|
2008-02-09 23:42:56 +01:00
|
|
|
|
``rtt`` is an estimated round trip time to this peer, in milliseconds. It is
|
|
|
|
|
estimated by timing the the tcp ``connect()``. It may be 0 for incoming connections.
|
|
|
|
|
|
2008-10-24 02:15:39 +02:00
|
|
|
|
``num_pieces`` is the number of pieces this peer has.
|
|
|
|
|
|
2008-04-03 08:11:21 +02:00
|
|
|
|
``download_rate_peak`` and ``upload_rate_peak`` are the highest download and upload
|
|
|
|
|
rates seen on this connection. They are given in bytes per second. This number is
|
|
|
|
|
reset to 0 on reconnect.
|
2008-02-09 23:42:56 +01:00
|
|
|
|
|
2009-07-19 06:59:27 +02:00
|
|
|
|
``progress`` is the progress of the peer in the range [0, 1]. This is always 0 when
|
|
|
|
|
floating point operations are diabled, instead use ``progress_ppm``.
|
|
|
|
|
|
|
|
|
|
``progress_ppm`` indicates the download progress of the peer in the range [0, 1000000]
|
|
|
|
|
(parts per million).
|
2008-09-25 22:39:06 +02:00
|
|
|
|
|
2009-05-12 20:05:04 +02:00
|
|
|
|
session customization
|
|
|
|
|
=====================
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2009-05-12 20:05:04 +02:00
|
|
|
|
You have some control over session configuration through the ``session_settings`` object. You
|
2006-05-21 01:58:09 +02:00
|
|
|
|
create it and fill it with your settings and then use ``session::set_settings()``
|
2009-05-12 20:05:04 +02:00
|
|
|
|
to apply them.
|
|
|
|
|
|
|
|
|
|
You have control over proxy and authorization settings and also the user-agent
|
|
|
|
|
that will be sent to the tracker. The user-agent will also be used to identify the
|
|
|
|
|
client with other peers.
|
|
|
|
|
|
|
|
|
|
presets
|
|
|
|
|
-------
|
|
|
|
|
|
|
|
|
|
The default values of the session settings are set for a regular bittorrent client running
|
|
|
|
|
on a desktop system. There are functions that can set the session settings to pre set
|
|
|
|
|
settings for other environments. These can be used for the basis, and should be tweaked to
|
|
|
|
|
fit your needs better.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
session_settings min_memory_usage();
|
|
|
|
|
session_settings high_performance_seed();
|
|
|
|
|
|
|
|
|
|
``min_memory_usage`` returns settings that will use the minimal amount of RAM, at the
|
|
|
|
|
potential expense of upload and download performance. It adjusts the socket buffer sizes,
|
|
|
|
|
disables the disk cache, lowers the send buffer watermarks so that each connection only has
|
|
|
|
|
at most one block in use at any one time. It lowers the outstanding blocks send to the disk
|
|
|
|
|
I/O thread so that connections only have one block waiting to be flushed to disk at any given
|
|
|
|
|
time. It lowers the max number of peers in the peer list for torrents. It performs multiple
|
|
|
|
|
smaller reads when it hashes pieces, instead of reading it all into memory before hashing.
|
|
|
|
|
|
|
|
|
|
This configuration is inteded to be the starting point for embedded devices. It will
|
|
|
|
|
significantly reduce memory usage.
|
|
|
|
|
|
|
|
|
|
``high_performance_seed`` returns settings optimized for a seed box, serving many peers
|
|
|
|
|
and that doesn't do any downloading. It has a 128 MB disk cache and has a limit of 400 files
|
|
|
|
|
in its file pool. It support fast upload rates by allowing large send buffers.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
session_settings
|
|
|
|
|
----------------
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2006-05-21 01:58:09 +02:00
|
|
|
|
struct session_settings
|
2004-01-07 01:48:02 +01:00
|
|
|
|
{
|
2006-05-21 01:58:09 +02:00
|
|
|
|
session_settings();
|
2004-01-07 01:48:02 +01:00
|
|
|
|
std::string user_agent;
|
2006-04-25 23:04:48 +02:00
|
|
|
|
int tracker_completion_timeout;
|
|
|
|
|
int tracker_receive_timeout;
|
2007-05-23 03:08:57 +02:00
|
|
|
|
int stop_tracker_timeout;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
int tracker_maximum_response_length;
|
2006-05-21 01:58:09 +02:00
|
|
|
|
|
|
|
|
|
int piece_timeout;
|
|
|
|
|
float request_queue_time;
|
|
|
|
|
int max_allowed_in_request_queue;
|
|
|
|
|
int max_out_request_queue;
|
|
|
|
|
int whole_pieces_threshold;
|
2006-06-29 01:27:44 +02:00
|
|
|
|
int peer_timeout;
|
|
|
|
|
int urlseed_timeout;
|
2006-08-01 17:27:08 +02:00
|
|
|
|
int urlseed_pipeline_size;
|
2006-11-14 16:53:38 +01:00
|
|
|
|
int file_pool_size;
|
|
|
|
|
bool allow_multiple_connections_per_ip;
|
2007-04-15 04:14:02 +02:00
|
|
|
|
int max_failcount;
|
|
|
|
|
int min_reconnect_time;
|
2007-05-05 02:29:33 +02:00
|
|
|
|
int peer_connect_timeout;
|
2007-05-31 21:57:15 +02:00
|
|
|
|
bool ignore_limits_on_local_network;
|
|
|
|
|
int connection_speed;
|
2008-03-01 19:26:15 +01:00
|
|
|
|
bool send_redundant_have;
|
2007-05-31 21:57:15 +02:00
|
|
|
|
bool lazy_bitfields;
|
|
|
|
|
int inactivity_timeout;
|
2008-02-27 18:47:34 +01:00
|
|
|
|
int unchoke_interval;
|
2008-10-19 00:35:10 +02:00
|
|
|
|
int optimistic_unchoke_interval;
|
2009-11-23 09:38:50 +01:00
|
|
|
|
std::string announce_ip;
|
2008-02-27 18:47:34 +01:00
|
|
|
|
int num_want;
|
|
|
|
|
int initial_picker_threshold;
|
|
|
|
|
int allowed_fast_set_size;
|
2009-06-10 10:30:55 +02:00
|
|
|
|
int max_queued_disk_bytes;
|
2008-02-27 18:47:34 +01:00
|
|
|
|
int handshake_timeout;
|
2007-02-12 10:20:49 +01:00
|
|
|
|
bool use_dht_as_fallback;
|
2007-11-24 04:37:05 +01:00
|
|
|
|
bool free_torrent_hashes;
|
2008-01-07 06:48:28 +01:00
|
|
|
|
bool upnp_ignore_nonrouters;
|
2008-01-08 02:16:30 +01:00
|
|
|
|
int send_buffer_watermark;
|
2008-01-13 12:18:18 +01:00
|
|
|
|
bool auto_upload_slots;
|
2009-04-04 09:55:34 +02:00
|
|
|
|
bool auto_upload_slots_rate_based;
|
2008-07-11 11:23:22 +02:00
|
|
|
|
bool use_parole_mode;
|
2008-02-08 11:22:05 +01:00
|
|
|
|
int cache_size;
|
2009-05-12 20:52:05 +02:00
|
|
|
|
int cache_buffer_chunk_size;
|
2008-02-10 01:58:25 +01:00
|
|
|
|
int cache_expiry;
|
2009-01-10 06:46:02 +01:00
|
|
|
|
bool use_read_cache;
|
2009-01-11 03:02:34 +01:00
|
|
|
|
bool disk_io_no_buffer;
|
2008-02-28 08:34:07 +01:00
|
|
|
|
std::pair<int, int> outgoing_ports;
|
2008-03-12 17:58:23 +01:00
|
|
|
|
char peer_tos;
|
2008-04-24 05:28:48 +02:00
|
|
|
|
|
|
|
|
|
int active_downloads;
|
|
|
|
|
int active_seeds;
|
2008-06-21 14:31:28 +02:00
|
|
|
|
int active_limit;
|
2009-05-27 21:27:12 +02:00
|
|
|
|
bool auto_manage_prefer_seeds;
|
2008-06-21 14:31:28 +02:00
|
|
|
|
bool dont_count_slow_torrents;
|
2008-04-24 05:28:48 +02:00
|
|
|
|
int auto_manage_interval;
|
|
|
|
|
float share_ratio_limit;
|
|
|
|
|
float seed_time_ratio_limit;
|
|
|
|
|
int seed_time_limit;
|
2008-05-12 08:25:53 +02:00
|
|
|
|
bool close_redundant_connections;
|
2008-05-19 06:06:25 +02:00
|
|
|
|
|
|
|
|
|
int auto_scrape_interval;
|
|
|
|
|
int auto_scrape_min_interval;
|
2008-05-28 20:25:48 +02:00
|
|
|
|
|
|
|
|
|
int max_peerlist_size;
|
2008-08-02 00:34:37 +02:00
|
|
|
|
|
|
|
|
|
int min_announce_interval;
|
2008-10-01 07:25:18 +02:00
|
|
|
|
|
|
|
|
|
bool prioritize_partial_pieces;
|
|
|
|
|
int auto_manage_startup;
|
2008-11-18 12:14:44 +01:00
|
|
|
|
|
|
|
|
|
bool rate_limit_ip_overhead;
|
2008-11-29 09:38:40 +01:00
|
|
|
|
|
|
|
|
|
bool announce_to_all_trackers;
|
2009-06-28 22:21:55 +02:00
|
|
|
|
bool announce_to_all_tiers;
|
|
|
|
|
|
2008-12-08 10:13:21 +01:00
|
|
|
|
bool prefer_udp_trackers;
|
2008-12-09 08:56:37 +01:00
|
|
|
|
bool strict_super_seeding;
|
2008-12-13 05:36:41 +01:00
|
|
|
|
|
|
|
|
|
int seeding_piece_quota;
|
2009-01-05 02:08:09 +01:00
|
|
|
|
|
|
|
|
|
int max_sparse_regions;
|
2009-02-06 10:46:13 +01:00
|
|
|
|
|
|
|
|
|
bool lock_disk_cache;
|
2009-03-12 18:06:41 +01:00
|
|
|
|
|
|
|
|
|
int max_rejects;
|
2009-05-01 06:59:15 +02:00
|
|
|
|
|
|
|
|
|
int recv_socket_buffer_size;
|
|
|
|
|
int send_socket_buffer_size;
|
2009-05-03 21:09:06 +02:00
|
|
|
|
|
|
|
|
|
bool optimize_hashing_for_speed;
|
2009-05-22 08:32:39 +02:00
|
|
|
|
|
|
|
|
|
int file_checks_delay_per_block;
|
2009-05-23 09:35:45 +02:00
|
|
|
|
|
|
|
|
|
enum disk_cache_algo_t
|
|
|
|
|
{ lru, largest_contiguous };
|
|
|
|
|
|
|
|
|
|
disk_cache_algo_t disk_cache_algorithm;
|
2009-05-23 21:27:27 +02:00
|
|
|
|
|
|
|
|
|
int read_cache_line_size;
|
2009-05-24 02:12:53 +02:00
|
|
|
|
int write_cache_line_size;
|
2009-06-10 11:20:55 +02:00
|
|
|
|
|
2009-06-19 00:32:55 +02:00
|
|
|
|
int optimistic_disk_retry;
|
2009-08-02 08:40:45 +02:00
|
|
|
|
bool disable_hash_check;
|
2009-09-01 06:41:50 +02:00
|
|
|
|
|
|
|
|
|
int max_suggest_pieces;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
};
|
|
|
|
|
|
2006-12-22 17:51:19 +01:00
|
|
|
|
``user_agent`` this is the client identification to the tracker.
|
|
|
|
|
The recommended format of this string is:
|
|
|
|
|
"ClientName/ClientVersion libtorrent/libtorrentVersion".
|
2006-04-25 23:04:48 +02:00
|
|
|
|
This name will not only be used when making HTTP requests, but also when
|
|
|
|
|
sending extended headers to peers that support that extension.
|
|
|
|
|
|
|
|
|
|
``tracker_completion_timeout`` is the number of seconds the tracker
|
|
|
|
|
connection will wait from when it sent the request until it considers the
|
|
|
|
|
tracker to have timed-out. Default value is 60 seconds.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2006-04-25 23:04:48 +02:00
|
|
|
|
``tracker_receive_timeout`` is the number of seconds to wait to receive
|
|
|
|
|
any data from the tracker. If no data is received for this number of
|
|
|
|
|
seconds, the tracker will be considered as having timed out. If a tracker
|
|
|
|
|
is down, this is the kind of timeout that will occur. The default value
|
|
|
|
|
is 20 seconds.
|
2007-05-23 03:08:57 +02:00
|
|
|
|
|
|
|
|
|
``stop_tracker_timeout`` is the time to wait for tracker responses when
|
|
|
|
|
shutting down the session object. This is given in seconds. Default is
|
|
|
|
|
10 seconds.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
|
|
|
|
``tracker_maximum_response_length`` is the maximum number of bytes in a
|
|
|
|
|
tracker response. If a response size passes this number it will be rejected
|
|
|
|
|
and the connection will be closed. On gzipped responses this size is measured
|
|
|
|
|
on the uncompressed data. So, if you get 20 bytes of gzip response that'll
|
|
|
|
|
expand to 2 megs, it will be interrupted before the entire response has been
|
|
|
|
|
uncompressed (given your limit is lower than 2 megs). Default limit is
|
|
|
|
|
1 megabyte.
|
|
|
|
|
|
2006-05-21 01:58:09 +02:00
|
|
|
|
``piece_timeout`` controls the number of seconds from a request is sent until
|
|
|
|
|
it times out if no piece response is returned.
|
|
|
|
|
|
|
|
|
|
``request_queue_time`` is the length of the request queue given in the number
|
|
|
|
|
of seconds it should take for the other end to send all the pieces. i.e. the
|
|
|
|
|
actual number of requests depends on the download rate and this number.
|
|
|
|
|
|
|
|
|
|
``max_allowed_in_request_queue`` is the number of outstanding block requests
|
|
|
|
|
a peer is allowed to queue up in the client. If a peer sends more requests
|
2006-05-21 11:46:01 +02:00
|
|
|
|
than this (before the first one has been handled) the last request will be
|
2006-05-21 01:58:09 +02:00
|
|
|
|
dropped. The higher this is, the faster upload speeds the client can get to a
|
|
|
|
|
single peer.
|
|
|
|
|
|
|
|
|
|
``max_out_request_queue`` is the maximum number of outstanding requests to
|
|
|
|
|
send to a peer. This limit takes precedence over ``request_queue_time``. i.e.
|
|
|
|
|
no matter the download speed, the number of outstanding requests will never
|
|
|
|
|
exceed this limit.
|
|
|
|
|
|
|
|
|
|
``whole_pieces_threshold`` is a limit in seconds. if a whole piece can be
|
2006-05-21 11:46:01 +02:00
|
|
|
|
downloaded in at least this number of seconds from a specific peer, the
|
|
|
|
|
peer_connection will prefer requesting whole pieces at a time from this peer.
|
|
|
|
|
The benefit of this is to better utilize disk caches by doing localized
|
|
|
|
|
accesses and also to make it easier to identify bad peers if a piece fails
|
|
|
|
|
the hash check.
|
2006-05-21 01:58:09 +02:00
|
|
|
|
|
2006-06-29 01:27:44 +02:00
|
|
|
|
``peer_timeout`` is the number of seconds the peer connection should
|
|
|
|
|
wait (for any activity on the peer connection) before closing it due
|
|
|
|
|
to time out. This defaults to 120 seconds, since that's what's specified
|
|
|
|
|
in the protocol specification. After half the time out, a keep alive message
|
|
|
|
|
is sent.
|
|
|
|
|
|
|
|
|
|
``urlseed_timeout`` is the same as ``peer_timeout`` but applies only to
|
|
|
|
|
url seeds. This value defaults to 20 seconds.
|
|
|
|
|
|
2006-08-01 17:27:08 +02:00
|
|
|
|
``urlseed_pipeline_size`` controls the pipelining with the web server. When
|
|
|
|
|
using persistent connections to HTTP 1.1 servers, the client is allowed to
|
|
|
|
|
send more requests before the first response is received. This number controls
|
|
|
|
|
the number of outstanding requests to use with url-seeds. Default is 5.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2006-11-14 16:53:38 +01:00
|
|
|
|
``file_pool_size`` is the the upper limit on the total number of files this
|
|
|
|
|
session will keep open. The reason why files are left open at all is that
|
|
|
|
|
some anti virus software hooks on every file close, and scans the file for
|
|
|
|
|
viruses. deferring the closing of the files will be the difference between
|
|
|
|
|
a usable system and a completely hogged down system. Most operating systems
|
|
|
|
|
also has a limit on the total number of file descriptors a process may have
|
|
|
|
|
open. It is usually a good idea to find this limit and set the number of
|
|
|
|
|
connections and the number of files limits so their sum is slightly below it.
|
|
|
|
|
|
|
|
|
|
``allow_multiple_connections_per_ip`` determines if connections from the
|
|
|
|
|
same IP address as existing connections should be rejected or not. Multiple
|
|
|
|
|
connections from the same IP address is not allowed by default, to prevent
|
|
|
|
|
abusive behavior by peers. It may be useful to allow such connections in
|
|
|
|
|
cases where simulations are run on the same machie, and all peers in a
|
|
|
|
|
swarm has the same IP address.
|
|
|
|
|
|
2007-04-15 04:14:02 +02:00
|
|
|
|
``max_failcount`` is the maximum times we try to connect to a peer before
|
|
|
|
|
stop connecting again. If a peer succeeds, the failcounter is reset. If
|
|
|
|
|
a peer is retrieved from a peer source (other than DHT) the failcount is
|
|
|
|
|
decremented by one, allowing another try.
|
|
|
|
|
|
|
|
|
|
``min_reconnect_time`` is the time to wait between connection attempts. If
|
|
|
|
|
the peer fails, the time is multiplied by fail counter.
|
|
|
|
|
|
2007-05-05 02:29:33 +02:00
|
|
|
|
``peer_connect_timeout`` the number of seconds to wait after a connection
|
|
|
|
|
attempt is initiated to a peer until it is considered as having timed out.
|
|
|
|
|
The default is 10 seconds. This setting is especially important in case
|
|
|
|
|
the number of half-open connections are limited, since stale half-open
|
|
|
|
|
connection may delay the connection of other peers considerably.
|
|
|
|
|
|
2007-05-31 21:57:15 +02:00
|
|
|
|
``ignore_limits_on_local_network``, if set to true, upload, download and
|
|
|
|
|
unchoke limits are ignored for peers on the local network.
|
|
|
|
|
|
|
|
|
|
``connection_speed`` is the number of connection attempts that
|
2008-02-11 04:55:53 +01:00
|
|
|
|
are made per second. If a number <= 0 is specified, it will default to
|
|
|
|
|
200 connections per second.
|
2007-05-31 21:57:15 +02:00
|
|
|
|
|
|
|
|
|
``send_redundant_have`` controls if have messages will be sent
|
|
|
|
|
to peers that already have the piece. This is typically not necessary,
|
|
|
|
|
but it might be necessary for collecting statistics in some cases.
|
|
|
|
|
Default is false.
|
|
|
|
|
|
|
|
|
|
``lazy_bitfields`` prevents outgoing bitfields from being full. If the
|
|
|
|
|
client is seed, a few bits will be set to 0, and later filled in with
|
|
|
|
|
have-messages. This is to prevent certain ISPs from stopping people
|
|
|
|
|
from seeding.
|
|
|
|
|
|
|
|
|
|
``inactivity_timeout``, if a peer is uninteresting and uninterested
|
|
|
|
|
for longer than this number of seconds, it will be disconnected.
|
|
|
|
|
Default is 10 minutes
|
|
|
|
|
|
2008-02-27 18:47:34 +01:00
|
|
|
|
``unchoke_interval`` is the number of seconds between chokes/unchokes.
|
|
|
|
|
On this interval, peers are re-evaluated for being choked/unchoked. This
|
|
|
|
|
is defined as 30 seconds in the protocol, and it should be significantly
|
|
|
|
|
longer than what it takes for TCP to ramp up to it's max rate.
|
|
|
|
|
|
2008-10-19 00:35:10 +02:00
|
|
|
|
``optimistic_unchoke_interval`` is the number of seconds between
|
|
|
|
|
each *optimistic* unchoke. On this timer, the currently optimistically
|
2008-02-27 18:47:34 +01:00
|
|
|
|
unchoked peer will change.
|
|
|
|
|
|
|
|
|
|
``announce_ip`` is the ip address passed along to trackers as the ``&ip=`` parameter.
|
2009-11-23 09:38:50 +01:00
|
|
|
|
If left as the default (an empty string), that parameter is omitted.
|
2008-02-27 18:47:34 +01:00
|
|
|
|
|
|
|
|
|
``num_want`` is the number of peers we want from each tracker request. It defines
|
|
|
|
|
what is sent as the ``&num_want=`` parameter to the tracker.
|
|
|
|
|
|
|
|
|
|
``initial_picker_threshold`` specifies the number of pieces we need before we
|
|
|
|
|
switch to rarest first picking. This defaults to 4, which means the 4 first
|
|
|
|
|
pieces in any torrent are picked at random, the following pieces are picked
|
|
|
|
|
in rarest first order.
|
|
|
|
|
|
|
|
|
|
``allowed_fast_set_size`` is the number of pieces we allow peers to download
|
|
|
|
|
from us without being unchoked.
|
|
|
|
|
|
2009-06-10 10:30:55 +02:00
|
|
|
|
``max_queued_disk_bytes`` is the number maximum number of bytes, to be
|
|
|
|
|
written to disk, that can wait in the disk I/O thread queue. This queue
|
|
|
|
|
is only for waiting for the disk I/O thread to receive the job and either
|
|
|
|
|
write it to disk or insert it in the write cache. When this limit is reached,
|
|
|
|
|
the peer connections will stop reading data from their sockets, until the disk
|
|
|
|
|
thread catches up. Setting this too low will severly limit your download rate.
|
2008-02-27 18:47:34 +01:00
|
|
|
|
|
|
|
|
|
``handshake_timeout`` specifies the number of seconds we allow a peer to
|
|
|
|
|
delay responding to a protocol handshake. If no response is received within
|
|
|
|
|
this time, the connection is closed.
|
|
|
|
|
|
2009-08-05 04:31:57 +02:00
|
|
|
|
``use_dht_as_fallback`` determines how the DHT is used. If this is true,
|
|
|
|
|
the DHT will only be used for torrents where all trackers in its tracker
|
|
|
|
|
list has failed. Either by an explicit error message or a time out. This
|
|
|
|
|
is false by default, which means the DHT is used by default regardless of
|
|
|
|
|
if the trackers fail or not.
|
2007-02-12 10:20:49 +01:00
|
|
|
|
|
2007-11-24 04:37:05 +01:00
|
|
|
|
``free_torrent_hashes`` determines whether or not the torrent's piece hashes
|
|
|
|
|
are kept in memory after the torrent becomes a seed or not. If it is set to
|
|
|
|
|
``true`` the hashes are freed once the torrent is a seed (they're not
|
|
|
|
|
needed anymore since the torrent won't download anything more). If it's set
|
|
|
|
|
to false they are not freed. If they are freed, the torrent_info_ returned
|
|
|
|
|
by get_torrent_info() will return an object that may be incomplete, that
|
|
|
|
|
cannot be passed back to `add_torrent()`_ for instance.
|
|
|
|
|
|
2008-01-07 06:48:28 +01:00
|
|
|
|
``upnp_ignore_nonrouters`` indicates whether or not the UPnP implementation
|
|
|
|
|
should ignore any broadcast response from a device whose address is not the
|
|
|
|
|
configured router for this machine. i.e. it's a way to not talk to other
|
|
|
|
|
people's routers by mistake.
|
|
|
|
|
|
2008-01-08 02:16:30 +01:00
|
|
|
|
``send_buffer_waterbark`` is the upper limit of the send buffer low-watermark.
|
|
|
|
|
if the send buffer has fewer bytes than this, we'll read another 16kB block
|
|
|
|
|
onto it. If set too small, upload rate capacity will suffer. If set too high,
|
|
|
|
|
memory will be wasted. The actual watermark may be lower than this in case
|
|
|
|
|
the upload rate is low, this is the upper limit.
|
|
|
|
|
|
2008-01-13 12:18:18 +01:00
|
|
|
|
``auto_upload_slots`` defaults to true. When true, if there is a global upload
|
|
|
|
|
limit set and the current upload rate is less than 90% of that, another upload
|
|
|
|
|
slot is opened. If the upload rate has been saturated for an extended period
|
|
|
|
|
of time, on upload slot is closed. The number of upload slots will never be
|
|
|
|
|
less than what has been set by ``session::set_max_uploads()``. To query the
|
|
|
|
|
current number of upload slots, see ``session_status::allowed_upload_slots``.
|
2009-04-04 09:55:34 +02:00
|
|
|
|
|
|
|
|
|
When ``auto_upload_slots_rate_based`` is set, and ``auto_upload_slots`` is set,
|
2009-07-19 00:55:07 +02:00
|
|
|
|
the max upload slots setting is used as a minimum number of unchoked slots.
|
2009-04-04 09:55:34 +02:00
|
|
|
|
This algorithm is designed to prevent the peer from spreading its upload
|
2009-07-19 00:55:07 +02:00
|
|
|
|
capacity too thin, but still open more slots in order to utilize the full capacity.
|
2008-01-13 12:18:18 +01:00
|
|
|
|
|
2008-07-11 11:23:22 +02:00
|
|
|
|
``use_parole_mode`` specifies if parole mode should be used. Parole mode means
|
|
|
|
|
that peers that participate in pieces that fail the hash check are put in a mode
|
|
|
|
|
where they are only allowed to download whole pieces. If the whole piece a peer
|
|
|
|
|
in parole mode fails the hash check, it is banned. If a peer participates in a
|
|
|
|
|
piece that passes the hash check, it is taken out of parole mode.
|
|
|
|
|
|
2009-05-01 10:00:58 +02:00
|
|
|
|
``cache_size`` is the disk write and read cache. It is specified in units of
|
|
|
|
|
16 KiB blocks. It defaults to 1024 (= 16 MB). Buffers that are part of a peer's
|
|
|
|
|
send or receive buffer also count against this limit. Send and receive buffers
|
|
|
|
|
will never be denied to be allocated, but they will cause the actual cached blocks
|
|
|
|
|
to be flushed or evicted.
|
2008-02-08 11:22:05 +01:00
|
|
|
|
|
2009-05-12 20:52:05 +02:00
|
|
|
|
Disk buffers are allocated using a pool allocator, the number of blocks that
|
|
|
|
|
are allocated at a time when the pool needs to grow can be specified in
|
|
|
|
|
``cache_buffer_chunk_size``. This defaults to 16 blocks. Lower numbers
|
|
|
|
|
saves memory at the expense of more heap allocations. It must be at least 1.
|
|
|
|
|
|
2008-02-10 01:58:25 +01:00
|
|
|
|
``cache_expiry`` is the number of seconds from the last cached write to a piece
|
|
|
|
|
in the write cache, to when it's forcefully flushed to disk. Default is 60 second.
|
|
|
|
|
|
2009-01-10 06:46:02 +01:00
|
|
|
|
``use_read_cache``, is set to true (default), the disk cache is also used to
|
|
|
|
|
cache pieces read from disk. Blocks for writing pieces takes presedence.
|
|
|
|
|
|
2009-01-11 03:02:34 +01:00
|
|
|
|
``disk_io_no_buffer`` defaults to true. When set to true, files are preferred
|
|
|
|
|
to be opened in unbuffered mode. This helps the operating system from growing
|
|
|
|
|
its file cache indefinitely. Currently only files whose offset in the torrent
|
|
|
|
|
is page aligned are opened in unbuffered mode. A page is typically 4096 bytes
|
|
|
|
|
and since blocks in bittorrent are 16kB, any file that is aligned to a block
|
|
|
|
|
or piece will get the benefit of be opened in unbuffered mode. It is therefore
|
|
|
|
|
recommended to make the largest file in a torrent the first file (with offset 0)
|
|
|
|
|
or use pad files to align all files to piece boundries.
|
|
|
|
|
|
2008-02-28 08:34:07 +01:00
|
|
|
|
``outgoing_ports``, if set to something other than (0, 0) is a range of ports
|
|
|
|
|
used to bind outgoing sockets to. This may be useful for users whose router
|
|
|
|
|
allows them to assign QoS classes to traffic based on its local port. It is
|
|
|
|
|
a range instead of a single port because of the problems with failing to reconnect
|
|
|
|
|
to peers if a previous socket to that peer and port is in ``TIME_WAIT`` state.
|
|
|
|
|
|
2008-03-12 17:58:23 +01:00
|
|
|
|
``peer_tos`` determines the TOS byte set in the IP header of every packet
|
|
|
|
|
sent to peers (including web seeds). The default value for this is ``0x0``
|
|
|
|
|
(no marking). One potentially useful TOS mark is ``0x20``, this represents
|
|
|
|
|
the *QBone scavenger service*. For more details, see QBSS_.
|
|
|
|
|
|
|
|
|
|
.. _`QBSS`: http://qbone.internet2.edu/qbss/
|
|
|
|
|
|
2008-04-24 05:28:48 +02:00
|
|
|
|
``active_downloads`` and ``active_seeds`` controls how many active seeding and
|
2008-06-13 07:11:36 +02:00
|
|
|
|
downloading torrents the queuing mechanism allows. The target number of active
|
2008-12-27 18:22:02 +01:00
|
|
|
|
torrents is ``min(active_downloads + active_seeds, active_limit)``.
|
|
|
|
|
``active_downloads`` and ``active_seeds`` are upper limits on the number of
|
|
|
|
|
downloading torrents and seeding torrents respectively. Setting the value to
|
|
|
|
|
-1 means unlimited.
|
2008-06-13 07:11:36 +02:00
|
|
|
|
|
|
|
|
|
For example if there are 10 seeding torrents and 10 downloading torrents, and
|
2008-12-27 18:22:02 +01:00
|
|
|
|
``active_downloads`` is 4 and ``active_seeds`` is 4, there will be 4 seeds
|
|
|
|
|
active and 4 downloading torrents. If the settings are ``active_downloads`` = 2
|
2008-12-30 05:04:17 +01:00
|
|
|
|
and ``active_seeds`` = 4, then there will be 2 downloading torrents and 4 seeding
|
2008-06-13 07:11:36 +02:00
|
|
|
|
torrents active. Torrents that are not auto managed are also counted against these
|
|
|
|
|
limits. If there are non-auto managed torrents that use up all the slots, no
|
|
|
|
|
auto managed torrent will be activated.
|
2008-04-24 05:28:48 +02:00
|
|
|
|
|
2009-05-27 21:27:12 +02:00
|
|
|
|
``auto_manage_prefer_seeds`` specifies if libtorrent should prefer giving seeds
|
|
|
|
|
active slots or downloading torrents. The default is ``false``.
|
|
|
|
|
|
2008-06-21 14:31:28 +02:00
|
|
|
|
if ``dont_count_slow_torrents`` is true, torrents without any payload transfers are
|
|
|
|
|
not subject to the ``active_seeds`` and ``active_downloads`` limits. This is intended
|
|
|
|
|
to make it more likely to utilize all available bandwidth, and avoid having torrents
|
|
|
|
|
that don't transfer anything block the active slots.
|
|
|
|
|
|
2008-12-27 18:22:02 +01:00
|
|
|
|
``active_limit`` is a hard limit on the number of active torrents. This applies even to
|
2008-06-21 14:31:28 +02:00
|
|
|
|
slow torrents.
|
|
|
|
|
|
2008-04-24 05:28:48 +02:00
|
|
|
|
``auto_manage_interval`` is the number of seconds between the torrent queue
|
|
|
|
|
is updated, and rotated.
|
|
|
|
|
|
|
|
|
|
``share_ratio_limit`` is the upload / download ratio limit for considering a
|
2008-05-06 20:03:41 +02:00
|
|
|
|
seeding torrent have met the seed limit criteria. See queuing_.
|
2008-04-24 05:28:48 +02:00
|
|
|
|
|
|
|
|
|
``seed_time_ratio_limit`` is the seeding time / downloading time ratio limit
|
2008-05-06 20:03:41 +02:00
|
|
|
|
for considering a seeding torrent to have met the seed limit criteria. See queuing_.
|
2008-04-24 05:28:48 +02:00
|
|
|
|
|
|
|
|
|
``seed_time_limit`` is the limit on the time a torrent has been an active seed
|
2008-05-06 20:03:41 +02:00
|
|
|
|
(specified in seconds) before it is considered having met the seed limit criteria.
|
2008-04-24 05:28:48 +02:00
|
|
|
|
See queuing_.
|
2008-05-12 08:25:53 +02:00
|
|
|
|
|
|
|
|
|
``close_redundant_connections`` specifies whether libtorrent should close
|
|
|
|
|
connections where both ends have no utility in keeping the connection open.
|
|
|
|
|
For instance if both ends have completed their downloads, there's no point
|
|
|
|
|
in keeping it open. This defaults to ``true``.
|
2008-05-19 06:06:25 +02:00
|
|
|
|
|
|
|
|
|
``auto_scrape_interval`` is the number of seconds between scrapes of
|
|
|
|
|
queued torrents (auto managed and paused torrents). Auto managed
|
|
|
|
|
torrents that are paused, are scraped regularly in order to keep
|
|
|
|
|
track of their downloader/seed ratio. This ratio is used to determine
|
|
|
|
|
which torrents to seed and which to pause.
|
|
|
|
|
|
|
|
|
|
``auto_scrape_min_interval`` is the minimum number of seconds between any
|
|
|
|
|
automatic scrape (regardless of torrent). In case there are a large number
|
|
|
|
|
of paused auto managed torrents, this puts a limit on how often a scrape
|
|
|
|
|
request is sent.
|
2008-04-24 05:28:48 +02:00
|
|
|
|
|
2008-05-28 20:25:48 +02:00
|
|
|
|
``max_peerlist_size`` is the maximum number of peers in the list of
|
|
|
|
|
known peers. These peers are not necessarily connected, so this number
|
|
|
|
|
should be much greater than the maximum number of connected peers.
|
|
|
|
|
Peers are evicted from the cache when the list grows passed 90% of
|
|
|
|
|
this limit, and once the size hits the limit, peers are no longer
|
2009-05-07 00:36:24 +02:00
|
|
|
|
added to the list. If this limit is set to 0, there is no limit on
|
|
|
|
|
how many peers we'll keep in the peer list.
|
2008-02-10 01:58:25 +01:00
|
|
|
|
|
2009-05-13 03:34:10 +02:00
|
|
|
|
``max_paused_peerlist_size`` is the max peer list size used for torrents
|
|
|
|
|
that are paused. This default to the same as ``max_peerlist_size``, but
|
|
|
|
|
can be used to save memory for paused torrents, since it's not as
|
|
|
|
|
important for them to keep a large peer list.
|
|
|
|
|
|
2008-08-02 00:34:37 +02:00
|
|
|
|
``min_announce_interval`` is the minimum allowed announce interval
|
|
|
|
|
for a tracker. This is specified in seconds, defaults to 5 minutes and
|
|
|
|
|
is used as a sanity check on what is returned from a tracker. It
|
|
|
|
|
mitigates hammering misconfigured trackers.
|
|
|
|
|
|
2008-10-01 07:25:18 +02:00
|
|
|
|
If ``prioritize_partial_pieces`` is true, partial pieces are picked
|
|
|
|
|
before pieces that are more rare. If false, rare pieces are always
|
|
|
|
|
prioritized, unless the number of partial pieces is growing out of
|
|
|
|
|
proportion.
|
|
|
|
|
|
|
|
|
|
``auto_manage_startup`` is the number of seconds a torrent is considered
|
|
|
|
|
active after it was started, regardless of upload and download speed. This
|
|
|
|
|
is so that newly started torrents are not considered inactive until they
|
|
|
|
|
have a fair chance to start downloading.
|
|
|
|
|
|
2008-11-18 12:14:44 +01:00
|
|
|
|
If ``rate_limit_ip_overhead`` is set to true, the estimated TCP/IP overhead is
|
|
|
|
|
drained from the rate limiters, to avoid exceeding the limits with the total traffic
|
|
|
|
|
|
2008-11-29 09:38:40 +01:00
|
|
|
|
``announce_to_all_trackers`` controls how multi tracker torrents are
|
|
|
|
|
treated. If this is set to true, all trackers in the same tier are
|
|
|
|
|
announced to in parallel. If all trackers in tier 0 fails, all trackers
|
2009-06-28 22:21:55 +02:00
|
|
|
|
in tier 1 are announced as well. If it's set to false, the behavior is as
|
|
|
|
|
defined by the multi tracker specification. It defaults to false, which
|
|
|
|
|
is the same behavior previous versions of libtorrent has had as well.
|
|
|
|
|
|
|
|
|
|
``announce_to_all_tiers`` also controls how multi tracker torrents are
|
|
|
|
|
treated. When this is set to true, one tracker from each tier is announced
|
|
|
|
|
to. This is the uTorrent behavior. This is false by default in order
|
|
|
|
|
to comply with the multi-tracker specification.
|
2008-11-29 09:38:40 +01:00
|
|
|
|
|
2008-12-08 10:13:21 +01:00
|
|
|
|
``prefer_udp_trackers`` is true by default. It means that trackers may
|
|
|
|
|
be rearranged in a way that udp trackers are always tried before http
|
|
|
|
|
trackers for the same hostname. Setting this to fails means that the
|
|
|
|
|
trackers' tier is respected and there's no preference of one protocol
|
|
|
|
|
over another.
|
2008-08-02 00:34:37 +02:00
|
|
|
|
|
2008-12-09 08:56:37 +01:00
|
|
|
|
``strict_super_seeding`` when this is set to true, a piece has to
|
|
|
|
|
have been forwarded to a third peer before another one is handed out.
|
|
|
|
|
This is the traditional definition of super seeding.
|
|
|
|
|
|
2008-12-13 05:36:41 +01:00
|
|
|
|
``seeding_piece_quota`` is the number of pieces to send to a peer,
|
|
|
|
|
when seeding, before rotating in another peer to the unchoke set.
|
|
|
|
|
It defaults to 3 pieces, which means that when seeding, any peer we've
|
|
|
|
|
sent more than this number of pieces to will be unchoked in favour of
|
|
|
|
|
a choked peer.
|
|
|
|
|
|
2009-01-05 02:08:09 +01:00
|
|
|
|
``max_sparse_regions`` is a limit of the number of *sparse regions* in
|
|
|
|
|
a torrent. A sparse region is defined as a hole of pieces we have not
|
|
|
|
|
yet downloaded, in between pieces that have been downloaded. This is
|
|
|
|
|
used as a hack for windows vista which has a bug where you cannot
|
|
|
|
|
write files with more than a certain number of sparse regions. This
|
|
|
|
|
limit is not hard, it will be exceeded. Once it's exceeded, pieces
|
|
|
|
|
that will maintain or decrease the number of sparse regions are
|
|
|
|
|
prioritized. To disable this functionality, set this to 0. It defaults
|
|
|
|
|
to 0 on all platforms except windows.
|
|
|
|
|
|
2009-02-06 10:46:13 +01:00
|
|
|
|
``lock_disk_cache`` if lock disk cache is set to true the disk cache
|
|
|
|
|
that's in use, will be locked in physical memory, preventing it from
|
|
|
|
|
being swapped out.
|
|
|
|
|
|
2009-03-12 18:06:41 +01:00
|
|
|
|
``max_rejects`` is the number of piece requests we will reject in a row
|
|
|
|
|
while a peer is choked before the peer is considered abusive and is
|
|
|
|
|
disconnected.
|
|
|
|
|
|
|
|
|
|
|
2009-05-01 06:59:15 +02:00
|
|
|
|
``recv_socket_buffer_size`` and ``send_socket_buffer_size`` specifies
|
|
|
|
|
the buffer sizes set on peer sockets. 0 (which is the default) means
|
|
|
|
|
the OS default (i.e. don't change the buffer sizes). The socket buffer
|
|
|
|
|
sizes are changed using setsockopt() with SOL_SOCKET/SO_RCVBUF and
|
|
|
|
|
SO_SNDBUFFER.
|
|
|
|
|
|
2009-05-03 21:09:06 +02:00
|
|
|
|
``optimize_hashing_for_speed`` chooses between two ways of reading back
|
|
|
|
|
piece data from disk when its complete and needs to be verified against
|
|
|
|
|
the piece hash. This happens if some blocks were flushed to the disk
|
|
|
|
|
out of order. Everything that is flushed in order is hashed as it goes
|
|
|
|
|
along. Optimizing for speed will allocate space to fit all the the
|
|
|
|
|
remaingin, unhashed, part of the piece, reads the data into it in a single
|
|
|
|
|
call and hashes it. This is the default. If ``optimizing_hashing_for_speed``
|
|
|
|
|
is false, a single block will be allocated (16 kB), and the unhashed parts
|
|
|
|
|
of the piece are read, one at a time, and hashed in this single block. This
|
|
|
|
|
is appropriate on systems that are memory constrained.
|
|
|
|
|
|
2009-05-22 08:32:39 +02:00
|
|
|
|
``file_checks_delay_per_block`` is the number of milliseconds to sleep
|
|
|
|
|
in between disk read operations when checking torrents. This defaults
|
|
|
|
|
to 0, but can be set to higher numbers to slow down the rate at which
|
|
|
|
|
data is read from the disk while checking. This may be useful for
|
|
|
|
|
background tasks that doesn't matter if they take a bit longer, as long
|
|
|
|
|
as they leave disk I/O time for other processes.
|
2009-05-01 06:59:15 +02:00
|
|
|
|
|
2009-05-23 09:35:45 +02:00
|
|
|
|
``disk_cache_algorithm`` tells the disk I/O thread which cache flush
|
|
|
|
|
algorithm to use. The default (and original) algorithm is LRU. This
|
|
|
|
|
flushes the entire piece, in the write cache, that was least recently
|
|
|
|
|
written to. This is specified by the ``session_settings::lru`` enum
|
|
|
|
|
value. ``session_settings::largest_contiguous`` will flush the largest
|
|
|
|
|
sequences of contiguous blocks from the write cache, regarless of the
|
|
|
|
|
piece's last use time.
|
|
|
|
|
|
2009-05-23 21:27:27 +02:00
|
|
|
|
``read_cache_line_size`` is the number of blocks to read into the read
|
|
|
|
|
cache when a read cache miss occurs. Setting this to 0 is essentially
|
|
|
|
|
the same thing as disabling read cache. The number of blocks read
|
|
|
|
|
into the read cache is always capped by the piece boundry.
|
2009-05-23 09:35:45 +02:00
|
|
|
|
|
2009-05-24 02:12:53 +02:00
|
|
|
|
When a piece in the write cache has ``write_cache_line_size`` contiguous
|
|
|
|
|
blocks in it, they will be flushed. Setting this to 1 effectively
|
|
|
|
|
disables the write cache.
|
|
|
|
|
|
2009-06-19 00:32:55 +02:00
|
|
|
|
``optimistic_disk_retry`` is the number of seconds from a disk write
|
|
|
|
|
errors occur on a torrent until libtorrent will take it out of the
|
|
|
|
|
upload mode, to test if the error condition has been fixed.
|
|
|
|
|
|
|
|
|
|
libtorrent will only do this automatically for auto managed torrents.
|
2009-06-10 11:20:55 +02:00
|
|
|
|
|
2009-06-19 00:32:55 +02:00
|
|
|
|
You can explicitly take a torrent out of upload only mode using
|
|
|
|
|
`set_upload_mode()`_.
|
2009-06-10 11:20:55 +02:00
|
|
|
|
|
2009-08-02 08:40:45 +02:00
|
|
|
|
``disable_hash_check`` controls if downloaded pieces are verified against
|
|
|
|
|
the piece hashes in the torrent file or not. The default is false, i.e.
|
|
|
|
|
to verify all downloaded data. It may be useful to turn this off for performance
|
|
|
|
|
profiling and simulation scenarios. Do not disable the hash check for regular
|
|
|
|
|
bittorrent clients.
|
|
|
|
|
|
2009-09-01 06:41:50 +02:00
|
|
|
|
``max_suggest_pieces`` is the max number of suggested piece indices received
|
|
|
|
|
from a peer that's remembered. If a peer floods suggest messages, this limit
|
|
|
|
|
prevents libtorrent from using too much RAM. It defaults to 10.
|
|
|
|
|
|
2007-06-06 02:41:20 +02:00
|
|
|
|
pe_settings
|
|
|
|
|
===========
|
|
|
|
|
|
|
|
|
|
The ``pe_settings`` structure is used to control the settings related
|
|
|
|
|
to peer protocol encryption::
|
|
|
|
|
|
|
|
|
|
struct pe_settings
|
|
|
|
|
{
|
|
|
|
|
pe_settings();
|
|
|
|
|
|
|
|
|
|
enum enc_policy
|
|
|
|
|
{
|
|
|
|
|
forced,
|
|
|
|
|
enabled,
|
|
|
|
|
disabled
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum enc_level
|
|
|
|
|
{
|
|
|
|
|
plaintext,
|
|
|
|
|
rc4,
|
|
|
|
|
both
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enc_policy out_enc_policy;
|
|
|
|
|
enc_policy in_enc_policy;
|
|
|
|
|
enc_level allowed_enc_level;
|
|
|
|
|
bool prefer_rc4;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
``in_enc_policy`` and ``out_enc_policy`` control the settings for incoming
|
|
|
|
|
and outgoing connections respectively. The settings for these are:
|
|
|
|
|
|
|
|
|
|
* ``forced`` - Only encrypted connections are allowed. Incoming connections
|
|
|
|
|
that are not encrypted are closed and if the encrypted outgoing connection
|
|
|
|
|
fails, a non-encrypted retry will not be made.
|
|
|
|
|
|
|
|
|
|
* ``enabled`` - encrypted connections are enabled, but non-encrypted
|
|
|
|
|
connections are allowed. An incoming non-encrypted connection will
|
|
|
|
|
be accepted, and if an outgoing encrypted connection fails, a non-
|
|
|
|
|
encrypted connection will be tried.
|
|
|
|
|
|
|
|
|
|
* ``disabled`` - only non-encrypted connections are allowed.
|
|
|
|
|
|
|
|
|
|
``allowed_enc_level`` determines the encryption level of the
|
|
|
|
|
connections. This setting will adjust which encryption scheme is
|
|
|
|
|
offered to the other peer, as well as which encryption scheme is
|
|
|
|
|
selected by the client. The settings are:
|
|
|
|
|
|
|
|
|
|
* ``plaintext`` - only the handshake is encrypted, the bulk of the traffic
|
|
|
|
|
remains unchanged.
|
|
|
|
|
|
|
|
|
|
* ``rc4`` - the entire stream is encrypted with RC4
|
|
|
|
|
|
|
|
|
|
* ``both`` - both RC4 and plaintext connections are allowed.
|
|
|
|
|
|
|
|
|
|
``prefer_rc4`` can be set to true if you want to prefer the RC4 encrypted stream.
|
|
|
|
|
|
|
|
|
|
|
2007-04-26 01:38:25 +02:00
|
|
|
|
proxy_settings
|
|
|
|
|
==============
|
|
|
|
|
|
|
|
|
|
The ``proxy_settings`` structs contains the information needed to
|
|
|
|
|
direct certain traffic to a proxy.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2007-04-30 00:36:28 +02:00
|
|
|
|
struct proxy_settings
|
2007-04-26 01:38:25 +02:00
|
|
|
|
{
|
|
|
|
|
proxy_settings();
|
|
|
|
|
|
|
|
|
|
std::string hostname;
|
|
|
|
|
int port;
|
|
|
|
|
|
|
|
|
|
std::string username;
|
|
|
|
|
std::string password;
|
|
|
|
|
|
|
|
|
|
enum proxy_type
|
|
|
|
|
{
|
|
|
|
|
none,
|
2007-05-31 22:52:20 +02:00
|
|
|
|
socks4,
|
2007-04-26 01:38:25 +02:00
|
|
|
|
socks5,
|
|
|
|
|
socks5_pw,
|
|
|
|
|
http,
|
|
|
|
|
http_pw
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
proxy_type type;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
``hostname`` is the name or IP of the proxy server. ``port`` is the
|
|
|
|
|
port number the proxy listens to. If required, ``username`` and ``password``
|
|
|
|
|
can be set to authenticate with the proxy.
|
|
|
|
|
|
|
|
|
|
The ``type`` tells libtorrent what kind of proxy server it is. The following
|
|
|
|
|
options are available:
|
|
|
|
|
|
|
|
|
|
* ``none`` - This is the default, no proxy server is used, all other fields
|
|
|
|
|
are ignored.
|
|
|
|
|
|
2007-05-31 22:52:20 +02:00
|
|
|
|
* ``socks4`` - The server is assumed to be a `SOCKS4 server`_ that
|
|
|
|
|
requires a username.
|
|
|
|
|
|
2007-04-26 01:38:25 +02:00
|
|
|
|
* ``socks5`` - The server is assumed to be a SOCKS5 server (`RFC 1928`_) that
|
|
|
|
|
does not require any authentication. The username and password are ignored.
|
|
|
|
|
|
|
|
|
|
* ``socks5_pw`` - The server is assumed to be a SOCKS5 server that supports
|
|
|
|
|
plain text username and password authentication (`RFC 1929`_). The username
|
|
|
|
|
and password specified may be sent to the proxy if it requires.
|
|
|
|
|
|
|
|
|
|
* ``http`` - The server is assumed to be an HTTP proxy. If the transport used
|
|
|
|
|
for the connection is non-HTTP, the server is assumed to support the
|
2007-04-26 02:35:28 +02:00
|
|
|
|
CONNECT_ method. i.e. for web seeds and HTTP trackers, a plain proxy will
|
2007-04-26 01:38:25 +02:00
|
|
|
|
suffice. The proxy is assumed to not require authorization. The username
|
|
|
|
|
and password will not be used.
|
|
|
|
|
|
|
|
|
|
* ``http_pw`` - The server is assumed to be an HTTP proxy that requires
|
|
|
|
|
user authorization. The username and password will be sent to the proxy.
|
|
|
|
|
|
2007-05-31 22:52:20 +02:00
|
|
|
|
.. _`SOCKS4 server`: http://www.ufasoft.com/doc/socks4_protocol.htm
|
2007-04-26 02:35:28 +02:00
|
|
|
|
.. _`RFC 1928`: http://www.faqs.org/rfcs/rfc1928.html
|
|
|
|
|
.. _`RFC 1929`: http://www.faqs.org/rfcs/rfc1929.html
|
|
|
|
|
.. _CONNECT: draft-luotonen-web-proxy-tunneling-01.txt
|
2007-04-26 01:38:25 +02:00
|
|
|
|
|
2005-07-06 02:58:23 +02:00
|
|
|
|
ip_filter
|
|
|
|
|
=========
|
|
|
|
|
|
|
|
|
|
The ``ip_filter`` class is a set of rules that uniquely categorizes all
|
|
|
|
|
ip addresses as allowed or disallowed. The default constructor creates
|
2006-09-23 23:24:28 +02:00
|
|
|
|
a single rule that allows all addresses (0.0.0.0 - 255.255.255.255 for
|
|
|
|
|
the IPv4 range, and the equivalent range covering all addresses for the
|
|
|
|
|
IPv6 range).
|
2005-07-06 02:58:23 +02:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2006-09-23 23:24:28 +02:00
|
|
|
|
template <class Addr>
|
|
|
|
|
struct ip_range
|
|
|
|
|
{
|
|
|
|
|
Addr first;
|
|
|
|
|
Addr last;
|
|
|
|
|
int flags;
|
|
|
|
|
};
|
|
|
|
|
|
2005-07-06 02:58:23 +02:00
|
|
|
|
class ip_filter
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
enum access_flags { blocked = 1 };
|
|
|
|
|
|
|
|
|
|
ip_filter();
|
2006-09-23 23:24:28 +02:00
|
|
|
|
void add_rule(address first, address last, int flags);
|
|
|
|
|
int access(address const& addr) const;
|
2005-07-16 02:56:50 +02:00
|
|
|
|
|
2006-09-23 23:24:28 +02:00
|
|
|
|
typedef boost::tuple<std::vector<ip_range<address_v4> >
|
|
|
|
|
, std::vector<ip_range<address_v6> > > filter_tuple_t;
|
2005-07-16 02:56:50 +02:00
|
|
|
|
|
2006-09-23 23:24:28 +02:00
|
|
|
|
filter_tuple_t export_filter() const;
|
2005-07-06 02:58:23 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ip_filter()
|
|
|
|
|
-----------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
ip_filter()
|
|
|
|
|
|
|
|
|
|
Creates a default filter that doesn't filter any address.
|
|
|
|
|
|
|
|
|
|
postcondition:
|
|
|
|
|
``access(x) == 0`` for every ``x``
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
add_rule()
|
|
|
|
|
----------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2006-09-23 23:24:28 +02:00
|
|
|
|
void add_rule(address first, address last, int flags);
|
2005-07-06 02:58:23 +02:00
|
|
|
|
|
|
|
|
|
Adds a rule to the filter. ``first`` and ``last`` defines a range of
|
|
|
|
|
ip addresses that will be marked with the given flags. The ``flags``
|
2006-05-21 12:41:37 +02:00
|
|
|
|
can currently be 0, which means allowed, or ``ip_filter::blocked``, which
|
2005-07-06 02:58:23 +02:00
|
|
|
|
means disallowed.
|
|
|
|
|
|
2006-09-23 23:24:28 +02:00
|
|
|
|
precondition:
|
|
|
|
|
``first.is_v4() == last.is_v4() && first.is_v6() == last.is_v6()``
|
|
|
|
|
|
2005-07-06 02:58:23 +02:00
|
|
|
|
postcondition:
|
|
|
|
|
``access(x) == flags`` for every ``x`` in the range [``first``, ``last``]
|
|
|
|
|
|
|
|
|
|
This means that in a case of overlapping ranges, the last one applied takes
|
|
|
|
|
precedence.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
access()
|
|
|
|
|
--------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2006-09-23 23:24:28 +02:00
|
|
|
|
int access(address const& addr) const;
|
2005-07-06 02:58:23 +02:00
|
|
|
|
|
|
|
|
|
Returns the access permissions for the given address (``addr``). The permission
|
|
|
|
|
can currently be 0 or ``ip_filter::blocked``. The complexity of this operation
|
|
|
|
|
is O(``log`` n), where n is the minimum number of non-overlapping ranges to describe
|
|
|
|
|
the current filter.
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2005-07-16 02:56:50 +02:00
|
|
|
|
export_filter()
|
|
|
|
|
---------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2006-09-23 23:24:28 +02:00
|
|
|
|
boost::tuple<std::vector<ip_range<address_v4> >
|
|
|
|
|
, std::vector<ip_range<address_v6> > > export_filter() const;
|
2005-07-16 02:56:50 +02:00
|
|
|
|
|
|
|
|
|
This function will return the current state of the filter in the minimum number of
|
|
|
|
|
ranges possible. They are sorted from ranges in low addresses to high addresses. Each
|
|
|
|
|
entry in the returned vector is a range with the access control specified in its
|
|
|
|
|
``flags`` field.
|
|
|
|
|
|
2006-09-23 23:24:28 +02:00
|
|
|
|
The return value is a tuple containing two range-lists. One for IPv4 addresses
|
|
|
|
|
and one for IPv6 addresses.
|
|
|
|
|
|
2005-07-16 02:56:50 +02:00
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
big_number
|
|
|
|
|
==========
|
|
|
|
|
|
|
|
|
|
Both the ``peer_id`` and ``sha1_hash`` types are typedefs of the class
|
|
|
|
|
``big_number``. It represents 20 bytes of data. Its synopsis follows::
|
|
|
|
|
|
|
|
|
|
class big_number
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
bool operator==(const big_number& n) const;
|
|
|
|
|
bool operator!=(const big_number& n) const;
|
|
|
|
|
bool operator<(const big_number& n) const;
|
|
|
|
|
|
|
|
|
|
const unsigned char* begin() const;
|
|
|
|
|
const unsigned char* end() const;
|
|
|
|
|
|
|
|
|
|
unsigned char* begin();
|
|
|
|
|
unsigned char* end();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
The iterators gives you access to individual bytes.
|
|
|
|
|
|
|
|
|
|
|
2008-06-07 04:58:28 +02:00
|
|
|
|
bitfield
|
|
|
|
|
========
|
|
|
|
|
|
|
|
|
|
The bitfiled type stores any number of bits as a bitfield in an array.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
class bitfield
|
|
|
|
|
{
|
|
|
|
|
bitfield();
|
|
|
|
|
bitfield(int bits);
|
|
|
|
|
bitfield(int bits, bool val);
|
|
|
|
|
bitfield(char const* bytes, int bits);
|
|
|
|
|
bitfield(bitfield const& rhs);
|
|
|
|
|
|
|
|
|
|
void borrow_bytes(char* bytes, int bits);
|
|
|
|
|
~bitfield();
|
|
|
|
|
|
|
|
|
|
void assign(char const* bytes, int bits);
|
|
|
|
|
|
|
|
|
|
bool operator[](int index) const;
|
|
|
|
|
|
|
|
|
|
bool get_bit(int index) const;
|
|
|
|
|
|
|
|
|
|
void clear_bit(int index);
|
|
|
|
|
void set_bit(int index);
|
|
|
|
|
|
|
|
|
|
std::size_t size() const;
|
|
|
|
|
bool empty() const;
|
|
|
|
|
|
|
|
|
|
char const* bytes() const;
|
|
|
|
|
|
|
|
|
|
bitfield& operator=(bitfield const& rhs);
|
|
|
|
|
|
|
|
|
|
int count() const;
|
|
|
|
|
|
|
|
|
|
typedef const_iterator;
|
|
|
|
|
const_iterator begin() const;
|
|
|
|
|
const_iterator end() const;
|
|
|
|
|
|
|
|
|
|
void resize(int bits, bool val);
|
|
|
|
|
void set_all();
|
|
|
|
|
void clear_all();
|
|
|
|
|
void resize(int bits);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
|
|
|
|
hasher
|
|
|
|
|
======
|
|
|
|
|
|
|
|
|
|
This class creates sha1-hashes. Its declaration looks like this::
|
|
|
|
|
|
|
|
|
|
class hasher
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
hasher();
|
2006-04-25 23:04:48 +02:00
|
|
|
|
hasher(char const* data, unsigned int len);
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2006-04-25 23:04:48 +02:00
|
|
|
|
void update(char const* data, unsigned int len);
|
2004-01-07 01:48:02 +01:00
|
|
|
|
sha1_hash final();
|
|
|
|
|
void reset();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
You use it by first instantiating it, then call ``update()`` to feed it
|
|
|
|
|
with data. i.e. you don't have to keep the entire buffer of which you want to
|
|
|
|
|
create the hash in memory. You can feed the hasher parts of it at a time. When
|
|
|
|
|
You have fed the hasher with all the data, you call ``final()`` and it
|
|
|
|
|
will return the sha1-hash of the data.
|
|
|
|
|
|
2006-04-25 23:04:48 +02:00
|
|
|
|
The constructor that takes a ``char const*`` and an integer will construct the
|
|
|
|
|
sha1 context and feed it the data passed in.
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
If you want to reuse the hasher object once you have created a hash, you have to
|
|
|
|
|
call ``reset()`` to reinitialize it.
|
|
|
|
|
|
|
|
|
|
The sha1-algorithm used was implemented by Steve Reid and released as public domain.
|
2005-01-11 03:24:52 +01:00
|
|
|
|
For more info, see ``src/sha1.cpp``.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fingerprint
|
|
|
|
|
===========
|
|
|
|
|
|
|
|
|
|
The fingerprint class represents information about a client and its version. It is used
|
|
|
|
|
to encode this information into the client's peer id.
|
|
|
|
|
|
|
|
|
|
This is the class declaration::
|
|
|
|
|
|
|
|
|
|
struct fingerprint
|
|
|
|
|
{
|
2005-10-13 09:59:05 +02:00
|
|
|
|
fingerprint(const char* id_string, int major, int minor
|
|
|
|
|
, int revision, int tag);
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
|
|
|
|
std::string to_string() const;
|
|
|
|
|
|
2006-04-25 23:04:48 +02:00
|
|
|
|
char name[2];
|
2004-01-07 01:48:02 +01:00
|
|
|
|
char major_version;
|
|
|
|
|
char minor_version;
|
|
|
|
|
char revision_version;
|
|
|
|
|
char tag_version;
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
The constructor takes a ``char const*`` that should point to a string constant containing
|
2004-01-07 01:48:02 +01:00
|
|
|
|
exactly two characters. These are the characters that should be unique for your client. Make
|
|
|
|
|
sure not to clash with anybody else. Here are some taken id's:
|
|
|
|
|
|
|
|
|
|
+----------+-----------------------+
|
|
|
|
|
| id chars | client |
|
|
|
|
|
+==========+=======================+
|
|
|
|
|
| 'AZ' | Azureus |
|
|
|
|
|
+----------+-----------------------+
|
|
|
|
|
| 'LT' | libtorrent (default) |
|
|
|
|
|
+----------+-----------------------+
|
|
|
|
|
| 'BX' | BittorrentX |
|
|
|
|
|
+----------+-----------------------+
|
|
|
|
|
| 'MT' | Moonlight Torrent |
|
|
|
|
|
+----------+-----------------------+
|
2004-06-14 01:30:42 +02:00
|
|
|
|
| 'TS' | Torrent Storm |
|
|
|
|
|
+----------+-----------------------+
|
|
|
|
|
| 'SS' | Swarm Scope |
|
|
|
|
|
+----------+-----------------------+
|
|
|
|
|
| 'XT' | Xan Torrent |
|
|
|
|
|
+----------+-----------------------+
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2005-10-13 09:59:05 +02:00
|
|
|
|
There's currently an informal directory of client id's here__.
|
|
|
|
|
|
|
|
|
|
__ http://wiki.theory.org/BitTorrentSpecification#peer_id
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
|
|
|
|
The ``major``, ``minor``, ``revision`` and ``tag`` parameters are used to identify the
|
|
|
|
|
version of your client. All these numbers must be within the range [0, 9].
|
|
|
|
|
|
|
|
|
|
``to_string()`` will generate the actual string put in the peer-id, and return it.
|
|
|
|
|
|
2004-01-08 18:03:04 +01:00
|
|
|
|
|
2008-04-07 01:18:35 +02:00
|
|
|
|
UPnP and NAT-PMP
|
|
|
|
|
================
|
|
|
|
|
|
|
|
|
|
The ``upnp`` and ``natpmp`` classes contains the state for all UPnP and NAT-PMP mappings,
|
|
|
|
|
by default 1 or two mappings are made by libtorrent, one for the listen port and one
|
|
|
|
|
for the DHT port (UDP).
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
class upnp
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
enum protocol_type { none = 0, udp = 1, tcp = 2 };
|
|
|
|
|
int add_mapping(protocol_type p, int external_port, int local_port);
|
|
|
|
|
void delete_mapping(int mapping_index);
|
|
|
|
|
|
|
|
|
|
void discover_device();
|
|
|
|
|
void close();
|
|
|
|
|
|
|
|
|
|
std::string router_model();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class natpmp
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
enum protocol_type { none = 0, udp = 1, tcp = 2 };
|
|
|
|
|
int add_mapping(protocol_type p, int external_port, int local_port);
|
|
|
|
|
void delete_mapping(int mapping_index);
|
|
|
|
|
|
|
|
|
|
void close();
|
|
|
|
|
void rebind(address const& listen_interface);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
``discover_device()``, ``close()`` and ``rebind()`` are for internal uses and should
|
|
|
|
|
not be called directly by clients.
|
|
|
|
|
|
|
|
|
|
add_mapping
|
|
|
|
|
-----------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
int add_mapping(protocol_type p, int external_port, int local_port);
|
|
|
|
|
|
|
|
|
|
Attempts to add a port mapping for the specified protocol. Valid protocols are
|
|
|
|
|
``upnp::tcp`` and ``upnp::udp`` for the UPnP class and ``natpmp::tcp`` and
|
|
|
|
|
``natpmp::udp`` for the NAT-PMP class.
|
|
|
|
|
|
|
|
|
|
``external_port`` is the port on the external address that will be mapped. This
|
|
|
|
|
is a hint, you are not guaranteed that this port will be available, and it may
|
|
|
|
|
end up being something else. In the portmap_alert_ notification, the actual
|
|
|
|
|
external port is reported.
|
|
|
|
|
|
|
|
|
|
``local_port`` is the port in the local machine that the mapping should forward
|
|
|
|
|
to.
|
|
|
|
|
|
|
|
|
|
The return value is an index that identifies this port mapping. This is used
|
|
|
|
|
to refer to mappings that fails or succeeds in the portmap_error_alert_ and
|
|
|
|
|
portmap_alert_ respectively. If The mapping fails immediately, the return value
|
|
|
|
|
is -1, which means failure. There will not be any error alert notification for
|
|
|
|
|
mappings that fail with a -1 return value.
|
|
|
|
|
|
|
|
|
|
delete_mapping
|
|
|
|
|
--------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
void delete_mapping(int mapping_index);
|
|
|
|
|
|
|
|
|
|
This function removes a port mapping. ``mapping_index`` is the index that refers
|
|
|
|
|
to the mapping you want to remove, which was returned from add_mapping_.
|
|
|
|
|
|
|
|
|
|
router_model()
|
|
|
|
|
--------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
std::string router_model();
|
|
|
|
|
|
|
|
|
|
This is only available for UPnP routers. If the model is advertized by
|
|
|
|
|
the router, it can be queried through this function.
|
|
|
|
|
|
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
free functions
|
|
|
|
|
==============
|
|
|
|
|
|
|
|
|
|
identify_client()
|
|
|
|
|
-----------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
std::string identify_client(peer_id const& id);
|
2004-01-08 18:03:04 +01:00
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
This function is declared in the header ``<libtorrent/identify_client.hpp>``. It can can be used
|
|
|
|
|
to extract a string describing a client version from its peer-id. It will recognize most clients
|
|
|
|
|
that have this kind of identification in the peer-id.
|
|
|
|
|
|
2006-05-15 00:30:05 +02:00
|
|
|
|
|
|
|
|
|
client_fingerprint()
|
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
boost::optional<fingerprint> client_fingerprint(peer_id const& p);
|
|
|
|
|
|
|
|
|
|
Returns an optional fingerprint if any can be identified from the peer id. This can be used
|
2006-05-21 12:41:37 +02:00
|
|
|
|
to automate the identification of clients. It will not be able to identify peers with non-
|
2006-05-15 00:30:05 +02:00
|
|
|
|
standard encodings. Only Azureus style, Shadow's style and Mainline style. This function is
|
|
|
|
|
declared in the header ``<libtorrent/identify_client.hpp>``.
|
|
|
|
|
|
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
bdecode() bencode()
|
|
|
|
|
-------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
template<class InIt> entry bdecode(InIt start, InIt end);
|
|
|
|
|
template<class OutIt> void bencode(OutIt out, const entry& e);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
These functions will encode data to bencoded_ or decode bencoded_ data.
|
|
|
|
|
|
|
|
|
|
.. _bencoded: http://wiki.theory.org/index.php/BitTorrentSpecification
|
|
|
|
|
|
|
|
|
|
The entry_ class is the internal representation of the bencoded data
|
2006-05-21 12:41:37 +02:00
|
|
|
|
and it can be used to retrieve information, an entry_ can also be build by
|
2004-04-17 17:17:43 +02:00
|
|
|
|
the program and given to ``bencode()`` to encode it into the ``OutIt``
|
|
|
|
|
iterator.
|
|
|
|
|
|
|
|
|
|
The ``OutIt`` and ``InIt`` are iterators
|
2005-02-24 00:12:29 +01:00
|
|
|
|
(InputIterator_ and OutputIterator_ respectively). They
|
|
|
|
|
are templates and are usually instantiated as ostream_iterator_,
|
|
|
|
|
back_insert_iterator_ or istream_iterator_. These
|
2004-04-17 17:17:43 +02:00
|
|
|
|
functions will assume that the iterator refers to a character
|
|
|
|
|
(``char``). So, if you want to encode entry ``e`` into a buffer
|
|
|
|
|
in memory, you can do it like this::
|
|
|
|
|
|
|
|
|
|
std::vector<char> buffer;
|
2005-02-24 00:12:29 +01:00
|
|
|
|
bencode(std::back_inserter(buf), e);
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
|
|
|
|
.. _InputIterator: http://www.sgi.com/tech/stl/InputIterator.html
|
|
|
|
|
.. _OutputIterator: http://www.sgi.com/tech/stl/OutputIterator.html
|
|
|
|
|
.. _ostream_iterator: http://www.sgi.com/tech/stl/ostream_iterator.html
|
|
|
|
|
.. _back_insert_iterator: http://www.sgi.com/tech/stl/back_insert_iterator.html
|
|
|
|
|
.. _istream_iterator: http://www.sgi.com/tech/stl/istream_iterator.html
|
|
|
|
|
|
|
|
|
|
If you want to decode a torrent file from a buffer in memory, you can do it like this::
|
|
|
|
|
|
|
|
|
|
std::vector<char> buffer;
|
|
|
|
|
// ...
|
|
|
|
|
entry e = bdecode(buf.begin(), buf.end());
|
|
|
|
|
|
|
|
|
|
Or, if you have a raw char buffer::
|
|
|
|
|
|
|
|
|
|
const char* buf;
|
|
|
|
|
// ...
|
|
|
|
|
entry e = bdecode(buf, buf + data_size);
|
|
|
|
|
|
|
|
|
|
Now we just need to know how to retrieve information from the entry_.
|
|
|
|
|
|
|
|
|
|
If ``bdecode()`` encounters invalid encoded data in the range given to it
|
2009-03-21 05:33:53 +01:00
|
|
|
|
it will throw libtorrent_exception_.
|
2004-01-08 18:03:04 +01:00
|
|
|
|
|
2008-08-03 17:14:08 +02:00
|
|
|
|
add_magnet_uri()
|
|
|
|
|
----------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
torrent_handle add_magnet_uri(session& ses, std::string const& uri
|
|
|
|
|
add_torrent_params p);
|
2009-02-26 08:09:56 +01:00
|
|
|
|
torrent_handle add_magnet_uri(session& ses, std::string const& uri
|
|
|
|
|
add_torrent_params p, error_code& ec);
|
2008-08-03 17:14:08 +02:00
|
|
|
|
|
|
|
|
|
This function parses the magnet URI (``uri``) as a bittorrent magnet link,
|
|
|
|
|
and adds the torrent to the specified session (``ses``). It returns the
|
|
|
|
|
handle to the newly added torrent, or an invalid handle in case parsing
|
|
|
|
|
failed. To control some initial settings of the torrent, sepcify those in
|
|
|
|
|
the ``add_torrent_params``, ``p``. See `add_torrent()`_.
|
|
|
|
|
|
2009-02-26 08:09:56 +01:00
|
|
|
|
The overload that does not take an ``error_code`` throws an exception on
|
|
|
|
|
error and is not available when building without exception support.
|
|
|
|
|
|
2008-08-03 17:14:08 +02:00
|
|
|
|
For more information about magnet links, see `magnet links`_.
|
|
|
|
|
|
|
|
|
|
make_magnet_uri()
|
|
|
|
|
-----------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
std::string make_magnet_uri(torrent_handle const& handle);
|
|
|
|
|
|
|
|
|
|
Generates a magnet URI from the specified torrent. If the torrent
|
|
|
|
|
handle is invalid, an empty string is returned.
|
|
|
|
|
|
|
|
|
|
For more information about magnet links, see `magnet links`_.
|
|
|
|
|
|
2004-01-08 18:03:04 +01:00
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
alerts
|
|
|
|
|
======
|
|
|
|
|
|
|
|
|
|
The ``pop_alert()`` function on session is the interface for retrieving
|
2008-07-06 14:22:56 +02:00
|
|
|
|
alerts, warnings, messages and errors from libtorrent. If no alerts have
|
|
|
|
|
been posted by libtorrent ``pop_alert()`` will return a default initialized
|
|
|
|
|
``auto_ptr`` object. If there is an alert in libtorrent's queue, the alert
|
|
|
|
|
from the front of the queue is popped and returned.
|
|
|
|
|
You can then use the alert object and query
|
|
|
|
|
|
2008-12-14 20:47:02 +01:00
|
|
|
|
By default, only errors are reported. `set_alert_mask()`_ can be
|
2008-07-06 14:22:56 +02:00
|
|
|
|
used to specify which kinds of events should be reported. The alert mask
|
|
|
|
|
is a bitmask with the following bits:
|
|
|
|
|
|
|
|
|
|
+--------------------------------+---------------------------------------------------------------------+
|
|
|
|
|
| ``error_notification`` | Enables alerts that report an error. This includes: |
|
|
|
|
|
| | |
|
|
|
|
|
| | * tracker errors |
|
|
|
|
|
| | * tracker warnings |
|
|
|
|
|
| | * file errors |
|
|
|
|
|
| | * resume data failures |
|
|
|
|
|
| | * web seed errors |
|
|
|
|
|
| | * .torrent files errors |
|
|
|
|
|
| | * listen socket errors |
|
|
|
|
|
| | * port mapping errors |
|
|
|
|
|
+--------------------------------+---------------------------------------------------------------------+
|
|
|
|
|
| ``peer_notification`` | Enables alerts when peers send invalid requests, get banned or |
|
|
|
|
|
| | snubbed. |
|
|
|
|
|
+--------------------------------+---------------------------------------------------------------------+
|
|
|
|
|
| ``port_mapping_notification`` | Enables alerts for port mapping events. For NAT-PMP and UPnP. |
|
|
|
|
|
+--------------------------------+---------------------------------------------------------------------+
|
|
|
|
|
| ``storage_notification`` | Enables alerts for events related to the storage. File errors and |
|
|
|
|
|
| | synchronization events for moving the storage, renaming files etc. |
|
|
|
|
|
+--------------------------------+---------------------------------------------------------------------+
|
|
|
|
|
| ``tracker_notification`` | Enables all tracker events. Includes announcing to trackers, |
|
|
|
|
|
| | receiving responses, warnings and errors. |
|
|
|
|
|
+--------------------------------+---------------------------------------------------------------------+
|
|
|
|
|
| ``debug_notification`` | Low level alerts for when peers are connected and disconnected. |
|
|
|
|
|
+--------------------------------+---------------------------------------------------------------------+
|
|
|
|
|
| ``status_notification`` | Enables alerts for when a torrent or the session changes state. |
|
|
|
|
|
+--------------------------------+---------------------------------------------------------------------+
|
|
|
|
|
| ``progress_notification`` | Alerts for when blocks are requested and completed. Also when |
|
|
|
|
|
| | pieces are completed. |
|
|
|
|
|
+--------------------------------+---------------------------------------------------------------------+
|
|
|
|
|
| ``ip_block_notification`` | Alerts when a peer is blocked by the ip blocker or port blocker. |
|
|
|
|
|
+--------------------------------+---------------------------------------------------------------------+
|
2008-08-19 17:04:14 +02:00
|
|
|
|
| ``performance_warning`` | Alerts when some limit is reached that might limit the download |
|
|
|
|
|
| | or upload rate. |
|
|
|
|
|
+--------------------------------+---------------------------------------------------------------------+
|
2008-07-06 14:22:56 +02:00
|
|
|
|
| ``all_categories`` | The full bitmask, representing all available categories. |
|
|
|
|
|
+--------------------------------+---------------------------------------------------------------------+
|
|
|
|
|
|
|
|
|
|
Every alert belongs to one or more category. There is a small cost involved in posting alerts. Only
|
|
|
|
|
alerts that belong to an enabled category are posted. Setting the alert bitmask to 0 will disable
|
|
|
|
|
all alerts
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2009-11-02 04:34:16 +01:00
|
|
|
|
When you get an alert, you can use ``alert_cast<>`` to attempt to cast the pointer to a
|
|
|
|
|
more specific alert type, to be queried for more information about the alert. ``alert_cast``
|
|
|
|
|
has the followinf signature::
|
|
|
|
|
|
|
|
|
|
template <T> T* alert_cast(alert* a);
|
|
|
|
|
template <T> T const* alert_cast(alert const* a);
|
|
|
|
|
|
|
|
|
|
You can also use a dispatcher_ mechanism that's available in libtorrent.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2004-03-08 13:26:07 +01:00
|
|
|
|
All alert types are defined in the ``<libtorrent/alert_types.hpp>`` header file.
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
The ``alert`` class is the base class that specific messages are derived from. This
|
2008-07-06 14:22:56 +02:00
|
|
|
|
is its synopsis:
|
|
|
|
|
|
|
|
|
|
.. parsed-literal::
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
|
|
|
|
class alert
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
2008-07-06 14:22:56 +02:00
|
|
|
|
enum category_t
|
|
|
|
|
{
|
|
|
|
|
error_notification = *implementation defined*,
|
|
|
|
|
peer_notification = *implementation defined*,
|
|
|
|
|
port_mapping_notification = *implementation defined*,
|
|
|
|
|
storage_notification = *implementation defined*,
|
|
|
|
|
tracker_notification = *implementation defined*,
|
|
|
|
|
debug_notification = *implementation defined*,
|
|
|
|
|
status_notification = *implementation defined*,
|
|
|
|
|
progress_notification = *implementation defined*,
|
|
|
|
|
ip_block_notification = *implementation defined*,
|
2008-08-19 17:04:14 +02:00
|
|
|
|
performance_warning = *implementation defined*,
|
2008-09-20 19:42:25 +02:00
|
|
|
|
dht_notification = *implementation defined*,
|
2008-07-06 14:22:56 +02:00
|
|
|
|
|
|
|
|
|
all_categories = *implementation defined*
|
|
|
|
|
};
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2008-07-06 14:22:56 +02:00
|
|
|
|
ptime timestamp() const;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2008-07-06 14:22:56 +02:00
|
|
|
|
virtual ~alert();
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2009-10-30 04:21:25 +01:00
|
|
|
|
virtual int type() const = 0;
|
2008-07-06 14:22:56 +02:00
|
|
|
|
virtual std::string message() const = 0;
|
|
|
|
|
virtual char const* what() const = 0;
|
|
|
|
|
virtual int category() const = 0;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
virtual std::auto_ptr<alert> clone() const = 0;
|
|
|
|
|
};
|
|
|
|
|
|
2009-10-30 04:21:25 +01:00
|
|
|
|
``type()`` returns an integer that is unique to this alert type. It can be
|
|
|
|
|
compared against a specific alert by querying a static constant called ``alert_type``
|
|
|
|
|
in the alert. It can be used to determine the run-time type of an alert* in
|
|
|
|
|
order to cast to that alert type and access specific members.
|
|
|
|
|
|
|
|
|
|
e.g::
|
|
|
|
|
|
|
|
|
|
std::auto_ptr<alert> a = ses.pop_alert();
|
|
|
|
|
switch (a->type())
|
|
|
|
|
{
|
|
|
|
|
case read_piece_alert::alert_type:
|
|
|
|
|
{
|
|
|
|
|
read_piece_alert* p = (read_piece_alert*)a.get();
|
|
|
|
|
// use p
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case file_renamed_alert::alert_type:
|
|
|
|
|
{
|
|
|
|
|
// etc...
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-07-06 14:22:56 +02:00
|
|
|
|
``what()`` returns a string literal describing the type of the alert. It does
|
|
|
|
|
not include any information that might be bundled with the alert.
|
|
|
|
|
|
|
|
|
|
``category()`` returns a bitmask specifying which categories this alert belong to.
|
|
|
|
|
|
|
|
|
|
``clone()`` returns a pointer to a copy of the alert.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2008-07-06 14:22:56 +02:00
|
|
|
|
``message()`` generate a string describing the alert and the information bundled
|
|
|
|
|
with it. This is mainly intended for debug and development use. It is not suitable
|
|
|
|
|
to use this for applications that may be localized. Instead, handle each alert
|
|
|
|
|
type individually and extract and render the information from the alert depending
|
|
|
|
|
on the locale.
|
|
|
|
|
|
|
|
|
|
There's another alert base class that most alerts derives from, all the
|
2007-01-16 06:05:52 +01:00
|
|
|
|
alerts that are generated for a specific torrent are derived from::
|
|
|
|
|
|
|
|
|
|
struct torrent_alert: alert
|
|
|
|
|
{
|
2008-07-06 14:22:56 +02:00
|
|
|
|
// ...
|
2007-01-16 06:05:52 +01:00
|
|
|
|
torrent_handle handle;
|
|
|
|
|
};
|
|
|
|
|
|
2008-07-06 14:22:56 +02:00
|
|
|
|
There's also a base class for all alerts referring to tracker events::
|
|
|
|
|
|
|
|
|
|
struct tracker_alert: torrent_alert
|
|
|
|
|
{
|
|
|
|
|
// ...
|
|
|
|
|
std::string url;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
The specific alerts are:
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2008-12-14 20:47:02 +01:00
|
|
|
|
read_piece_alert
|
|
|
|
|
----------------
|
|
|
|
|
|
|
|
|
|
This alert is posted when the asynchronous read operation initiated by
|
|
|
|
|
a call to `read_piece()`_ is completed. If the read failed, the torrent
|
|
|
|
|
is paused and an error state is set and the buffer member of the alert
|
|
|
|
|
is 0. If successful, ``buffer`` points to a buffer containing all the data
|
|
|
|
|
of the piece. ``piece`` is the piece index that was read. ``size`` is the
|
|
|
|
|
number of bytes that was read.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct read_piece_alert: torrent_alert
|
|
|
|
|
{
|
|
|
|
|
// ...
|
|
|
|
|
boost::shared_ptr<char> buffer;
|
|
|
|
|
int piece;
|
|
|
|
|
int size;
|
|
|
|
|
};
|
|
|
|
|
|
2008-03-29 23:45:55 +01:00
|
|
|
|
external_ip_alert
|
|
|
|
|
-----------------
|
|
|
|
|
|
|
|
|
|
Whenever libtorrent learns about the machines external IP, this alert is
|
|
|
|
|
generated. The external IP address can be acquired from the tracker (if it
|
|
|
|
|
supports that) or from peers that supports the extension protocol.
|
|
|
|
|
The address can be accessed through the ``external_address`` member.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct external_ip_alert: alert
|
|
|
|
|
{
|
2008-07-06 14:22:56 +02:00
|
|
|
|
// ...
|
2008-03-29 23:45:55 +01:00
|
|
|
|
address external_address;
|
|
|
|
|
};
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2004-01-26 11:29:00 +01:00
|
|
|
|
listen_failed_alert
|
|
|
|
|
-------------------
|
|
|
|
|
|
|
|
|
|
This alert is generated when none of the ports, given in the port range, to
|
2009-08-20 04:40:18 +02:00
|
|
|
|
session_ can be opened for listening. The ``endpoint`` member is the
|
|
|
|
|
interface and port that failed, ``error`` is the error code describing
|
|
|
|
|
the failure.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct listen_failed_alert: alert
|
|
|
|
|
{
|
|
|
|
|
// ...
|
|
|
|
|
tcp::endpoint endpoint;
|
|
|
|
|
error_code error;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
listen_succeeded_alert
|
|
|
|
|
----------------------
|
|
|
|
|
|
|
|
|
|
This alert is posted when the listen port succeeds to be opened on a
|
|
|
|
|
particular interface. ``endpoint`` is the endpoint that successfully
|
|
|
|
|
was opened for listening.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct listen_succeeded_alert: alert
|
|
|
|
|
{
|
|
|
|
|
// ...
|
|
|
|
|
tcp::endpoint endpoint;
|
|
|
|
|
};
|
2004-01-26 11:29:00 +01:00
|
|
|
|
|
|
|
|
|
|
2007-03-16 09:25:08 +01:00
|
|
|
|
portmap_error_alert
|
|
|
|
|
-------------------
|
|
|
|
|
|
|
|
|
|
This alert is generated when a NAT router was successfully found but some
|
|
|
|
|
part of the port mapping request failed. It contains a text message that
|
|
|
|
|
may help the user figure out what is wrong. This alert is not generated in
|
|
|
|
|
case it appears the client is not running on a NAT:ed network or if it
|
|
|
|
|
appears there is no NAT router that can be remote controlled to add port
|
|
|
|
|
mappings.
|
|
|
|
|
|
2008-04-07 01:18:35 +02:00
|
|
|
|
``mapping`` refers to the mapping index of the port map that failed, i.e.
|
|
|
|
|
the index returned from add_mapping_.
|
|
|
|
|
|
2009-10-30 04:21:25 +01:00
|
|
|
|
``map_type`` is 0 for NAT-PMP and 1 for UPnP.
|
2008-04-07 01:18:35 +02:00
|
|
|
|
|
2009-06-12 18:40:38 +02:00
|
|
|
|
``error`` tells you what failed.
|
2007-03-16 09:25:08 +01:00
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct portmap_error_alert: alert
|
|
|
|
|
{
|
2008-07-06 14:22:56 +02:00
|
|
|
|
// ...
|
2008-04-07 01:18:35 +02:00
|
|
|
|
int mapping;
|
|
|
|
|
int type;
|
2009-06-12 18:40:38 +02:00
|
|
|
|
error_code error;
|
2007-03-16 09:25:08 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
portmap_alert
|
|
|
|
|
-------------
|
|
|
|
|
|
|
|
|
|
This alert is generated when a NAT router was successfully found and
|
|
|
|
|
a port was successfully mapped on it. On a NAT:ed network with a NAT-PMP
|
|
|
|
|
capable router, this is typically generated once when mapping the TCP
|
2008-07-06 14:22:56 +02:00
|
|
|
|
port and, if DHT is enabled, when the UDP port is mapped.
|
2007-03-16 09:25:08 +01:00
|
|
|
|
|
2008-04-07 01:18:35 +02:00
|
|
|
|
``mapping`` refers to the mapping index of the port map that failed, i.e.
|
|
|
|
|
the index returned from add_mapping_.
|
|
|
|
|
|
|
|
|
|
``external_port`` is the external port allocated for the mapping.
|
|
|
|
|
|
|
|
|
|
``type`` is 0 for NAT-PMP and 1 for UPnP.
|
|
|
|
|
|
2007-03-16 09:25:08 +01:00
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct portmap_alert: alert
|
|
|
|
|
{
|
2008-07-06 14:22:56 +02:00
|
|
|
|
// ...
|
2008-04-07 01:18:35 +02:00
|
|
|
|
int mapping;
|
|
|
|
|
int external_port;
|
2009-10-30 04:21:25 +01:00
|
|
|
|
int map_type;
|
2007-03-16 09:25:08 +01:00
|
|
|
|
};
|
2004-01-26 11:29:00 +01:00
|
|
|
|
|
2008-10-22 03:12:14 +02:00
|
|
|
|
portmap_log_alert
|
|
|
|
|
-----------------
|
|
|
|
|
|
|
|
|
|
This alert is generated to log informational events related to either
|
|
|
|
|
UPnP or NAT-PMP. They contain a log line and the type (0 = NAT-PMP
|
|
|
|
|
and 1 = UPnP). Displaying these messages to an end user is only useful
|
|
|
|
|
for debugging the UPnP or NAT-PMP implementation.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct portmap_log_alert: alert
|
|
|
|
|
{
|
|
|
|
|
//...
|
2009-10-30 04:21:25 +01:00
|
|
|
|
int map_type;
|
2008-10-22 03:12:14 +02:00
|
|
|
|
std::string msg;
|
|
|
|
|
};
|
|
|
|
|
|
2004-01-26 11:29:00 +01:00
|
|
|
|
file_error_alert
|
|
|
|
|
----------------
|
|
|
|
|
|
|
|
|
|
If the storage fails to read or write files that it needs access to, this alert is
|
2008-07-06 14:22:56 +02:00
|
|
|
|
generated and the torrent is paused.
|
|
|
|
|
|
|
|
|
|
``file`` is the path to the file that was accessed when the error occurred.
|
|
|
|
|
|
2009-06-10 10:30:55 +02:00
|
|
|
|
``error`` is the error code describing the error.
|
2004-01-26 11:29:00 +01:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2007-01-16 06:05:52 +01:00
|
|
|
|
struct file_error_alert: torrent_alert
|
2004-01-26 11:29:00 +01:00
|
|
|
|
{
|
2008-07-06 14:22:56 +02:00
|
|
|
|
// ...
|
|
|
|
|
std::string file;
|
2009-06-10 10:30:55 +02:00
|
|
|
|
error_code error;
|
2004-01-26 11:29:00 +01:00
|
|
|
|
};
|
|
|
|
|
|
2009-05-07 08:41:41 +02:00
|
|
|
|
file_renamed_alert
|
2009-07-04 06:58:24 +02:00
|
|
|
|
------------------
|
2009-05-07 08:41:41 +02:00
|
|
|
|
|
|
|
|
|
This is posted as a response to a ``torrent_handle::rename_file`` call, if the rename
|
|
|
|
|
operation succeeds.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct file_renamed_alert: torrent_alert
|
|
|
|
|
{
|
|
|
|
|
// ...
|
|
|
|
|
std::string name;
|
|
|
|
|
int index;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
The ``index`` member refers to the index of the file that was renamed,
|
|
|
|
|
``name`` is the new name of the file.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
file_rename_failed_alert
|
|
|
|
|
------------------------
|
|
|
|
|
|
|
|
|
|
This is posted as a response to a ``torrent_handle::rename_file`` call, if the rename
|
|
|
|
|
operation failed.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct file_rename_failed_alert: torrent_alert
|
|
|
|
|
{
|
|
|
|
|
// ...
|
|
|
|
|
int index;
|
|
|
|
|
error_code error;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
The ``index`` member refers to the index of the file that was supposed to be renamed,
|
|
|
|
|
``error`` is the error code returned from the filesystem.
|
2004-01-26 11:29:00 +01:00
|
|
|
|
|
2005-06-06 12:33:44 +02:00
|
|
|
|
tracker_announce_alert
|
|
|
|
|
----------------------
|
|
|
|
|
|
|
|
|
|
This alert is generated each time a tracker announce is sent (or attempted to be sent).
|
2008-07-06 14:22:56 +02:00
|
|
|
|
There are no extra data members in this alert. The url can be found in the base class
|
|
|
|
|
however.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2008-07-11 14:00:29 +02:00
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct tracker_announce_alert: tracker_alert
|
|
|
|
|
{
|
|
|
|
|
// ...
|
|
|
|
|
int event;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Event specifies what event was sent to the tracker. It is defined as:
|
|
|
|
|
|
|
|
|
|
0. None
|
|
|
|
|
1. Completed
|
|
|
|
|
2. Started
|
|
|
|
|
3. Stopped
|
|
|
|
|
|
2008-04-23 03:54:21 +02:00
|
|
|
|
|
|
|
|
|
tracker_error_alert
|
|
|
|
|
-------------------
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
This alert is generated on tracker time outs, premature disconnects, invalid response or
|
|
|
|
|
a HTTP response other than "200 OK". From the alert you can get the handle to the torrent
|
2008-07-06 14:22:56 +02:00
|
|
|
|
the tracker belongs to.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2004-09-12 12:12:16 +02:00
|
|
|
|
The ``times_in_row`` member says how many times in a row this tracker has failed.
|
2005-04-21 01:00:27 +02:00
|
|
|
|
``status_code`` is the code returned from the HTTP server. 401 means the tracker needs
|
|
|
|
|
authentication, 404 means not found etc. If the tracker timed out, the code will be set
|
|
|
|
|
to 0.
|
2004-09-12 12:12:16 +02:00
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
::
|
|
|
|
|
|
2008-04-23 03:54:21 +02:00
|
|
|
|
struct tracker_error_alert: tracker_alert
|
2004-01-07 01:48:02 +01:00
|
|
|
|
{
|
2008-07-06 14:22:56 +02:00
|
|
|
|
// ...
|
2004-09-12 12:12:16 +02:00
|
|
|
|
int times_in_row;
|
2005-04-21 01:00:27 +02:00
|
|
|
|
int status_code;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2005-03-10 10:59:12 +01:00
|
|
|
|
tracker_reply_alert
|
|
|
|
|
-------------------
|
|
|
|
|
|
|
|
|
|
This alert is only for informational purpose. It is generated when a tracker announce
|
2007-02-01 08:33:04 +01:00
|
|
|
|
succeeds. It is generated regardless what kind of tracker was used, be it UDP, HTTP or
|
2008-07-06 14:22:56 +02:00
|
|
|
|
the DHT.
|
2005-03-10 10:59:12 +01:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2008-04-23 03:54:21 +02:00
|
|
|
|
struct tracker_reply_alert: tracker_alert
|
2005-03-10 10:59:12 +01:00
|
|
|
|
{
|
2008-07-06 14:22:56 +02:00
|
|
|
|
// ...
|
2007-02-01 08:33:04 +01:00
|
|
|
|
int num_peers;
|
2005-03-10 10:59:12 +01:00
|
|
|
|
};
|
2007-02-01 08:33:04 +01:00
|
|
|
|
|
|
|
|
|
The ``num_peers`` tells how many peers were returned from the tracker. This is
|
|
|
|
|
not necessarily all new peers, some of them may already be connected.
|
2008-07-06 14:22:56 +02:00
|
|
|
|
|
|
|
|
|
dht_reply_alert
|
2008-10-06 01:03:33 +02:00
|
|
|
|
---------------
|
2008-07-06 14:22:56 +02:00
|
|
|
|
|
|
|
|
|
This alert is generated each time the DHT receives peers from a node. ``num_peers``
|
|
|
|
|
is the number of peers we received in this packet. Typically these packets are
|
|
|
|
|
received from multiple DHT nodes, and so the alerts are typically generated
|
|
|
|
|
a few at a time.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct dht_reply_alert: tracker_alert
|
|
|
|
|
{
|
|
|
|
|
// ...
|
|
|
|
|
int num_peers;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2005-08-11 01:32:39 +02:00
|
|
|
|
tracker_warning_alert
|
|
|
|
|
---------------------
|
|
|
|
|
|
|
|
|
|
This alert is triggered if the tracker reply contains a warning field. Usually this
|
|
|
|
|
means that the tracker announce was successful, but the tracker has a message to
|
2008-07-06 14:22:56 +02:00
|
|
|
|
the client. The ``msg`` string in the alert contains the warning message from
|
|
|
|
|
the tracker.
|
2005-08-11 01:32:39 +02:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2008-04-23 03:54:21 +02:00
|
|
|
|
struct tracker_warning_alert: tracker_alert
|
2005-08-11 01:32:39 +02:00
|
|
|
|
{
|
2008-07-06 14:22:56 +02:00
|
|
|
|
// ...
|
|
|
|
|
std::string msg;
|
2005-08-11 01:32:39 +02:00
|
|
|
|
};
|
|
|
|
|
|
2007-11-24 04:10:20 +01:00
|
|
|
|
scrape_reply_alert
|
|
|
|
|
------------------
|
|
|
|
|
|
2008-07-06 14:22:56 +02:00
|
|
|
|
This alert is generated when a scrape request succeeds. ``incomplete``
|
|
|
|
|
and ``complete`` is the data returned in the scrape response. These numbers
|
|
|
|
|
may be -1 if the reponse was malformed.
|
|
|
|
|
|
2007-11-24 04:10:20 +01:00
|
|
|
|
::
|
|
|
|
|
|
2008-04-23 03:54:21 +02:00
|
|
|
|
struct scrape_reply_alert: tracker_alert
|
2007-11-24 04:10:20 +01:00
|
|
|
|
{
|
2008-07-06 14:22:56 +02:00
|
|
|
|
// ...
|
2007-11-24 04:10:20 +01:00
|
|
|
|
int incomplete;
|
|
|
|
|
int complete;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scrape_failed_alert
|
|
|
|
|
-------------------
|
|
|
|
|
|
2008-07-06 14:22:56 +02:00
|
|
|
|
If a scrape request fails, this alert is generated. This might be due
|
|
|
|
|
to the tracker timing out, refusing connection or returning an http response
|
|
|
|
|
code indicating an error. ``msg`` contains a message describing the error.
|
|
|
|
|
|
2007-11-24 04:10:20 +01:00
|
|
|
|
::
|
|
|
|
|
|
2008-04-23 03:54:21 +02:00
|
|
|
|
struct scrape_failed_alert: tracker_alert
|
2007-11-24 04:10:20 +01:00
|
|
|
|
{
|
2008-07-06 14:22:56 +02:00
|
|
|
|
// ...
|
|
|
|
|
std::string msg;
|
2007-11-24 04:10:20 +01:00
|
|
|
|
};
|
|
|
|
|
|
2006-04-25 23:04:48 +02:00
|
|
|
|
url_seed_alert
|
|
|
|
|
--------------
|
|
|
|
|
|
2008-07-06 14:22:56 +02:00
|
|
|
|
This alert is generated when a HTTP seed name lookup fails.
|
2006-04-25 23:04:48 +02:00
|
|
|
|
|
|
|
|
|
It contains ``url`` to the HTTP seed that failed along with an error message.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2007-01-16 06:05:52 +01:00
|
|
|
|
struct url_seed_alert: torrent_alert
|
2006-04-25 23:04:48 +02:00
|
|
|
|
{
|
2008-07-06 14:22:56 +02:00
|
|
|
|
// ...
|
2006-04-25 23:04:48 +02:00
|
|
|
|
std::string url;
|
|
|
|
|
};
|
|
|
|
|
|
2005-08-11 01:32:39 +02:00
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
hash_failed_alert
|
|
|
|
|
-----------------
|
|
|
|
|
|
|
|
|
|
This alert is generated when a finished piece fails its hash check. You can get the handle
|
|
|
|
|
to the torrent which got the failed piece and the index of the piece itself from the alert.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2007-01-16 06:05:52 +01:00
|
|
|
|
struct hash_failed_alert: torrent_alert
|
2004-01-07 01:48:02 +01:00
|
|
|
|
{
|
2008-07-06 14:22:56 +02:00
|
|
|
|
// ...
|
2004-01-07 01:48:02 +01:00
|
|
|
|
int piece_index;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2009-06-12 18:40:38 +02:00
|
|
|
|
peer_alert
|
|
|
|
|
----------
|
|
|
|
|
|
|
|
|
|
The peer alert is a base class for alerts that refer to a specific peer. It includes all
|
|
|
|
|
the information to identify the peer. i.e. ``ip`` and ``peer-id``.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct peer_alert: torrent_alert
|
|
|
|
|
{
|
|
|
|
|
// ...
|
|
|
|
|
tcp::endpoint ip;
|
|
|
|
|
peer_id pid;
|
|
|
|
|
};
|
|
|
|
|
|
2009-08-20 04:40:18 +02:00
|
|
|
|
peer_connect_alert
|
|
|
|
|
------------------
|
|
|
|
|
|
|
|
|
|
This alert is posted every time an outgoing peer connect attempts succeeds.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct peer_connect_alert: peer_alert
|
|
|
|
|
{
|
|
|
|
|
// ...
|
|
|
|
|
};
|
|
|
|
|
|
2004-03-21 03:03:37 +01:00
|
|
|
|
peer_ban_alert
|
|
|
|
|
--------------
|
|
|
|
|
|
|
|
|
|
This alert is generated when a peer is banned because it has sent too many corrupt pieces
|
2008-07-06 14:22:56 +02:00
|
|
|
|
to us. ``ip`` is the endpoint to the peer that was banned.
|
2004-03-21 03:03:37 +01:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2009-06-12 18:40:38 +02:00
|
|
|
|
struct peer_ban_alert: peer_alert
|
|
|
|
|
{
|
|
|
|
|
// ...
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
peer_snubbed_alert
|
|
|
|
|
------------------
|
|
|
|
|
|
|
|
|
|
This alert is generated when a peer is snubbed, when it stops sending data when we request
|
|
|
|
|
it.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct peer_snubbed_alert: peer_alert
|
|
|
|
|
{
|
|
|
|
|
// ...
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
peer_unsnubbed_alert
|
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
|
|
This alert is generated when a peer is unsnubbed. Essentially when it was snubbed for stalling
|
|
|
|
|
sending data, and now it started sending data again.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct peer_unsnubbed_alert: peer_alert
|
2004-03-21 03:03:37 +01:00
|
|
|
|
{
|
2008-07-06 14:22:56 +02:00
|
|
|
|
// ...
|
2004-03-21 03:03:37 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
peer_error_alert
|
|
|
|
|
----------------
|
|
|
|
|
|
|
|
|
|
This alert is generated when a peer sends invalid data over the peer-peer protocol. The peer
|
2008-07-06 14:22:56 +02:00
|
|
|
|
will be disconnected, but you get its ip address from the alert, to identify it.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2009-06-12 18:40:38 +02:00
|
|
|
|
The ``error_code`` tells you what error caused this alert.
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
::
|
|
|
|
|
|
2009-06-12 18:40:38 +02:00
|
|
|
|
struct peer_error_alert: peer_alert
|
2004-01-07 01:48:02 +01:00
|
|
|
|
{
|
2008-07-06 14:22:56 +02:00
|
|
|
|
// ...
|
2009-06-12 18:40:38 +02:00
|
|
|
|
error_code error;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
peer_connected_alert
|
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
|
|
This alert is generated when a peer is connected.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct peer_connected_alert: peer_alert
|
|
|
|
|
{
|
|
|
|
|
// ...
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
peer_disconnected_alert
|
|
|
|
|
-----------------------
|
|
|
|
|
|
|
|
|
|
This alert is generated when a peer is disconnected for any reason (other than the ones
|
|
|
|
|
covered by ``peer_error_alert``).
|
|
|
|
|
|
|
|
|
|
The ``error_code`` tells you what error caused peer to disconnect.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct peer_disconnected_alert: peer_alert
|
|
|
|
|
{
|
|
|
|
|
// ...
|
|
|
|
|
error_code error;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2004-01-13 04:08:59 +01:00
|
|
|
|
invalid_request_alert
|
|
|
|
|
---------------------
|
|
|
|
|
|
2008-07-06 14:22:56 +02:00
|
|
|
|
This is a debug alert that is generated by an incoming invalid piece request.
|
|
|
|
|
``<EFBFBD>p`` is the address of the peer and the ``request`` is the actual incoming
|
|
|
|
|
request from the peer.
|
2004-01-13 04:08:59 +01:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2009-06-12 18:40:38 +02:00
|
|
|
|
struct invalid_request_alert: peer_alert
|
2004-01-13 04:08:59 +01:00
|
|
|
|
{
|
2009-06-12 18:40:38 +02:00
|
|
|
|
// ...
|
2004-01-13 04:08:59 +01:00
|
|
|
|
peer_request request;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2004-01-31 11:20:19 +01:00
|
|
|
|
struct peer_request
|
|
|
|
|
{
|
|
|
|
|
int piece;
|
|
|
|
|
int start;
|
|
|
|
|
int length;
|
2004-03-28 19:45:37 +02:00
|
|
|
|
bool operator==(peer_request const& r) const;
|
2004-01-31 11:20:19 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The ``peer_request`` contains the values the client sent in its ``request`` message. ``piece`` is
|
|
|
|
|
the index of the piece it want data from, ``start`` is the offset within the piece where the data
|
|
|
|
|
should be read, and ``length`` is the amount of data it wants.
|
|
|
|
|
|
2009-06-12 18:40:38 +02:00
|
|
|
|
request_dropped_alert
|
|
|
|
|
---------------------
|
|
|
|
|
|
|
|
|
|
This alert is generated when a peer rejects or ignores a piece request.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct request_dropped_alert: peer_alert
|
|
|
|
|
{
|
|
|
|
|
// ...
|
|
|
|
|
int block_index;
|
|
|
|
|
int piece_index;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
block_timeout_alert
|
|
|
|
|
-------------------
|
|
|
|
|
|
|
|
|
|
This alert is generated when a block request times out.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct block_timeout_alert: peer_alert
|
|
|
|
|
{
|
|
|
|
|
// ...
|
|
|
|
|
int block_index;
|
|
|
|
|
int piece_index;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
block_finished_alert
|
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
|
|
This alert is generated when a block request receives a response.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct block_finished_alert: peer_alert
|
|
|
|
|
{
|
|
|
|
|
// ...
|
|
|
|
|
int block_index;
|
|
|
|
|
int piece_index;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2009-07-04 06:58:24 +02:00
|
|
|
|
file_completed_alert
|
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
|
|
This is posted whenever an individual file completes its download. i.e.
|
|
|
|
|
All pieces overlapping this file have passed their hash check.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct file_completed_alert: torrent_alert
|
|
|
|
|
{
|
|
|
|
|
// ...
|
|
|
|
|
int index;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
The ``index`` member refers to the index of the file that completed.
|
|
|
|
|
|
|
|
|
|
|
2009-06-12 18:40:38 +02:00
|
|
|
|
block_downloading_alert
|
|
|
|
|
-----------------------
|
|
|
|
|
|
|
|
|
|
This alert is generated when a block request is sent to a peer.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct block_downloading_alert: peer_alert
|
|
|
|
|
{
|
|
|
|
|
// ...
|
|
|
|
|
int block_index;
|
|
|
|
|
int piece_index;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unwanted_block_alert
|
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
|
|
This alert is generated when a block is received that was not requested or
|
|
|
|
|
whose request timed out.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct unwanted_block_alert: peer_alert
|
|
|
|
|
{
|
|
|
|
|
// ...
|
|
|
|
|
int block_index;
|
|
|
|
|
int piece_index;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
torrent_delete_failed_alert
|
|
|
|
|
---------------------------
|
|
|
|
|
|
|
|
|
|
This alert is generated when a request to delete the files of a torrent fails.
|
|
|
|
|
|
|
|
|
|
The ``error_code`` tells you why it failed.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct torrent_delete_failed_alert: torrent_alert
|
|
|
|
|
{
|
|
|
|
|
// ...
|
|
|
|
|
error_code error;
|
|
|
|
|
};
|
|
|
|
|
|
2004-01-19 20:36:55 +01:00
|
|
|
|
torrent_finished_alert
|
|
|
|
|
----------------------
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2004-01-19 20:36:55 +01:00
|
|
|
|
This alert is generated when a torrent switches from being a downloader to a seed.
|
|
|
|
|
It will only be generated once per torrent. It contains a torrent_handle to the
|
2008-07-06 14:22:56 +02:00
|
|
|
|
torrent in question.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2008-07-06 14:22:56 +02:00
|
|
|
|
There are no additional data members in this alert.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2005-10-17 15:45:53 +02:00
|
|
|
|
|
2008-08-19 17:04:14 +02:00
|
|
|
|
performance_alert
|
|
|
|
|
-----------------
|
|
|
|
|
|
|
|
|
|
This alert is generated when a limit is reached that might have a negative impact on
|
|
|
|
|
upload or download rate performance.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct performance_alert: torrent_alert
|
|
|
|
|
{
|
|
|
|
|
// ...
|
|
|
|
|
|
|
|
|
|
enum performance_warning_t
|
|
|
|
|
{
|
|
|
|
|
outstanding_disk_buffer_limit_reached,
|
|
|
|
|
outstanding_request_limit_reached,
|
2008-10-28 07:45:42 +01:00
|
|
|
|
upload_limit_too_low,
|
2009-08-17 22:29:09 +02:00
|
|
|
|
download_limit_too_low,
|
|
|
|
|
send_buffer_watermark_too_low
|
2008-08-19 17:04:14 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
performance_warning_t warning_code;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2008-12-01 01:19:05 +01:00
|
|
|
|
state_changed_alert
|
|
|
|
|
-------------------
|
|
|
|
|
|
|
|
|
|
Generated whenever a torrent changes its state.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct state_changed_alert: torrent_alert
|
|
|
|
|
{
|
|
|
|
|
// ...
|
|
|
|
|
|
|
|
|
|
torrent_status::state_t state;
|
|
|
|
|
torrent_status::state_t prev_state;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
``state`` is the new state of the torrent. ``prev_state`` is the previous state.
|
|
|
|
|
|
|
|
|
|
|
2005-10-17 15:45:53 +02:00
|
|
|
|
metadata_failed_alert
|
|
|
|
|
---------------------
|
|
|
|
|
|
|
|
|
|
This alert is generated when the metadata has been completely received and the info-hash
|
|
|
|
|
failed to match it. i.e. the metadata that was received was corrupt. libtorrent will
|
|
|
|
|
automatically retry to fetch it in this case. This is only relevant when running a
|
|
|
|
|
torrent-less download, with the metadata extension provided by libtorrent.
|
|
|
|
|
|
2008-07-06 14:22:56 +02:00
|
|
|
|
There are no additional data members in this alert.
|
2005-10-17 15:45:53 +02:00
|
|
|
|
|
|
|
|
|
|
2004-09-10 02:47:30 +02:00
|
|
|
|
metadata_received_alert
|
|
|
|
|
-----------------------
|
|
|
|
|
|
|
|
|
|
This alert is generated when the metadata has been completely received and the torrent
|
2004-09-16 03:14:16 +02:00
|
|
|
|
can start downloading. It is not generated on torrents that are started with metadata, but
|
2004-09-10 02:47:30 +02:00
|
|
|
|
only those that needs to download it from peers (when utilizing the libtorrent extension).
|
|
|
|
|
|
2008-07-06 14:22:56 +02:00
|
|
|
|
There are no additional data members in this alert.
|
2004-09-10 02:47:30 +02:00
|
|
|
|
|
|
|
|
|
|
2005-06-16 17:41:04 +02:00
|
|
|
|
fastresume_rejected_alert
|
|
|
|
|
-------------------------
|
|
|
|
|
|
|
|
|
|
This alert is generated when a fastresume file has been passed to ``add_torrent`` but the
|
2009-06-12 18:40:38 +02:00
|
|
|
|
files on disk did not match the fastresume file. The ``error_code`` explains the reason why the
|
2008-07-06 14:22:56 +02:00
|
|
|
|
resume file was rejected.
|
2005-06-16 17:41:04 +02:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2007-03-16 08:59:04 +01:00
|
|
|
|
struct fastresume_rejected_alert: torrent_alert
|
2005-06-16 17:41:04 +02:00
|
|
|
|
{
|
2008-07-06 14:22:56 +02:00
|
|
|
|
// ...
|
2009-06-12 18:40:38 +02:00
|
|
|
|
error_code error;
|
2005-06-16 17:41:04 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2007-04-17 07:56:43 +02:00
|
|
|
|
peer_blocked_alert
|
|
|
|
|
------------------
|
|
|
|
|
|
2008-07-06 14:22:56 +02:00
|
|
|
|
This alert is generated when a peer is blocked by the IP filter. The ``ip`` member is the
|
|
|
|
|
address that was blocked.
|
2007-04-17 07:56:43 +02:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2009-09-07 03:47:30 +02:00
|
|
|
|
struct peer_blocked_alert: torrent_alert
|
2007-04-17 07:56:43 +02:00
|
|
|
|
{
|
2008-07-06 14:22:56 +02:00
|
|
|
|
// ...
|
2007-04-17 07:56:43 +02:00
|
|
|
|
address ip;
|
|
|
|
|
};
|
|
|
|
|
|
2008-07-06 14:22:56 +02:00
|
|
|
|
|
2007-06-11 23:24:14 +02:00
|
|
|
|
storage_moved_alert
|
|
|
|
|
-------------------
|
|
|
|
|
|
|
|
|
|
The ``storage_moved_alert`` is generated when all the disk IO has completed and the
|
|
|
|
|
files have been moved, as an effect of a call to ``torrent_handle::move_storage``. This
|
2008-07-06 14:22:56 +02:00
|
|
|
|
is useful to synchronize with the actual disk. The ``path`` member is the new path of
|
|
|
|
|
the storage.
|
2007-06-11 23:24:14 +02:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct storage_moved_alert: torrent_alert
|
|
|
|
|
{
|
2008-07-06 14:22:56 +02:00
|
|
|
|
// ...
|
|
|
|
|
std::string path;
|
2007-06-11 23:24:14 +02:00
|
|
|
|
};
|
|
|
|
|
|
2008-07-06 14:22:56 +02:00
|
|
|
|
|
2009-05-11 23:18:09 +02:00
|
|
|
|
storage_moved_failed_alert
|
|
|
|
|
--------------------------
|
|
|
|
|
|
|
|
|
|
The ``storage_moved_failed_alert`` is generated when an attempt to move the storage
|
|
|
|
|
(via torrent_handle::move_storage()) fails.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct storage_moved_failed_alert: torrent_alert
|
|
|
|
|
{
|
|
|
|
|
// ...
|
|
|
|
|
error_code error;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2007-06-11 23:24:14 +02:00
|
|
|
|
torrent_paused_alert
|
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
|
|
This alert is generated as a response to a ``torrent_handle::pause`` request. It is
|
|
|
|
|
generated once all disk IO is complete and the files in the torrent have been closed.
|
|
|
|
|
This is useful for synchronizing with the disk.
|
|
|
|
|
|
2008-07-06 14:22:56 +02:00
|
|
|
|
There are no additional data members in this alert.
|
2007-06-11 23:24:14 +02:00
|
|
|
|
|
2008-07-06 14:22:56 +02:00
|
|
|
|
torrent_resumed_alert
|
|
|
|
|
---------------------
|
|
|
|
|
|
|
|
|
|
This alert is generated as a response to a ``torrent_handle::resume`` request. It is
|
|
|
|
|
generated when a torrent goes from a paused state to an active state.
|
|
|
|
|
|
|
|
|
|
There are no additional data members in this alert.
|
2007-06-11 23:24:14 +02:00
|
|
|
|
|
2008-04-13 20:54:36 +02:00
|
|
|
|
save_resume_data_alert
|
|
|
|
|
----------------------
|
|
|
|
|
|
|
|
|
|
This alert is generated as a response to a ``torrent_handle::save_resume_data`` request.
|
|
|
|
|
It is generated once the disk IO thread is done writing the state for this torrent.
|
2008-07-06 14:22:56 +02:00
|
|
|
|
The ``resume_data`` member points to the resume data.
|
2008-04-13 20:54:36 +02:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct save_resume_data_alert: torrent_alert
|
|
|
|
|
{
|
2008-07-06 14:22:56 +02:00
|
|
|
|
// ...
|
2008-04-13 20:54:36 +02:00
|
|
|
|
boost::shared_ptr<entry> resume_data;
|
|
|
|
|
};
|
|
|
|
|
|
2008-07-06 14:22:56 +02:00
|
|
|
|
save_resume_data_failed_alert
|
|
|
|
|
-----------------------------
|
2008-06-08 07:17:35 +02:00
|
|
|
|
|
2008-07-06 14:22:56 +02:00
|
|
|
|
This alert is generated instead of ``save_resume_data_alert`` if there was an error
|
2009-06-12 18:40:38 +02:00
|
|
|
|
generating the resume data. ``error`` describes what went wrong.
|
2008-06-08 07:17:35 +02:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2008-07-06 14:22:56 +02:00
|
|
|
|
struct save_resume_data_failed_alert: torrent_alert
|
2008-06-08 07:17:35 +02:00
|
|
|
|
{
|
2008-07-06 14:22:56 +02:00
|
|
|
|
// ...
|
2009-06-12 18:40:38 +02:00
|
|
|
|
error_code error;
|
2008-06-08 07:17:35 +02:00
|
|
|
|
};
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2008-09-20 19:42:25 +02:00
|
|
|
|
dht_announce_alert
|
|
|
|
|
------------------
|
|
|
|
|
|
|
|
|
|
This alert is generated when a DHT node announces to an info-hash on our DHT node. It belongs
|
|
|
|
|
to the ``dht_notification`` category.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct dht_announce_alert: alert
|
|
|
|
|
{
|
|
|
|
|
// ...
|
|
|
|
|
address ip;
|
|
|
|
|
int port;
|
|
|
|
|
sha1_hash info_hash;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
dht_get_peers_alert
|
|
|
|
|
-------------------
|
|
|
|
|
|
|
|
|
|
This alert is generated when a DHT node sends a ``get_peers`` message to our DHT node.
|
|
|
|
|
It belongs to the ``dht_notification`` category.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
struct dht_get_peers_alert: alert
|
|
|
|
|
{
|
|
|
|
|
// ...
|
|
|
|
|
sha1_hash info_hash;
|
|
|
|
|
};
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
dispatcher
|
|
|
|
|
----------
|
|
|
|
|
|
2007-04-15 20:34:39 +02:00
|
|
|
|
The ``handle_alert`` class is defined in ``<libtorrent/alert.hpp>``.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2007-04-15 20:34:39 +02:00
|
|
|
|
Examples usage::
|
|
|
|
|
|
|
|
|
|
struct my_handler
|
|
|
|
|
{
|
2009-08-20 04:40:18 +02:00
|
|
|
|
void operator()(portmap_error_alert const& a) const
|
2007-04-15 20:34:39 +02:00
|
|
|
|
{
|
|
|
|
|
std::cout << "Portmapper: " << a.msg << std::endl;
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-20 04:40:18 +02:00
|
|
|
|
void operator()(tracker_warning_alert const& a) const
|
2007-04-15 20:34:39 +02:00
|
|
|
|
{
|
|
|
|
|
std::cout << "Tracker warning: " << a.msg << std::endl;
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-20 04:40:18 +02:00
|
|
|
|
void operator()(torrent_finished_alert const& a) const
|
2007-04-15 20:34:39 +02:00
|
|
|
|
{
|
|
|
|
|
// write fast resume data
|
|
|
|
|
// ...
|
|
|
|
|
|
|
|
|
|
std::cout << a.handle.get_torrent_info().name() << "completed"
|
|
|
|
|
<< std::endl;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
std::auto_ptr<alert> a;
|
|
|
|
|
a = ses.pop_alert();
|
|
|
|
|
my_handler h;
|
|
|
|
|
while (a.get())
|
|
|
|
|
{
|
|
|
|
|
handle_alert<portmap_error_alert
|
|
|
|
|
, tracker_warning_alert
|
|
|
|
|
, torrent_finished_alert
|
|
|
|
|
>::handle_alert(h, a);
|
|
|
|
|
a = ses.pop_alert();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
In this example 3 alert types are used. You can use any number of template
|
|
|
|
|
parameters to select between more types. If the number of types are more than
|
|
|
|
|
15, you can define ``TORRENT_MAX_ALERT_TYPES`` to a greater number before
|
|
|
|
|
including ``<libtorrent/alert.hpp>``.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exceptions
|
|
|
|
|
==========
|
|
|
|
|
|
2009-02-23 02:21:19 +01:00
|
|
|
|
Many functions in libtorrent have two versions, one that throws exceptions on
|
|
|
|
|
errors and one that takes an ``error_code`` reference which is filled with the
|
|
|
|
|
error code on errors.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2009-02-23 02:21:19 +01:00
|
|
|
|
There is one exception class that is used for errors in libtorrent, it is based
|
|
|
|
|
on boost.system's ``error_code`` class to carry the error code.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2009-02-23 02:21:19 +01:00
|
|
|
|
libtorrent_exception
|
|
|
|
|
--------------------
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2009-02-23 02:21:19 +01:00
|
|
|
|
struct libtorrent_exception: std::exception
|
2004-01-07 01:48:02 +01:00
|
|
|
|
{
|
2009-02-23 02:21:19 +01:00
|
|
|
|
libtorrent_exception(error_code const& s);
|
|
|
|
|
virtual const char* what() const throw();
|
|
|
|
|
virtual ~libtorrent_exception() throw() {}
|
|
|
|
|
boost::system::error_code error() const;
|
2004-01-07 01:48:02 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2009-02-23 02:21:19 +01:00
|
|
|
|
error_code
|
|
|
|
|
==========
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2009-02-23 02:21:19 +01:00
|
|
|
|
libtorrent uses boost.system's ``error_code`` class to represent errors. libtorrent has
|
|
|
|
|
its own error category (``libtorrent::libtorrent_category``) whith the following error
|
|
|
|
|
codes:
|
|
|
|
|
|
2009-06-12 18:40:38 +02:00
|
|
|
|
====== ========================================= =================================================================
|
|
|
|
|
code symbol description
|
|
|
|
|
====== ========================================= =================================================================
|
|
|
|
|
0 no_error Not an error
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
1 file_collision Two torrents has files which end up overwriting each other
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
2 failed_hash_check A piece did not match its piece hash
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
3 torrent_is_no_dict The .torrent file does not contain a bencoded dictionary at
|
|
|
|
|
its top level
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
4 torrent_missing_info The .torrent file does not have an ``info`` dictionary
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
5 torrent_info_no_dict The .torrent file's ``info`` entry is not a dictionary
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
6 torrent_missing_piece_length The .torrent file does not have a ``piece length`` entry
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
7 torrent_missing_name The .torrent file does not have a ``name`` entry
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
8 torrent_invalid_name The .torrent file's name entry is invalid
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
9 torrent_invalid_length The length of a file, or of the whole .torrent file is invalid.
|
|
|
|
|
Either negative or not an integer
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
10 torrent_file_parse_failed Failed to parse a file entry in the .torrent
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
11 torrent_missing_pieces The ``pieces`` field is missing or invalid in the .torrent file
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
12 torrent_invalid_hashes The ``pieces`` string has incorrect length
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
13 too_many_pieces_in_torrent The .torrent file has more pieces than is supported by libtorrent
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
14 invalid_swarm_metadata The metadata (.torrent file) that was received from the swarm
|
|
|
|
|
matched the info-hash, but failed to be parsed
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
15 invalid_bencoding The file or buffer is not correctly bencoded
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
16 no_files_in_torrent The .torrent file does not contain any files
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
17 invalid_escaped_string The string was not properly url-encoded as expected
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
18 session_is_closing Operation is not permitted since the session is shutting down
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
19 duplicate_torrent There's already a torrent with that info-hash added to the
|
|
|
|
|
session
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
20 invalid_torrent_handle The supplied torrent_handle is not referring to a valid torrent
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
21 invalid_entry_type The type requested from the entry did not match its type
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
22 missing_info_hash_in_uri The specified URI does not contain a valid info-hash
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
23 file_too_short One of the files in the torrent was unexpectadly small. This
|
|
|
|
|
might be caused by files being changed by an external process
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
24 unsupported_url_protocol The URL used an unknown protocol. Currently ``http`` and
|
|
|
|
|
``https`` (if built with openssl support) are recognized. For
|
|
|
|
|
trackers ``udp`` is recognized as well.
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
25 url_parse_error The URL did not conform to URL syntax and failed to be parsed
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
26 peer_sent_empty_piece The peer sent a 'piece' message of length 0
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
27 parse_failed A bencoded structure was currupt and failed to be parsed
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
28 invalid_file_tag The fast resume file was missing or had an invalid file version
|
|
|
|
|
tag
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
29 missing_info_hash The fast resume file was missing or had an invalid info-hash
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
30 mismatching_info_hash The info-hash in the resume file did not match the torrent
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
31 invalid_hostname The URL contained an invalid hostname
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
32 invalid_port The URL had an invalid port
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
33 port_blocked The port is blocked by the port-filter, and prevented the
|
|
|
|
|
connection
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
34 expected_close_bracket_in_address The IPv6 address was expected to end with ']'
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
35 destructing_torrent The torrent is being destructed, preventing the operation to
|
|
|
|
|
succeed
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
36 timed_out The connection timed out
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
37 upload_upload_connection The peer is upload only, and we are upload only. There's no point
|
|
|
|
|
in keeping the connection
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
38 uninteresting_upload_peer The peer is upload only, and we're not interested in it. There's
|
|
|
|
|
no point in keeping the connection
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
39 invalid_info_hash The peer sent an unknown info-hash
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
40 torrent_paused The torrent is paused, preventing the operation from succeeding
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
41 invalid_have The peer sent an invalid have message, either wrong size or
|
|
|
|
|
referring to a piece that doesn't exist in the torrent
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
42 invalid_bitfield_size The bitfield message had the incorrect size
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
43 too_many_requests_when_choked The peer kept requesting pieces after it was choked, possible
|
|
|
|
|
abuse attempt.
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
44 invalid_piece The peer sent a piece message that does not correspond to a
|
|
|
|
|
piece request sent by the client
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
45 no_memory memory allocation failed
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
46 torrent_aborted The torrent is aborted, preventing the operation to succeed
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
47 self_connection The peer is a connection to ourself, no point in keeping it
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
48 invalid_piece_size The peer sent a piece message with invalid size, either negative
|
|
|
|
|
or greater than one block
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
49 timed_out_no_interest The peer has not been interesting or interested in us for too
|
|
|
|
|
long, no point in keeping it around
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
50 timed_out_inactivity The peer has not said anything in a long time, possibly dead
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
51 timed_out_no_handshake The peer did not send a handshake within a reasonable amount of
|
|
|
|
|
time, it might not be a bittorrent peer
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
52 timed_out_no_request The peer has been unchoked for too long without requesting any
|
|
|
|
|
data. It might be lying about its interest in us
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
53 invalid_choke The peer sent an invalid choke message
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
54 invalid_unchoke The peer send an invalid unchoke message
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
55 invalid_interested The peer sent an invalid interested message
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
56 invalid_not_interested The peer sent an invalid not-interested message
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
57 invalid_request The peer sent an invalid piece request message
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
58 invalid_hash_list The peer sent an invalid hash-list message (this is part of the
|
|
|
|
|
merkle-torrent extension)
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
59 invalid_hash_piece The peer sent an invalid hash-piece message (this is part of the
|
|
|
|
|
merkle-torrent extension)
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
60 invalid_cancel The peer sent an invalid cancel message
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
61 invalid_dht_port The peer sent an invalid DHT port-message
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
62 invalid_suggest The peer sent an invalid suggest piece-message
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
63 invalid_have_all The peer sent an invalid have all-message
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
64 invalid_have_none The peer sent an invalid have none-message
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
65 invalid_reject The peer sent an invalid reject message
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
66 invalid_allow_fast The peer sent an invalid allow fast-message
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
67 invalid_extended The peer sent an invalid extesion message ID
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
68 invalid_message The peer sent an invalid message ID
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
69 sync_hash_not_found The synchronization hash was not found in the encrypted handshake
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
70 invalid_encryption_constant The encryption constant in the handshake is invalid
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
71 no_plaintext_mode The peer does not support plaintext, which is the selected mode
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
72 no_rc4_mode The peer does not support rc4, which is the selected mode
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
73 unsupported_encryption_mode The peer does not support any of the encryption modes that the
|
|
|
|
|
client supports
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
74 unsupported_encryption_mode_selected The peer selected an encryption mode that the client did not
|
|
|
|
|
advertise and does not support
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
75 invalid_pad_size The pad size used in the encryption handshake is of invalid size
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
76 invalid_encrypt_handshake The encryption handshake is invalid
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
77 no_incoming_encrypted The client is set to not support incoming encrypted connections
|
|
|
|
|
and this is an encrypted connection
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
78 no_incoming_regular The client is set to not support incoming regular bittorrent
|
|
|
|
|
connections, and this is a regular connection
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
79 duplicate_peer_id The client is already connected to this peer-ID
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
80 torrent_removed Torrent was removed
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
81 packet_too_large The packet size exceeded the upper sanity check-limit
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
2009-12-06 00:03:48 +01:00
|
|
|
|
82 reserved
|
2009-06-12 18:40:38 +02:00
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
83 http_error The web server responded with an error
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
84 missing_location The web server response is missing a location header
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
85 invalid_redirection The web seed redirected to a path that no longer matches the
|
|
|
|
|
.torrent directory structure
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
86 redirecting The connection was closed becaused it redirected to a different
|
|
|
|
|
URL
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
87 invalid_range The HTTP range header is invalid
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
88 no_content_length The HTTP response did not have a content length
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
89 banned_by_ip_filter The IP is blocked by the IP filter
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
90 too_many_connections At the connection limit
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
91 peer_banned The peer is marked as banned
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
92 stopping_torrent The torrent is stopping, causing the operation to fail
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
93 too_many_corrupt_pieces The peer has sent too many corrupt pieces and is banned
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
94 torrent_not_ready The torrent is not ready to receive peers
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
95 peer_not_constructed The peer is not completely constructed yet
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
96 session_closing The session is closing, causing the operation to fail
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
97 optimistic_disconnect The peer was disconnected in order to leave room for a
|
|
|
|
|
potentially better peer
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
98 torrent_finished The torrent is finished
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
99 no_router No UPnP router found
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
100 metadata_too_large The metadata message says the metadata exceeds the limit
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
101 invalid_metadata_request The peer sent an invalid metadata request message
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
102 invalid_metadata_size The peer advertised an invalid metadata size
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
103 invalid_metadata_offset The peer sent a message with an invalid metadata offset
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
104 invalid_metadata_message The peer sent an invalid metadata message
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
105 pex_message_too_large The peer sent a peer exchange message that was too large
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
106 invalid_pex_message The peer sent an invalid peer exchange message
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
107 invalid_lt_tracker_message The peer sent an invalid tracker exchange message
|
2009-06-28 02:36:41 +02:00
|
|
|
|
====== ========================================= =================================================================
|
|
|
|
|
|
|
|
|
|
NAT-PMP errors:
|
|
|
|
|
|
|
|
|
|
====== ========================================= =================================================================
|
|
|
|
|
code symbol description
|
|
|
|
|
====== ========================================= =================================================================
|
2009-12-06 00:03:48 +01:00
|
|
|
|
120 unsupported_protocol_version The NAT-PMP router responded with an unsupported protocol version
|
2009-06-12 18:40:38 +02:00
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
2009-12-06 00:03:48 +01:00
|
|
|
|
121 natpmp_not_authorized You are not authorized to map ports on this NAT-PMP router
|
2009-06-12 18:40:38 +02:00
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
2009-12-06 00:03:48 +01:00
|
|
|
|
122 network_failure The NAT-PMP router failed because of a network failure
|
2009-06-12 18:40:38 +02:00
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
2009-12-06 00:03:48 +01:00
|
|
|
|
123 no_resources The NAT-PMP router failed because of lack of resources
|
2009-06-12 18:40:38 +02:00
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
2009-12-06 00:03:48 +01:00
|
|
|
|
124 unsupported_opcode The NAT-PMP router failed because an unsupported opcode was sent
|
2009-06-12 18:40:38 +02:00
|
|
|
|
====== ========================================= =================================================================
|
2009-02-23 02:21:19 +01:00
|
|
|
|
|
2009-06-28 02:36:41 +02:00
|
|
|
|
fastresume data errors:
|
|
|
|
|
|
|
|
|
|
====== ========================================= =================================================================
|
|
|
|
|
code symbol description
|
|
|
|
|
====== ========================================= =================================================================
|
2009-12-06 00:03:48 +01:00
|
|
|
|
130 missing_file_sizes The resume data file is missing the 'file sizes' entry
|
2009-06-28 02:36:41 +02:00
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
2009-12-06 00:03:48 +01:00
|
|
|
|
131 no_files_in_resume_data The resume data file 'file sizes' entry is empty
|
2009-06-28 02:36:41 +02:00
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
2009-12-06 00:03:48 +01:00
|
|
|
|
132 missing_pieces The resume data file is missing the 'pieces' and 'slots' entry
|
2009-06-28 02:36:41 +02:00
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
2009-12-06 00:03:48 +01:00
|
|
|
|
133 mismatching_number_of_files The number of files in the resume data does not match the number
|
2009-06-28 02:36:41 +02:00
|
|
|
|
of files in the torrent
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
2009-12-06 00:03:48 +01:00
|
|
|
|
134 mismatching_files_size One of the files on disk has a different size than in the fast
|
2009-06-28 02:36:41 +02:00
|
|
|
|
resume file
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
2009-12-06 00:03:48 +01:00
|
|
|
|
135 mismatching_file_timestamp One of the files on disk has a different timestamp than in the
|
2009-06-28 02:36:41 +02:00
|
|
|
|
fast resume file
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
2009-12-06 00:03:48 +01:00
|
|
|
|
136 not_a_dictionary The resume data file is not a dictionary
|
2009-06-28 02:36:41 +02:00
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
2009-12-06 00:03:48 +01:00
|
|
|
|
137 invalid_blocks_per_piece The 'blocks per piece' entry is invalid in the resume data file
|
2009-06-28 02:36:41 +02:00
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
2009-12-06 00:03:48 +01:00
|
|
|
|
138 missing_slots The resume file is missing the 'slots' entry, which is required
|
2009-06-28 02:36:41 +02:00
|
|
|
|
for torrents with compact allocation
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
2009-12-06 00:03:48 +01:00
|
|
|
|
139 too_many_slots The resume file contains more slots than the torrent
|
2009-06-28 02:36:41 +02:00
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
2009-12-06 00:03:48 +01:00
|
|
|
|
140 invalid_slot_list The 'slot' entry is invalid in the resume data
|
2009-06-28 02:36:41 +02:00
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
2009-12-06 00:03:48 +01:00
|
|
|
|
141 invalid_piece_index One index in the 'slot' list is invalid
|
2009-06-28 02:36:41 +02:00
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
2009-12-06 00:03:48 +01:00
|
|
|
|
142 pieces_need_reorder The pieces on disk needs to be re-ordered for the specified
|
2009-06-28 02:36:41 +02:00
|
|
|
|
allocation mode. This happens if you specify sparse allocation
|
|
|
|
|
and the files on disk are using compact storage. The pieces needs
|
|
|
|
|
to be moved to their right position
|
|
|
|
|
====== ========================================= =================================================================
|
|
|
|
|
|
2009-12-06 00:03:48 +01:00
|
|
|
|
HTTP errors:
|
|
|
|
|
|
|
|
|
|
====== ========================================= =================================================================
|
|
|
|
|
150 http_parse_error The HTTP header was not correctly formatted
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
151 http_missing_location The HTTP response was in the 300-399 range but lacked a location
|
|
|
|
|
header
|
|
|
|
|
------ ----------------------------------------- -----------------------------------------------------------------
|
|
|
|
|
152 http_failed_decompress The HTTP response was encoded with gzip or deflate but
|
|
|
|
|
decompressing it failed
|
|
|
|
|
====== ========================================= =================================================================
|
|
|
|
|
|
|
|
|
|
I2P errors:
|
|
|
|
|
|
|
|
|
|
====== ========================================= =================================================================
|
|
|
|
|
160 no_i2p_router The URL specified an i2p address, but no i2p router is configured
|
|
|
|
|
====== ========================================= =================================================================
|
|
|
|
|
|
2009-02-23 02:21:19 +01:00
|
|
|
|
The names of these error codes are declared in then ``libtorrent::errors`` namespace.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2009-06-12 18:40:38 +02:00
|
|
|
|
There is also another error category, ``libtorrent::upnp_category``, defining errors
|
|
|
|
|
retrned by UPnP routers. Here's a (possibly incomplete) list of UPnP error codes:
|
|
|
|
|
|
|
|
|
|
====== ========================================= ====================================================
|
|
|
|
|
code symbol description
|
|
|
|
|
====== ========================================= ====================================================
|
|
|
|
|
0 no_error No error
|
|
|
|
|
------ ----------------------------------------- ----------------------------------------------------
|
|
|
|
|
402 invalid_argument One of the arguments in the request is invalid
|
|
|
|
|
------ ----------------------------------------- ----------------------------------------------------
|
|
|
|
|
501 action_failed The request failed
|
|
|
|
|
------ ----------------------------------------- ----------------------------------------------------
|
|
|
|
|
714 value_not_in_array The specified value does not exist in the array
|
|
|
|
|
------ ----------------------------------------- ----------------------------------------------------
|
|
|
|
|
715 source_ip_cannot_be_wildcarded The source IP address cannot be wild-carded, but
|
|
|
|
|
must be fully specified
|
|
|
|
|
------ ----------------------------------------- ----------------------------------------------------
|
|
|
|
|
716 external_port_cannot_be_wildcarded The external port cannot be wildcarded, but must
|
|
|
|
|
be specified
|
|
|
|
|
------ ----------------------------------------- ----------------------------------------------------
|
|
|
|
|
718 port_mapping_conflict The port mapping entry specified conflicts with a
|
|
|
|
|
mapping assigned previously to another client
|
|
|
|
|
------ ----------------------------------------- ----------------------------------------------------
|
|
|
|
|
724 internal_port_must_match_external Internal and external port value must be the same
|
|
|
|
|
------ ----------------------------------------- ----------------------------------------------------
|
|
|
|
|
725 only_permanent_leases_supported The NAT implementation only supports permanent
|
|
|
|
|
lease times on port mappings
|
|
|
|
|
------ ----------------------------------------- ----------------------------------------------------
|
|
|
|
|
726 remote_host_must_be_wildcard RemoteHost must be a wildcard and cannot be a
|
|
|
|
|
specific IP addres or DNS name
|
|
|
|
|
------ ----------------------------------------- ----------------------------------------------------
|
|
|
|
|
727 external_port_must_be_wildcard ExternalPort must be a wildcard and cannot be a
|
|
|
|
|
specific port
|
|
|
|
|
====== ========================================= ====================================================
|
|
|
|
|
|
|
|
|
|
The UPnP errors are declared in the ``libtorrent::upnp_errors`` namespace.
|
|
|
|
|
|
2009-05-30 20:50:38 +02:00
|
|
|
|
translating error codes
|
|
|
|
|
-----------------------
|
|
|
|
|
|
|
|
|
|
The error_code::message() function will typically return a localized error string,
|
|
|
|
|
for system errors. That is, errors that belong to the generic or system category.
|
|
|
|
|
|
|
|
|
|
Errors that belong to the libtorrent error category are not localized however, they
|
|
|
|
|
are only available in english. In order to translate libtorrent errors, compare the
|
|
|
|
|
error category of the ``error_code`` object against ``libtorrent::libtorrent_category``,
|
|
|
|
|
and if matches, you know the error code refers to the list above. You can provide
|
|
|
|
|
your own mapping from error code to string, which is localized. In this case, you
|
|
|
|
|
cannot rely on ``error_code::message()`` to generate your strings.
|
|
|
|
|
|
|
|
|
|
The numeric values of the errors are part of the API and will stay the same, although
|
|
|
|
|
new error codes may be appended at the end.
|
|
|
|
|
|
|
|
|
|
Here's a simple example of how to translate error codes::
|
|
|
|
|
|
|
|
|
|
std::string error_code_to_string(boost::system::error_code const& ec)
|
|
|
|
|
{
|
|
|
|
|
if (ec.category() != libtorrent::libtorrent_category)
|
|
|
|
|
{
|
|
|
|
|
return ec.message();
|
|
|
|
|
}
|
|
|
|
|
// the error is a libtorrent error
|
|
|
|
|
|
|
|
|
|
int code = ec.value();
|
|
|
|
|
static const char const* swedish[] =
|
|
|
|
|
{
|
|
|
|
|
"inget fel",
|
|
|
|
|
"en fil i torrenten kolliderar med en fil fr<66>n en annan torrent",
|
|
|
|
|
"hash check misslyckades",
|
|
|
|
|
"torrent filen <20>r inte en dictionary",
|
|
|
|
|
"'info'-nyckeln saknas eller <20>r korrupt i torrentfilen",
|
|
|
|
|
"'info'-f<>ltet <20>r inte en dictionary",
|
|
|
|
|
"'piece length' f<>ltet saknas eller <20>r korrupt i torrentfilen",
|
|
|
|
|
"torrentfilen saknar namnf<6E>ltet",
|
|
|
|
|
"ogiltigt namn i torrentfilen (kan vara en attack)",
|
|
|
|
|
// ... more strings here
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// use the default error string in case we don't have it
|
|
|
|
|
// in our translated list
|
|
|
|
|
if (code < 0 || code >= sizeof(swedish)/sizeof(swedish[0]))
|
|
|
|
|
return ec.message();
|
|
|
|
|
|
|
|
|
|
return swedish[code];
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-22 10:27:22 +01:00
|
|
|
|
storage_interface
|
|
|
|
|
=================
|
|
|
|
|
|
|
|
|
|
The storage interface is a pure virtual class that can be implemented to
|
2009-04-10 09:22:27 +02:00
|
|
|
|
customize how and where data for a torrent is stored. The default storage
|
|
|
|
|
implementation uses regular files in the filesystem, mapping the files in the
|
|
|
|
|
torrent in the way one would assume a torrent is saved to disk. Implementing
|
|
|
|
|
your own storage interface makes it possible to store all data in RAM, or in
|
|
|
|
|
some optimized order on disk (the order the pieces are received for instance),
|
|
|
|
|
or saving multifile torrents in a single file in order to be able to take
|
|
|
|
|
advantage of optimized disk-I/O.
|
|
|
|
|
|
|
|
|
|
It is also possible to write a thin class that uses the default storage but
|
|
|
|
|
modifies some particular behavior, for instance encrypting the data before
|
|
|
|
|
it's written to disk, and decrypting it when it's read again.
|
|
|
|
|
|
|
|
|
|
The storage interface is based on slots, each slot is 'piece_size' number
|
|
|
|
|
of bytes. All access is done by writing and reading whole or partial
|
|
|
|
|
slots. One slot is one piece in the torrent, but the data in the slot
|
|
|
|
|
does not necessarily correspond to the piece with the same index (in
|
|
|
|
|
compact allocation mode it won't).
|
|
|
|
|
|
|
|
|
|
The interface looks like this::
|
2007-11-22 10:27:22 +01:00
|
|
|
|
|
|
|
|
|
struct storage_interface
|
|
|
|
|
{
|
2008-09-04 13:09:39 +02:00
|
|
|
|
virtual bool initialize(bool allocate_files) = 0;
|
2009-04-10 09:22:27 +02:00
|
|
|
|
virtual bool has_any_file() = 0;
|
2009-01-11 03:02:34 +01:00
|
|
|
|
virtual int readv(file::iovec_t const* bufs, int slot, int offset, int num_bufs) = 0;
|
|
|
|
|
virtual int writev(file::iovec_t const* bufs, int slot, int offset, int num_bufs) = 0;
|
2009-02-17 01:11:38 +01:00
|
|
|
|
virtual int sparse_end(int start) const;
|
2007-11-22 10:27:22 +01:00
|
|
|
|
virtual bool move_storage(fs::path save_path) = 0;
|
2009-06-28 02:36:41 +02:00
|
|
|
|
virtual bool verify_resume_data(lazy_entry const& rd, error_code& error) = 0;
|
2008-09-04 13:09:39 +02:00
|
|
|
|
virtual bool write_resume_data(entry& rd) const = 0;
|
|
|
|
|
virtual bool move_slot(int src_slot, int dst_slot) = 0;
|
|
|
|
|
virtual bool swap_slots(int slot1, int slot2) = 0;
|
|
|
|
|
virtual bool swap_slots3(int slot1, int slot2, int slot3) = 0;
|
|
|
|
|
virtual bool rename_file(int file, std::string const& new_name) = 0;
|
|
|
|
|
virtual bool release_files() = 0;
|
|
|
|
|
virtual bool delete_files() = 0;
|
2007-11-22 10:27:22 +01:00
|
|
|
|
virtual ~storage_interface() {}
|
2009-01-17 09:35:48 +01:00
|
|
|
|
|
|
|
|
|
// non virtual functions
|
|
|
|
|
|
2009-02-03 08:46:24 +01:00
|
|
|
|
disk_buffer_pool* disk_pool();
|
2009-01-17 09:35:48 +01:00
|
|
|
|
void set_error(boost::filesystem::path const& file, error_code const& ec) const;
|
|
|
|
|
error_code const& error() const;
|
|
|
|
|
std::string const& error_file() const;
|
|
|
|
|
void clear_error();
|
2007-11-22 10:27:22 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initialize()
|
|
|
|
|
------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2008-09-04 13:09:39 +02:00
|
|
|
|
bool initialize(bool allocate_files) = 0;
|
2007-11-22 10:27:22 +01:00
|
|
|
|
|
|
|
|
|
This function is called when the storage is to be initialized. The default storage
|
|
|
|
|
will create directories and empty files at this point. If ``allocate_files`` is true,
|
|
|
|
|
it will also ``ftruncate`` all files to their target size.
|
|
|
|
|
|
2008-09-04 13:09:39 +02:00
|
|
|
|
Returning ``true`` indicates an error occurred.
|
2007-11-22 10:27:22 +01:00
|
|
|
|
|
2009-04-10 09:22:27 +02:00
|
|
|
|
has_any_file()
|
|
|
|
|
--------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
virtual bool has_any_file() = 0;
|
|
|
|
|
|
|
|
|
|
This function is called when first checking (or re-checking) the storage for a torrent.
|
|
|
|
|
It should return true if any of the files that is used in this storage exists on disk.
|
|
|
|
|
If so, the storage will be checked for existing pieces before starting the download.
|
2009-01-11 03:02:34 +01:00
|
|
|
|
|
2009-01-17 09:35:48 +01:00
|
|
|
|
readv() writev()
|
|
|
|
|
----------------
|
2007-11-22 10:27:22 +01:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2009-01-11 03:02:34 +01:00
|
|
|
|
int readv(file::iovec_t const* buf, int slot, int offset, int num_bufs) = 0;
|
2008-09-04 13:09:39 +02:00
|
|
|
|
int write(const char* buf, int slot, int offset, int size) = 0;
|
2007-11-22 10:27:22 +01:00
|
|
|
|
|
2009-01-17 09:35:48 +01:00
|
|
|
|
These functions should read or write the data in or to the given ``slot`` at the given ``offset``.
|
|
|
|
|
It should read or write ``num_bufs`` buffers sequentially, where the size of each buffer
|
|
|
|
|
is specified in the buffer array ``bufs``. The file::iovec_t type has the following members::
|
2009-01-11 03:02:34 +01:00
|
|
|
|
|
|
|
|
|
struct iovec_t
|
|
|
|
|
{
|
|
|
|
|
void* iov_base;
|
|
|
|
|
size_t iov_len;
|
|
|
|
|
};
|
2007-11-22 10:27:22 +01:00
|
|
|
|
|
2009-01-17 09:35:48 +01:00
|
|
|
|
The return value is the number of bytes actually read or written, or -1 on failure. If
|
|
|
|
|
it returns -1, the error code is expected to be set to
|
2008-09-04 13:09:39 +02:00
|
|
|
|
|
2009-01-11 03:02:34 +01:00
|
|
|
|
Every buffer in ``bufs`` can be assumed to be page aligned and be of a page aligned size,
|
2009-01-17 09:35:48 +01:00
|
|
|
|
except for the last buffer of the torrent. The allocated buffer can be assumed to fit a
|
|
|
|
|
fully page aligned number of bytes though. This is useful when reading and writing the
|
|
|
|
|
last piece of a file in unbuffered mode.
|
|
|
|
|
|
|
|
|
|
The ``offset`` is aligned to 16 kiB boundries *most of the time*, but there are rare
|
|
|
|
|
exceptions when it's not. Specifically if the read cache is disabled/or full and a
|
|
|
|
|
client requests unaligned data, or the file itself is not aligned in the torrent.
|
|
|
|
|
Most clients request aligned data.
|
2009-01-11 03:02:34 +01:00
|
|
|
|
|
2009-02-17 01:11:38 +01:00
|
|
|
|
sparse_end()
|
|
|
|
|
------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
int sparse_end(int start) const;
|
|
|
|
|
|
|
|
|
|
This function is optional. It is supposed to return the first piece, starting at
|
|
|
|
|
``start`` that is fully contained within a data-region on disk (i.e. non-sparse
|
|
|
|
|
region). The purpose of this is to skip parts of files that can be known to contain
|
|
|
|
|
zeros when checking files.
|
2007-11-22 10:27:22 +01:00
|
|
|
|
|
|
|
|
|
move_storage()
|
|
|
|
|
--------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
bool move_storage(fs::path save_path) = 0;
|
|
|
|
|
|
|
|
|
|
This function should move all the files belonging to the storage to the new save_path.
|
|
|
|
|
The default storage moves the single file or the directory of the torrent.
|
|
|
|
|
|
|
|
|
|
Before moving the files, any open file handles may have to be closed, like
|
|
|
|
|
``release_files()``.
|
|
|
|
|
|
2009-08-05 04:31:57 +02:00
|
|
|
|
Returning ``false`` indicates an error occurred.
|
2008-09-04 13:09:39 +02:00
|
|
|
|
|
2007-11-22 10:27:22 +01:00
|
|
|
|
|
|
|
|
|
verify_resume_data()
|
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2009-06-28 02:36:41 +02:00
|
|
|
|
bool verify_resume_data(lazy_entry const& rd, error_code& error) = 0;
|
2007-11-22 10:27:22 +01:00
|
|
|
|
|
|
|
|
|
This function should verify the resume data ``rd`` with the files
|
|
|
|
|
on disk. If the resume data seems to be up-to-date, return true. If
|
|
|
|
|
not, set ``error`` to a description of what mismatched and return false.
|
|
|
|
|
|
|
|
|
|
The default storage may compare file sizes and time stamps of the files.
|
|
|
|
|
|
2009-06-28 02:36:41 +02:00
|
|
|
|
Returning ``false`` indicates an error occurred.
|
2008-09-04 13:09:39 +02:00
|
|
|
|
|
2007-11-22 10:27:22 +01:00
|
|
|
|
|
2008-04-13 20:54:36 +02:00
|
|
|
|
write_resume_data()
|
|
|
|
|
-------------------
|
2007-11-22 10:27:22 +01:00
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2008-09-04 13:09:39 +02:00
|
|
|
|
bool write_resume_data(entry& rd) const = 0;
|
2007-11-22 10:27:22 +01:00
|
|
|
|
|
|
|
|
|
This function should fill in resume data, the current state of the
|
|
|
|
|
storage, in ``rd``. The default storage adds file timestamps and
|
|
|
|
|
sizes.
|
|
|
|
|
|
2008-09-04 13:09:39 +02:00
|
|
|
|
Returning ``true`` indicates an error occurred.
|
|
|
|
|
|
2007-11-22 10:27:22 +01:00
|
|
|
|
|
|
|
|
|
move_slot()
|
|
|
|
|
-----------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2008-09-04 13:09:39 +02:00
|
|
|
|
bool move_slot(int src_slot, int dst_slot) = 0;
|
2007-11-22 10:27:22 +01:00
|
|
|
|
|
|
|
|
|
This function should copy or move the data in slot ``src_slot`` to
|
|
|
|
|
the slot ``dst_slot``. This is only used in compact mode.
|
|
|
|
|
|
|
|
|
|
If the storage caches slots, this could be implemented more
|
|
|
|
|
efficient than reading and writing the data.
|
|
|
|
|
|
2008-09-04 13:09:39 +02:00
|
|
|
|
Returning ``true`` indicates an error occurred.
|
|
|
|
|
|
2007-11-22 10:27:22 +01:00
|
|
|
|
|
|
|
|
|
swap_slots()
|
|
|
|
|
------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2008-09-04 13:09:39 +02:00
|
|
|
|
bool swap_slots(int slot1, int slot2) = 0;
|
2007-11-22 10:27:22 +01:00
|
|
|
|
|
|
|
|
|
This function should swap the data in ``slot1`` and ``slot2``. The default
|
|
|
|
|
storage uses a scratch buffer to read the data into, then moving the other
|
|
|
|
|
slot and finally writing back the temporary slot's data
|
|
|
|
|
|
|
|
|
|
This is only used in compact mode.
|
|
|
|
|
|
2008-09-04 13:09:39 +02:00
|
|
|
|
Returning ``true`` indicates an error occurred.
|
|
|
|
|
|
2007-11-22 10:27:22 +01:00
|
|
|
|
|
|
|
|
|
swap_slots3()
|
|
|
|
|
-------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2008-09-04 13:09:39 +02:00
|
|
|
|
bool swap_slots3(int slot1, int slot2, int slot3) = 0;
|
2007-11-22 10:27:22 +01:00
|
|
|
|
|
|
|
|
|
This function should do a 3-way swap, or shift of the slots. ``slot1``
|
|
|
|
|
should move to ``slot2``, which should be moved to ``slot3`` which in turn
|
|
|
|
|
should be moved to ``slot1``.
|
|
|
|
|
|
|
|
|
|
This is only used in compact mode.
|
|
|
|
|
|
2008-09-04 13:09:39 +02:00
|
|
|
|
Returning ``true`` indicates an error occurred.
|
|
|
|
|
|
2007-11-22 10:27:22 +01:00
|
|
|
|
|
2008-09-04 13:09:39 +02:00
|
|
|
|
rename_file()
|
|
|
|
|
-------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
bool rename_file(int file, std::string const& new_name) = 0;
|
|
|
|
|
|
|
|
|
|
Rename file with index ``file`` to the thame ``new_name``. If there is an error,
|
|
|
|
|
``true`` should be returned.
|
|
|
|
|
|
2007-11-22 10:27:22 +01:00
|
|
|
|
|
|
|
|
|
release_files()
|
|
|
|
|
---------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2008-09-04 13:09:39 +02:00
|
|
|
|
bool release_files() = 0;
|
2007-11-22 10:27:22 +01:00
|
|
|
|
|
|
|
|
|
This function should release all the file handles that it keeps open to files
|
|
|
|
|
belonging to this storage. The default implementation just calls
|
|
|
|
|
``file_pool::release_files(this)``.
|
|
|
|
|
|
2008-09-04 13:09:39 +02:00
|
|
|
|
Returning ``true`` indicates an error occurred.
|
|
|
|
|
|
2007-11-22 10:27:22 +01:00
|
|
|
|
|
|
|
|
|
delete_files()
|
|
|
|
|
--------------
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
2008-09-04 13:09:39 +02:00
|
|
|
|
bool delete_files() = 0;
|
2007-11-22 10:27:22 +01:00
|
|
|
|
|
|
|
|
|
This function should delete all files and directories belonging to this storage.
|
|
|
|
|
|
2008-09-04 13:09:39 +02:00
|
|
|
|
Returning ``true`` indicates an error occurred.
|
|
|
|
|
|
2009-02-03 08:46:24 +01:00
|
|
|
|
The ``disk_buffer_pool`` is used to allocate and free disk buffers. It has the
|
|
|
|
|
following members::
|
|
|
|
|
|
|
|
|
|
struct disk_buffer_pool : boost::noncopyable
|
|
|
|
|
{
|
|
|
|
|
char* allocate_buffer(char const* category);
|
|
|
|
|
void free_buffer(char* buf);
|
|
|
|
|
|
|
|
|
|
char* allocate_buffers(int blocks, char const* category);
|
|
|
|
|
void free_buffers(char* buf, int blocks);
|
|
|
|
|
|
|
|
|
|
int block_size() const { return m_block_size; }
|
|
|
|
|
|
|
|
|
|
void release_memory();
|
|
|
|
|
};
|
|
|
|
|
|
2007-11-22 10:27:22 +01:00
|
|
|
|
|
2008-08-03 17:14:08 +02:00
|
|
|
|
magnet links
|
|
|
|
|
============
|
|
|
|
|
|
|
|
|
|
Magnet links are URIs that includes an info-hash, a display name and optionally
|
|
|
|
|
a tracker url. The idea behind magnet links is that an end user can click on a
|
|
|
|
|
link in a browser and have it handled by a bittorrent application, to start a
|
|
|
|
|
download, without any .torrent file.
|
|
|
|
|
|
|
|
|
|
The format of the magnet URI is:
|
|
|
|
|
|
|
|
|
|
**magnet:?xt=urn:btih:** *Base32 encoded info-hash* [ **&dn=** *name of download* ] [ **&tr=** *tracker URL* ]*
|
|
|
|
|
|
2008-04-24 05:28:48 +02:00
|
|
|
|
queuing
|
|
|
|
|
=======
|
|
|
|
|
|
|
|
|
|
libtorrent supports *queuing*. Which means it makes sure that a limited number of
|
|
|
|
|
torrents are being downloaded at any given time, and once a torrent is completely
|
|
|
|
|
downloaded, the next in line is started.
|
|
|
|
|
|
|
|
|
|
Torrents that are *auto managed* are subject to the queuing and the active torrents
|
|
|
|
|
limits. To make a torrent auto managed, set ``auto_managed`` to true when adding the
|
|
|
|
|
torrent (see `add_torrent()`_).
|
|
|
|
|
|
|
|
|
|
The limits of the number of downloading and seeding torrents are controlled via
|
2008-07-01 23:07:18 +02:00
|
|
|
|
``active_downloads``, ``active_seeds`` and ``active_limit`` in session_settings_.
|
|
|
|
|
These limits takes non auto managed torrents into account as well. If there are
|
|
|
|
|
more non-auto managed torrents being downloaded than the ``active_downloads``
|
|
|
|
|
setting, any auto managed torrents will be queued until torrents are removed so
|
|
|
|
|
that the number drops below the limit.
|
|
|
|
|
|
2008-04-24 05:28:48 +02:00
|
|
|
|
The default values are 8 active downloads and 5 active seeds.
|
|
|
|
|
|
|
|
|
|
At a regular interval, torrents are checked if there needs to be any re-ordering of
|
|
|
|
|
which torrents are active and which are queued. This interval can be controlled via
|
|
|
|
|
``auto_manage_interval`` in session_settings_. It defaults to every 30 seconds.
|
|
|
|
|
|
|
|
|
|
For queuing to work, resume data needs to be saved and restored for all torrents.
|
|
|
|
|
See `save_resume_data()`_.
|
|
|
|
|
|
|
|
|
|
downloading
|
|
|
|
|
-----------
|
|
|
|
|
|
2008-05-29 05:37:19 +02:00
|
|
|
|
Torrents that are currently being downloaded or incomplete (with bytes still to download)
|
|
|
|
|
are queued. The torrents in the front of the queue are started to be actively downloaded
|
|
|
|
|
and the rest are ordered with regards to their queue position. Any newly added torrent
|
|
|
|
|
is placed at the end of the queue. Once a torrent is removed or turns into a seed, its
|
|
|
|
|
queue position is -1 and all torrents that used to be after it in the queue, decreases their
|
|
|
|
|
position in order to fill the gap.
|
|
|
|
|
|
|
|
|
|
The queue positions are always in a sequence without any gaps.
|
|
|
|
|
|
|
|
|
|
Lower queue position means closer to the front of the queue, and will be started sooner than
|
|
|
|
|
torrents with higher queue positions.
|
|
|
|
|
|
|
|
|
|
To query a torrent for its position in the queue, or change its position, see:
|
|
|
|
|
`queue_position() queue_position_up() queue_position_down() queue_position_top() queue_position_bottom()`_.
|
2008-04-24 05:28:48 +02:00
|
|
|
|
|
|
|
|
|
seeding
|
|
|
|
|
-------
|
|
|
|
|
|
|
|
|
|
Auto managed seeding torrents are rotated, so that all of them are allocated a fair
|
|
|
|
|
amount of seeding. Torrents with fewer completed *seed cycles* are prioritized for
|
|
|
|
|
seeding. A seed cycle is completed when a torrent meets either the share ratio limit
|
|
|
|
|
(uploaded bytes / downloaded bytes), the share time ratio (time seeding / time
|
|
|
|
|
downloaing) or seed time limit (time seeded).
|
|
|
|
|
|
|
|
|
|
The relevant settings to control these limits are ``share_ratio_limit``,
|
|
|
|
|
``seed_time_ratio_limit`` and ``seed_time_limit`` in session_settings_.
|
|
|
|
|
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
fast resume
|
|
|
|
|
===========
|
|
|
|
|
|
2005-08-15 20:03:57 +02:00
|
|
|
|
The fast resume mechanism is a way to remember which pieces are downloaded
|
|
|
|
|
and where they are put between sessions. You can generate fast resume data by
|
2008-04-13 20:54:36 +02:00
|
|
|
|
calling `save_resume_data()`_ on torrent_handle_. You can
|
2005-08-15 20:03:57 +02:00
|
|
|
|
then save this data to disk and use it when resuming the torrent. libtorrent
|
|
|
|
|
will not check the piece hashes then, and rely on the information given in the
|
|
|
|
|
fast-resume data. The fast-resume data also contains information about which
|
|
|
|
|
blocks, in the unfinished pieces, were downloaded, so it will not have to
|
|
|
|
|
start from scratch on the partially downloaded pieces.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2004-04-17 17:17:43 +02:00
|
|
|
|
To use the fast-resume data you simply give it to `add_torrent()`_, and it
|
2005-08-15 20:03:57 +02:00
|
|
|
|
will skip the time consuming checks. It may have to do the checking anyway, if
|
|
|
|
|
the fast-resume data is corrupt or doesn't fit the storage for that torrent,
|
|
|
|
|
then it will not trust the fast-resume data and just do the checking.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
|
|
|
|
file format
|
2004-01-14 02:19:30 +01:00
|
|
|
|
-----------
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2004-01-12 04:05:10 +01:00
|
|
|
|
The file format is a bencoded dictionary containing the following fields:
|
|
|
|
|
|
2009-03-21 05:33:53 +01:00
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``file-format`` | string: "libtorrent resume file" |
|
|
|
|
|
| | |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``file-version`` | integer: 1 |
|
|
|
|
|
| | |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``info-hash`` | string, the info hash of the torrent this data is saved for. |
|
|
|
|
|
| | |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``blocks per piece`` | integer, the number of blocks per piece. Must be: piece_size |
|
|
|
|
|
| | / (16 * 1024). Clamped to be within the range [1, 256]. It |
|
|
|
|
|
| | is the number of blocks per (normal sized) piece. Usually |
|
|
|
|
|
| | each block is 16 * 1024 bytes in size. But if piece size is |
|
|
|
|
|
| | greater than 4 megabytes, the block size will increase. |
|
|
|
|
|
| | |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``pieces`` | A string with piece flags, one character per piece. |
|
|
|
|
|
| | Bit 1 means we have that piece. |
|
|
|
|
|
| | Bit 2 means we have verified that this piece is correct. |
|
|
|
|
|
| | This only applies when the torrent is in seed_mode. |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``slots`` | list of integers. The list maps slots to piece indices. It |
|
|
|
|
|
| | tells which piece is on which slot. If piece index is -2 it |
|
|
|
|
|
| | means it is free, that there's no piece there. If it is -1, |
|
|
|
|
|
| | means the slot isn't allocated on disk yet. The pieces have |
|
|
|
|
|
| | to meet the following requirement: |
|
|
|
|
|
| | |
|
|
|
|
|
| | If there's a slot at the position of the piece index, |
|
|
|
|
|
| | the piece must be located in that slot. |
|
|
|
|
|
| | |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``total_uploaded`` | integer. The number of bytes that have been uploaded in |
|
|
|
|
|
| | total for this torrent. |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``total_downloaded`` | integer. The number of bytes that have been downloaded in |
|
|
|
|
|
| | total for this torrent. |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``active_time`` | integer. The number of seconds this torrent has been active. |
|
|
|
|
|
| | i.e. not paused. |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``seeding_time`` | integer. The number of seconds this torrent has been active |
|
|
|
|
|
| | and seeding. |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``num_seeds`` | integer. An estimate of the number of seeds on this torrent |
|
|
|
|
|
| | when the resume data was saved. This is scrape data or based |
|
|
|
|
|
| | on the peer list if scrape data is unavailable. |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``num_downloaders`` | integer. An estimate of the number of downloaders on this |
|
|
|
|
|
| | torrent when the resume data was last saved. This is used as |
|
|
|
|
|
| | an initial estimate until we acquire up-to-date scrape info. |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``upload_rate_limit`` | integer. In case this torrent has a per-torrent upload rate |
|
|
|
|
|
| | limit, this is that limit. In bytes per second. |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``download_rate_limit`` | integer. The download rate limit for this torrent in case |
|
|
|
|
|
| | one is set, in bytes per second. |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``max_connections`` | integer. The max number of peer connections this torrent |
|
|
|
|
|
| | may have, if a limit is set. |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``max_uploads`` | integer. The max number of unchoked peers this torrent may |
|
|
|
|
|
| | have, if a limit is set. |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``seed_mode`` | integer. 1 if the torrent is in seed mode, 0 otherwise. |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``file_priority`` | list of integers. One entry per file in the torrent. Each |
|
|
|
|
|
| | entry is the priority of the file with the same index. |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``piece_priority`` | string of bytes. Each byte is interpreted as an integer and |
|
|
|
|
|
| | is the priority of that piece. |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``auto_managed`` | integer. 1 if the torrent is auto managed, otherwise 0. |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``sequential_download`` | integer. 1 if the torrent is in sequential download mode, |
|
|
|
|
|
| | 0 otherwise. |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``paused`` | integer. 1 if the torrent is paused, 0 otherwise. |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``trackers`` | list of lists of strings. The top level list lists all |
|
|
|
|
|
| | tracker tiers. Each second level list is one tier of |
|
|
|
|
|
| | trackers. |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``mapped_files`` | list of strings. If any file in the torrent has been |
|
|
|
|
|
| | renamed, this entry contains a list of all the filenames. |
|
|
|
|
|
| | In the same order as in the torrent file. |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``url-list`` | list of strings. List of url-seed URLs used by this torrent. |
|
2009-07-19 01:18:16 +02:00
|
|
|
|
| | The urls are expected to be properly encoded and not contain |
|
|
|
|
|
| | any illegal url characters. |
|
2009-03-21 05:33:53 +01:00
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``httpseeds`` | list of strings. List of httpseed URLs used by this torrent. |
|
2009-07-19 01:18:16 +02:00
|
|
|
|
| | The urls are expected to be properly encoded and not contain |
|
|
|
|
|
| | any illegal url characters. |
|
2009-03-21 05:33:53 +01:00
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``merkle tree`` | string. In case this torrent is a merkle torrent, this is a |
|
|
|
|
|
| | string containing the entire merkle tree, all nodes, |
|
|
|
|
|
| | including the root and all leaves. The tree is not |
|
|
|
|
|
| | necessarily complete, but complete enough to be able to send |
|
|
|
|
|
| | any piece that we have, indicated by the have bitmask. |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``peers`` | list of dictionaries. Each dictionary has the following |
|
|
|
|
|
| | layout: |
|
|
|
|
|
| | |
|
|
|
|
|
| | +----------+-----------------------------------------------+ |
|
|
|
|
|
| | | ``ip`` | string, the ip address of the peer. This is | |
|
|
|
|
|
| | | | not a binary representation of the ip | |
|
|
|
|
|
| | | | address, but the string representation. It | |
|
|
|
|
|
| | | | may be an IPv6 string or an IPv4 string. | |
|
|
|
|
|
| | +----------+-----------------------------------------------+ |
|
|
|
|
|
| | | ``port`` | integer, the listen port of the peer | |
|
|
|
|
|
| | +----------+-----------------------------------------------+ |
|
|
|
|
|
| | |
|
|
|
|
|
| | These are the local peers we were connected to when this |
|
|
|
|
|
| | fast-resume data was saved. |
|
|
|
|
|
| | |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``unfinished`` | list of dictionaries. Each dictionary represents an |
|
|
|
|
|
| | piece, and has the following layout: |
|
|
|
|
|
| | |
|
|
|
|
|
| | +-------------+--------------------------------------------+ |
|
|
|
|
|
| | | ``piece`` | integer, the index of the piece this entry | |
|
|
|
|
|
| | | | refers to. | |
|
|
|
|
|
| | +-------------+--------------------------------------------+ |
|
|
|
|
|
| | | ``bitmask`` | string, a binary bitmask representing the | |
|
|
|
|
|
| | | | blocks that have been downloaded in this | |
|
|
|
|
|
| | | | piece. | |
|
|
|
|
|
| | +-------------+--------------------------------------------+ |
|
|
|
|
|
| | | ``adler32`` | The adler32 checksum of the data in the | |
|
|
|
|
|
| | | | blocks specified by ``bitmask``. | |
|
|
|
|
|
| | | | | |
|
|
|
|
|
| | +-------------+--------------------------------------------+ |
|
|
|
|
|
| | |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``file sizes`` | list where each entry corresponds to a file in the file list |
|
|
|
|
|
| | in the metadata. Each entry has a list of two values, the |
|
|
|
|
|
| | first value is the size of the file in bytes, the second |
|
|
|
|
|
| | is the time stamp when the last time someone wrote to it. |
|
|
|
|
|
| | This information is used to compare with the files on disk. |
|
|
|
|
|
| | All the files must match exactly this information in order |
|
|
|
|
|
| | to consider the resume data as current. Otherwise a full |
|
|
|
|
|
| | re-check is issued. |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
|
|
|
|
| ``allocation`` | The allocation mode for the storage. Can be either ``full`` |
|
|
|
|
|
| | or ``compact``. If this is full, the file sizes and |
|
|
|
|
|
| | timestamps are disregarded. Pieces are assumed not to have |
|
|
|
|
|
| | moved around even if the files have been modified after the |
|
|
|
|
|
| | last resume data checkpoint. |
|
|
|
|
|
+--------------------------+--------------------------------------------------------------+
|
2004-01-12 04:05:10 +01:00
|
|
|
|
|
2005-08-10 20:04:39 +02:00
|
|
|
|
threads
|
|
|
|
|
=======
|
|
|
|
|
|
2006-05-21 12:41:37 +02:00
|
|
|
|
libtorrent starts 2 or 3 threads.
|
2005-08-10 20:04:39 +02:00
|
|
|
|
|
|
|
|
|
* The first thread is the main thread that will sit
|
|
|
|
|
idle in a ``select()`` call most of the time. This thread runs the main loop
|
|
|
|
|
that will send and receive data on all connections.
|
2008-12-30 04:56:51 +01:00
|
|
|
|
|
2008-12-21 03:19:02 +01:00
|
|
|
|
* The second thread is the disk I/O thread. All disk read and write operations
|
2008-12-30 04:56:51 +01:00
|
|
|
|
are passed to this thread and messages are passed back to the main thread when
|
|
|
|
|
the operation compeltes. The disk thread also verifies the piece hashes.
|
2008-12-21 03:19:02 +01:00
|
|
|
|
|
|
|
|
|
* The third and forth threads are spawned by asio on systems that don't support
|
|
|
|
|
non-blocking host name resolution to simulate non-blocking getaddrinfo().
|
2005-08-10 20:04:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
storage allocation
|
|
|
|
|
==================
|
|
|
|
|
|
2007-11-20 08:54:51 +01:00
|
|
|
|
There are three modes in which storage (files on disk) are allocated in libtorrent.
|
2005-08-10 20:04:39 +02:00
|
|
|
|
|
2007-11-20 08:54:51 +01:00
|
|
|
|
1. The traditional *full allocation* mode, where the entire files are filled up with
|
2007-04-17 23:54:40 +02:00
|
|
|
|
zeros before anything is downloaded. libtorrent will look for sparse files support
|
2007-04-26 02:35:28 +02:00
|
|
|
|
in the filesystem that is used for storage, and use sparse files or file system
|
2007-04-26 02:40:27 +02:00
|
|
|
|
zero fill support if present. This means that on NTFS, full allocation mode will
|
2007-04-26 02:35:28 +02:00
|
|
|
|
only allocate storage for the downloaded pieces.
|
2005-08-10 20:04:39 +02:00
|
|
|
|
|
2007-11-20 08:54:51 +01:00
|
|
|
|
2. The *compact allocation* mode, where only files are allocated for actual
|
2008-09-17 17:25:12 +02:00
|
|
|
|
pieces that have been downloaded.
|
2005-08-10 20:04:39 +02:00
|
|
|
|
|
2008-09-17 17:25:12 +02:00
|
|
|
|
3. The *sparse allocation*, sparse files are used, and pieces are downloaded directly
|
2007-11-20 08:54:51 +01:00
|
|
|
|
to where they belong. This is the recommended (and default) mode.
|
|
|
|
|
|
|
|
|
|
The allocation mode is selected when a torrent is started. It is passed as an
|
|
|
|
|
argument to ``session::add_torrent()`` (see `add_torrent()`_).
|
2005-08-10 20:04:39 +02:00
|
|
|
|
|
2007-04-18 02:36:09 +02:00
|
|
|
|
The decision to use full allocation or compact allocation typically depends on whether
|
|
|
|
|
any files are filtered and if the filesystem supports sparse files.
|
|
|
|
|
|
2007-11-20 08:54:51 +01:00
|
|
|
|
sparse allocation
|
|
|
|
|
-----------------
|
|
|
|
|
|
|
|
|
|
On filesystems that supports sparse files, this allocation mode will only use
|
|
|
|
|
as much space as has been downloaded.
|
|
|
|
|
|
|
|
|
|
* It does not require an allocation pass on startup.
|
|
|
|
|
|
|
|
|
|
* It supports skipping files (setting prioirty to 0 to not download).
|
|
|
|
|
|
|
|
|
|
* Fast resume data will remain valid even when file time stamps are out of date.
|
|
|
|
|
|
2007-04-18 02:36:09 +02:00
|
|
|
|
|
2005-08-10 20:04:39 +02:00
|
|
|
|
full allocation
|
|
|
|
|
---------------
|
|
|
|
|
|
2008-09-17 17:25:12 +02:00
|
|
|
|
When a torrent is started in full allocation mode, the disk-io thread (see threads_)
|
2006-05-21 12:41:37 +02:00
|
|
|
|
will make sure that the entire storage is allocated, and fill any gaps with zeros.
|
2007-04-17 23:54:40 +02:00
|
|
|
|
This will be skipped if the filesystem supports sparse files or automatic zero filling.
|
2005-08-10 20:04:39 +02:00
|
|
|
|
It will of course still check for existing pieces and fast resume data. The main
|
|
|
|
|
drawbacks of this mode are:
|
|
|
|
|
|
2007-04-17 23:54:40 +02:00
|
|
|
|
* It may take longer to start the torrent, since it will need to fill the files
|
|
|
|
|
with zeros on some systems. This delay is linearly dependent on the size of
|
|
|
|
|
the download.
|
2005-08-10 20:04:39 +02:00
|
|
|
|
|
2007-04-17 23:54:40 +02:00
|
|
|
|
* The download may occupy unnecessary disk space between download sessions. In case
|
|
|
|
|
sparse files are not supported.
|
2005-08-10 20:04:39 +02:00
|
|
|
|
|
2005-11-01 19:30:39 +01:00
|
|
|
|
* Disk caches usually perform extremely poorly with random access to large files
|
|
|
|
|
and may slow down a download considerably.
|
|
|
|
|
|
2006-05-21 12:41:37 +02:00
|
|
|
|
The benefits of this mode are:
|
2005-08-10 20:04:39 +02:00
|
|
|
|
|
|
|
|
|
* Downloaded pieces are written directly to their final place in the files and the
|
|
|
|
|
total number of disk operations will be fewer and may also play nicer to
|
|
|
|
|
filesystems' file allocation, and reduce fragmentation.
|
|
|
|
|
|
2007-04-17 23:54:40 +02:00
|
|
|
|
* No risk of a download failing because of a full disk during download. Unless
|
|
|
|
|
sparse files are being used.
|
|
|
|
|
|
|
|
|
|
* The fast resume data will be more likely to be usable, regardless of crashes or
|
|
|
|
|
out of date data, since pieces won't move around.
|
2005-08-10 20:04:39 +02:00
|
|
|
|
|
2007-04-17 23:54:40 +02:00
|
|
|
|
* Can be used with the filter files feature.
|
2005-08-10 20:04:39 +02:00
|
|
|
|
|
|
|
|
|
compact allocation
|
|
|
|
|
------------------
|
|
|
|
|
|
|
|
|
|
The compact allocation will only allocate as much storage as it needs to keep the
|
|
|
|
|
pieces downloaded so far. This means that pieces will be moved around to be placed
|
|
|
|
|
at their final position in the files while downloading (to make sure the completed
|
|
|
|
|
download has all its pieces in the correct place). So, the main drawbacks are:
|
|
|
|
|
|
|
|
|
|
* More disk operations while downloading since pieces are moved around.
|
|
|
|
|
|
|
|
|
|
* Potentially more fragmentation in the filesystem.
|
|
|
|
|
|
2007-04-17 23:54:40 +02:00
|
|
|
|
* Cannot be used while filtering files.
|
|
|
|
|
|
2005-08-10 20:04:39 +02:00
|
|
|
|
The benefits though, are:
|
|
|
|
|
|
|
|
|
|
* No startup delay, since the files doesn't need allocating.
|
|
|
|
|
|
|
|
|
|
* The download will not use unnecessary disk space.
|
|
|
|
|
|
2005-11-01 19:30:39 +01:00
|
|
|
|
* Disk caches perform much better than in full allocation and raises the download
|
|
|
|
|
speed limit imposed by the disk.
|
|
|
|
|
|
2007-04-17 23:54:40 +02:00
|
|
|
|
* Works well on filesystems that doesn't support sparse files.
|
|
|
|
|
|
2005-08-10 20:04:39 +02:00
|
|
|
|
The algorithm that is used when allocating pieces and slots isn't very complicated.
|
|
|
|
|
For the interested, a description follows.
|
|
|
|
|
|
|
|
|
|
storing a piece:
|
|
|
|
|
|
|
|
|
|
1. let **A** be a newly downloaded piece, with index **n**.
|
|
|
|
|
2. let **s** be the number of slots allocated in the file we're
|
|
|
|
|
downloading to. (the number of pieces it has room for).
|
|
|
|
|
3. if **n** >= **s** then allocate a new slot and put the piece there.
|
|
|
|
|
4. if **n** < **s** then allocate a new slot, move the data at
|
|
|
|
|
slot **n** to the new slot and put **A** in slot **n**.
|
|
|
|
|
|
|
|
|
|
allocating a new slot:
|
|
|
|
|
|
|
|
|
|
1. if there's an unassigned slot (a slot that doesn't
|
|
|
|
|
contain any piece), return that slot index.
|
|
|
|
|
2. append the new slot at the end of the file (or find an unused slot).
|
|
|
|
|
3. let **i** be the index of newly allocated slot
|
|
|
|
|
4. if we have downloaded piece index **i** already (to slot **j**) then
|
|
|
|
|
|
|
|
|
|
1. move the data at slot **j** to slot **i**.
|
|
|
|
|
2. return slot index **j** as the newly allocated free slot.
|
2004-01-12 04:05:10 +01:00
|
|
|
|
|
2005-08-10 20:04:39 +02:00
|
|
|
|
5. return **i** as the newly allocated slot.
|
|
|
|
|
|
|
|
|
|
|
2004-01-07 01:48:02 +01:00
|
|
|
|
extensions
|
|
|
|
|
==========
|
|
|
|
|
|
|
|
|
|
These extensions all operates within the `extension protocol`__. The
|
|
|
|
|
name of the extension is the name used in the extension-list packets,
|
|
|
|
|
and the payload is the data in the extended message (not counting the
|
|
|
|
|
length-prefix, message-id nor extension-id).
|
|
|
|
|
|
2005-11-01 19:30:39 +01:00
|
|
|
|
__ extension_protocol.html
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2004-06-17 22:56:49 +02:00
|
|
|
|
Note that since this protocol relies on one of the reserved bits in the
|
|
|
|
|
handshake, it may be incompatible with future versions of the mainline
|
|
|
|
|
bittorrent client.
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2004-06-17 22:56:49 +02:00
|
|
|
|
These are the extensions that are currently implemented.
|
2004-01-14 02:19:30 +01:00
|
|
|
|
|
2004-06-17 22:56:49 +02:00
|
|
|
|
metadata from peers
|
|
|
|
|
-------------------
|
2004-01-07 01:48:02 +01:00
|
|
|
|
|
2006-12-04 13:15:49 +01:00
|
|
|
|
Extension name: "LT_metadata"
|
2004-06-17 22:56:49 +02:00
|
|
|
|
|
|
|
|
|
The point with this extension is that you don't have to distribute the
|
|
|
|
|
metadata (.torrent-file) separately. The metadata can be distributed
|
|
|
|
|
through the bittorrent swarm. The only thing you need to download such
|
|
|
|
|
a torrent is the tracker url and the info-hash of the torrent.
|
|
|
|
|
|
|
|
|
|
It works by assuming that the initial seeder has the metadata and that
|
|
|
|
|
the metadata will propagate through the network as more peers join.
|
|
|
|
|
|
|
|
|
|
There are three kinds of messages in the metadata extension. These packets
|
|
|
|
|
are put as payload to the extension message. The three packets are:
|
|
|
|
|
|
|
|
|
|
* request metadata
|
|
|
|
|
* metadata
|
|
|
|
|
* don't have metadata
|
|
|
|
|
|
|
|
|
|
request metadata:
|
|
|
|
|
|
2006-08-01 17:27:08 +02:00
|
|
|
|
+-----------+---------------+----------------------------------------+
|
|
|
|
|
| size | name | description |
|
|
|
|
|
+===========+===============+========================================+
|
|
|
|
|
| uint8_t | msg_type | Determines the kind of message this is |
|
|
|
|
|
| | | 0 means 'request metadata' |
|
|
|
|
|
+-----------+---------------+----------------------------------------+
|
|
|
|
|
| uint8_t | start | The start of the metadata block that |
|
|
|
|
|
| | | is requested. It is given in 256:ths |
|
|
|
|
|
| | | of the total size of the metadata, |
|
|
|
|
|
| | | since the requesting client don't know |
|
|
|
|
|
| | | the size of the metadata. |
|
|
|
|
|
+-----------+---------------+----------------------------------------+
|
|
|
|
|
| uint8_t | size | The size of the metadata block that is |
|
|
|
|
|
| | | requested. This is also given in |
|
|
|
|
|
| | | 256:ths of the total size of the |
|
|
|
|
|
| | | metadata. The size is given as size-1. |
|
|
|
|
|
| | | That means that if this field is set |
|
|
|
|
|
| | | 0, the request wants one 256:th of the |
|
|
|
|
|
| | | metadata. |
|
|
|
|
|
+-----------+---------------+----------------------------------------+
|
2004-06-17 22:56:49 +02:00
|
|
|
|
|
|
|
|
|
metadata:
|
|
|
|
|
|
2006-08-01 17:27:08 +02:00
|
|
|
|
+-----------+---------------+----------------------------------------+
|
|
|
|
|
| size | name | description |
|
|
|
|
|
+===========+===============+========================================+
|
|
|
|
|
| uint8_t | msg_type | 1 means 'metadata' |
|
|
|
|
|
+-----------+---------------+----------------------------------------+
|
|
|
|
|
| int32_t | total_size | The total size of the metadata, given |
|
|
|
|
|
| | | in number of bytes. |
|
|
|
|
|
+-----------+---------------+----------------------------------------+
|
|
|
|
|
| int32_t | offset | The offset of where the metadata block |
|
|
|
|
|
| | | in this message belongs in the final |
|
|
|
|
|
| | | metadata. This is given in bytes. |
|
|
|
|
|
+-----------+---------------+----------------------------------------+
|
|
|
|
|
| uint8_t[] | metadata | The actual metadata block. The size of |
|
|
|
|
|
| | | this part is given implicit by the |
|
|
|
|
|
| | | length prefix in the bittorrent |
|
|
|
|
|
| | | protocol packet. |
|
|
|
|
|
+-----------+---------------+----------------------------------------+
|
2004-06-17 22:56:49 +02:00
|
|
|
|
|
|
|
|
|
Don't have metadata:
|
|
|
|
|
|
2006-08-01 17:27:08 +02:00
|
|
|
|
+-----------+---------------+----------------------------------------+
|
|
|
|
|
| size | name | description |
|
|
|
|
|
+===========+===============+========================================+
|
|
|
|
|
| uint8_t | msg_type | 2 means 'I don't have metadata'. |
|
|
|
|
|
| | | This message is sent as a reply to a |
|
|
|
|
|
| | | metadata request if the the client |
|
|
|
|
|
| | | doesn't have any metadata. |
|
|
|
|
|
+-----------+---------------+----------------------------------------+
|
2004-06-17 22:56:49 +02:00
|
|
|
|
|
2006-04-25 23:04:48 +02:00
|
|
|
|
HTTP seeding
|
|
|
|
|
------------
|
|
|
|
|
|
2008-12-30 04:54:07 +01:00
|
|
|
|
There are two kinds of HTTP seeding. One with that assumes a smart
|
|
|
|
|
(and polite) client and one that assumes a smart server. These
|
|
|
|
|
are specified in `BEP 19`_ and `BEP 17`_ respectively.
|
|
|
|
|
|
|
|
|
|
libtorrent supports both. In the libtorrent source code and API,
|
|
|
|
|
BEP 19 urls are typically referred to as *url seeds* and BEP 17
|
|
|
|
|
urls are typically referred to as *HTTP seeds*.
|
2006-04-25 23:04:48 +02:00
|
|
|
|
|
2008-12-30 04:54:07 +01:00
|
|
|
|
The libtorrent implementation of `BEP 19`_ assumes that, if the URL ends with a slash
|
2006-04-25 23:04:48 +02:00
|
|
|
|
('/'), the filename should be appended to it in order to request pieces from
|
|
|
|
|
that file. The way this works is that if the torrent is a single-file torrent,
|
|
|
|
|
only that filename is appended. If the torrent is a multi-file torrent, the
|
|
|
|
|
torrent's name '/' the file name is appended. This is the same directory
|
|
|
|
|
structure that libtorrent will download torrents into.
|
|
|
|
|
|
2008-12-30 04:54:07 +01:00
|
|
|
|
.. _`BEP 17`: http://bittorrent.org/beps/bep_0017.html
|
|
|
|
|
.. _`BEP 19`: http://bittorrent.org/beps/bep_0019.html
|
2004-06-17 22:56:49 +02:00
|
|
|
|
|
|
|
|
|
filename checks
|
|
|
|
|
===============
|
2004-02-08 17:04:50 +01:00
|
|
|
|
|
|
|
|
|
Boost.Filesystem will by default check all its paths to make sure they conform
|
|
|
|
|
to filename requirements on many platforms. If you don't want this check, you can
|
|
|
|
|
set it to either only check for native filesystem requirements or turn it off
|
2006-05-21 12:41:37 +02:00
|
|
|
|
altogether. You can use::
|
2004-04-17 17:17:43 +02:00
|
|
|
|
|
|
|
|
|
boost::filesystem::path::default_name_check(boost::filesystem::native);
|
|
|
|
|
|
2004-02-08 17:04:50 +01:00
|
|
|
|
for example. For more information, see the `Boost.Filesystem docs`__.
|
|
|
|
|
|
|
|
|
|
__ http://www.boost.org/libs/filesystem/doc/index.htm
|
|
|
|
|
|