forked from premiere/premiere-libtorrent
added support for compact=1
This commit is contained in:
parent
d6dc5b52e4
commit
f4cc9f755f
|
@ -44,6 +44,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/entry.hpp"
|
||||
#include "libtorrent/bencode.hpp"
|
||||
#include "libtorrent/torrent.hpp"
|
||||
#include "libtorrent/io.hpp"
|
||||
|
||||
using namespace libtorrent;
|
||||
|
||||
|
@ -154,6 +155,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 += "&compact=1";
|
||||
|
||||
m_send_buffer += " HTTP/1.0\r\nAccept-Encoding: gzip\r\n"
|
||||
"User-Agent: ";
|
||||
|
@ -504,11 +506,34 @@ namespace libtorrent
|
|||
|
||||
peer_list.clear();
|
||||
|
||||
const entry::list_type& l = e["peers"].list();
|
||||
for(entry::list_type::const_iterator i = l.begin(); i != l.end(); ++i)
|
||||
if (e["peers"].type() == entry::string_t)
|
||||
{
|
||||
peer_entry p = extract_peer_info(*i);
|
||||
peer_list.push_back(p);
|
||||
std::string const& peers = e["peers"].string();
|
||||
for (std::string::const_iterator i = peers.begin();
|
||||
i != peers.end();)
|
||||
{
|
||||
if (std::distance(i, peers.end()) < 6) break;
|
||||
|
||||
peer_entry p;
|
||||
p.id.clear();
|
||||
std::stringstream ip_str;
|
||||
ip_str << (int)detail::read_uint8(i) << ".";
|
||||
ip_str << (int)detail::read_uint8(i) << ".";
|
||||
ip_str << (int)detail::read_uint8(i) << ".";
|
||||
ip_str << (int)detail::read_uint8(i);
|
||||
p.ip = ip_str.str();
|
||||
p.port = detail::read_uint16(i);
|
||||
peer_list.push_back(p);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const entry::list_type& l = e["peers"].list();
|
||||
for(entry::list_type::const_iterator i = l.begin(); i != l.end(); ++i)
|
||||
{
|
||||
peer_entry p = extract_peer_info(*i);
|
||||
peer_list.push_back(p);
|
||||
}
|
||||
}
|
||||
|
||||
requester()->tracker_response(peer_list, interval);
|
||||
|
|
|
@ -486,8 +486,17 @@ namespace libtorrent
|
|||
++i)
|
||||
{
|
||||
peer_connection* c = i->connection;
|
||||
// ignore peers that are choked or
|
||||
// whose connection is closed
|
||||
if (c == 0) continue;
|
||||
if (c->is_choked()) continue;
|
||||
|
||||
// if we still owe this peer some upload
|
||||
// don't choke it
|
||||
if (c->share_diff() > 0) continue;
|
||||
|
||||
// select the one that has been waiting
|
||||
// for an unchoke the longest
|
||||
if (last_unchoke > i->last_optimistically_unchoked) continue;
|
||||
last_unchoke = i->last_optimistically_unchoked;
|
||||
candidate = &(*i);
|
||||
|
|
Loading…
Reference in New Issue