*** empty log message ***

This commit is contained in:
Arvid Norberg 2004-04-02 22:21:20 +00:00
parent 653a4a970d
commit 1313fb9fb8
4 changed files with 151 additions and 74 deletions

View File

@ -24,7 +24,8 @@ the request. If no reply has been received after 60 seconds, stop
retrying.</p>
<div class="section" id="connecting">
<h1><a name="connecting">connecting</a></h1>
<p>Client sends packet:</p>
<div class="section" id="client-sends-packet">
<h2><a name="client-sends-packet">Client sends packet:</a></h2>
<table border class="table">
<colgroup>
<col width="18%" />
@ -52,38 +53,9 @@ retrying.</p>
</tr>
</tbody>
</table>
<p>optional part</p>
<table border class="table">
<colgroup>
<col width="18%" />
<col width="28%" />
<col width="54%" />
</colgroup>
<thead valign="bottom">
<tr><th>size</th>
<th>name</th>
<th>description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>int8_t</td>
<td>flags</td>
<td>1 = authentication</td>
</tr>
<tr><td>int8_t[8]</td>
<td>username</td>
<td>&nbsp;</td>
</tr>
<tr><td>int8_t[8]</td>
<td>password_hash</td>
<td>sha1-hash of the tracker password</td>
</tr>
</tbody>
</table>
<p>what is the point of having a fixed size username field instead of
a null-terminated string?</p>
<p>Why send the hash of the password instead of the password itself?</p>
<p>Server replies with packet:</p>
</div>
<div class="section" id="server-replies-with-packet">
<h2><a name="server-replies-with-packet">Server replies with packet:</a></h2>
<table border class="table">
<colgroup>
<col width="18%" />
@ -121,9 +93,11 @@ anymore.</td>
</tbody>
</table>
</div>
</div>
<div class="section" id="announcing">
<h1><a name="announcing">announcing</a></h1>
<p>Client sends packet:</p>
<div class="section" id="id2">
<h2><a name="id2">Client sends packet:</a></h2>
<table border class="table">
<colgroup>
<col width="18%" />
@ -193,6 +167,11 @@ in this session.</td>
the tracker to use the <tt class="literal"><span class="pre">sender</span></tt> of
this udp packet.</td>
</tr>
<tr><td>uint32_t</td>
<td>key</td>
<td>A unique key that is randomized by the
client.</td>
</tr>
<tr><td>int32_t</td>
<td>num_want</td>
<td>The maximum number of peers you want
@ -204,7 +183,39 @@ in the reply. Use -1 for default.</td>
</tr>
</tbody>
</table>
<p>Server replies with packet:</p>
<p>If the server requires authorization, the following structure has to be
appended on the announce packet.</p>
<table border class="table">
<colgroup>
<col width="18%" />
<col width="28%" />
<col width="54%" />
</colgroup>
<thead valign="bottom">
<tr><th>size</th>
<th>name</th>
<th>description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>uint8_t[20]</td>
<td>passwd_hash</td>
<td>The sha1-hash of the announce packet
with the password appended. The
announce message here means the
mandatory part, not including this
authentication appendix.</td>
</tr>
<tr><td>int8_t[]</td>
<td>username</td>
<td>The rest of the packet is the
username.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="id3">
<h2><a name="id3">Server replies with packet:</a></h2>
<table border class="table">
<colgroup>
<col width="18%" />
@ -234,6 +245,17 @@ in the announce request.</td>
<td>the number of seconds you should wait
until reannouncing yourself.</td>
</tr>
<tr><td>int32_t</td>
<td>leechers</td>
<td>The number of peers in the swarm that
has not finished downloading.</td>
</tr>
<tr><td>int32_t</td>
<td>seeders</td>
<td>The number of peers in the swarm that
has finished downloading and are
seeding.</td>
</tr>
</tbody>
</table>
<p>The rest of the server reply is a variable number of the following structure:</p>
@ -261,9 +283,11 @@ until reannouncing yourself.</td>
</tbody>
</table>
</div>
</div>
<div class="section" id="scraping">
<h1><a name="scraping">scraping</a></h1>
<p>Client sends packet:</p>
<div class="section" id="id4">
<h2><a name="id4">Client sends packet:</a></h2>
<table border class="table">
<colgroup>
<col width="18%" />
@ -291,13 +315,31 @@ scrape.</td>
<td>transaction_id</td>
<td>Randomized by client.</td>
</tr>
</tbody>
</table>
<p>The rest of the packet contains a variable number of the following structure:</p>
<table border class="table">
<colgroup>
<col width="18%" />
<col width="28%" />
<col width="54%" />
</colgroup>
<thead valign="bottom">
<tr><th>size</th>
<th>name</th>
<th>description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>int8_t[20]</td>
<td>info_hash</td>
<td>The info hash that is to be scraped.</td>
</tr>
</tbody>
</table>
<p>Server replies with packet:</p>
</div>
<div class="section" id="id5">
<h2><a name="id5">Server replies with packet:</a></h2>
<table border class="table">
<colgroup>
<col width="18%" />
@ -337,10 +379,6 @@ If 3 (for error) see <a class="reference" href="#errors">errors</a>.</td>
</tr>
</thead>
<tbody valign="top">
<tr><td>int8_t[20]</td>
<td>info_hash</td>
<td>The info hash of this info.</td>
</tr>
<tr><td>int32_t</td>
<td>complete</td>
<td>The total number of completed
@ -358,9 +396,12 @@ leechers.</td>
</tbody>
</table>
</div>
</div>
<div class="section" id="errors">
<h1><a name="errors">errors</a></h1>
<p>In case of a tracker error, the server replies with this packet:</p>
<p>In case of a tracker error,</p>
<div class="section" id="server-replies-packet">
<h2><a name="server-replies-packet">server replies packet:</a></h2>
<table border class="table">
<colgroup>
<col width="18%" />
@ -391,6 +432,7 @@ describing the error.</td>
</tbody>
</table>
</div>
</div>
<div class="section" id="actions">
<h1><a name="actions">actions</a></h1>
<p>The action fields has the following encoding:</p>

View File

@ -26,9 +26,10 @@ retrying.
connecting
----------
++++++++++
Client sends packet:
--------------------
+-------------+---------------------+----------------------------------------+
| size | name | description |
@ -40,25 +41,8 @@ Client sends packet:
| int32_t | transaction_id | Randomized by client. |
+-------------+---------------------+----------------------------------------+
optional part
+-------------+---------------------+----------------------------------------+
| size | name | description |
+=============+=====================+========================================+
| int8_t | flags | 1 = authentication |
+-------------+---------------------+----------------------------------------+
| int8_t[8] | username | |
+-------------+---------------------+----------------------------------------+
| int8_t[8] | password_hash | sha1-hash of the tracker password |
+-------------+---------------------+----------------------------------------+
what is the point of having a fixed size username field instead of
a null-terminated string?
Why send the hash of the password instead of the password itself?
Server replies with packet:
---------------------------
+-------------+---------------------+----------------------------------------+
| size | name | description |
@ -81,9 +65,10 @@ Server replies with packet:
announcing
----------
++++++++++
Client sends packet:
--------------------
+-------------+---------------------+----------------------------------------+
| size | name | description |
@ -120,13 +105,34 @@ Client sends packet:
| | | the tracker to use the ``sender`` of |
| | | this udp packet. |
+-------------+---------------------+----------------------------------------+
| uint32_t | key | A unique key that is randomized by the |
| | | client. |
+-------------+---------------------+----------------------------------------+
| int32_t | num_want | The maximum number of peers you want |
| | | in the reply. Use -1 for default. |
+-------------+---------------------+----------------------------------------+
| uint16_t | port | The port you're listening on. |
+-------------+---------------------+----------------------------------------+
If the server requires authorization, the following structure has to be
appended on the announce packet.
+-------------+---------------------+----------------------------------------+
| size | name | description |
+=============+=====================+========================================+
| uint8_t[20] | passwd_hash | The sha1-hash of the announce packet |
| | | with the password appended. The |
| | | announce message here means the |
| | | mandatory part, not including this |
| | | authentication appendix. |
+-------------+---------------------+----------------------------------------+
| int8_t[] | username | The rest of the packet is the |
| | | username. |
+-------------+---------------------+----------------------------------------+
Server replies with packet:
---------------------------
+-------------+---------------------+----------------------------------------+
| size | name | description |
@ -141,6 +147,13 @@ Server replies with packet:
| int32_t | interval | the number of seconds you should wait |
| | | until reannouncing yourself. |
+-------------+---------------------+----------------------------------------+
| int32_t | leechers | The number of peers in the swarm that |
| | | has not finished downloading. |
+-------------+---------------------+----------------------------------------+
| int32_t | seeders | The number of peers in the swarm that |
| | | has finished downloading and are |
| | | seeding. |
+-------------+---------------------+----------------------------------------+
The rest of the server reply is a variable number of the following structure:
@ -154,9 +167,11 @@ The rest of the server reply is a variable number of the following structure:
scraping
--------
++++++++
Client sends packet:
--------------------
+-------------+---------------------+----------------------------------------+
| size | name | description |
@ -169,10 +184,18 @@ Client sends packet:
+-------------+---------------------+----------------------------------------+
| int32_t | transaction_id | Randomized by client. |
+-------------+---------------------+----------------------------------------+
The rest of the packet contains a variable number of the following structure:
+-------------+---------------------+----------------------------------------+
| size | name | description |
+=============+=====================+========================================+
| int8_t[20] | info_hash | The info hash that is to be scraped. |
+-------------+---------------------+----------------------------------------+
Server replies with packet:
---------------------------
+-------------+---------------------+----------------------------------------+
| size | name | description |
@ -189,8 +212,6 @@ The rest of the packet contains a variable number of the following structures:
+-------------+---------------------+----------------------------------------+
| size | name | description |
+=============+=====================+========================================+
| int8_t[20] | info_hash | The info hash of this info. |
+-------------+---------------------+----------------------------------------+
| int32_t | complete | The total number of completed |
| | | downloads. |
+-------------+---------------------+----------------------------------------+
@ -201,9 +222,12 @@ The rest of the packet contains a variable number of the following structures:
+-------------+---------------------+----------------------------------------+
errors
------
++++++
In case of a tracker error, the server replies with this packet:
In case of a tracker error,
server replies packet:
----------------------
+-------------+---------------------+----------------------------------------+
| size | name | description |
@ -219,7 +243,7 @@ In case of a tracker error, the server replies with this packet:
actions
-------
+++++++
The action fields has the following encoding:
@ -230,7 +254,7 @@ The action fields has the following encoding:
credits
-------
+++++++
Protocol designed by Olaf van der Spek

View File

@ -113,12 +113,19 @@ namespace libtorrent
<< strerror(errno);
throw file_error(msg.str());
}
#ifdef WIN32
assert(_lseeki64(m_fd, 0, SEEK_SET) == 0);
#endif
m_open_mode = mode;
}
void close()
{
if (m_fd == -1) return;
std::stringstream str;
str << "fd: " << m_fd << "\n";
::close(m_fd);
m_fd = -1;
m_open_mode = 0;
@ -165,14 +172,14 @@ namespace libtorrent
#else
size_type ret = lseek(m_fd, offset, seekdir);
#endif
/*
if (ret == -1)
{
std::stringstream msg;
msg << "seek failed: '" << strerror(errno) << "' fd: " << m_fd << " offset: " << offset << " seekdir: " << seekdir;
throw file_error(msg.str());
}
*/
}
size_type tell()

View File

@ -918,6 +918,7 @@ namespace libtorrent
m_slot_to_piece.resize(m_info.num_pieces(), unallocated);
m_free_slots.clear();
m_unallocated_slots.clear();
pieces.clear();
pieces.resize(m_info.num_pieces(), false);
@ -1257,6 +1258,7 @@ namespace libtorrent
if (iter == m_free_slots.end())
{
assert(m_slot_to_piece[piece_index] != unassigned);
assert(!m_free_slots.empty());
iter = m_free_slots.end() - 1;
// special case to make sure we don't use the last slot
@ -1388,6 +1390,8 @@ namespace libtorrent
INVARIANT_CHECK;
namespace fs = boost::filesystem;
assert(!m_unallocated_slots.empty());
const int piece_size = static_cast<int>(m_info.piece_length());
@ -1514,11 +1518,11 @@ namespace libtorrent
else if (m_slot_to_piece[i] == unallocated)
{
#ifdef TORRENT_STORAGE_DEBUG
assert(
std::find(
assert(m_unallocated_slots.empty()
|| (std::find(
m_unallocated_slots.begin()
, m_unallocated_slots.end()
, i) != m_unallocated_slots.end()
, i) != m_unallocated_slots.end())
);
#endif
}