*** empty log message ***
This commit is contained in:
parent
97b387b196
commit
8a3d994416
|
@ -345,6 +345,8 @@ const char* buf;
|
|||
entry e = bdecode(buf, buf + data_size);
|
||||
</pre>
|
||||
<p>Now we just need to know how to retrieve information from the <tt class="literal"><span class="pre">entry</span></tt>.</p>
|
||||
<p>If <tt class="literal"><span class="pre">bdecode()</span></tt> encounters invalid encoded data in the range given to it
|
||||
it will throw <a class="reference" href="#invalid-encoding">invalid_encoding</a>.</p>
|
||||
</div>
|
||||
<div class="section" id="entry">
|
||||
<h2><a class="toc-backref" href="#id12" name="entry">entry</a></h2>
|
||||
|
@ -392,7 +394,7 @@ public:
|
|||
</pre>
|
||||
<p>The <tt class="literal"><span class="pre">integer()</span></tt>, <tt class="literal"><span class="pre">string()</span></tt>, <tt class="literal"><span class="pre">list()</span></tt> and <tt class="literal"><span class="pre">dict()</span></tt> functions
|
||||
are accessorts that return the respecive type. If the <tt class="literal"><span class="pre">entry</span></tt> object isn't of the
|
||||
type you request, the accessor will throw <tt class="literal"><span class="pre">type_error</span></tt> (which derives from
|
||||
type you request, the accessor will throw <a class="reference" href="#type-error">type_error</a> (which derives from
|
||||
<tt class="literal"><span class="pre">std::runtime_error</span></tt>). You can ask an <tt class="literal"><span class="pre">entry</span></tt> for its type through the
|
||||
<tt class="literal"><span class="pre">type()</span></tt> function.</p>
|
||||
<p>The <tt class="literal"><span class="pre">print()</span></tt> function is there for debug purposes only.</p>
|
||||
|
@ -541,7 +543,7 @@ was started.</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>
|
||||
<p><tt class="literal"><span class="pre">write_resume_data()</span></tt> takes a non-const reference to a char-vector, that vector will be filled
|
||||
with the fast-resume data. For more information about hpw fast-resume works, see <a class="reference" href="#fast-resume">fast resume</a>.</p>
|
||||
with the fast-resume data. For more information about how fast-resume works, see <a class="reference" href="#fast-resume">fast resume</a>.</p>
|
||||
<div class="section" id="status">
|
||||
<h3><a class="toc-backref" href="#id15" name="status">status()</a></h3>
|
||||
<p><tt class="literal"><span class="pre">status()</span></tt> will return a structure with information about the status of this
|
||||
|
@ -1140,8 +1142,8 @@ for each slot
|
|||
4 bytes, the number of unfinished pieces
|
||||
for each unfinished piece
|
||||
4 bytes, index of the unfinished piece
|
||||
blocks_per_piece / 32 bytes, the bitmask describing which
|
||||
blocks are finished in this piece.
|
||||
blocks_per_piece / 8 bytes, the bitmask describing which
|
||||
blocks are finished in this piece.
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -325,6 +325,8 @@ Or, if you have a raw char buffer::
|
|||
|
||||
Now we just need to know how to retrieve information from the ``entry``.
|
||||
|
||||
If ``bdecode()`` encounters invalid encoded data in the range given to it
|
||||
it will throw invalid_encoding_.
|
||||
|
||||
|
||||
|
||||
|
@ -375,7 +377,7 @@ or a string. This is its synopsis::
|
|||
|
||||
The ``integer()``, ``string()``, ``list()`` and ``dict()`` functions
|
||||
are accessorts that return the respecive type. If the ``entry`` object isn't of the
|
||||
type you request, the accessor will throw ``type_error`` (which derives from
|
||||
type you request, the accessor will throw type_error_ (which derives from
|
||||
``std::runtime_error``). You can ask an ``entry`` for its type through the
|
||||
``type()`` function.
|
||||
|
||||
|
@ -551,7 +553,7 @@ was started.
|
|||
torrent. If you set this to -1, there will be no limit.
|
||||
|
||||
``write_resume_data()`` takes a non-const reference to a char-vector, that vector will be filled
|
||||
with the fast-resume data. For more information about hpw fast-resume works, see `fast resume`_.
|
||||
with the fast-resume data. For more information about how fast-resume works, see `fast resume`_.
|
||||
|
||||
status()
|
||||
~~~~~~~~
|
||||
|
@ -1211,8 +1213,8 @@ The format of the fast-resume data is as follows, given that all
|
|||
4 bytes, the number of unfinished pieces
|
||||
for each unfinished piece
|
||||
4 bytes, index of the unfinished piece
|
||||
blocks_per_piece / 32 bytes, the bitmask describing which
|
||||
blocks are finished in this piece.
|
||||
blocks_per_piece / 8 bytes, the bitmask describing which
|
||||
blocks are finished in this piece.
|
||||
|
||||
Feedback
|
||||
========
|
||||
|
|
|
@ -319,7 +319,9 @@ int main(int argc, char* argv[])
|
|||
<< static_cast<const char*>((i->flags & peer_info::interesting)?"I":"_")
|
||||
<< static_cast<const char*>((i->flags & peer_info::choked)?"C":"_")
|
||||
<< static_cast<const char*>((i->flags & peer_info::remote_interested)?"i":"_")
|
||||
<< static_cast<const char*>((i->flags & peer_info::remote_choked)?"c":"_") << "\n";
|
||||
<< static_cast<const char*>((i->flags & peer_info::remote_choked)?"c":"_")
|
||||
<< static_cast<const char*>((i->flags & peer_info::supports_extensions)?"e":"_")
|
||||
<< "\n";
|
||||
|
||||
if (i->downloading_piece_index >= 0)
|
||||
{
|
||||
|
|
|
@ -298,6 +298,9 @@ namespace libtorrent
|
|||
- m_statistics.total_payload_upload();
|
||||
}
|
||||
|
||||
bool support_extensions() const
|
||||
{ return m_supports_extensions; }
|
||||
|
||||
#ifndef NDEBUG
|
||||
boost::shared_ptr<logger> m_logger;
|
||||
#endif
|
||||
|
@ -310,6 +313,7 @@ namespace libtorrent
|
|||
void send_bitfield();
|
||||
void send_have(int index);
|
||||
void send_handshake();
|
||||
void send_extensions();
|
||||
|
||||
// is used during handshake
|
||||
enum state
|
||||
|
@ -330,6 +334,7 @@ namespace libtorrent
|
|||
|
||||
enum message_type
|
||||
{
|
||||
// standard messages
|
||||
msg_choke = 0,
|
||||
msg_unchoke,
|
||||
msg_interested,
|
||||
|
@ -338,7 +343,11 @@ namespace libtorrent
|
|||
msg_bitfield,
|
||||
msg_request,
|
||||
msg_piece,
|
||||
msg_cancel
|
||||
msg_cancel,
|
||||
// extension protocol message
|
||||
msg_extensions = 20,
|
||||
// extended messages
|
||||
msg_gzip_piece
|
||||
};
|
||||
|
||||
std::size_t m_packet_size;
|
||||
|
@ -420,6 +429,11 @@ namespace libtorrent
|
|||
// we have choked the upload to the peer
|
||||
bool m_choked;
|
||||
|
||||
// this is set to true if the handshake from
|
||||
// the peer indicated that it supports the
|
||||
// extension protocol
|
||||
bool m_supports_extensions;
|
||||
|
||||
// the pieces the other end have
|
||||
std::vector<bool> m_have_piece;
|
||||
|
||||
|
@ -477,6 +491,14 @@ namespace libtorrent
|
|||
// this value. If it sinks below a threshold, its
|
||||
// considered a bad peer and will be banned.
|
||||
int m_trust_points;
|
||||
|
||||
enum extension_index
|
||||
{
|
||||
gzip_piece,
|
||||
num_supported_extensions
|
||||
};
|
||||
static const char* extension_names[num_supported_extensions];
|
||||
unsigned char m_extension_messages[num_supported_extensions];
|
||||
};
|
||||
|
||||
// this is called each time this peer generates some
|
||||
|
|
|
@ -46,7 +46,8 @@ namespace libtorrent
|
|||
interesting = 0x1,
|
||||
choked = 0x2,
|
||||
remote_interested = 0x4,
|
||||
remote_choked = 0x8
|
||||
remote_choked = 0x8,
|
||||
supports_extensions = 0x10
|
||||
};
|
||||
unsigned int flags;
|
||||
address ip;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -880,6 +880,7 @@ namespace libtorrent
|
|||
m_impl.m_alerts.set_severity(s);
|
||||
}
|
||||
|
||||
// TODO: store resume data as an entry instead
|
||||
void detail::piece_checker_data::parse_resume_data(
|
||||
const std::vector<char>* rd
|
||||
, const torrent_info& info)
|
||||
|
@ -920,7 +921,7 @@ namespace libtorrent
|
|||
|
||||
int num_unfinished = read_int(ptr);
|
||||
if (num_unfinished < 0) return;
|
||||
if (data.size() != 20 + (1 + num_slots + 2 + num_unfinished * (num_blocks_per_piece / 32 + 1)) * 4)
|
||||
if (data.size() != 20 + (1 + num_slots + 2 + num_unfinished) * 4 + num_unfinished * (num_blocks_per_piece / 8))
|
||||
return;
|
||||
|
||||
tmp_unfinished.reserve(num_unfinished);
|
||||
|
@ -935,12 +936,13 @@ namespace libtorrent
|
|||
|| p.index >= info.num_pieces())
|
||||
return;
|
||||
|
||||
for (int j = 0; j < num_blocks_per_piece / 32; ++j)
|
||||
const int num_bitmask_bytes = std::max(num_blocks_per_piece / 8, 1);
|
||||
for (int j = 0; j < num_bitmask_bytes; ++j)
|
||||
{
|
||||
unsigned int bits = read_int(ptr);
|
||||
for (int k = 0; k < 32; ++k)
|
||||
unsigned char bits = read_uchar(ptr);
|
||||
for (int k = 0; k < 8; ++k)
|
||||
{
|
||||
const int bit = j * 32 + k;
|
||||
const int bit = j * 8 + k;
|
||||
if (bits & (1 << bit))
|
||||
p.finished_blocks[bit] = true;
|
||||
}
|
||||
|
|
|
@ -231,12 +231,15 @@ namespace libtorrent
|
|||
// the unsinished piece's index
|
||||
detail::write_int(i->index, out);
|
||||
|
||||
// write
|
||||
for (int j = 0; j < num_blocks_per_piece / 32; ++j)
|
||||
// TODO: write the bitmask in correct byteorder
|
||||
// TODO: make sure to read it in the correct order too
|
||||
const int num_bitmask_bytes = std::max(num_blocks_per_piece / 8, 1);
|
||||
for (int j = 0; j < num_bitmask_bytes; ++j)
|
||||
{
|
||||
unsigned int v = 0;
|
||||
for (int k = 0; k < 32; ++k) v |= i->finished_blocks[j*32+k]?(1 << k):0;
|
||||
detail::write_int(v, out);
|
||||
unsigned char v = 0;
|
||||
for (int k = 0; k < 8; ++k)
|
||||
v |= i->finished_blocks[j*8+k]?(1 << k):0;
|
||||
detail::write_uchar(v, out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -337,6 +340,7 @@ namespace libtorrent
|
|||
if (peer->is_choked()) p.flags |= peer_info::choked;
|
||||
if (peer->is_peer_interested()) p.flags |= peer_info::remote_interested;
|
||||
if (peer->has_peer_choked()) p.flags |= peer_info::remote_choked;
|
||||
if (peer->support_extensions()) p.flags |= peer_info::supports_extensions;
|
||||
|
||||
p.pieces = peer->get_bitfield();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue