*** 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> retrying.</p>
<div class="section" id="connecting"> <div class="section" id="connecting">
<h1><a name="connecting">connecting</a></h1> <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"> <table border class="table">
<colgroup> <colgroup>
<col width="18%" /> <col width="18%" />
@ -52,38 +53,9 @@ retrying.</p>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<p>optional part</p> </div>
<table border class="table"> <div class="section" id="server-replies-with-packet">
<colgroup> <h2><a name="server-replies-with-packet">Server replies with packet:</a></h2>
<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>
<table border class="table"> <table border class="table">
<colgroup> <colgroup>
<col width="18%" /> <col width="18%" />
@ -121,9 +93,11 @@ anymore.</td>
</tbody> </tbody>
</table> </table>
</div> </div>
</div>
<div class="section" id="announcing"> <div class="section" id="announcing">
<h1><a name="announcing">announcing</a></h1> <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"> <table border class="table">
<colgroup> <colgroup>
<col width="18%" /> <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 the tracker to use the <tt class="literal"><span class="pre">sender</span></tt> of
this udp packet.</td> this udp packet.</td>
</tr> </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> <tr><td>int32_t</td>
<td>num_want</td> <td>num_want</td>
<td>The maximum number of peers you want <td>The maximum number of peers you want
@ -204,7 +183,39 @@ in the reply. Use -1 for default.</td>
</tr> </tr>
</tbody> </tbody>
</table> </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"> <table border class="table">
<colgroup> <colgroup>
<col width="18%" /> <col width="18%" />
@ -234,6 +245,17 @@ in the announce request.</td>
<td>the number of seconds you should wait <td>the number of seconds you should wait
until reannouncing yourself.</td> until reannouncing yourself.</td>
</tr> </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> </tbody>
</table> </table>
<p>The rest of the server reply is a variable number of the following structure:</p> <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> </tbody>
</table> </table>
</div> </div>
</div>
<div class="section" id="scraping"> <div class="section" id="scraping">
<h1><a name="scraping">scraping</a></h1> <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"> <table border class="table">
<colgroup> <colgroup>
<col width="18%" /> <col width="18%" />
@ -291,13 +315,31 @@ scrape.</td>
<td>transaction_id</td> <td>transaction_id</td>
<td>Randomized by client.</td> <td>Randomized by client.</td>
</tr> </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> <tr><td>int8_t[20]</td>
<td>info_hash</td> <td>info_hash</td>
<td>The info hash that is to be scraped.</td> <td>The info hash that is to be scraped.</td>
</tr> </tr>
</tbody> </tbody>
</table> </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"> <table border class="table">
<colgroup> <colgroup>
<col width="18%" /> <col width="18%" />
@ -337,10 +379,6 @@ If 3 (for error) see <a class="reference" href="#errors">errors</a>.</td>
</tr> </tr>
</thead> </thead>
<tbody valign="top"> <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> <tr><td>int32_t</td>
<td>complete</td> <td>complete</td>
<td>The total number of completed <td>The total number of completed
@ -358,9 +396,12 @@ leechers.</td>
</tbody> </tbody>
</table> </table>
</div> </div>
</div>
<div class="section" id="errors"> <div class="section" id="errors">
<h1><a name="errors">errors</a></h1> <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"> <table border class="table">
<colgroup> <colgroup>
<col width="18%" /> <col width="18%" />
@ -391,6 +432,7 @@ describing the error.</td>
</tbody> </tbody>
</table> </table>
</div> </div>
</div>
<div class="section" id="actions"> <div class="section" id="actions">
<h1><a name="actions">actions</a></h1> <h1><a name="actions">actions</a></h1>
<p>The action fields has the following encoding:</p> <p>The action fields has the following encoding:</p>

View File

@ -26,9 +26,10 @@ retrying.
connecting connecting
---------- ++++++++++
Client sends packet: Client sends packet:
--------------------
+-------------+---------------------+----------------------------------------+ +-------------+---------------------+----------------------------------------+
| size | name | description | | size | name | description |
@ -40,25 +41,8 @@ Client sends packet:
| int32_t | transaction_id | Randomized by client. | | 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: Server replies with packet:
---------------------------
+-------------+---------------------+----------------------------------------+ +-------------+---------------------+----------------------------------------+
| size | name | description | | size | name | description |
@ -81,9 +65,10 @@ Server replies with packet:
announcing announcing
---------- ++++++++++
Client sends packet: Client sends packet:
--------------------
+-------------+---------------------+----------------------------------------+ +-------------+---------------------+----------------------------------------+
| size | name | description | | size | name | description |
@ -120,13 +105,34 @@ Client sends packet:
| | | the tracker to use the ``sender`` of | | | | the tracker to use the ``sender`` of |
| | | this udp packet. | | | | 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 | | int32_t | num_want | The maximum number of peers you want |
| | | in the reply. Use -1 for default. | | | | in the reply. Use -1 for default. |
+-------------+---------------------+----------------------------------------+ +-------------+---------------------+----------------------------------------+
| uint16_t | port | The port you're listening on. | | 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: Server replies with packet:
---------------------------
+-------------+---------------------+----------------------------------------+ +-------------+---------------------+----------------------------------------+
| size | name | description | | size | name | description |
@ -141,6 +147,13 @@ Server replies with packet:
| int32_t | interval | the number of seconds you should wait | | int32_t | interval | the number of seconds you should wait |
| | | until reannouncing yourself. | | | | 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: 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 scraping
-------- ++++++++
Client sends packet: Client sends packet:
--------------------
+-------------+---------------------+----------------------------------------+ +-------------+---------------------+----------------------------------------+
| size | name | description | | size | name | description |
@ -169,10 +184,18 @@ Client sends packet:
+-------------+---------------------+----------------------------------------+ +-------------+---------------------+----------------------------------------+
| int32_t | transaction_id | Randomized by client. | | 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. | | int8_t[20] | info_hash | The info hash that is to be scraped. |
+-------------+---------------------+----------------------------------------+ +-------------+---------------------+----------------------------------------+
Server replies with packet: Server replies with packet:
---------------------------
+-------------+---------------------+----------------------------------------+ +-------------+---------------------+----------------------------------------+
| size | name | description | | size | name | description |
@ -189,8 +212,6 @@ The rest of the packet contains a variable number of the following structures:
+-------------+---------------------+----------------------------------------+ +-------------+---------------------+----------------------------------------+
| size | name | description | | size | name | description |
+=============+=====================+========================================+ +=============+=====================+========================================+
| int8_t[20] | info_hash | The info hash of this info. |
+-------------+---------------------+----------------------------------------+
| int32_t | complete | The total number of completed | | int32_t | complete | The total number of completed |
| | | downloads. | | | | downloads. |
+-------------+---------------------+----------------------------------------+ +-------------+---------------------+----------------------------------------+
@ -201,9 +222,12 @@ The rest of the packet contains a variable number of the following structures:
+-------------+---------------------+----------------------------------------+ +-------------+---------------------+----------------------------------------+
errors 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 | | size | name | description |
@ -219,7 +243,7 @@ In case of a tracker error, the server replies with this packet:
actions actions
------- +++++++
The action fields has the following encoding: The action fields has the following encoding:
@ -230,7 +254,7 @@ The action fields has the following encoding:
credits credits
------- +++++++
Protocol designed by Olaf van der Spek Protocol designed by Olaf van der Spek

View File

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

View File

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