Skip to content

Commit b2fec4e

Browse files
committed
Merge #8885: gui: fix ban from qt console
cb78c60 gui: fix ban from qt console (Cory Fields)
2 parents 61d191f + cb78c60 commit b2fec4e

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

src/net.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,7 @@ void CNode::copyStats(CNodeStats &stats)
629629
{
630630
stats.nodeid = this->GetId();
631631
X(nServices);
632+
X(addr);
632633
X(fRelayTxes);
633634
X(nLastSend);
634635
X(nLastRecv);

src/net.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,7 @@ class CNodeStats
505505
double dPingWait;
506506
double dPingMin;
507507
std::string addrLocal;
508+
CAddress addr;
508509
};
509510

510511

src/qt/rpcconsole.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -981,20 +981,21 @@ void RPCConsole::banSelectedNode(int bantime)
981981
if (!clientModel || !g_connman)
982982
return;
983983

984-
// Get currently selected peer address
985-
QString strNode = GUIUtil::getEntryData(ui->peerWidget, 0, PeerTableModel::Address).toString();
986-
// Find possible nodes, ban it and clear the selected node
987-
std::string nStr = strNode.toStdString();
988-
std::string addr;
989-
int port = 0;
990-
SplitHostPort(nStr, port, addr);
984+
if(cachedNodeid == -1)
985+
return;
991986

992-
CNetAddr resolved;
993-
if(!LookupHost(addr.c_str(), resolved, false))
987+
// Get currently selected peer address
988+
int detailNodeRow = clientModel->getPeerTableModel()->getRowByNodeId(cachedNodeid);
989+
if(detailNodeRow < 0)
994990
return;
995-
g_connman->Ban(resolved, BanReasonManuallyAdded, bantime);
996-
clearSelectedNode();
997-
clientModel->getBanTableModel()->refresh();
991+
992+
// Find possible nodes, ban it and clear the selected node
993+
const CNodeCombinedStats *stats = clientModel->getPeerTableModel()->getNodeStats(detailNodeRow);
994+
if(stats) {
995+
g_connman->Ban(stats->nodeStats.addr, BanReasonManuallyAdded, bantime);
996+
clearSelectedNode();
997+
clientModel->getBanTableModel()->refresh();
998+
}
998999
}
9991000

10001001
void RPCConsole::unbanSelectedNode()

0 commit comments

Comments
 (0)