From 56277d5e2bc7a0dcdbb88dcc9f6ee6d51ac6f086 Mon Sep 17 00:00:00 2001 From: anikey Date: Fri, 5 Sep 2025 12:40:25 +0000 Subject: [PATCH] WebUI: add I2P peers to peer list The WebUI part of the changes for #23061. Now qBittorrent will display I2P peers in WebUI peers tab. Fixes the second part of #19794 ("i2p peer list does not show in GUI"). PR #23185. --- src/webui/www/private/scripts/dynamicTable.js | 12 ++---------- src/webui/www/private/scripts/prop-peers.js | 6 ++++++ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/webui/www/private/scripts/dynamicTable.js b/src/webui/www/private/scripts/dynamicTable.js index f3754381a..7fe01b0d2 100644 --- a/src/webui/www/private/scripts/dynamicTable.js +++ b/src/webui/www/private/scripts/dynamicTable.js @@ -1829,7 +1829,7 @@ window.qBittorrent.DynamicTable ??= (() => { class TorrentPeersTable extends DynamicTable { initColumns() { this.newColumn("country", "", "QBT_TR(Country/Region)QBT_TR[CONTEXT=PeerListWidget]", 22, true); - this.newColumn("ip", "", "QBT_TR(IP)QBT_TR[CONTEXT=PeerListWidget]", 80, true); + this.newColumn("ip", "", "QBT_TR(IP/Address)QBT_TR[CONTEXT=PeerListWidget]", 80, true); this.newColumn("port", "", "QBT_TR(Port)QBT_TR[CONTEXT=PeerListWidget]", 35, true); this.newColumn("connection", "", "QBT_TR(Connection)QBT_TR[CONTEXT=PeerListWidget]", 50, true); this.newColumn("flags", "", "QBT_TR(Flags)QBT_TR[CONTEXT=PeerListWidget]", 50, true); @@ -1871,15 +1871,7 @@ window.qBittorrent.DynamicTable ??= (() => { const ip1 = this.getRowValue(row1); const ip2 = this.getRowValue(row2); - const a = ip1.split("."); - const b = ip2.split("."); - - for (let i = 0; i < 4; ++i) { - if (a[i] !== b[i]) - return a[i] - b[i]; - } - - return 0; + return window.qBittorrent.Misc.naturalSortCollator.compare(ip1, ip2); }; // flags diff --git a/src/webui/www/private/scripts/prop-peers.js b/src/webui/www/private/scripts/prop-peers.js index 80e58a8e9..a3f22eeb0 100644 --- a/src/webui/www/private/scripts/prop-peers.js +++ b/src/webui/www/private/scripts/prop-peers.js @@ -86,6 +86,12 @@ window.qBittorrent.PropPeers ??= (() => { continue; responseJSON["peers"][key]["rowId"] = key; + + if (Object.hasOwn(responseJSON["peers"][key], "i2p_dest")) { + responseJSON["peers"][key]["ip"] = responseJSON["peers"][key]["i2p_dest"]; + responseJSON["peers"][key]["port"] = "N/A"; + } + torrentPeersTable.updateRowData(responseJSON["peers"][key]); } }