From a9357f0c67059b2cb215a0bafcf62089d9793ea1 Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Tue, 4 Oct 2016 19:27:11 -0400 Subject: [PATCH] gui: fix ban from qt console --- src/net.cpp | 1 + src/net.h | 1 + src/qt/rpcconsole.cpp | 22 ++++++++++------------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index 3c7295a0b..0576a9d8d 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -685,6 +685,7 @@ void CNode::copyStats(CNodeStats &stats) { stats.nodeid = this->GetId(); X(nServices); + X(addr); X(fRelayTxes); X(nLastSend); X(nLastRecv); diff --git a/src/net.h b/src/net.h index 21a27bfc3..542982b28 100644 --- a/src/net.h +++ b/src/net.h @@ -213,6 +213,7 @@ public: double dPingWait; double dPingMin; std::string addrLocal; + CAddress addr; }; diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 3a0075f3c..e7225f7dc 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -985,20 +985,18 @@ void RPCConsole::banSelectedNode(int bantime) if (!clientModel) return; + if(cachedNodeid == -1) + return; + // Get currently selected peer address - QString strNode = GUIUtil::getEntryData(ui->peerWidget, 0, PeerTableModel::Address).toString(); + int detailNodeRow = clientModel->getPeerTableModel()->getRowByNodeId(cachedNodeid); + if(detailNodeRow < 0) + return; + // Find possible nodes, ban it and clear the selected node - if (FindNode(strNode.toStdString())) { - std::string nStr = strNode.toStdString(); - std::string addr; - int port = 0; - SplitHostPort(nStr, port, addr); - - CNetAddr resolved; - if(!LookupHost(addr.c_str(), resolved, false)) - return; - CNode::Ban(resolved, BanReasonManuallyAdded, bantime); - + const CNodeCombinedStats *stats = clientModel->getPeerTableModel()->getNodeStats(detailNodeRow); + if(stats) { + CNode::Ban(stats->nodeStats.addr, BanReasonManuallyAdded, bantime); clearSelectedNode(); clientModel->getBanTableModel()->refresh(); }