diff --git a/WebAPI_Changelog.md b/WebAPI_Changelog.md index 53eb32980..67bc7af85 100644 --- a/WebAPI_Changelog.md +++ b/WebAPI_Changelog.md @@ -10,6 +10,9 @@ * `torrents/editTracker` endpoint now supports setting a tracker's tier via `tier` parameter * `torrents/editTracker` endpoint always responds with a 204 when successful * `torrents/editTracker` endpoint `origUrl` parameter renamed to `url` +* [#23061](https://github.com/qbittorrent/qBittorrent/pull/23061) + * `sync/torrentPeers` returns one new field: `i2p_dest`, only when the peer is from I2P + * In this case, the fields `ip` and `port` are not returned * [#23085](https://github.com/qbittorrent/qBittorrent/pull/23085) * `torrents/parseMetadata` now responds with an array of metadata in the same order as the files in the request. It previously responded with an object keyed off of the submitted file name. diff --git a/src/webui/api/synccontroller.cpp b/src/webui/api/synccontroller.cpp index b324fd541..f2f05c55b 100644 --- a/src/webui/api/synccontroller.cpp +++ b/src/webui/api/synccontroller.cpp @@ -72,6 +72,7 @@ namespace const QString KEY_PEER_FLAGS = u"flags"_s; const QString KEY_PEER_FLAGS_DESCRIPTION = u"flags_desc"_s; const QString KEY_PEER_IP = u"ip"_s; + const QString KEY_PEER_I2P_DEST = u"i2p_dest"_s; const QString KEY_PEER_PORT = u"port"_s; const QString KEY_PEER_PROGRESS = u"progress"_s; const QString KEY_PEER_RELEVANCE = u"relevance"_s; @@ -847,12 +848,11 @@ void SyncController::torrentPeersAction() for (const BitTorrent::PeerInfo &pi : peersList) { - if (pi.address().ip.isNull()) continue; + const bool useI2PSocket = pi.useI2PSocket(); + if (pi.address().ip.isNull() && !useI2PSocket) continue; QVariantMap peer = { - {KEY_PEER_IP, pi.address().ip.toString()}, - {KEY_PEER_PORT, pi.address().port}, {KEY_PEER_CLIENT, pi.client()}, {KEY_PEER_ID_CLIENT, pi.peerIdClient()}, {KEY_PEER_PROGRESS, pi.progress()}, @@ -876,13 +876,23 @@ void SyncController::torrentPeersAction() peer.insert(KEY_PEER_FILES, filesForPiece.join(u'\n')); } - if (resolvePeerCountries) + if (resolvePeerCountries && !useI2PSocket) { peer[KEY_PEER_COUNTRY_CODE] = pi.country().toLower(); peer[KEY_PEER_COUNTRY] = Net::GeoIPManager::CountryName(pi.country()); } - peers[pi.address().toString()] = peer; + if (useI2PSocket) + { + peer[KEY_PEER_I2P_DEST] = pi.I2PAddress(); + peers[pi.I2PAddress()] = peer; + } + else + { + peer[KEY_PEER_IP] = pi.address().ip.toString(); + peer[KEY_PEER_PORT] = pi.address().port; + peers[pi.address().toString()] = peer; + } } data[u"peers"_s] = peers;