diff options
author | Jonas Schnelli <dev@jonasschnelli.ch> | 2016-10-08 16:43:11 +0200 |
---|---|---|
committer | Jonas Schnelli <dev@jonasschnelli.ch> | 2016-10-08 16:43:15 +0200 |
commit | b2fec4e9a17503ff8fae4fba6e9c875112fb9071 (patch) | |
tree | 3121a29a5df7eeea85bd9ab69809e32617174ff5 /src | |
parent | 61d191fbf953700ba8aeadc9c8cf4c195efbd10c (diff) | |
parent | cb78c60534e5be205f9190cb0cde700f9e9fa38d (diff) |
Merge #8885: gui: fix ban from qt console
cb78c60 gui: fix ban from qt console (Cory Fields)
Diffstat (limited to 'src')
-rw-r--r-- | src/net.cpp | 1 | ||||
-rw-r--r-- | src/net.h | 1 | ||||
-rw-r--r-- | src/qt/rpcconsole.cpp | 25 |
3 files changed, 15 insertions, 12 deletions
diff --git a/src/net.cpp b/src/net.cpp index 770e2d2959..19dd040997 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -629,6 +629,7 @@ void CNode::copyStats(CNodeStats &stats) { stats.nodeid = this->GetId(); X(nServices); + X(addr); X(fRelayTxes); X(nLastSend); X(nLastRecv); @@ -505,6 +505,7 @@ public: double dPingWait; double dPingMin; std::string addrLocal; + CAddress addr; }; diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index ace9f1ceaa..b6ed75535c 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -981,20 +981,21 @@ void RPCConsole::banSelectedNode(int bantime) if (!clientModel || !g_connman) return; - // Get currently selected peer address - QString strNode = GUIUtil::getEntryData(ui->peerWidget, 0, PeerTableModel::Address).toString(); - // Find possible nodes, ban it and clear the selected node - std::string nStr = strNode.toStdString(); - std::string addr; - int port = 0; - SplitHostPort(nStr, port, addr); + if(cachedNodeid == -1) + return; - CNetAddr resolved; - if(!LookupHost(addr.c_str(), resolved, false)) + // Get currently selected peer address + int detailNodeRow = clientModel->getPeerTableModel()->getRowByNodeId(cachedNodeid); + if(detailNodeRow < 0) return; - g_connman->Ban(resolved, BanReasonManuallyAdded, bantime); - clearSelectedNode(); - clientModel->getBanTableModel()->refresh(); + + // Find possible nodes, ban it and clear the selected node + const CNodeCombinedStats *stats = clientModel->getPeerTableModel()->getNodeStats(detailNodeRow); + if(stats) { + g_connman->Ban(stats->nodeStats.addr, BanReasonManuallyAdded, bantime); + clearSelectedNode(); + clientModel->getBanTableModel()->refresh(); + } } void RPCConsole::unbanSelectedNode() |