qBittorrent PR to display I2P peers in WebUI

Discussions about i2P enabled Bittorrent clients, experience reports and issues
Post Reply
anikey
Posts: 84
Joined: Thu Dec 07, 2023 9:22 pm

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 only displayed I2P peers 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.

(This is only relevant to those who use the "-nox" version of qBittorrent, i.e. run it without a GUI and instead access it through a web browser)
User avatar
cumlord
Posts: 162
Joined: Thu Oct 05, 2023 5:01 pm
Location: Erect, NC
Contact:

Re: qBittorrent PR to display I2P peers in WebUI

Post by cumlord »

nice work :D
anikey
Posts: 84
Joined: Thu Dec 07, 2023 9:22 pm

Re: qBittorrent PR to display I2P peers in WebUI

Post by anikey »

Just in case, posting the patch here:

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;
 
anikey
Posts: 84
Joined: Thu Dec 07, 2023 9:22 pm

Re: qBittorrent PR to display I2P peers in WebUI

Post by anikey »

The fix has been changed and split up into two PRs, but in the end they got merged.
This functionality will most likely land in qBT 5.2.
Post Reply