diff --git a/src/net.cpp b/src/net.cpp index 2f11a61321..1e24b0e2da 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -566,7 +566,7 @@ void CNode::copyStats(CNodeStats &stats, const std::vector &m_asmap) X(nServices); X(addr); X(addrBind); - stats.m_network = GetNetworkName(ConnectedThroughNetwork()); + stats.m_network = ConnectedThroughNetwork(); stats.m_mapped_as = addr.GetMappedAS(m_asmap); if (m_tx_relay != nullptr) { LOCK(m_tx_relay->cs_filter); diff --git a/src/net.h b/src/net.h index 7c396a99cf..6316c73eee 100644 --- a/src/net.h +++ b/src/net.h @@ -720,8 +720,8 @@ public: CAddress addr; // Bind address of our side of the connection CAddress addrBind; - // Name of the network the peer connected through - std::string m_network; + // Network the peer connected through + Network m_network; uint32_t m_mapped_as; std::string m_conn_type_string; }; diff --git a/src/qt/forms/debugwindow.ui b/src/qt/forms/debugwindow.ui index 139c8e161e..d8112117cc 100644 --- a/src/qt/forms/debugwindow.ui +++ b/src/qt/forms/debugwindow.ui @@ -1100,14 +1100,17 @@ - + + + The network protocol this peer is connected through: IPv4, IPv6, Onion, I2P, or CJDNS. + - Version + Network - + IBeamCursor @@ -1123,14 +1126,14 @@ - + - User Agent + Version - + IBeamCursor @@ -1146,14 +1149,14 @@ - + - Services + User Agent - + IBeamCursor @@ -1169,14 +1172,14 @@ - + - Starting Block + Services - + IBeamCursor @@ -1192,14 +1195,14 @@ - + - Synced Headers + Starting Block - + IBeamCursor @@ -1215,14 +1218,14 @@ - + - Synced Blocks + Synced Headers - + IBeamCursor @@ -1238,14 +1241,14 @@ - + - Connection Time + Synced Blocks - + IBeamCursor @@ -1261,14 +1264,14 @@ - + - Last Send + Connection Time - + IBeamCursor @@ -1284,14 +1287,14 @@ - + - Last Receive + Last Send - + IBeamCursor @@ -1307,14 +1310,14 @@ - + - Sent + Last Receive - + IBeamCursor @@ -1330,14 +1333,14 @@ - + - Received + Sent - + IBeamCursor @@ -1353,14 +1356,14 @@ - + - Ping Time + Received - + IBeamCursor @@ -1376,17 +1379,14 @@ - - - The duration of a currently outstanding ping. - + - Ping Wait + Ping Time - + IBeamCursor @@ -1402,14 +1402,17 @@ - + + + The duration of a currently outstanding ping. + - Min Ping + Ping Wait - + IBeamCursor @@ -1425,14 +1428,14 @@ - + - Time Offset + Min Ping - + IBeamCursor @@ -1448,17 +1451,14 @@ - - - The mapped Autonomous System used for diversifying peer selection. - + - Mapped AS + Time Offset - + IBeamCursor @@ -1474,6 +1474,32 @@ + + + The mapped Autonomous System used for diversifying peer selection. + + + Mapped AS + + + + + + + IBeamCursor + + + N/A + + + Qt::PlainText + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + Qt::Vertical diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 53ffb27f50..88249c4e2e 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -749,6 +749,21 @@ QString boostPathToQString(const fs::path &path) return QString::fromStdString(path.string()); } +QString NetworkToQString(Network net) +{ + switch (net) { + case NET_UNROUTABLE: return QObject::tr("Unroutable"); + case NET_IPV4: return "IPv4"; + case NET_IPV6: return "IPv6"; + case NET_ONION: return "Onion"; + case NET_I2P: return "I2P"; + case NET_CJDNS: return "CJDNS"; + case NET_INTERNAL: return QObject::tr("Internal"); + case NET_MAX: assert(false); + } // no default case, so the compiler can warn about missing cases + assert(false); +} + QString formatDurationStr(int secs) { QStringList strList; diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index d7bd124884..4bef13efb5 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -218,22 +219,25 @@ namespace GUIUtil bool GetStartOnSystemStartup(); bool SetStartOnSystemStartup(bool fAutoStart); - /* Convert QString to OS specific boost path through UTF-8 */ + /** Convert QString to OS specific boost path through UTF-8 */ fs::path qstringToBoostPath(const QString &path); - /* Convert OS specific boost path to QString through UTF-8 */ + /** Convert OS specific boost path to QString through UTF-8 */ QString boostPathToQString(const fs::path &path); - /* Convert seconds into a QString with days, hours, mins, secs */ + /** Convert enum Network to QString */ + QString NetworkToQString(Network net); + + /** Convert seconds into a QString with days, hours, mins, secs */ QString formatDurationStr(int secs); - /* Format CNodeStats.nServices bitmask into a user-readable string */ + /** Format CNodeStats.nServices bitmask into a user-readable string */ QString formatServicesStr(quint64 mask); - /* Format a CNodeStats.m_ping_usec into a user-readable string or display N/A, if 0*/ + /** Format a CNodeStats.m_ping_usec into a user-readable string or display N/A, if 0 */ QString formatPingTime(int64_t ping_usec); - /* Format a CNodeCombinedStats.nTimeOffset into a user-readable string. */ + /** Format a CNodeCombinedStats.nTimeOffset into a user-readable string */ QString formatTimeOffset(int64_t nTimeOffset); QString formatNiceTimeOffset(qint64 secs); diff --git a/src/qt/peertablemodel.cpp b/src/qt/peertablemodel.cpp index 5220f8e138..2d7dbb38a3 100644 --- a/src/qt/peertablemodel.cpp +++ b/src/qt/peertablemodel.cpp @@ -29,14 +29,16 @@ bool NodeLessThan::operator()(const CNodeCombinedStats &left, const CNodeCombine return pLeft->nodeid < pRight->nodeid; case PeerTableModel::Address: return pLeft->addrName.compare(pRight->addrName) < 0; - case PeerTableModel::Subversion: - return pLeft->cleanSubVer.compare(pRight->cleanSubVer) < 0; + case PeerTableModel::Network: + return pLeft->m_network < pRight->m_network; case PeerTableModel::Ping: return pLeft->m_min_ping_usec < pRight->m_min_ping_usec; case PeerTableModel::Sent: return pLeft->nSendBytes < pRight->nSendBytes; case PeerTableModel::Received: return pLeft->nRecvBytes < pRight->nRecvBytes; + case PeerTableModel::Subversion: + return pLeft->cleanSubVer.compare(pRight->cleanSubVer) < 0; } return false; @@ -104,7 +106,6 @@ PeerTableModel::PeerTableModel(interfaces::Node& node, QObject* parent) : m_node(node), timer(nullptr) { - columns << tr("NodeId") << tr("Node/Service") << tr("Ping") << tr("Sent") << tr("Received") << tr("User Agent"); priv.reset(new PeerTablePriv()); // set up timer for auto refresh @@ -158,17 +159,21 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const case Address: // prepend to peer address down-arrow symbol for inbound connection and up-arrow for outbound connection return QString(rec->nodeStats.fInbound ? "↓ " : "↑ ") + QString::fromStdString(rec->nodeStats.addrName); - case Subversion: - return QString::fromStdString(rec->nodeStats.cleanSubVer); + case Network: + return GUIUtil::NetworkToQString(rec->nodeStats.m_network); case Ping: return GUIUtil::formatPingTime(rec->nodeStats.m_min_ping_usec); case Sent: return GUIUtil::formatBytes(rec->nodeStats.nSendBytes); case Received: return GUIUtil::formatBytes(rec->nodeStats.nRecvBytes); + case Subversion: + return QString::fromStdString(rec->nodeStats.cleanSubVer); } } else if (role == Qt::TextAlignmentRole) { switch (index.column()) { + case Network: + return QVariant(Qt::AlignCenter); case Ping: case Sent: case Received: diff --git a/src/qt/peertablemodel.h b/src/qt/peertablemodel.h index 99de772ac0..61a0132e00 100644 --- a/src/qt/peertablemodel.h +++ b/src/qt/peertablemodel.h @@ -60,10 +60,11 @@ public: enum ColumnIndex { NetNodeId = 0, Address = 1, - Ping = 2, - Sent = 3, - Received = 4, - Subversion = 5 + Network = 2, + Ping = 3, + Sent = 4, + Received = 5, + Subversion = 6 }; /** @name Methods overridden from QAbstractTableModel @@ -82,7 +83,7 @@ public Q_SLOTS: private: interfaces::Node& m_node; - QStringList columns; + const QStringList columns{tr("Peer Id"), tr("Address"), tr("Network"), tr("Ping"), tr("Sent"), tr("Received"), tr("User Agent")}; std::unique_ptr priv; QTimer *timer; }; diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 2bd8114902..aa2c28453b 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -1092,7 +1092,7 @@ void RPCConsole::updateDetailWidget() const CNodeCombinedStats *stats = clientModel->getPeerTableModel()->getNodeStats(selected_rows.first().row()); // update the detail ui with latest node information QString peerAddrDetails(QString::fromStdString(stats->nodeStats.addrName) + " "); - peerAddrDetails += tr("(node id: %1)").arg(QString::number(stats->nodeStats.nodeid)); + peerAddrDetails += tr("(peer id: %1)").arg(QString::number(stats->nodeStats.nodeid)); if (!stats->nodeStats.addrLocal.empty()) peerAddrDetails += "
" + tr("via %1").arg(QString::fromStdString(stats->nodeStats.addrLocal)); ui->peerHeading->setText(peerAddrDetails); @@ -1109,6 +1109,7 @@ void RPCConsole::updateDetailWidget() ui->peerVersion->setText(QString::number(stats->nodeStats.nVersion)); ui->peerSubversion->setText(QString::fromStdString(stats->nodeStats.cleanSubVer)); ui->peerDirection->setText(stats->nodeStats.fInbound ? tr("Inbound") : tr("Outbound")); + ui->peerNetwork->setText(GUIUtil::NetworkToQString(stats->nodeStats.m_network)); if (stats->nodeStats.m_permissionFlags == PF_NONE) { ui->peerPermissions->setText(tr("N/A")); } else { diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index 1e82bc068a..89ddfb35cb 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -187,7 +187,7 @@ static RPCHelpMan getpeerinfo() if (!(stats.addrLocal.empty())) { obj.pushKV("addrlocal", stats.addrLocal); } - obj.pushKV("network", stats.m_network); + obj.pushKV("network", GetNetworkName(stats.m_network)); if (stats.m_mapped_as != 0) { obj.pushKV("mapped_as", uint64_t(stats.m_mapped_as)); }