Browse Source

Fix BEP-23 support

The embedded tracker was returning a non-compliant response.
The peer lists should be packed strings instead of lists.

Also clarify level of compliance with BEP-7.
adaptive-webui-19844
FranciscoPombal 5 years ago
parent
commit
abc69dfd20
  1. 20
      src/base/bittorrent/tracker.cpp

20
src/base/bittorrent/tracker.cpp

@ -392,26 +392,26 @@ void Tracker::prepareAnnounceResponse(const TrackerAnnounceRequest &announceReq)
}; };
// peer list // peer list
// [BEP-7] IPv6 Tracker Extension (partial support) // [BEP-7] IPv6 Tracker Extension (partial support - only the part that concerns BEP-23)
// [BEP-23] Tracker Returns Compact Peer Lists // [BEP-23] Tracker Returns Compact Peer Lists
if (announceReq.compact) { if (announceReq.compact) {
lt::entry::list_type peerList; lt::entry::string_type peers;
lt::entry::list_type peer6List; lt::entry::string_type peers6;
int counter = 0; int counter = 0;
for (const Peer &peer : asConst(torrentStats.peers)) { for (const Peer &peer : asConst(torrentStats.peers)) {
if (counter++ >= announceReq.numwant) if (counter++ >= announceReq.numwant)
break; break;
if (peer.endpoint.size() == 6) // IPv4 if (peer.endpoint.size() == 6) // IPv4 + port
peerList.emplace_back(peer.endpoint); peers.append(peer.endpoint);
else if (peer.endpoint.size() == 18) // IPv6 else if (peer.endpoint.size() == 18) // IPv6 + port
peer6List.emplace_back(peer.endpoint); peers6.append(peer.endpoint);
} }
replyDict[ANNOUNCE_RESPONSE_PEERS] = peerList; // required, even it's empty replyDict[ANNOUNCE_RESPONSE_PEERS] = peers; // required, even it's empty
if (!peer6List.empty()) if (!peers6.empty())
replyDict[ANNOUNCE_RESPONSE_PEERS6] = peer6List; replyDict[ANNOUNCE_RESPONSE_PEERS6] = peers6;
} }
else { else {
lt::entry::list_type peerList; lt::entry::list_type peerList;

Loading…
Cancel
Save