Made the Jamfile to work with boost-build.
updated documentation to reflect the new (working) Jamfile.
This commit is contained in:
parent
f656b34d63
commit
9a2fc89eae
37
Jamfile
37
Jamfile
|
@ -12,28 +12,30 @@ use-project /boost/date_time : $(BOOST_ROOT)/libs/date_time/build ;
|
|||
|
||||
project torrent
|
||||
: requirements
|
||||
<use>/boost/thread
|
||||
<use>/boost/date_time
|
||||
<use>/boost/filesystem
|
||||
|
||||
<use>/boost/thread
|
||||
<use>/boost/date_time
|
||||
<use>/boost/filesystem
|
||||
|
||||
<library>/boost/thread
|
||||
<library>/boost/date_time
|
||||
<library>/boost/filesystem
|
||||
<library>/boost/thread
|
||||
<library>/boost/date_time
|
||||
<library>/boost/filesystem
|
||||
|
||||
: usage-requirements
|
||||
|
||||
<include>./include
|
||||
<include>$(BOOST_ROOT)
|
||||
<include>./include
|
||||
<include>$(BOOST_ROOT)
|
||||
<variant>release:<define>NDEBUG
|
||||
|
||||
# devstudio switches
|
||||
|
||||
<toolset>msvc-7:<cxxflags>/Zc:wchar_t
|
||||
<toolset>msvc-7.1:<cxxflags>/Zc:wchar_t
|
||||
<toolset>msvc:<define>WIN32
|
||||
<toolset>msvc-7:<cxxflags>/Zc:wchar_t
|
||||
<toolset>msvc-7.1:<cxxflags>/Zc:wchar_t
|
||||
<toolset>msvc:<define>WIN32
|
||||
|
||||
# gcc switches
|
||||
|
||||
<toolset>gcc:<cxxflags>-Wno-unused-variable
|
||||
<toolset>gcc:<cxxflags>-Wno-unused-variable
|
||||
|
||||
;
|
||||
|
||||
|
@ -82,11 +84,12 @@ SOURCES =
|
|||
|
||||
lib torrent
|
||||
:
|
||||
zlib//zlib
|
||||
src/$(SOURCES)
|
||||
: <include>./include
|
||||
<threading>multi
|
||||
<link>static
|
||||
zlib//zlib
|
||||
src/$(SOURCES)
|
||||
:
|
||||
<include>./include
|
||||
<threading>multi
|
||||
<link>static
|
||||
: debug release
|
||||
;
|
||||
|
||||
|
|
134
docs/manual.html
134
docs/manual.html
|
@ -13,63 +13,63 @@
|
|||
<div class="contents topic" id="contents">
|
||||
<p class="topic-title"><a name="contents">Contents</a></p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="#introduction" id="id10" name="id10">introduction</a></li>
|
||||
<li><a class="reference" href="#building" id="id11" name="id11">building</a><ul>
|
||||
<li><a class="reference" href="#release-and-debug-builds" id="id12" name="id12">release and debug builds</a></li>
|
||||
<li><a class="reference" href="#introduction" id="id12" name="id12">introduction</a></li>
|
||||
<li><a class="reference" href="#building" id="id13" name="id13">building</a><ul>
|
||||
<li><a class="reference" href="#release-and-debug-builds" id="id14" name="id14">release and debug builds</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#using" id="id13" name="id13">using</a></li>
|
||||
<li><a class="reference" href="#session" id="id14" name="id14">session</a></li>
|
||||
<li><a class="reference" href="#parsing-torrent-files" id="id15" name="id15">parsing torrent files</a></li>
|
||||
<li><a class="reference" href="#entry" id="id16" name="id16">entry</a></li>
|
||||
<li><a class="reference" href="#torrent-info" id="id17" name="id17">torrent_info</a></li>
|
||||
<li><a class="reference" href="#torrent-handle" id="id18" name="id18">torrent_handle</a><ul>
|
||||
<li><a class="reference" href="#status" id="id19" name="id19">status()</a></li>
|
||||
<li><a class="reference" href="#get-download-queue" id="id20" name="id20">get_download_queue()</a></li>
|
||||
<li><a class="reference" href="#get-peer-info" id="id21" name="id21">get_peer_info()</a></li>
|
||||
<li><a class="reference" href="#get-torrent-info" id="id22" name="id22">get_torrent_info()</a></li>
|
||||
<li><a class="reference" href="#is-valid" id="id23" name="id23">is_valid()</a></li>
|
||||
<li><a class="reference" href="#using" id="id15" name="id15">using</a></li>
|
||||
<li><a class="reference" href="#session" id="id16" name="id16">session</a></li>
|
||||
<li><a class="reference" href="#parsing-torrent-files" id="id17" name="id17">parsing torrent files</a></li>
|
||||
<li><a class="reference" href="#entry" id="id18" name="id18">entry</a></li>
|
||||
<li><a class="reference" href="#torrent-info" id="id19" name="id19">torrent_info</a></li>
|
||||
<li><a class="reference" href="#torrent-handle" id="id20" name="id20">torrent_handle</a><ul>
|
||||
<li><a class="reference" href="#status" id="id21" name="id21">status()</a></li>
|
||||
<li><a class="reference" href="#get-download-queue" id="id22" name="id22">get_download_queue()</a></li>
|
||||
<li><a class="reference" href="#get-peer-info" id="id23" name="id23">get_peer_info()</a></li>
|
||||
<li><a class="reference" href="#get-torrent-info" id="id24" name="id24">get_torrent_info()</a></li>
|
||||
<li><a class="reference" href="#is-valid" id="id25" name="id25">is_valid()</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#address" id="id24" name="id24">address</a></li>
|
||||
<li><a class="reference" href="#http-settings" id="id25" name="id25">http_settings</a></li>
|
||||
<li><a class="reference" href="#big-number" id="id26" name="id26">big_number</a></li>
|
||||
<li><a class="reference" href="#hasher" id="id27" name="id27">hasher</a></li>
|
||||
<li><a class="reference" href="#fingerprint" id="id28" name="id28">fingerprint</a><ul>
|
||||
<li><a class="reference" href="#identify-client" id="id29" name="id29">identify_client</a></li>
|
||||
<li><a class="reference" href="#address" id="id26" name="id26">address</a></li>
|
||||
<li><a class="reference" href="#http-settings" id="id27" name="id27">http_settings</a></li>
|
||||
<li><a class="reference" href="#big-number" id="id28" name="id28">big_number</a></li>
|
||||
<li><a class="reference" href="#hasher" id="id29" name="id29">hasher</a></li>
|
||||
<li><a class="reference" href="#fingerprint" id="id30" name="id30">fingerprint</a><ul>
|
||||
<li><a class="reference" href="#identify-client" id="id31" name="id31">identify_client</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#alerts" id="id30" name="id30">alerts</a><ul>
|
||||
<li><a class="reference" href="#listen-failed-alert" id="id31" name="id31">listen_failed_alert</a></li>
|
||||
<li><a class="reference" href="#file-error-alert" id="id32" name="id32">file_error_alert</a></li>
|
||||
<li><a class="reference" href="#tracker-alert" id="id33" name="id33">tracker_alert</a></li>
|
||||
<li><a class="reference" href="#hash-failed-alert" id="id34" name="id34">hash_failed_alert</a></li>
|
||||
<li><a class="reference" href="#peer-error-alert" id="id35" name="id35">peer_error_alert</a></li>
|
||||
<li><a class="reference" href="#invalid-request-alert" id="id36" name="id36">invalid_request_alert</a></li>
|
||||
<li><a class="reference" href="#torrent-finished-alert" id="id37" name="id37">torrent_finished_alert</a></li>
|
||||
<li><a class="reference" href="#dispatcher" id="id38" name="id38">dispatcher</a></li>
|
||||
<li><a class="reference" href="#alerts" id="id32" name="id32">alerts</a><ul>
|
||||
<li><a class="reference" href="#listen-failed-alert" id="id33" name="id33">listen_failed_alert</a></li>
|
||||
<li><a class="reference" href="#file-error-alert" id="id34" name="id34">file_error_alert</a></li>
|
||||
<li><a class="reference" href="#tracker-alert" id="id35" name="id35">tracker_alert</a></li>
|
||||
<li><a class="reference" href="#hash-failed-alert" id="id36" name="id36">hash_failed_alert</a></li>
|
||||
<li><a class="reference" href="#peer-error-alert" id="id37" name="id37">peer_error_alert</a></li>
|
||||
<li><a class="reference" href="#invalid-request-alert" id="id38" name="id38">invalid_request_alert</a></li>
|
||||
<li><a class="reference" href="#torrent-finished-alert" id="id39" name="id39">torrent_finished_alert</a></li>
|
||||
<li><a class="reference" href="#dispatcher" id="id40" name="id40">dispatcher</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#exceptions" id="id39" name="id39">exceptions</a><ul>
|
||||
<li><a class="reference" href="#invalid-handle" id="id40" name="id40">invalid_handle</a></li>
|
||||
<li><a class="reference" href="#duplicate-torrent" id="id41" name="id41">duplicate_torrent</a></li>
|
||||
<li><a class="reference" href="#invalid-encoding" id="id42" name="id42">invalid_encoding</a></li>
|
||||
<li><a class="reference" href="#type-error" id="id43" name="id43">type_error</a></li>
|
||||
<li><a class="reference" href="#invalid-torrent-file" id="id44" name="id44">invalid_torrent_file</a></li>
|
||||
<li><a class="reference" href="#exceptions" id="id41" name="id41">exceptions</a><ul>
|
||||
<li><a class="reference" href="#invalid-handle" id="id42" name="id42">invalid_handle</a></li>
|
||||
<li><a class="reference" href="#duplicate-torrent" id="id43" name="id43">duplicate_torrent</a></li>
|
||||
<li><a class="reference" href="#invalid-encoding" id="id44" name="id44">invalid_encoding</a></li>
|
||||
<li><a class="reference" href="#type-error" id="id45" name="id45">type_error</a></li>
|
||||
<li><a class="reference" href="#invalid-torrent-file" id="id46" name="id46">invalid_torrent_file</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#examples" id="id45" name="id45">examples</a><ul>
|
||||
<li><a class="reference" href="#dump-torrent" id="id46" name="id46">dump_torrent</a></li>
|
||||
<li><a class="reference" href="#simple-client" id="id47" name="id47">simple client</a></li>
|
||||
<li><a class="reference" href="#examples" id="id47" name="id47">examples</a><ul>
|
||||
<li><a class="reference" href="#dump-torrent" id="id48" name="id48">dump_torrent</a></li>
|
||||
<li><a class="reference" href="#simple-client" id="id49" name="id49">simple client</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#fast-resume" id="id48" name="id48">fast resume</a><ul>
|
||||
<li><a class="reference" href="#file-format" id="id49" name="id49">file format</a></li>
|
||||
<li><a class="reference" href="#fast-resume" id="id50" name="id50">fast resume</a><ul>
|
||||
<li><a class="reference" href="#file-format" id="id51" name="id51">file format</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference" href="#extensions" id="id50" name="id50">extensions</a></li>
|
||||
<li><a class="reference" href="#filenames-checks" id="id51" name="id51">filenames checks</a></li>
|
||||
<li><a class="reference" href="#aknowledgements" id="id52" name="id52">aknowledgements</a></li>
|
||||
<li><a class="reference" href="#extensions" id="id52" name="id52">extensions</a></li>
|
||||
<li><a class="reference" href="#filenames-checks" id="id53" name="id53">filenames checks</a></li>
|
||||
<li><a class="reference" href="#aknowledgements" id="id54" name="id54">aknowledgements</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="introduction">
|
||||
|
@ -148,36 +148,22 @@ boost.filesystem, boost.date_time and various other boost libraries as well as z
|
|||
</div>
|
||||
<div class="section" id="building">
|
||||
<h1><a name="building">building</a></h1>
|
||||
<p>To build libtorrent you need <a class="reference" href="http://www.boost.org">boost</a> and bjam installed.
|
||||
Then you can use <tt class="literal"><span class="pre">bjam</span></tt> to build libtorrent.</p>
|
||||
<!-- http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=80982 -->
|
||||
<p>To make bjam work, you need to set the environment variable <tt class="literal"><span class="pre">BOOST_ROOT</span></tt> to the
|
||||
path where boost is installed (e.g. c:\boost_1_30_2 on windows). Then you can just run
|
||||
<tt class="literal"><span class="pre">bjam</span></tt> in the libtorrent directory.</p>
|
||||
<p>The Jamfile doesn't work yet. On unix-systems you can use the makefile however. You
|
||||
first have to build boost.thread and boost.filesystem. You do this by, in the directory
|
||||
'boost-1.30.2/tools/build/jam_src' run the build script <tt class="literal"><span class="pre">./build.sh</span></tt>. This should
|
||||
produce at least one folder with the 'bin' prefix (and the rest of the name describes
|
||||
your platform). Put the files in that folder somewhere in your path.</p>
|
||||
<p>You can then invoke <tt class="literal"><span class="pre">bjam</span></tt> in the directories 'boost-1.30.2/libs/thread/build',
|
||||
'boost-1.30.2/libs/date_time/build' and 'boost-1.30.2/libs/filesystem/build'. That will
|
||||
produce the needed libraries. Put these libraries in the libtorrent root directory.
|
||||
You then have to modify the makefile to use you prefered compiler and to have the
|
||||
correct path to your boost istallation.</p>
|
||||
<p>Then the makefile should be able to do the rest.</p>
|
||||
<p>When building (with boost 1.30.2) on linux and solaris however, I found that I had to make the following
|
||||
modifications to the boost.date-time library. In the file:
|
||||
'boost-1.30.2/boost/date_time/gregorian_calendar.hpp' line 59. Prepend 'boost/date_time/'
|
||||
to the include path.</p>
|
||||
<p>And the second modification was in the file:
|
||||
'boost-1.30.2/boost/date_time/microsec_time_clock.hpp' add the following include at the top
|
||||
of the file:</p>
|
||||
<p>The easiest way to build libtorrent is probably to use <a class="reference" href="http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=80982">boost-build</a>. Make sure you install it
|
||||
correctly by setting the environment variable <tt class="literal"><span class="pre">BOOST_BUILD_PATH</span></tt> and modifying the
|
||||
<tt class="literal"><span class="pre">user_config.jam</span></tt> to reflect the toolsets you have installed.</p>
|
||||
<p>You also need to install <a class="reference" href="http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=8041&release_id=214915">boost 1.31.0</a>.</p>
|
||||
<p>Before you invoke <tt class="literal"><span class="pre">bjam</span></tt> you have to set the environment variable <tt class="literal"><span class="pre">BOOST_ROOT</span></tt> to the
|
||||
path where you installed boost. This will be used to build and link against the required
|
||||
boost libraries as well as be used as include path for boost headers.</p>
|
||||
<p>To build you just have to run:</p>
|
||||
<pre class="literal-block">
|
||||
#include "boost/cstdint.hpp"
|
||||
bjam <toolset>
|
||||
</pre>
|
||||
<p>In developer studio, you may have to set the compiler options "force conformance in for
|
||||
loop scope" and "treat wchar_t as built-in type" to Yes.</p>
|
||||
<p>TODO: more detailed build instructions.</p>
|
||||
<p>in the libtorrent directory.</p>
|
||||
<p>If you're building in developer studio, you may have to set the compiler options
|
||||
"force conformance in for loop scope" and "treat wchar_t as built-in type" to Yes.</p>
|
||||
<p>If you're building in developer studio 6, you will probably have to use the previous
|
||||
version of boost, <a class="reference" href="http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=8041&release_id=178835">boost 1.30.2</a>.</p>
|
||||
<div class="section" id="release-and-debug-builds">
|
||||
<h2><a name="release-and-debug-builds">release and debug builds</a></h2>
|
||||
<p>If you just invoke the makefile you'll get a debug build. In debug the libtorrent vill
|
||||
|
@ -536,6 +522,8 @@ struct torrent_handle
|
|||
void connect_peer(const address& adr) const;
|
||||
void set_ratio(float ratio);
|
||||
|
||||
void set_tracker_login(std::string const& username, std::string const& password);
|
||||
|
||||
boost::filsystem::path save_path() const;
|
||||
|
||||
void set_max_uploads(int max_uploads);
|
||||
|
@ -564,10 +552,12 @@ will throw <a class="reference" href="#invalid-handle">invalid_handle</a>.</p>
|
|||
<p><tt class="literal"><span class="pre">set_ratio()</span></tt> 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.</p>
|
||||
<p>Besides 0, the ration can be set to any number greater than or equal to 1. It means how much to
|
||||
<p>Besides 0, the ratio can be set to any number greater than or equal to 1. It means how much to
|
||||
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.</p>
|
||||
<p><tt class="literal"><span class="pre">set_tracker_login()</span></tt> 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.</p>
|
||||
<p><tt class="literal"><span class="pre">info_hash()</span></tt> returns the info hash for the torrent.</p>
|
||||
<p><tt class="literal"><span class="pre">set_max_uploads()</span></tt> 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.</p>
|
||||
|
|
|
@ -83,47 +83,33 @@ libtorrent is released under the BSD-license_.
|
|||
building
|
||||
========
|
||||
|
||||
To build libtorrent you need boost_ and bjam installed.
|
||||
Then you can use ``bjam`` to build libtorrent.
|
||||
The easiest way to build libtorrent is probably to use `boost-build`_. Make sure you install it
|
||||
correctly by setting the environment variable ``BOOST_BUILD_PATH`` and modifying the
|
||||
``user_config.jam`` to reflect the toolsets you have installed.
|
||||
|
||||
.. _boost: http://www.boost.org
|
||||
.. _`boost-build`: http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=80982
|
||||
|
||||
.. http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=80982
|
||||
You also need to install `boost 1.31.0`__.
|
||||
|
||||
To make bjam work, you need to set the environment variable ``BOOST_ROOT`` to the
|
||||
path where boost is installed (e.g. c:\\boost_1_30_2 on windows). Then you can just run
|
||||
``bjam`` in the libtorrent directory.
|
||||
__ http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=8041&release_id=214915
|
||||
|
||||
The Jamfile doesn't work yet. On unix-systems you can use the makefile however. You
|
||||
first have to build boost.thread and boost.filesystem. You do this by, in the directory
|
||||
'boost-1.30.2/tools/build/jam_src' run the build script ``./build.sh``. This should
|
||||
produce at least one folder with the 'bin' prefix (and the rest of the name describes
|
||||
your platform). Put the files in that folder somewhere in your path.
|
||||
Before you invoke ``bjam`` you have to set the environment variable ``BOOST_ROOT`` to the
|
||||
path where you installed boost. This will be used to build and link against the required
|
||||
boost libraries as well as be used as include path for boost headers.
|
||||
|
||||
You can then invoke ``bjam`` in the directories 'boost-1.30.2/libs/thread/build',
|
||||
'boost-1.30.2/libs/date_time/build' and 'boost-1.30.2/libs/filesystem/build'. That will
|
||||
produce the needed libraries. Put these libraries in the libtorrent root directory.
|
||||
You then have to modify the makefile to use you prefered compiler and to have the
|
||||
correct path to your boost istallation.
|
||||
To build you just have to run::
|
||||
|
||||
Then the makefile should be able to do the rest.
|
||||
bjam <toolset>
|
||||
|
||||
When building (with boost 1.30.2) on linux and solaris however, I found that I had to make the following
|
||||
modifications to the boost.date-time library. In the file:
|
||||
'boost-1.30.2/boost/date_time/gregorian_calendar.hpp' line 59. Prepend 'boost/date_time/'
|
||||
to the include path.
|
||||
in the libtorrent directory.
|
||||
|
||||
And the second modification was in the file:
|
||||
'boost-1.30.2/boost/date_time/microsec_time_clock.hpp' add the following include at the top
|
||||
of the file::
|
||||
If you're building in developer studio, you may have to set the compiler options
|
||||
"force conformance in for loop scope" and "treat wchar_t as built-in type" to Yes.
|
||||
|
||||
#include "boost/cstdint.hpp"
|
||||
|
||||
In developer studio, you may have to set the compiler options "force conformance in for
|
||||
loop scope" and "treat wchar_t as built-in type" to Yes.
|
||||
|
||||
TODO: more detailed build instructions.
|
||||
If you're building in developer studio 6, you will probably have to use the previous
|
||||
version of boost, `boost 1.30.2`__.
|
||||
|
||||
__ http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=8041&release_id=178835
|
||||
|
||||
release and debug builds
|
||||
------------------------
|
||||
|
@ -523,6 +509,8 @@ Its declaration looks like this::
|
|||
void connect_peer(const address& adr) const;
|
||||
void set_ratio(float ratio);
|
||||
|
||||
void set_tracker_login(std::string const& username, std::string const& password);
|
||||
|
||||
boost::filsystem::path save_path() const;
|
||||
|
||||
void set_max_uploads(int max_uploads);
|
||||
|
@ -556,11 +544,14 @@ will throw invalid_handle_.
|
|||
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.
|
||||
|
||||
Besides 0, the ration can be set to any number greater than or equal to 1. It means how much to
|
||||
Besides 0, the ratio can be set to any number greater than or equal to 1. It means how much to
|
||||
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.
|
||||
|
||||
``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.
|
||||
|
||||
``info_hash()`` returns the info hash for the torrent.
|
||||
|
||||
``set_max_uploads()`` sets the maximum number of peers that's unchoked at the same time on this
|
||||
|
|
|
@ -71,7 +71,8 @@ namespace libtorrent
|
|||
, unsigned short port
|
||||
, std::string const& request
|
||||
, request_callback* c
|
||||
, const http_settings& stn);
|
||||
, const http_settings& stn
|
||||
, std::string const& password = "");
|
||||
virtual bool tick();
|
||||
virtual bool send_finished() const
|
||||
{ return m_send_buffer.empty(); }
|
||||
|
|
|
@ -187,6 +187,7 @@ namespace libtorrent
|
|||
// generates a request string for sending
|
||||
// to the tracker
|
||||
tracker_request generate_tracker_request(int port);
|
||||
std::string tracker_password() const;
|
||||
|
||||
boost::posix_time::ptime next_announce() const
|
||||
{ return m_next_request; }
|
||||
|
@ -261,6 +262,12 @@ namespace libtorrent
|
|||
alert_manager& alerts() const;
|
||||
torrent_handle get_handle() const;
|
||||
|
||||
void set_tracker_login(std::string const& name, std::string const& pw)
|
||||
{
|
||||
m_username = name;
|
||||
m_password = pw;
|
||||
}
|
||||
|
||||
// DEBUG
|
||||
#ifndef NDEBUG
|
||||
logger* spawn_logger(const char* title);
|
||||
|
@ -349,6 +356,9 @@ namespace libtorrent
|
|||
// tries to maintain.
|
||||
// 0 is infinite
|
||||
float m_ratio;
|
||||
|
||||
std::string m_username;
|
||||
std::string m_password;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -181,6 +181,8 @@ namespace libtorrent
|
|||
// -1 means unlimited connections
|
||||
void set_max_connections(int max_connections);
|
||||
|
||||
void set_tracker_login(std::string const& name, std::string const& password);
|
||||
|
||||
const sha1_hash& info_hash() const
|
||||
{ return m_info_hash; }
|
||||
|
||||
|
|
|
@ -137,7 +137,10 @@ namespace libtorrent
|
|||
: m_settings(s) {}
|
||||
|
||||
void tick();
|
||||
void queue_request(tracker_request const& r, request_callback* c = 0);
|
||||
void queue_request(
|
||||
tracker_request const& r
|
||||
, request_callback* c = 0
|
||||
, std::string const& password = "");
|
||||
void abort_request(request_callback* c);
|
||||
void abort_all_requests();
|
||||
bool send_finished() const;
|
||||
|
|
|
@ -81,7 +81,8 @@ namespace libtorrent
|
|||
, unsigned short port
|
||||
, std::string const& request
|
||||
, request_callback* c
|
||||
, const http_settings& stn)
|
||||
, const http_settings& stn
|
||||
, std::string const& password)
|
||||
: tracker_connection(c)
|
||||
, m_state(read_status)
|
||||
, m_content_encoding(plain)
|
||||
|
@ -121,6 +122,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
m_send_buffer += request;
|
||||
/*
|
||||
m_send_buffer += "?info_hash=";
|
||||
m_send_buffer += escape_string(
|
||||
reinterpret_cast<const char*>(req.info_hash.begin()), 20);
|
||||
|
@ -151,7 +153,7 @@ namespace libtorrent
|
|||
// extension that tells the tracker that
|
||||
// we don't need any peer_id's in the response
|
||||
m_send_buffer += "&no_peer_id=1";
|
||||
|
||||
*/
|
||||
m_send_buffer += " HTTP/1.0\r\nAccept-Encoding: gzip\r\n"
|
||||
"User-Agent: ";
|
||||
m_send_buffer += m_settings.user_agent;
|
||||
|
@ -168,6 +170,11 @@ namespace libtorrent
|
|||
m_send_buffer += "\r\nProxy-Authorization: Basic ";
|
||||
m_send_buffer += base64encode(m_settings.proxy_login + ":" + m_settings.proxy_password);
|
||||
}
|
||||
if (password != "")
|
||||
{
|
||||
m_send_buffer += "\r\nAuthorization: Basic ";
|
||||
m_send_buffer += base64encode(password);
|
||||
}
|
||||
m_send_buffer += "\r\n\r\n";
|
||||
#ifndef NDEBUG
|
||||
if (c) c->debug_log("==> TRACKER_REQUEST [ str: " + m_send_buffer + " ]");
|
||||
|
|
|
@ -590,7 +590,8 @@ namespace libtorrent
|
|||
++i)
|
||||
{
|
||||
i->second->abort();
|
||||
m_tracker_manager.queue_request(i->second->generate_tracker_request(m_listen_port));
|
||||
m_tracker_manager.queue_request(
|
||||
i->second->generate_tracker_request(m_listen_port));
|
||||
}
|
||||
m_connections.clear();
|
||||
m_torrents.clear();
|
||||
|
@ -844,8 +845,9 @@ namespace libtorrent
|
|||
else if (i->second->should_request())
|
||||
{
|
||||
m_tracker_manager.queue_request(
|
||||
i->second->generate_tracker_request(m_listen_port),
|
||||
boost::get_pointer(i->second));
|
||||
i->second->generate_tracker_request(m_listen_port)
|
||||
, boost::get_pointer(i->second)
|
||||
, i->second->tracker_password());
|
||||
}
|
||||
|
||||
i->second->second_tick();
|
||||
|
|
|
@ -459,6 +459,12 @@ namespace libtorrent
|
|||
i->second->announce_piece(index);
|
||||
}
|
||||
|
||||
std::string torrent::tracker_password() const
|
||||
{
|
||||
if (m_username.empty() && m_password.empty()) return "";
|
||||
return m_username + ":" + m_password;
|
||||
}
|
||||
|
||||
tracker_request torrent::generate_tracker_request(int port)
|
||||
{
|
||||
assert(port > 0);
|
||||
|
|
|
@ -185,6 +185,26 @@ namespace libtorrent
|
|||
throw invalid_handle();
|
||||
}
|
||||
|
||||
void torrent_handle::set_tracker_login(std::string const& name, std::string const& password)
|
||||
{
|
||||
if (m_ses == 0) throw invalid_handle();
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock l(m_ses->m_mutex);
|
||||
torrent* t = m_ses->find_torrent(m_info_hash);
|
||||
if (t != 0) t->set_tracker_login(name, password);
|
||||
}
|
||||
|
||||
if (m_chk)
|
||||
{
|
||||
boost::mutex::scoped_lock l(m_chk->m_mutex);
|
||||
detail::piece_checker_data* d = m_chk->find_torrent(m_info_hash);
|
||||
if (d != 0) d->torrent_ptr->set_tracker_login(name, password);
|
||||
}
|
||||
|
||||
throw invalid_handle();
|
||||
}
|
||||
|
||||
bool torrent_handle::is_valid() const
|
||||
{
|
||||
if (m_ses == 0) return false;
|
||||
|
|
|
@ -304,7 +304,8 @@ namespace libtorrent
|
|||
|
||||
void tracker_manager::queue_request(
|
||||
tracker_request const& req
|
||||
, request_callback* c)
|
||||
, request_callback* c
|
||||
, std::string const& password)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -363,7 +364,8 @@ namespace libtorrent
|
|||
, port
|
||||
, request_string
|
||||
, c
|
||||
, m_settings));
|
||||
, m_settings
|
||||
, password));
|
||||
}
|
||||
else if (protocol == "udp")
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue