adds ut_pex, ut_metadata and smart_ban by default in session constructor. Also starts upnp and nat-pmp by default. Fixes #399
This commit is contained in:
parent
13b343c1af
commit
ea578a6acf
176
docs/manual.html
176
docs/manual.html
|
@ -178,57 +178,59 @@
|
||||||
<li><a class="reference" href="#torrent-resumed-alert" id="id155" name="id155">torrent_resumed_alert</a></li>
|
<li><a class="reference" href="#torrent-resumed-alert" id="id155" name="id155">torrent_resumed_alert</a></li>
|
||||||
<li><a class="reference" href="#save-resume-data-alert" id="id156" name="id156">save_resume_data_alert</a></li>
|
<li><a class="reference" href="#save-resume-data-alert" id="id156" name="id156">save_resume_data_alert</a></li>
|
||||||
<li><a class="reference" href="#save-resume-data-failed-alert" id="id157" name="id157">save_resume_data_failed_alert</a></li>
|
<li><a class="reference" href="#save-resume-data-failed-alert" id="id157" name="id157">save_resume_data_failed_alert</a></li>
|
||||||
<li><a class="reference" href="#dispatcher" id="id158" name="id158">dispatcher</a></li>
|
<li><a class="reference" href="#dht-announce-alert" id="id158" name="id158">dht_announce_alert</a></li>
|
||||||
|
<li><a class="reference" href="#dht-get-peers-alert" id="id159" name="id159">dht_get_peers_alert</a></li>
|
||||||
|
<li><a class="reference" href="#dispatcher" id="id160" name="id160">dispatcher</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li><a class="reference" href="#exceptions" id="id159" name="id159">exceptions</a><ul>
|
<li><a class="reference" href="#exceptions" id="id161" name="id161">exceptions</a><ul>
|
||||||
<li><a class="reference" href="#invalid-handle" id="id160" name="id160">invalid_handle</a></li>
|
<li><a class="reference" href="#invalid-handle" id="id162" name="id162">invalid_handle</a></li>
|
||||||
<li><a class="reference" href="#duplicate-torrent" id="id161" name="id161">duplicate_torrent</a></li>
|
<li><a class="reference" href="#duplicate-torrent" id="id163" name="id163">duplicate_torrent</a></li>
|
||||||
<li><a class="reference" href="#invalid-encoding" id="id162" name="id162">invalid_encoding</a></li>
|
<li><a class="reference" href="#invalid-encoding" id="id164" name="id164">invalid_encoding</a></li>
|
||||||
<li><a class="reference" href="#type-error" id="id163" name="id163">type_error</a></li>
|
<li><a class="reference" href="#type-error" id="id165" name="id165">type_error</a></li>
|
||||||
<li><a class="reference" href="#invalid-torrent-file" id="id164" name="id164">invalid_torrent_file</a></li>
|
<li><a class="reference" href="#invalid-torrent-file" id="id166" name="id166">invalid_torrent_file</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li><a class="reference" href="#storage-interface" id="id165" name="id165">storage_interface</a><ul>
|
<li><a class="reference" href="#storage-interface" id="id167" name="id167">storage_interface</a><ul>
|
||||||
<li><a class="reference" href="#initialize" id="id166" name="id166">initialize()</a></li>
|
<li><a class="reference" href="#initialize" id="id168" name="id168">initialize()</a></li>
|
||||||
<li><a class="reference" href="#read" id="id167" name="id167">read()</a></li>
|
<li><a class="reference" href="#read" id="id169" name="id169">read()</a></li>
|
||||||
<li><a class="reference" href="#write" id="id168" name="id168">write()</a></li>
|
<li><a class="reference" href="#write" id="id170" name="id170">write()</a></li>
|
||||||
<li><a class="reference" href="#id12" id="id169" name="id169">move_storage()</a></li>
|
<li><a class="reference" href="#id12" id="id171" name="id171">move_storage()</a></li>
|
||||||
<li><a class="reference" href="#verify-resume-data" id="id170" name="id170">verify_resume_data()</a></li>
|
<li><a class="reference" href="#verify-resume-data" id="id172" name="id172">verify_resume_data()</a></li>
|
||||||
<li><a class="reference" href="#write-resume-data" id="id171" name="id171">write_resume_data()</a></li>
|
<li><a class="reference" href="#write-resume-data" id="id173" name="id173">write_resume_data()</a></li>
|
||||||
<li><a class="reference" href="#move-slot" id="id172" name="id172">move_slot()</a></li>
|
<li><a class="reference" href="#move-slot" id="id174" name="id174">move_slot()</a></li>
|
||||||
<li><a class="reference" href="#swap-slots" id="id173" name="id173">swap_slots()</a></li>
|
<li><a class="reference" href="#swap-slots" id="id175" name="id175">swap_slots()</a></li>
|
||||||
<li><a class="reference" href="#swap-slots3" id="id174" name="id174">swap_slots3()</a></li>
|
<li><a class="reference" href="#swap-slots3" id="id176" name="id176">swap_slots3()</a></li>
|
||||||
<li><a class="reference" href="#hash-for-slot" id="id175" name="id175">hash_for_slot()</a></li>
|
<li><a class="reference" href="#hash-for-slot" id="id177" name="id177">hash_for_slot()</a></li>
|
||||||
<li><a class="reference" href="#rename-file" id="id176" name="id176">rename_file()</a></li>
|
<li><a class="reference" href="#rename-file" id="id178" name="id178">rename_file()</a></li>
|
||||||
<li><a class="reference" href="#release-files" id="id177" name="id177">release_files()</a></li>
|
<li><a class="reference" href="#release-files" id="id179" name="id179">release_files()</a></li>
|
||||||
<li><a class="reference" href="#delete-files" id="id178" name="id178">delete_files()</a></li>
|
<li><a class="reference" href="#delete-files" id="id180" name="id180">delete_files()</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li><a class="reference" href="#magnet-links" id="id179" name="id179">magnet links</a></li>
|
<li><a class="reference" href="#magnet-links" id="id181" name="id181">magnet links</a></li>
|
||||||
<li><a class="reference" href="#queuing" id="id180" name="id180">queuing</a><ul>
|
<li><a class="reference" href="#queuing" id="id182" name="id182">queuing</a><ul>
|
||||||
<li><a class="reference" href="#downloading" id="id181" name="id181">downloading</a></li>
|
<li><a class="reference" href="#downloading" id="id183" name="id183">downloading</a></li>
|
||||||
<li><a class="reference" href="#seeding" id="id182" name="id182">seeding</a></li>
|
<li><a class="reference" href="#seeding" id="id184" name="id184">seeding</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li><a class="reference" href="#fast-resume" id="id183" name="id183">fast resume</a><ul>
|
<li><a class="reference" href="#fast-resume" id="id185" name="id185">fast resume</a><ul>
|
||||||
<li><a class="reference" href="#file-format" id="id184" name="id184">file format</a></li>
|
<li><a class="reference" href="#file-format" id="id186" name="id186">file format</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li><a class="reference" href="#threads" id="id185" name="id185">threads</a></li>
|
<li><a class="reference" href="#threads" id="id187" name="id187">threads</a></li>
|
||||||
<li><a class="reference" href="#storage-allocation" id="id186" name="id186">storage allocation</a><ul>
|
<li><a class="reference" href="#storage-allocation" id="id188" name="id188">storage allocation</a><ul>
|
||||||
<li><a class="reference" href="#sparse-allocation" id="id187" name="id187">sparse allocation</a></li>
|
<li><a class="reference" href="#sparse-allocation" id="id189" name="id189">sparse allocation</a></li>
|
||||||
<li><a class="reference" href="#full-allocation" id="id188" name="id188">full allocation</a></li>
|
<li><a class="reference" href="#full-allocation" id="id190" name="id190">full allocation</a></li>
|
||||||
<li><a class="reference" href="#compact-allocation" id="id189" name="id189">compact allocation</a></li>
|
<li><a class="reference" href="#compact-allocation" id="id191" name="id191">compact allocation</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li><a class="reference" href="#extensions" id="id190" name="id190">extensions</a><ul>
|
<li><a class="reference" href="#extensions" id="id192" name="id192">extensions</a><ul>
|
||||||
<li><a class="reference" href="#metadata-from-peers" id="id191" name="id191">metadata from peers</a></li>
|
<li><a class="reference" href="#metadata-from-peers" id="id193" name="id193">metadata from peers</a></li>
|
||||||
<li><a class="reference" href="#http-seeding" id="id192" name="id192">HTTP seeding</a></li>
|
<li><a class="reference" href="#http-seeding" id="id194" name="id194">HTTP seeding</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li><a class="reference" href="#filename-checks" id="id193" name="id193">filename checks</a></li>
|
<li><a class="reference" href="#filename-checks" id="id195" name="id195">filename checks</a></li>
|
||||||
<li><a class="reference" href="#acknowledgments" id="id194" name="id194">acknowledgments</a></li>
|
<li><a class="reference" href="#acknowledgments" id="id196" name="id196">acknowledgments</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section">
|
||||||
|
@ -294,12 +296,14 @@ class session: public boost::noncopyable
|
||||||
|
|
||||||
session(fingerprint const& print
|
session(fingerprint const& print
|
||||||
= libtorrent::fingerprint(
|
= libtorrent::fingerprint(
|
||||||
"LT", 0, 1, 0, 0));
|
"LT", 0, 1, 0, 0)
|
||||||
|
, int flags = start_default_features | add_default_plugins);
|
||||||
|
|
||||||
session(
|
session(
|
||||||
fingerprint const& print
|
fingerprint const& print
|
||||||
, std::pair<int, int> listen_port_range
|
, std::pair<int, int> listen_port_range
|
||||||
, char const* listen_interface = 0);
|
, char const* listen_interface = 0
|
||||||
|
, int flags = start_default_features | add_default_plugins);
|
||||||
|
|
||||||
torrent_handle add_torrent(add_torrent_params const& params);
|
torrent_handle add_torrent(add_torrent_params const& params);
|
||||||
|
|
||||||
|
@ -315,6 +319,12 @@ class session: public boost::noncopyable
|
||||||
delete_files = 1
|
delete_files = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum session_flags_t
|
||||||
|
{
|
||||||
|
add_default_plugins = 1,
|
||||||
|
start_default_features = 2
|
||||||
|
};
|
||||||
|
|
||||||
void remove_torrent(torrent_handle const& h, int options = none);
|
void remove_torrent(torrent_handle const& h, int options = none);
|
||||||
torrent_handle find_torrent(sha_hash const& ih);
|
torrent_handle find_torrent(sha_hash const& ih);
|
||||||
std::vector<torrent_handle> get_torrents() const;
|
std::vector<torrent_handle> get_torrents() const;
|
||||||
|
@ -394,10 +404,13 @@ The main thread will be idle as long it doesn't have any torrents to participate
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre class="literal-block">
|
<pre class="literal-block">
|
||||||
session(fingerprint const& print
|
session(fingerprint const& print
|
||||||
= libtorrent::fingerprint("LT", 0, 1, 0, 0));
|
= libtorrent::fingerprint("LT", 0, 1, 0, 0)
|
||||||
|
, int flags = start_default_features | add_default_plugins);
|
||||||
|
|
||||||
session(fingerprint const& print
|
session(fingerprint const& print
|
||||||
, std::pair<int, int> listen_port_range
|
, std::pair<int, int> listen_port_range
|
||||||
, char const* listen_interface = 0);
|
, char const* listen_interface = 0
|
||||||
|
, int flags = start_default_features | add_default_plugins);
|
||||||
</pre>
|
</pre>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<p>If the fingerprint in the first overload is omited, the client will get a default
|
<p>If the fingerprint in the first overload is omited, the client will get a default
|
||||||
|
@ -408,6 +421,9 @@ listen port for the session, to get it running you'll have to call <tt class="do
|
||||||
The other constructor, that takes a port range and an interface as well as the fingerprint
|
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
|
will automatically try to listen on a port on the given interface. For more information about
|
||||||
the parameters, see <tt class="docutils literal"><span class="pre">listen_on()</span></tt> function.</p>
|
the parameters, see <tt class="docutils literal"><span class="pre">listen_on()</span></tt> function.</p>
|
||||||
|
<p>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.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<h2><a id="id2" name="id2">~session()</a></h2>
|
<h2><a id="id2" name="id2">~session()</a></h2>
|
||||||
|
@ -685,25 +701,42 @@ session_status status() const;
|
||||||
<p><tt class="docutils literal"><span class="pre">status()</span></tt> returns session wide-statistics and status. The <tt class="docutils literal"><span class="pre">session_status</span></tt>
|
<p><tt class="docutils literal"><span class="pre">status()</span></tt> returns session wide-statistics and status. The <tt class="docutils literal"><span class="pre">session_status</span></tt>
|
||||||
struct has the following members:</p>
|
struct has the following members:</p>
|
||||||
<pre class="literal-block">
|
<pre class="literal-block">
|
||||||
|
struct dht_lookup
|
||||||
|
{
|
||||||
|
char const* type;
|
||||||
|
int outstanding_requests;
|
||||||
|
int timeouts;
|
||||||
|
int responses;
|
||||||
|
int branch_factor;
|
||||||
|
};
|
||||||
|
|
||||||
struct session_status
|
struct session_status
|
||||||
{
|
{
|
||||||
bool has_incoming_connections;
|
bool has_incoming_connections;
|
||||||
|
|
||||||
float upload_rate;
|
float upload_rate;
|
||||||
float download_rate;
|
float download_rate;
|
||||||
|
|
||||||
float payload_upload_rate;
|
|
||||||
float payload_download_rate;
|
|
||||||
|
|
||||||
size_type total_download;
|
size_type total_download;
|
||||||
size_type total_upload;
|
size_type total_upload;
|
||||||
|
|
||||||
size_type total_redundant_bytes;
|
float payload_upload_rate;
|
||||||
size_type total_failed_bytes;
|
float payload_download_rate;
|
||||||
|
|
||||||
size_type total_payload_download;
|
size_type total_payload_download;
|
||||||
size_type total_payload_upload;
|
size_type total_payload_upload;
|
||||||
|
|
||||||
|
float ip_overhead_upload_rate;
|
||||||
|
float ip_overhead_download_rate;
|
||||||
|
size_type total_ip_overhead_download;
|
||||||
|
size_type total_ip_overhead_upload;
|
||||||
|
|
||||||
|
float dht_upload_rate;
|
||||||
|
float dht_download_rate;
|
||||||
|
size_type total_dht_download;
|
||||||
|
size_type total_dht_upload;
|
||||||
|
|
||||||
|
size_type total_redundant_bytes;
|
||||||
|
size_type total_failed_bytes;
|
||||||
|
|
||||||
int num_peers;
|
int num_peers;
|
||||||
int num_unchoked;
|
int num_unchoked;
|
||||||
int allowed_upload_slots;
|
int allowed_upload_slots;
|
||||||
|
@ -712,17 +745,26 @@ struct session_status
|
||||||
int dht_cache_nodes;
|
int dht_cache_nodes;
|
||||||
int dht_torrents;
|
int dht_torrents;
|
||||||
int dht_global_nodes;
|
int dht_global_nodes;
|
||||||
|
std::vector<dht_lookup> active_requests;
|
||||||
};
|
};
|
||||||
</pre>
|
</pre>
|
||||||
<p><tt class="docutils literal"><span class="pre">has_incoming_connections</span></tt> is false as long as no incoming connections have been
|
<p><tt class="docutils literal"><span class="pre">has_incoming_connections</span></tt> is false as long as no incoming connections have been
|
||||||
established on the listening socket. Every time you change the listen port, this will
|
established on the listening socket. Every time you change the listen port, this will
|
||||||
be reset to false.</p>
|
be reset to false.</p>
|
||||||
<p><tt class="docutils literal"><span class="pre">upload_rate</span></tt>, <tt class="docutils literal"><span class="pre">download_rate</span></tt>, <tt class="docutils literal"><span class="pre">payload_download_rate</span></tt> and <tt class="docutils literal"><span class="pre">payload_upload_rate</span></tt>
|
<p><tt class="docutils literal"><span class="pre">upload_rate</span></tt>, <tt class="docutils literal"><span class="pre">download_rate</span></tt> are the total download and upload rates accumulated
|
||||||
are the total download and upload rates accumulated from all torrents. The payload
|
from all torrents. This includes bittorrent protocol, DHT and an estimated TCP/IP
|
||||||
versions is the payload download only.</p>
|
protocol overhead.</p>
|
||||||
<p><tt class="docutils literal"><span class="pre">total_download</span></tt> and <tt class="docutils literal"><span class="pre">total_upload</span></tt> are the total number of bytes downloaded and
|
<p><tt class="docutils literal"><span class="pre">total_download</span></tt> and <tt class="docutils literal"><span class="pre">total_upload</span></tt> are the total number of bytes downloaded and
|
||||||
uploaded to and from all torrents. <tt class="docutils literal"><span class="pre">total_payload_download</span></tt> and <tt class="docutils literal"><span class="pre">total_payload_upload</span></tt>
|
uploaded to and from all torrents. This also includes all the protocol overhead.</p>
|
||||||
are the same thing but where only the payload is considered.</p>
|
<p><tt class="docutils literal"><span class="pre">payload_download_rate</span></tt> and <tt class="docutils literal"><span class="pre">payload_upload_rate</span></tt> is the rate of the payload
|
||||||
|
down- and upload only.</p>
|
||||||
|
<p><tt class="docutils literal"><span class="pre">total_payload_download</span></tt> and <tt class="docutils literal"><span class="pre">total_payload_upload</span></tt> 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.</p>
|
||||||
|
<p><tt class="docutils literal"><span class="pre">ip_overhead_upload_rate</span></tt>, <tt class="docutils literal"><span class="pre">ip_overhead_download_rate</span></tt>, <tt class="docutils literal"><span class="pre">total_ip_overhead_download</span></tt>
|
||||||
|
and <tt class="docutils literal"><span class="pre">total_ip_overhead_upload</span></tt> is the estimated TCP/IP overhead in each direction.</p>
|
||||||
|
<p><tt class="docutils literal"><span class="pre">dht_upload_rate</span></tt>, <tt class="docutils literal"><span class="pre">dht_download_rate</span></tt>, <tt class="docutils literal"><span class="pre">total_dht_download</span></tt> and <tt class="docutils literal"><span class="pre">total_dht_upload</span></tt>
|
||||||
|
is the DHT bandwidth usage.</p>
|
||||||
<p><tt class="docutils literal"><span class="pre">total_redundant_bytes</span></tt> is the number of bytes that has been received more than once.
|
<p><tt class="docutils literal"><span class="pre">total_redundant_bytes</span></tt> 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
|
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
|
peer, and then received again from the first one. To make this lower, increase the
|
||||||
|
@ -746,6 +788,7 @@ becomes unresponsive.</p>
|
||||||
<p><tt class="docutils literal"><span class="pre">dht_torrents</span></tt> are the number of torrents tracked by the DHT at the moment.</p>
|
<p><tt class="docutils literal"><span class="pre">dht_torrents</span></tt> are the number of torrents tracked by the DHT at the moment.</p>
|
||||||
<p><tt class="docutils literal"><span class="pre">dht_global_nodes</span></tt> is an estimation of the total number of nodes in the DHT
|
<p><tt class="docutils literal"><span class="pre">dht_global_nodes</span></tt> is an estimation of the total number of nodes in the DHT
|
||||||
network.</p>
|
network.</p>
|
||||||
|
<p><tt class="docutils literal"><span class="pre">active_requests</span></tt> is a vector of the currently running DHT lookups.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<h2><a id="get-cache-status" name="get-cache-status">get_cache_status()</a></h2>
|
<h2><a id="get-cache-status" name="get-cache-status">get_cache_status()</a></h2>
|
||||||
|
@ -3773,6 +3816,7 @@ public:
|
||||||
progress_notification = <em>implementation defined</em>,
|
progress_notification = <em>implementation defined</em>,
|
||||||
ip_block_notification = <em>implementation defined</em>,
|
ip_block_notification = <em>implementation defined</em>,
|
||||||
performance_warning = <em>implementation defined</em>,
|
performance_warning = <em>implementation defined</em>,
|
||||||
|
dht_notification = <em>implementation defined</em>,
|
||||||
|
|
||||||
all_categories = <em>implementation defined</em>
|
all_categories = <em>implementation defined</em>
|
||||||
};
|
};
|
||||||
|
@ -4200,6 +4244,32 @@ struct save_resume_data_failed_alert: torrent_alert
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section">
|
||||||
|
<h2><a id="dht-announce-alert" name="dht-announce-alert">dht_announce_alert</a></h2>
|
||||||
|
<p>This alert is generated when a DHT node announces to an info-hash on our DHT node. It belongs
|
||||||
|
to the <tt class="docutils literal"><span class="pre">dht_notification</span></tt> category.</p>
|
||||||
|
<pre class="literal-block">
|
||||||
|
struct dht_announce_alert: alert
|
||||||
|
{
|
||||||
|
// ...
|
||||||
|
address ip;
|
||||||
|
int port;
|
||||||
|
sha1_hash info_hash;
|
||||||
|
};
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
<div class="section">
|
||||||
|
<h2><a id="dht-get-peers-alert" name="dht-get-peers-alert">dht_get_peers_alert</a></h2>
|
||||||
|
<p>This alert is generated when a DHT node sends a <tt class="docutils literal"><span class="pre">get_peers</span></tt> message to our DHT node.
|
||||||
|
It belongs to the <tt class="docutils literal"><span class="pre">dht_notification</span></tt> category.</p>
|
||||||
|
<pre class="literal-block">
|
||||||
|
struct dht_get_peers_alert: alert
|
||||||
|
{
|
||||||
|
// ...
|
||||||
|
sha1_hash info_hash;
|
||||||
|
};
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
<div class="section">
|
||||||
<h2><a id="dispatcher" name="dispatcher">dispatcher</a></h2>
|
<h2><a id="dispatcher" name="dispatcher">dispatcher</a></h2>
|
||||||
<p>The <tt class="docutils literal"><span class="pre">handle_alert</span></tt> class is defined in <tt class="docutils literal"><span class="pre"><libtorrent/alert.hpp></span></tt>.</p>
|
<p>The <tt class="docutils literal"><span class="pre">handle_alert</span></tt> class is defined in <tt class="docutils literal"><span class="pre"><libtorrent/alert.hpp></span></tt>.</p>
|
||||||
<p>Examples usage:</p>
|
<p>Examples usage:</p>
|
||||||
|
|
|
@ -74,12 +74,14 @@ The ``session`` class has the following synopsis::
|
||||||
|
|
||||||
session(fingerprint const& print
|
session(fingerprint const& print
|
||||||
= libtorrent::fingerprint(
|
= libtorrent::fingerprint(
|
||||||
"LT", 0, 1, 0, 0));
|
"LT", 0, 1, 0, 0)
|
||||||
|
, int flags = start_default_features | add_default_plugins);
|
||||||
|
|
||||||
session(
|
session(
|
||||||
fingerprint const& print
|
fingerprint const& print
|
||||||
, std::pair<int, int> listen_port_range
|
, std::pair<int, int> listen_port_range
|
||||||
, char const* listen_interface = 0);
|
, char const* listen_interface = 0
|
||||||
|
, int flags = start_default_features | add_default_plugins);
|
||||||
|
|
||||||
torrent_handle add_torrent(add_torrent_params const& params);
|
torrent_handle add_torrent(add_torrent_params const& params);
|
||||||
|
|
||||||
|
@ -95,6 +97,12 @@ The ``session`` class has the following synopsis::
|
||||||
delete_files = 1
|
delete_files = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum session_flags_t
|
||||||
|
{
|
||||||
|
add_default_plugins = 1,
|
||||||
|
start_default_features = 2
|
||||||
|
};
|
||||||
|
|
||||||
void remove_torrent(torrent_handle const& h, int options = none);
|
void remove_torrent(torrent_handle const& h, int options = none);
|
||||||
torrent_handle find_torrent(sha_hash const& ih);
|
torrent_handle find_torrent(sha_hash const& ih);
|
||||||
std::vector<torrent_handle> get_torrents() const;
|
std::vector<torrent_handle> get_torrents() const;
|
||||||
|
@ -176,10 +184,13 @@ session()
|
||||||
::
|
::
|
||||||
|
|
||||||
session(fingerprint const& print
|
session(fingerprint const& print
|
||||||
= libtorrent::fingerprint("LT", 0, 1, 0, 0));
|
= libtorrent::fingerprint("LT", 0, 1, 0, 0)
|
||||||
|
, int flags = start_default_features | add_default_plugins);
|
||||||
|
|
||||||
session(fingerprint const& print
|
session(fingerprint const& print
|
||||||
, std::pair<int, int> listen_port_range
|
, std::pair<int, int> listen_port_range
|
||||||
, char const* listen_interface = 0);
|
, char const* listen_interface = 0
|
||||||
|
, int flags = start_default_features | add_default_plugins);
|
||||||
|
|
||||||
If the fingerprint in the first overload is omited, the client will get a default
|
If the fingerprint in the first overload is omited, the client will get a default
|
||||||
fingerprint stating the version of libtorrent. The fingerprint is a short string that will be
|
fingerprint stating the version of libtorrent. The fingerprint is a short string that will be
|
||||||
|
@ -190,6 +201,10 @@ The other constructor, that takes a port range and an interface as well as the f
|
||||||
will automatically try to listen on a port on the given interface. For more information about
|
will automatically try to listen on a port on the given interface. For more information about
|
||||||
the parameters, see ``listen_on()`` function.
|
the parameters, see ``listen_on()`` function.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
~session()
|
~session()
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
|
|
@ -155,6 +155,7 @@ namespace libtorrent
|
||||||
|
|
||||||
session(fingerprint const& print = fingerprint("LT"
|
session(fingerprint const& print = fingerprint("LT"
|
||||||
, LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR, 0, 0)
|
, LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR, 0, 0)
|
||||||
|
, int flags = start_default_features | add_default_plugins
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||||
, fs::path logpath = "."
|
, fs::path logpath = "."
|
||||||
#endif
|
#endif
|
||||||
|
@ -163,6 +164,7 @@ namespace libtorrent
|
||||||
fingerprint const& print
|
fingerprint const& print
|
||||||
, std::pair<int, int> listen_port_range
|
, std::pair<int, int> listen_port_range
|
||||||
, char const* listen_interface = "0.0.0.0"
|
, char const* listen_interface = "0.0.0.0"
|
||||||
|
, int flags = start_default_features | add_default_plugins
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||||
, fs::path logpath = "."
|
, fs::path logpath = "."
|
||||||
#endif
|
#endif
|
||||||
|
@ -290,6 +292,12 @@ namespace libtorrent
|
||||||
delete_files = 1
|
delete_files = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum session_flags_t
|
||||||
|
{
|
||||||
|
add_default_plugins = 1,
|
||||||
|
start_default_features = 2
|
||||||
|
};
|
||||||
|
|
||||||
void remove_torrent(const torrent_handle& h, int options = none);
|
void remove_torrent(const torrent_handle& h, int options = none);
|
||||||
|
|
||||||
void set_settings(session_settings const& s);
|
void set_settings(session_settings const& s);
|
||||||
|
|
|
@ -56,6 +56,9 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "libtorrent/extensions/ut_pex.hpp"
|
||||||
|
#include "libtorrent/extensions/ut_metadata.hpp"
|
||||||
|
#include "libtorrent/extensions/smart_ban.hpp"
|
||||||
#include "libtorrent/peer_id.hpp"
|
#include "libtorrent/peer_id.hpp"
|
||||||
#include "libtorrent/torrent_info.hpp"
|
#include "libtorrent/torrent_info.hpp"
|
||||||
#include "libtorrent/tracker_manager.hpp"
|
#include "libtorrent/tracker_manager.hpp"
|
||||||
|
@ -112,6 +115,7 @@ namespace libtorrent
|
||||||
fingerprint const& id
|
fingerprint const& id
|
||||||
, std::pair<int, int> listen_port_range
|
, std::pair<int, int> listen_port_range
|
||||||
, char const* listen_interface
|
, char const* listen_interface
|
||||||
|
, int flags
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||||
, fs::path logpath
|
, fs::path logpath
|
||||||
#endif
|
#endif
|
||||||
|
@ -120,7 +124,7 @@ namespace libtorrent
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||||
, logpath
|
, logpath
|
||||||
#endif
|
#endif
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_MEMDEBUG
|
#ifdef TORRENT_MEMDEBUG
|
||||||
start_malloc_debug();
|
start_malloc_debug();
|
||||||
|
@ -135,9 +139,23 @@ namespace libtorrent
|
||||||
boost::function0<void> test = boost::ref(*m_impl);
|
boost::function0<void> test = boost::ref(*m_impl);
|
||||||
TORRENT_ASSERT(!test.empty());
|
TORRENT_ASSERT(!test.empty());
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
|
if (flags & add_default_plugins)
|
||||||
|
{
|
||||||
|
add_extension(create_ut_pex_plugin);
|
||||||
|
add_extension(create_ut_metadata_plugin);
|
||||||
|
add_extension(create_smart_ban_plugin);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (flags & start_default_features)
|
||||||
|
{
|
||||||
|
start_upnp();
|
||||||
|
start_upnp();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
session::session(fingerprint const& id
|
session::session(fingerprint const& id
|
||||||
|
, int flags
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||||
, fs::path logpath
|
, fs::path logpath
|
||||||
#endif
|
#endif
|
||||||
|
@ -155,6 +173,19 @@ namespace libtorrent
|
||||||
boost::function0<void> test = boost::ref(*m_impl);
|
boost::function0<void> test = boost::ref(*m_impl);
|
||||||
TORRENT_ASSERT(!test.empty());
|
TORRENT_ASSERT(!test.empty());
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
|
if (flags & add_default_plugins)
|
||||||
|
{
|
||||||
|
add_extension(create_ut_pex_plugin);
|
||||||
|
add_extension(create_ut_metadata_plugin);
|
||||||
|
add_extension(create_smart_ban_plugin);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (flags & start_default_features)
|
||||||
|
{
|
||||||
|
start_upnp();
|
||||||
|
start_natpmp();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
session::~session()
|
session::~session()
|
||||||
|
@ -170,10 +201,12 @@ namespace libtorrent
|
||||||
m_impl->abort();
|
m_impl->abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
void session::add_extension(boost::function<boost::shared_ptr<torrent_plugin>(torrent*, void*)> ext)
|
void session::add_extension(boost::function<boost::shared_ptr<torrent_plugin>(torrent*, void*)> ext)
|
||||||
{
|
{
|
||||||
m_impl->add_extension(ext);
|
m_impl->add_extension(ext);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_GEO_IP
|
#ifndef TORRENT_DISABLE_GEO_IP
|
||||||
bool session::load_asnum_db(char const* file)
|
bool session::load_asnum_db(char const* file)
|
||||||
|
|
|
@ -51,6 +51,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <boost/filesystem/exception.hpp>
|
#include <boost/filesystem/exception.hpp>
|
||||||
#include <boost/limits.hpp>
|
#include <boost/limits.hpp>
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
#include <boost/function_equal.hpp>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
|
@ -386,6 +387,17 @@ namespace aux {
|
||||||
void session_impl::add_extension(
|
void session_impl::add_extension(
|
||||||
boost::function<boost::shared_ptr<torrent_plugin>(torrent*, void*)> ext)
|
boost::function<boost::shared_ptr<torrent_plugin>(torrent*, void*)> ext)
|
||||||
{
|
{
|
||||||
|
TORRENT_ASSERT(ext);
|
||||||
|
|
||||||
|
typedef boost::shared_ptr<torrent_plugin>(*function_t)(torrent*, void*);
|
||||||
|
function_t const* f = ext.target<function_t>();
|
||||||
|
|
||||||
|
if (f)
|
||||||
|
{
|
||||||
|
for (extension_list_t::iterator i = m_extensions.begin(); i != m_extensions.end(); ++i)
|
||||||
|
if (function_equal(*i, *f)) return;
|
||||||
|
}
|
||||||
|
|
||||||
m_extensions.push_back(ext);
|
m_extensions.push_back(ext);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -2482,7 +2494,7 @@ namespace aux {
|
||||||
++total_downloaders;
|
++total_downloaders;
|
||||||
unique.insert(i->second->queue_position());
|
unique.insert(i->second->queue_position());
|
||||||
}
|
}
|
||||||
TORRENT_ASSERT(unique.size() == total_downloaders);
|
TORRENT_ASSERT(unique.size() == int(total_downloaders));
|
||||||
|
|
||||||
TORRENT_ASSERT(m_max_connections > 0);
|
TORRENT_ASSERT(m_max_connections > 0);
|
||||||
TORRENT_ASSERT(m_max_uploads > 0);
|
TORRENT_ASSERT(m_max_uploads > 0);
|
||||||
|
|
Loading…
Reference in New Issue