qBittorrent PR to display I2P peers in WebUI

Misc topics about I2P
Post Reply
anikey
Posts: 105
Joined: 30 Nov 2023 20:08

qBittorrent PR to display I2P peers in WebUI

Post by anikey »

I've made a pull request to qBittorrent that enables display of I2P peers in the WebUI peer list. Previously, it displayed I2P peers only on the GUI version.

Check it out here: https://github.com/qbittorrent/qBittorrent/pull/23061

You may apply the patch (append ".diff" or ".patch" to the URL to download it) and compile qBT yourself (it's not that hard), to get this feature before it gets into a qBT release.

Here's the (old version, it works just fine, but they wanted to change it a bit) patch:

Code: Select all

diff --git a/src/webui/api/synccontroller.cpp b/src/webui/api/synccontroller.cpp
index b324fd541b61..c862ca0b9a1a 100644
--- a/src/webui/api/synccontroller.cpp
+++ b/src/webui/api/synccontroller.cpp
@@ -847,12 +847,15 @@ 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;
+
+        const QString address = useI2PSocket ? pi.I2PAddress() : pi.address().ip.toString();
 
         QVariantMap peer =
         {
-            {KEY_PEER_IP, pi.address().ip.toString()},
-            {KEY_PEER_PORT, pi.address().port},
+            {KEY_PEER_IP, address},
+            {KEY_PEER_PORT, useI2PSocket ? 0 : pi.address().port},
             {KEY_PEER_CLIENT, pi.client()},
             {KEY_PEER_ID_CLIENT, pi.peerIdClient()},
             {KEY_PEER_PROGRESS, pi.progress()},
@@ -876,13 +879,13 @@ 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;
+        peers[address] = peer;
     }
     data[u"peers"_s] = peers;
 

Post Reply