mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-17 06:01:33 -06:00
WebAPI: Add I2P peers to peer list
Fixes the second part of #19794. PR #23061.
This commit is contained in:
@@ -10,6 +10,9 @@
|
|||||||
* `torrents/editTracker` endpoint now supports setting a tracker's tier via `tier` parameter
|
* `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 always responds with a 204 when successful
|
||||||
* `torrents/editTracker` endpoint `origUrl` parameter renamed to `url`
|
* `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)
|
* [#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.
|
* `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.
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ namespace
|
|||||||
const QString KEY_PEER_FLAGS = u"flags"_s;
|
const QString KEY_PEER_FLAGS = u"flags"_s;
|
||||||
const QString KEY_PEER_FLAGS_DESCRIPTION = u"flags_desc"_s;
|
const QString KEY_PEER_FLAGS_DESCRIPTION = u"flags_desc"_s;
|
||||||
const QString KEY_PEER_IP = u"ip"_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_PORT = u"port"_s;
|
||||||
const QString KEY_PEER_PROGRESS = u"progress"_s;
|
const QString KEY_PEER_PROGRESS = u"progress"_s;
|
||||||
const QString KEY_PEER_RELEVANCE = u"relevance"_s;
|
const QString KEY_PEER_RELEVANCE = u"relevance"_s;
|
||||||
@@ -847,12 +848,11 @@ void SyncController::torrentPeersAction()
|
|||||||
|
|
||||||
for (const BitTorrent::PeerInfo &pi : peersList)
|
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 =
|
QVariantMap peer =
|
||||||
{
|
{
|
||||||
{KEY_PEER_IP, pi.address().ip.toString()},
|
|
||||||
{KEY_PEER_PORT, pi.address().port},
|
|
||||||
{KEY_PEER_CLIENT, pi.client()},
|
{KEY_PEER_CLIENT, pi.client()},
|
||||||
{KEY_PEER_ID_CLIENT, pi.peerIdClient()},
|
{KEY_PEER_ID_CLIENT, pi.peerIdClient()},
|
||||||
{KEY_PEER_PROGRESS, pi.progress()},
|
{KEY_PEER_PROGRESS, pi.progress()},
|
||||||
@@ -876,13 +876,23 @@ void SyncController::torrentPeersAction()
|
|||||||
peer.insert(KEY_PEER_FILES, filesForPiece.join(u'\n'));
|
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_CODE] = pi.country().toLower();
|
||||||
peer[KEY_PEER_COUNTRY] = Net::GeoIPManager::CountryName(pi.country());
|
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;
|
data[u"peers"_s] = peers;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user