forked from premiere/premiere-libtorrent
*** empty log message ***
This commit is contained in:
parent
189375b761
commit
df281f81ae
33
Jamfile
33
Jamfile
|
@ -8,33 +8,33 @@ BOOST_ROOT = [ modules.peek : BOOST_ROOT ] ;
|
|||
ECHO "BOOST_ROOT =" $(BOOST_ROOT) ;
|
||||
ECHO "OS =" [ os.name ] ;
|
||||
|
||||
use-project /boost/thread : $(BOOST_ROOT)/libs/thread/build ;
|
||||
use-project /boost/filesystem : $(BOOST_ROOT)/libs/filesystem/build ;
|
||||
use-project /boost/date_time : $(BOOST_ROOT)/libs/date_time/build ;
|
||||
use-project /boost : $(BOOST_ROOT) ;
|
||||
|
||||
project torrent
|
||||
|
||||
: requirements
|
||||
|
||||
REQUIREMENTS =
|
||||
<include>./include
|
||||
<include>./zlib
|
||||
<include>$(BOOST_ROOT)
|
||||
<variant>release:<define>NDEBUG
|
||||
<define>BOOST_ALL_NO_LIB
|
||||
<define>_FILE_OFFSET_BITS=64
|
||||
<library>/boost/thread//boost_thread
|
||||
<library>/boost/thread//boost_thread/
|
||||
<library>/boost/filesystem//boost_filesystem/<link>static
|
||||
<library>/boost/date_time//boost_date_time/<link>static
|
||||
|
||||
# devstudio switches
|
||||
|
||||
<link>static
|
||||
<threading>multi
|
||||
<toolset>msvc-7:<cxxflags>/Zc:wchar_t
|
||||
<toolset>msvc-7.1:<cxxflags>/Zc:wchar_t
|
||||
|
||||
;
|
||||
: usage-requirements
|
||||
|
||||
USAGE_REQUIREMENTS =
|
||||
<include>./include
|
||||
<include>$(BOOST_ROOT)
|
||||
<variant>release:<define>NDEBUG
|
||||
<define>BOOST_ALL_NO_LIB
|
||||
|
||||
;
|
||||
|
||||
SOURCES =
|
||||
|
@ -89,24 +89,11 @@ LIBS = ;
|
|||
SOURCES += file.cpp ;
|
||||
}
|
||||
|
||||
project torrent
|
||||
: requirements
|
||||
$(REQUIREMENTS)
|
||||
: usage-requirements
|
||||
$(USAGE_REQUIREMENTS)
|
||||
;
|
||||
|
||||
|
||||
lib torrent
|
||||
:
|
||||
src/$(SOURCES)
|
||||
zlib/$(ZLIB_SOURCES)
|
||||
$(LIBS)
|
||||
:
|
||||
<threading>multi
|
||||
<link>static
|
||||
<variant>debug:<define>TORRENT_VERBOSE_LOGGING
|
||||
: debug release
|
||||
;
|
||||
|
||||
|
||||
|
|
186
docs/manual.html
186
docs/manual.html
|
@ -25,98 +25,99 @@
|
|||
<li><a class="reference" href="#id9" id="id25" name="id25">~session()</a></li>
|
||||
<li><a class="reference" href="#add-torrent" id="id26" name="id26">add_torrent()</a></li>
|
||||
<li><a class="reference" href="#remove-torrent" id="id27" name="id27">remove_torrent()</a></li>
|
||||
<li><a class="reference" href="#set-upload-rate-limit-set-download-rate-limit" id="id28" name="id28">set_upload_rate_limit() set_download_rate_limit()</a></li>
|
||||
<li><a class="reference" href="#set-max-uploads-set-max-connections" id="id29" name="id29">set_max_uploads() set_max_connections()</a></li>
|
||||
<li><a class="reference" href="#status" id="id30" name="id30">status()</a></li>
|
||||
<li><a class="reference" href="#is-listening-listen-port-listen-on" id="id31" name="id31">is_listening() listen_port() listen_on()</a></li>
|
||||
<li><a class="reference" href="#pop-alert-set-severity-level" id="id32" name="id32">pop_alert() set_severity_level()</a></li>
|
||||
<li><a class="reference" href="#disable-extensions-enable-extension" id="id28" name="id28">disable_extensions() enable_extension()</a></li>
|
||||
<li><a class="reference" href="#set-upload-rate-limit-set-download-rate-limit" id="id29" name="id29">set_upload_rate_limit() set_download_rate_limit()</a></li>
|
||||
<li><a class="reference" href="#set-max-uploads-set-max-connections" id="id30" name="id30">set_max_uploads() set_max_connections()</a></li>
|
||||
<li><a class="reference" href="#status" id="id31" name="id31">status()</a></li>
|
||||
<li><a class="reference" href="#is-listening-listen-port-listen-on" id="id32" name="id32">is_listening() listen_port() listen_on()</a></li>
|
||||
<li><a class="reference" href="#pop-alert-set-severity-level" id="id33" name="id33">pop_alert() set_severity_level()</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#entry" id="id33" name="id33">entry</a><ul>
|
||||
<li><a class="reference" href="#integer-string-list-dict-type" id="id34" name="id34">integer() string() list() dict() type()</a></li>
|
||||
<li><a class="reference" href="#entry" id="id34" name="id34">entry</a><ul>
|
||||
<li><a class="reference" href="#integer-string-list-dict-type" id="id35" name="id35">integer() string() list() dict() type()</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#torrent-info" id="id35" name="id35">torrent_info</a><ul>
|
||||
<li><a class="reference" href="#begin-files-end-files-rbegin-files-rend-files" id="id36" name="id36">begin_files() end_files() rbegin_files() rend_files()</a></li>
|
||||
<li><a class="reference" href="#num-files-file-at" id="id37" name="id37">num_files() file_at()</a></li>
|
||||
<li><a class="reference" href="#print" id="id38" name="id38">print()</a></li>
|
||||
<li><a class="reference" href="#trackers" id="id39" name="id39">trackers()</a></li>
|
||||
<li><a class="reference" href="#total-size-piece-length-piece-size-num-pieces" id="id40" name="id40">total_size() piece_length() piece_size() num_pieces()</a></li>
|
||||
<li><a class="reference" href="#hash-for-piece-info-hash" id="id41" name="id41">hash_for_piece() info_hash()</a></li>
|
||||
<li><a class="reference" href="#name-comment-creation-date" id="id42" name="id42">name() comment() creation_date()</a></li>
|
||||
<li><a class="reference" href="#torrent-info" id="id36" name="id36">torrent_info</a><ul>
|
||||
<li><a class="reference" href="#begin-files-end-files-rbegin-files-rend-files" id="id37" name="id37">begin_files() end_files() rbegin_files() rend_files()</a></li>
|
||||
<li><a class="reference" href="#num-files-file-at" id="id38" name="id38">num_files() file_at()</a></li>
|
||||
<li><a class="reference" href="#print" id="id39" name="id39">print()</a></li>
|
||||
<li><a class="reference" href="#trackers" id="id40" name="id40">trackers()</a></li>
|
||||
<li><a class="reference" href="#total-size-piece-length-piece-size-num-pieces" id="id41" name="id41">total_size() piece_length() piece_size() num_pieces()</a></li>
|
||||
<li><a class="reference" href="#hash-for-piece-info-hash" id="id42" name="id42">hash_for_piece() info_hash()</a></li>
|
||||
<li><a class="reference" href="#name-comment-creation-date" id="id43" name="id43">name() comment() creation_date()</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#torrent-handle" id="id43" name="id43">torrent_handle</a><ul>
|
||||
<li><a class="reference" href="#save-path" id="id44" name="id44">save_path()</a></li>
|
||||
<li><a class="reference" href="#move-storage" id="id45" name="id45">move_storage()</a></li>
|
||||
<li><a class="reference" href="#force-reannounce" id="id46" name="id46">force_reannounce()</a></li>
|
||||
<li><a class="reference" href="#connect-peer" id="id47" name="id47">connect_peer()</a></li>
|
||||
<li><a class="reference" href="#set-ratio" id="id48" name="id48">set_ratio()</a></li>
|
||||
<li><a class="reference" href="#set-upload-limit-set-download-limit" id="id49" name="id49">set_upload_limit() set_download_limit()</a></li>
|
||||
<li><a class="reference" href="#pause-resume-is-paused" id="id50" name="id50">pause() resume() is_paused()</a></li>
|
||||
<li><a class="reference" href="#is-seed" id="id51" name="id51">is_seed()</a></li>
|
||||
<li><a class="reference" href="#set-tracker-login" id="id52" name="id52">set_tracker_login()</a></li>
|
||||
<li><a class="reference" href="#use-interface" id="id53" name="id53">use_interface()</a></li>
|
||||
<li><a class="reference" href="#info-hash" id="id54" name="id54">info_hash()</a></li>
|
||||
<li><a class="reference" href="#id11" id="id55" name="id55">set_max_uploads() set_max_connections()</a></li>
|
||||
<li><a class="reference" href="#write-resume-data" id="id56" name="id56">write_resume_data()</a></li>
|
||||
<li><a class="reference" href="#metadata" id="id57" name="id57">metadata()</a></li>
|
||||
<li><a class="reference" href="#id12" id="id58" name="id58">status()</a></li>
|
||||
<li><a class="reference" href="#get-download-queue" id="id59" name="id59">get_download_queue()</a></li>
|
||||
<li><a class="reference" href="#get-peer-info" id="id60" name="id60">get_peer_info()</a></li>
|
||||
<li><a class="reference" href="#get-torrent-info" id="id61" name="id61">get_torrent_info()</a></li>
|
||||
<li><a class="reference" href="#is-valid" id="id62" name="id62">is_valid()</a></li>
|
||||
<li><a class="reference" href="#torrent-handle" id="id44" name="id44">torrent_handle</a><ul>
|
||||
<li><a class="reference" href="#save-path" id="id45" name="id45">save_path()</a></li>
|
||||
<li><a class="reference" href="#move-storage" id="id46" name="id46">move_storage()</a></li>
|
||||
<li><a class="reference" href="#force-reannounce" id="id47" name="id47">force_reannounce()</a></li>
|
||||
<li><a class="reference" href="#connect-peer" id="id48" name="id48">connect_peer()</a></li>
|
||||
<li><a class="reference" href="#set-ratio" id="id49" name="id49">set_ratio()</a></li>
|
||||
<li><a class="reference" href="#set-upload-limit-set-download-limit" id="id50" name="id50">set_upload_limit() set_download_limit()</a></li>
|
||||
<li><a class="reference" href="#pause-resume-is-paused" id="id51" name="id51">pause() resume() is_paused()</a></li>
|
||||
<li><a class="reference" href="#is-seed" id="id52" name="id52">is_seed()</a></li>
|
||||
<li><a class="reference" href="#set-tracker-login" id="id53" name="id53">set_tracker_login()</a></li>
|
||||
<li><a class="reference" href="#use-interface" id="id54" name="id54">use_interface()</a></li>
|
||||
<li><a class="reference" href="#info-hash" id="id55" name="id55">info_hash()</a></li>
|
||||
<li><a class="reference" href="#id11" id="id56" name="id56">set_max_uploads() set_max_connections()</a></li>
|
||||
<li><a class="reference" href="#write-resume-data" id="id57" name="id57">write_resume_data()</a></li>
|
||||
<li><a class="reference" href="#metadata" id="id58" name="id58">metadata()</a></li>
|
||||
<li><a class="reference" href="#id12" id="id59" name="id59">status()</a></li>
|
||||
<li><a class="reference" href="#get-download-queue" id="id60" name="id60">get_download_queue()</a></li>
|
||||
<li><a class="reference" href="#get-peer-info" id="id61" name="id61">get_peer_info()</a></li>
|
||||
<li><a class="reference" href="#get-torrent-info" id="id62" name="id62">get_torrent_info()</a></li>
|
||||
<li><a class="reference" href="#is-valid" id="id63" name="id63">is_valid()</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#torrent-status" id="id63" name="id63">torrent_status</a></li>
|
||||
<li><a class="reference" href="#peer-info" id="id64" name="id64">peer_info</a></li>
|
||||
<li><a class="reference" href="#address" id="id65" name="id65">address</a></li>
|
||||
<li><a class="reference" href="#http-settings" id="id66" name="id66">http_settings</a></li>
|
||||
<li><a class="reference" href="#big-number" id="id67" name="id67">big_number</a></li>
|
||||
<li><a class="reference" href="#hasher" id="id68" name="id68">hasher</a></li>
|
||||
<li><a class="reference" href="#fingerprint" id="id69" name="id69">fingerprint</a></li>
|
||||
<li><a class="reference" href="#free-functions" id="id70" name="id70">free functions</a><ul>
|
||||
<li><a class="reference" href="#identify-client" id="id71" name="id71">identify_client()</a></li>
|
||||
<li><a class="reference" href="#bdecode-bencode" id="id72" name="id72">bdecode() bencode()</a></li>
|
||||
<li><a class="reference" href="#torrent-status" id="id64" name="id64">torrent_status</a></li>
|
||||
<li><a class="reference" href="#peer-info" id="id65" name="id65">peer_info</a></li>
|
||||
<li><a class="reference" href="#address" id="id66" name="id66">address</a></li>
|
||||
<li><a class="reference" href="#http-settings" id="id67" name="id67">http_settings</a></li>
|
||||
<li><a class="reference" href="#big-number" id="id68" name="id68">big_number</a></li>
|
||||
<li><a class="reference" href="#hasher" id="id69" name="id69">hasher</a></li>
|
||||
<li><a class="reference" href="#fingerprint" id="id70" name="id70">fingerprint</a></li>
|
||||
<li><a class="reference" href="#free-functions" id="id71" name="id71">free functions</a><ul>
|
||||
<li><a class="reference" href="#identify-client" id="id72" name="id72">identify_client()</a></li>
|
||||
<li><a class="reference" href="#bdecode-bencode" id="id73" name="id73">bdecode() bencode()</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#alerts" id="id73" name="id73">alerts</a><ul>
|
||||
<li><a class="reference" href="#listen-failed-alert" id="id74" name="id74">listen_failed_alert</a></li>
|
||||
<li><a class="reference" href="#file-error-alert" id="id75" name="id75">file_error_alert</a></li>
|
||||
<li><a class="reference" href="#tracker-alert" id="id76" name="id76">tracker_alert</a></li>
|
||||
<li><a class="reference" href="#hash-failed-alert" id="id77" name="id77">hash_failed_alert</a></li>
|
||||
<li><a class="reference" href="#peer-ban-alert" id="id78" name="id78">peer_ban_alert</a></li>
|
||||
<li><a class="reference" href="#peer-error-alert" id="id79" name="id79">peer_error_alert</a></li>
|
||||
<li><a class="reference" href="#invalid-request-alert" id="id80" name="id80">invalid_request_alert</a></li>
|
||||
<li><a class="reference" href="#torrent-finished-alert" id="id81" name="id81">torrent_finished_alert</a></li>
|
||||
<li><a class="reference" href="#metadata-received-alert" id="id82" name="id82">metadata_received_alert</a></li>
|
||||
<li><a class="reference" href="#dispatcher" id="id83" name="id83">dispatcher</a></li>
|
||||
<li><a class="reference" href="#alerts" id="id74" name="id74">alerts</a><ul>
|
||||
<li><a class="reference" href="#listen-failed-alert" id="id75" name="id75">listen_failed_alert</a></li>
|
||||
<li><a class="reference" href="#file-error-alert" id="id76" name="id76">file_error_alert</a></li>
|
||||
<li><a class="reference" href="#tracker-alert" id="id77" name="id77">tracker_alert</a></li>
|
||||
<li><a class="reference" href="#hash-failed-alert" id="id78" name="id78">hash_failed_alert</a></li>
|
||||
<li><a class="reference" href="#peer-ban-alert" id="id79" name="id79">peer_ban_alert</a></li>
|
||||
<li><a class="reference" href="#peer-error-alert" id="id80" name="id80">peer_error_alert</a></li>
|
||||
<li><a class="reference" href="#invalid-request-alert" id="id81" name="id81">invalid_request_alert</a></li>
|
||||
<li><a class="reference" href="#torrent-finished-alert" id="id82" name="id82">torrent_finished_alert</a></li>
|
||||
<li><a class="reference" href="#metadata-received-alert" id="id83" name="id83">metadata_received_alert</a></li>
|
||||
<li><a class="reference" href="#dispatcher" id="id84" name="id84">dispatcher</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#exceptions" id="id84" name="id84">exceptions</a><ul>
|
||||
<li><a class="reference" href="#invalid-handle" id="id85" name="id85">invalid_handle</a></li>
|
||||
<li><a class="reference" href="#duplicate-torrent" id="id86" name="id86">duplicate_torrent</a></li>
|
||||
<li><a class="reference" href="#invalid-encoding" id="id87" name="id87">invalid_encoding</a></li>
|
||||
<li><a class="reference" href="#type-error" id="id88" name="id88">type_error</a></li>
|
||||
<li><a class="reference" href="#invalid-torrent-file" id="id89" name="id89">invalid_torrent_file</a></li>
|
||||
<li><a class="reference" href="#exceptions" id="id85" name="id85">exceptions</a><ul>
|
||||
<li><a class="reference" href="#invalid-handle" id="id86" name="id86">invalid_handle</a></li>
|
||||
<li><a class="reference" href="#duplicate-torrent" id="id87" name="id87">duplicate_torrent</a></li>
|
||||
<li><a class="reference" href="#invalid-encoding" id="id88" name="id88">invalid_encoding</a></li>
|
||||
<li><a class="reference" href="#type-error" id="id89" name="id89">type_error</a></li>
|
||||
<li><a class="reference" href="#invalid-torrent-file" id="id90" name="id90">invalid_torrent_file</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#examples" id="id90" name="id90">examples</a><ul>
|
||||
<li><a class="reference" href="#dump-torrent" id="id91" name="id91">dump_torrent</a></li>
|
||||
<li><a class="reference" href="#simple-client" id="id92" name="id92">simple client</a></li>
|
||||
<li><a class="reference" href="#examples" id="id91" name="id91">examples</a><ul>
|
||||
<li><a class="reference" href="#dump-torrent" id="id92" name="id92">dump_torrent</a></li>
|
||||
<li><a class="reference" href="#simple-client" id="id93" name="id93">simple client</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#fast-resume" id="id93" name="id93">fast resume</a><ul>
|
||||
<li><a class="reference" href="#file-format" id="id94" name="id94">file format</a></li>
|
||||
<li><a class="reference" href="#fast-resume" id="id94" name="id94">fast resume</a><ul>
|
||||
<li><a class="reference" href="#file-format" id="id95" name="id95">file format</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#extensions" id="id95" name="id95">extensions</a><ul>
|
||||
<li><a class="reference" href="#chat-messages" id="id96" name="id96">chat messages</a></li>
|
||||
<li><a class="reference" href="#metadata-from-peers" id="id97" name="id97">metadata from peers</a></li>
|
||||
<li><a class="reference" href="#extensions" id="id96" name="id96">extensions</a><ul>
|
||||
<li><a class="reference" href="#chat-messages" id="id97" name="id97">chat messages</a></li>
|
||||
<li><a class="reference" href="#metadata-from-peers" id="id98" name="id98">metadata from peers</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#filename-checks" id="id98" name="id98">filename checks</a></li>
|
||||
<li><a class="reference" href="#acknowledgements" id="id99" name="id99">acknowledgements</a></li>
|
||||
<li><a class="reference" href="#filename-checks" id="id99" name="id99">filename checks</a></li>
|
||||
<li><a class="reference" href="#acknowledgements" id="id100" name="id100">acknowledgements</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="introduction">
|
||||
|
@ -174,22 +175,22 @@ means it can resume a torrent downloaded by any client.</li>
|
|||
<li>file-level priority</li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<p>libtorrent is portable at least among windows, macosx, and UNIX-systems. It uses boost.thread,
|
||||
boost.filesystem, boost.date_time and various other boost libraries as well as zlib.</p>
|
||||
<p>libtorrent is portable at least among windows, macosx, and other UNIX-systems. It uses Boost.Thread,
|
||||
Boost.Filesystem, Boost.Date_time and various other boost libraries as well as zlib.</p>
|
||||
<p>libtorrent has been successfully compiled and tested on:</p>
|
||||
<blockquote>
|
||||
<ul class="simple">
|
||||
<li>Windows 2000 vc7.1</li>
|
||||
<li>Linux x86 (debian) GCC 3.0.4, GCC 3.2.3</li>
|
||||
<li>Linux x86 GCC 3.0.4, GCC 3.2.3, GCC 3.4.2</li>
|
||||
<li>MacOS X, GCC 3.3</li>
|
||||
<li>SunOS 5.8 GCC 3.1</li>
|
||||
<li>Cygwin GCC 3.3.3</li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<p>Fails on:</p>
|
||||
<blockquote>
|
||||
<ul class="simple">
|
||||
<li>GCC 2.95.4 (<tt class="literal"><span class="pre">std::ios_base</span></tt> is missing)</li>
|
||||
<li>Cygwin GCC 3.3.1 (builds but crashes)</li>
|
||||
<li>msvc6 sp5</li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
|
@ -272,11 +273,6 @@ written.</td>
|
|||
checks in the storage, including logging of
|
||||
piece sorting.</td>
|
||||
</tr>
|
||||
<tr><td><tt class="literal"><span class="pre">TORRENT_DISABLE_EXTENSIONS</span></tt></td>
|
||||
<td>This will disble the support for extensions.
|
||||
For more information on which extensions are
|
||||
currently implemented, see <a class="reference" href="#extensions">extensions</a>.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>If you experience that libtorrent uses unreasonable amounts of cpu, it will definately help to
|
||||
|
@ -337,6 +333,9 @@ class session: public boost::noncopyable
|
|||
|
||||
void remove_torrent(torrent_handle const& h);
|
||||
|
||||
void disable_extensions();
|
||||
void enable_extension(peer_connection::extension_index);
|
||||
|
||||
void set_http_settings(const http_settings& settings);
|
||||
|
||||
void set_upload_rate_limit(int bytes_per_second);
|
||||
|
@ -429,6 +428,31 @@ void remove_torrent(torrent_handle const& h);
|
|||
<p><tt class="literal"><span class="pre">remove_torrent()</span></tt> will close all peer connections associated with the torrent and tell
|
||||
the tracker that we've stopped participating in the swarm.</p>
|
||||
</div>
|
||||
<div class="section" id="disable-extensions-enable-extension">
|
||||
<h2><a name="disable-extensions-enable-extension">disable_extensions() enable_extension()</a></h2>
|
||||
<blockquote>
|
||||
<pre class="literal-block">
|
||||
void disable_extensions();
|
||||
void enable_extension(peer_connection::extension_index);
|
||||
</pre>
|
||||
</blockquote>
|
||||
<p><tt class="literal"><span class="pre">disable_extensions()</span></tt> will disable all extensions available in libtorrent.
|
||||
<tt class="literal"><span class="pre">enable_extension()</span></tt> will enable a single extension. The available extensions
|
||||
are enumerated in the <tt class="literal"><span class="pre">peer_connection</span></tt> class. These are the available extensions:</p>
|
||||
<pre class="literal-block">
|
||||
enum extension_index
|
||||
{
|
||||
extended_chat_message,
|
||||
extended_metadata_message,
|
||||
extended_peer_exchange_message,
|
||||
extended_listen_port_message,
|
||||
num_supported_extensions
|
||||
};
|
||||
</pre>
|
||||
<p><em>peer_exchange is not implemented yet</em></p>
|
||||
<p>By default, all extensions are enabled.
|
||||
For more information about the extensions, see the <a class="reference" href="#extensions">extensions</a> section.</p>
|
||||
</div>
|
||||
<div class="section" id="set-upload-rate-limit-set-download-rate-limit">
|
||||
<h2><a name="set-upload-rate-limit-set-download-rate-limit">set_upload_rate_limit() set_download_rate_limit()</a></h2>
|
||||
<blockquote>
|
||||
|
|
|
@ -61,20 +61,20 @@ Functions that are yet to be implemented:
|
|||
* ip-filters
|
||||
* file-level priority
|
||||
|
||||
libtorrent is portable at least among windows, macosx, and UNIX-systems. It uses boost.thread,
|
||||
boost.filesystem, boost.date_time and various other boost libraries as well as zlib.
|
||||
libtorrent is portable at least among windows, macosx, and other UNIX-systems. It uses Boost.Thread,
|
||||
Boost.Filesystem, Boost.Date_time and various other boost libraries as well as zlib.
|
||||
|
||||
libtorrent has been successfully compiled and tested on:
|
||||
|
||||
* Windows 2000 vc7.1
|
||||
* Linux x86 (debian) GCC 3.0.4, GCC 3.2.3
|
||||
* Linux x86 GCC 3.0.4, GCC 3.2.3, GCC 3.4.2
|
||||
* MacOS X, GCC 3.3
|
||||
* SunOS 5.8 GCC 3.1
|
||||
* Cygwin GCC 3.3.3
|
||||
|
||||
Fails on:
|
||||
|
||||
* GCC 2.95.4 (``std::ios_base`` is missing)
|
||||
* Cygwin GCC 3.3.1 (builds but crashes)
|
||||
* msvc6 sp5
|
||||
|
||||
libtorrent is released under the BSD-license_.
|
||||
|
@ -174,10 +174,6 @@ table below for which defines you can use to control the build. The ``Jamfile``
|
|||
| | checks in the storage, including logging of |
|
||||
| | piece sorting. |
|
||||
+--------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_DISABLE_EXTENSIONS`` | This will disble the support for extensions. |
|
||||
| | For more information on which extensions are |
|
||||
| | currently implemented, see extensions_. |
|
||||
+--------------------------------+-------------------------------------------------+
|
||||
|
||||
|
||||
If you experience that libtorrent uses unreasonable amounts of cpu, it will definately help to
|
||||
|
@ -235,6 +231,9 @@ The ``session`` class has the following synopsis::
|
|||
|
||||
void remove_torrent(torrent_handle const& h);
|
||||
|
||||
void disable_extensions();
|
||||
void enable_extension(peer_connection::extension_index);
|
||||
|
||||
void set_http_settings(const http_settings& settings);
|
||||
|
||||
void set_upload_rate_limit(int bytes_per_second);
|
||||
|
@ -335,6 +334,32 @@ remove_torrent()
|
|||
the tracker that we've stopped participating in the swarm.
|
||||
|
||||
|
||||
disable_extensions() enable_extension()
|
||||
---------------------------------------
|
||||
|
||||
::
|
||||
|
||||
void disable_extensions();
|
||||
void enable_extension(peer_connection::extension_index);
|
||||
|
||||
``disable_extensions()`` will disable all extensions available in libtorrent.
|
||||
``enable_extension()`` will enable a single extension. The available extensions
|
||||
are enumerated in the ``peer_connection`` class. These are the available extensions::
|
||||
|
||||
enum extension_index
|
||||
{
|
||||
extended_chat_message,
|
||||
extended_metadata_message,
|
||||
extended_peer_exchange_message,
|
||||
extended_listen_port_message,
|
||||
num_supported_extensions
|
||||
};
|
||||
|
||||
*peer_exchange is not implemented yet*
|
||||
|
||||
By default, all extensions are enabled.
|
||||
For more information about the extensions, see the extensions_ section.
|
||||
|
||||
set_upload_rate_limit() set_download_rate_limit()
|
||||
-------------------------------------------------
|
||||
|
||||
|
|
|
@ -1,38 +1,25 @@
|
|||
use-project /torrent : .. ;
|
||||
|
||||
project
|
||||
: requirements <source>/torrent <threading>multi
|
||||
;
|
||||
|
||||
exe client_test
|
||||
: client_test.cpp
|
||||
/torrent
|
||||
:
|
||||
<threading>multi
|
||||
: debug release
|
||||
;
|
||||
|
||||
|
||||
exe simple_client
|
||||
: simple_client.cpp
|
||||
/torrent
|
||||
:
|
||||
<threading>multi
|
||||
: debug release
|
||||
;
|
||||
|
||||
|
||||
exe dump_torrent
|
||||
: dump_torrent.cpp
|
||||
/torrent
|
||||
:
|
||||
<threading>multi
|
||||
: debug release
|
||||
;
|
||||
|
||||
exe make_torrent
|
||||
: make_torrent.cpp
|
||||
/torrent
|
||||
:
|
||||
<threading>multi
|
||||
: debug release
|
||||
;
|
||||
|
||||
|
||||
|
|
|
@ -216,6 +216,12 @@ namespace libtorrent
|
|||
|
||||
boost::shared_ptr<socket> m_listen_socket;
|
||||
|
||||
// the entries in this array maps the
|
||||
// extension index (as specified in peer_connection)
|
||||
bool m_extension_enabled[peer_connection::num_supported_extensions];
|
||||
|
||||
bool extensions_enabled() const;
|
||||
|
||||
// the settings for the client
|
||||
http_settings m_settings;
|
||||
|
||||
|
@ -304,6 +310,9 @@ namespace libtorrent
|
|||
|
||||
session_status status() const;
|
||||
|
||||
void enable_extension(peer_connection::extension_index i);
|
||||
void disable_extensions();
|
||||
|
||||
bool is_listening() const;
|
||||
|
||||
// if the listen port failed in some way
|
||||
|
|
|
@ -155,6 +155,7 @@ namespace
|
|||
map_entry name_map[] =
|
||||
{
|
||||
map_entry("A", "ABC")
|
||||
, map_entry("AR", "Arctic Torrent")
|
||||
, map_entry("AZ", "Azureus")
|
||||
, map_entry("BB", "BitBuddy")
|
||||
, map_entry("BX", "BittorrentX")
|
||||
|
|
|
@ -413,9 +413,9 @@ namespace libtorrent
|
|||
, m_send_buffer.begin() + pos + 8
|
||||
, 0);
|
||||
// indicate that we support the extension protocol
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
m_send_buffer[pos+7] = 0x01;
|
||||
#endif
|
||||
|
||||
if (m_ses.extensions_enabled())
|
||||
m_send_buffer[pos+7] = 0x01;
|
||||
pos += 8;
|
||||
|
||||
// info hash
|
||||
|
@ -1057,7 +1057,7 @@ namespace libtorrent
|
|||
|
||||
assert(m_torrent);
|
||||
assert(received > 0);
|
||||
if (m_packet_size > 100 * 1024)
|
||||
if (m_packet_size > 100 * 1000)
|
||||
{
|
||||
// too big extension message, abort
|
||||
throw protocol_error("'extensions' message size > 100kB");
|
||||
|
@ -1125,6 +1125,9 @@ namespace libtorrent
|
|||
const char* ptr = &m_recv_buffer[1];
|
||||
int extended_id = detail::read_int32(ptr);
|
||||
|
||||
if (!m_ses.m_extension_enabled[extended_id])
|
||||
throw protocol_error("'extended' message using disabled extension");
|
||||
|
||||
switch (extended_id)
|
||||
{
|
||||
case extended_chat_message:
|
||||
|
@ -1587,6 +1590,9 @@ namespace libtorrent
|
|||
|
||||
for (int i = 0; i < num_supported_extensions; ++i)
|
||||
{
|
||||
// if this specific extension is disabled
|
||||
// just don't add it to the supported set
|
||||
if (!m_ses.m_extension_enabled[i]) continue;
|
||||
extension_list[extension_names[i]] = i;
|
||||
}
|
||||
|
||||
|
@ -1953,10 +1959,8 @@ namespace libtorrent
|
|||
// ok, now we have got enough of the handshake. Is this connection
|
||||
// attached to a torrent?
|
||||
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
if (m_recv_buffer[7] & 0x01)
|
||||
if ((m_recv_buffer[7] & 0x01) && m_ses.extensions_enabled())
|
||||
m_supports_extensions = true;
|
||||
#endif
|
||||
|
||||
if (m_torrent == 0)
|
||||
{
|
||||
|
|
|
@ -203,6 +203,8 @@ namespace libtorrent { namespace detail
|
|||
#ifndef NDEBUG
|
||||
m_logger = create_log("main session");
|
||||
#endif
|
||||
std::fill(m_extension_enabled, m_extension_enabled
|
||||
+ peer_connection::num_supported_extensions, true);
|
||||
// ---- generate a peer id ----
|
||||
|
||||
std::srand((unsigned int)std::time(0));
|
||||
|
@ -229,6 +231,13 @@ namespace libtorrent { namespace detail
|
|||
}
|
||||
}
|
||||
|
||||
bool session_impl::extensions_enabled() const
|
||||
{
|
||||
const int n = peer_connection::num_supported_extensions;
|
||||
return std::find(m_extension_enabled
|
||||
, m_extension_enabled + n, true) != m_extension_enabled + n;
|
||||
}
|
||||
|
||||
void session_impl::purge_connections()
|
||||
{
|
||||
while (!m_disconnect_peer.empty())
|
||||
|
@ -852,6 +861,21 @@ namespace libtorrent
|
|||
#endif
|
||||
}
|
||||
|
||||
void session::disable_extensions()
|
||||
{
|
||||
boost::mutex::scoped_lock l(m_impl.m_mutex);
|
||||
std::fill(m_impl.m_extension_enabled, m_impl.m_extension_enabled
|
||||
+ peer_connection::num_supported_extensions, false);
|
||||
}
|
||||
|
||||
void session::enable_extension(peer_connection::extension_index i)
|
||||
{
|
||||
assert(i >= 0);
|
||||
assert(i < peer_connection::num_supported_extensions);
|
||||
boost::mutex::scoped_lock l(m_impl.m_mutex);
|
||||
m_impl.m_extension_enabled[i] = true;
|
||||
}
|
||||
|
||||
// TODO: add a check to see if filenames are accepted on the
|
||||
// current platform.
|
||||
// if the torrent already exists, this will throw duplicate_torrent
|
||||
|
@ -903,7 +927,6 @@ namespace libtorrent
|
|||
return torrent_handle(&m_impl, &m_checker_impl, ti.info_hash());
|
||||
}
|
||||
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
torrent_handle session::add_torrent(
|
||||
char const* tracker_url
|
||||
, sha1_hash const& info_hash
|
||||
|
@ -923,6 +946,10 @@ namespace libtorrent
|
|||
// lock the session
|
||||
boost::mutex::scoped_lock l(m_impl.m_mutex);
|
||||
|
||||
// the metadata extension has to be enabled for this to work
|
||||
assert(m_impl.m_extension_enabled
|
||||
[peer_connection::extended_metadata_message]);
|
||||
|
||||
// is the torrent already active?
|
||||
if (m_impl.find_torrent(info_hash))
|
||||
throw duplicate_torrent();
|
||||
|
@ -931,14 +958,14 @@ namespace libtorrent
|
|||
// the checker thread and store it before starting
|
||||
// the thread
|
||||
boost::shared_ptr<torrent> torrent_ptr(
|
||||
new torrent(m_impl, tracker_url, info_hash, save_path, m_impl.m_listen_interface));
|
||||
new torrent(m_impl, tracker_url, info_hash, save_path
|
||||
, m_impl.m_listen_interface));
|
||||
|
||||
m_impl.m_torrents.insert(
|
||||
std::make_pair(info_hash, torrent_ptr)).first;
|
||||
|
||||
return torrent_handle(&m_impl, &m_checker_impl, info_hash);
|
||||
}
|
||||
#endif
|
||||
|
||||
void session::remove_torrent(const torrent_handle& h)
|
||||
{
|
||||
|
|
|
@ -827,7 +827,7 @@ namespace libtorrent
|
|||
if (m_paused)
|
||||
{
|
||||
// let the stats fade out to 0
|
||||
m_stat.second_tick();
|
||||
m_stat.second_tick();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,10 +43,10 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#endif
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/date_time/time.hpp>
|
||||
#include <boost/date_time/gregorian/gregorian_types.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/next_prior.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
|
@ -83,13 +83,6 @@ namespace
|
|||
}
|
||||
}
|
||||
|
||||
size_type to_seconds(const boost::posix_time::time_duration& d)
|
||||
{
|
||||
return d.hours() * 60 * 60
|
||||
+ d.minutes() * 60
|
||||
+ d.seconds();
|
||||
}
|
||||
|
||||
void remove_dir(path& p)
|
||||
{
|
||||
assert(p.begin() != p.end());
|
||||
|
@ -318,6 +311,10 @@ namespace libtorrent
|
|||
announce_entry e(url);
|
||||
e.tier = tier;
|
||||
m_urls.push_back(e);
|
||||
|
||||
using boost::bind;
|
||||
std::sort(m_urls.begin(), m_urls.end(), bind(std::less<int>()
|
||||
, bind(&announce_entry::tier, _1), bind(&announce_entry::tier, _2)));
|
||||
}
|
||||
|
||||
void torrent_info::add_file(boost::filesystem::path file, size_type size)
|
||||
|
@ -455,12 +452,32 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
dict["announce"] = m_urls.front().url;
|
||||
|
||||
|
||||
if (m_urls.size() > 1)
|
||||
{
|
||||
entry trackers(entry::list_t);
|
||||
entry tier(entry::list_t);
|
||||
int current_tier = m_urls.front().tier;
|
||||
for (std::vector<announce_entry>::const_iterator i = m_urls.begin();
|
||||
i != m_urls.end(); ++i)
|
||||
{
|
||||
if (i->tier != current_tier)
|
||||
{
|
||||
current_tier = i->tier;
|
||||
trackers.list().push_back(tier);
|
||||
tier.list().clear();
|
||||
}
|
||||
tier.list().push_back(i->url);
|
||||
}
|
||||
trackers.list().push_back(tier);
|
||||
dict["announce-list"] = trackers;
|
||||
}
|
||||
|
||||
if (!m_comment.empty())
|
||||
dict["comment"] = m_comment;
|
||||
|
||||
dict["creation date"] =
|
||||
to_seconds(m_creation_date - ptime(date(1970, Jan, 1)));
|
||||
(m_creation_date - ptime(date(1970, Jan, 1))).total_seconds();
|
||||
|
||||
if (!m_created_by.empty())
|
||||
dict["created by"] = m_created_by;
|
||||
|
|
Loading…
Reference in New Issue