mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 15:27:54 +00:00
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.
This commit is contained in:
parent
9f045500d1
commit
abc69dfd20
@ -392,26 +392,26 @@ void Tracker::prepareAnnounceResponse(const TrackerAnnounceRequest &announceReq)
|
||||
};
|
||||
|
||||
// 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
|
||||
if (announceReq.compact) {
|
||||
lt::entry::list_type peerList;
|
||||
lt::entry::list_type peer6List;
|
||||
lt::entry::string_type peers;
|
||||
lt::entry::string_type peers6;
|
||||
|
||||
int counter = 0;
|
||||
for (const Peer &peer : asConst(torrentStats.peers)) {
|
||||
if (counter++ >= announceReq.numwant)
|
||||
break;
|
||||
|
||||
if (peer.endpoint.size() == 6) // IPv4
|
||||
peerList.emplace_back(peer.endpoint);
|
||||
else if (peer.endpoint.size() == 18) // IPv6
|
||||
peer6List.emplace_back(peer.endpoint);
|
||||
if (peer.endpoint.size() == 6) // IPv4 + port
|
||||
peers.append(peer.endpoint);
|
||||
else if (peer.endpoint.size() == 18) // IPv6 + port
|
||||
peers6.append(peer.endpoint);
|
||||
}
|
||||
|
||||
replyDict[ANNOUNCE_RESPONSE_PEERS] = peerList; // required, even it's empty
|
||||
if (!peer6List.empty())
|
||||
replyDict[ANNOUNCE_RESPONSE_PEERS6] = peer6List;
|
||||
replyDict[ANNOUNCE_RESPONSE_PEERS] = peers; // required, even it's empty
|
||||
if (!peers6.empty())
|
||||
replyDict[ANNOUNCE_RESPONSE_PEERS6] = peers6;
|
||||
}
|
||||
else {
|
||||
lt::entry::list_type peerList;
|
||||
|
Loading…
Reference in New Issue
Block a user