|
|
@ -469,7 +469,7 @@ void RPCConsole::setClientModel(ClientModel *model)
|
|
|
|
ui->peerWidget->verticalHeader()->hide();
|
|
|
|
ui->peerWidget->verticalHeader()->hide();
|
|
|
|
ui->peerWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
|
|
ui->peerWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
|
|
ui->peerWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
|
|
|
|
ui->peerWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
|
|
|
|
ui->peerWidget->setSelectionMode(QAbstractItemView::SingleSelection);
|
|
|
|
ui->peerWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
|
|
|
ui->peerWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
ui->peerWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
ui->peerWidget->setColumnWidth(PeerTableModel::Address, ADDRESS_COLUMN_WIDTH);
|
|
|
|
ui->peerWidget->setColumnWidth(PeerTableModel::Address, ADDRESS_COLUMN_WIDTH);
|
|
|
|
ui->peerWidget->setColumnWidth(PeerTableModel::Subversion, SUBVERSION_COLUMN_WIDTH);
|
|
|
|
ui->peerWidget->setColumnWidth(PeerTableModel::Subversion, SUBVERSION_COLUMN_WIDTH);
|
|
|
@ -477,11 +477,11 @@ void RPCConsole::setClientModel(ClientModel *model)
|
|
|
|
ui->peerWidget->horizontalHeader()->setStretchLastSection(true);
|
|
|
|
ui->peerWidget->horizontalHeader()->setStretchLastSection(true);
|
|
|
|
|
|
|
|
|
|
|
|
// create peer table context menu actions
|
|
|
|
// create peer table context menu actions
|
|
|
|
QAction* disconnectAction = new QAction(tr("&Disconnect Node"), this);
|
|
|
|
QAction* disconnectAction = new QAction(tr("&Disconnect"), this);
|
|
|
|
QAction* banAction1h = new QAction(tr("Ban Node for") + " " + tr("1 &hour"), this);
|
|
|
|
QAction* banAction1h = new QAction(tr("Ban for") + " " + tr("1 &hour"), this);
|
|
|
|
QAction* banAction24h = new QAction(tr("Ban Node for") + " " + tr("1 &day"), this);
|
|
|
|
QAction* banAction24h = new QAction(tr("Ban for") + " " + tr("1 &day"), this);
|
|
|
|
QAction* banAction7d = new QAction(tr("Ban Node for") + " " + tr("1 &week"), this);
|
|
|
|
QAction* banAction7d = new QAction(tr("Ban for") + " " + tr("1 &week"), this);
|
|
|
|
QAction* banAction365d = new QAction(tr("Ban Node for") + " " + tr("1 &year"), this);
|
|
|
|
QAction* banAction365d = new QAction(tr("Ban for") + " " + tr("1 &year"), this);
|
|
|
|
|
|
|
|
|
|
|
|
// create peer table context menu
|
|
|
|
// create peer table context menu
|
|
|
|
peersTableContextMenu = new QMenu();
|
|
|
|
peersTableContextMenu = new QMenu();
|
|
|
@ -527,7 +527,7 @@ void RPCConsole::setClientModel(ClientModel *model)
|
|
|
|
ui->banlistWidget->horizontalHeader()->setStretchLastSection(true);
|
|
|
|
ui->banlistWidget->horizontalHeader()->setStretchLastSection(true);
|
|
|
|
|
|
|
|
|
|
|
|
// create ban table context menu action
|
|
|
|
// create ban table context menu action
|
|
|
|
QAction* unbanAction = new QAction(tr("&Unban Node"), this);
|
|
|
|
QAction* unbanAction = new QAction(tr("&Unban"), this);
|
|
|
|
|
|
|
|
|
|
|
|
// create ban table context menu
|
|
|
|
// create ban table context menu
|
|
|
|
banTableContextMenu = new QMenu();
|
|
|
|
banTableContextMenu = new QMenu();
|
|
|
@ -973,33 +973,44 @@ void RPCConsole::disconnectSelectedNode()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(!g_connman)
|
|
|
|
if(!g_connman)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
// Get currently selected peer address
|
|
|
|
|
|
|
|
NodeId id = GUIUtil::getEntryData(ui->peerWidget, 0, PeerTableModel::NetNodeId).toInt();
|
|
|
|
// Get selected peer addresses
|
|
|
|
// Find the node, disconnect it and clear the selected node
|
|
|
|
QList<QModelIndex> nodes = GUIUtil::getEntryData(ui->peerWidget, 0);
|
|
|
|
if(g_connman->DisconnectNode(id))
|
|
|
|
for(int i = 0; i < nodes.count(); i++)
|
|
|
|
clearSelectedNode();
|
|
|
|
{
|
|
|
|
|
|
|
|
// Get currently selected peer address
|
|
|
|
|
|
|
|
NodeId id = nodes.at(i).data(PeerTableModel::NetNodeId).toInt();
|
|
|
|
|
|
|
|
// Find the node, disconnect it and clear the selected node
|
|
|
|
|
|
|
|
if(g_connman->DisconnectNode(id))
|
|
|
|
|
|
|
|
clearSelectedNode();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void RPCConsole::banSelectedNode(int bantime)
|
|
|
|
void RPCConsole::banSelectedNode(int bantime)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!clientModel || !g_connman)
|
|
|
|
if (!clientModel || !g_connman)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if(cachedNodeid == -1)
|
|
|
|
// Get selected peer addresses
|
|
|
|
return;
|
|
|
|
QList<QModelIndex> nodes = GUIUtil::getEntryData(ui->peerWidget, 0);
|
|
|
|
|
|
|
|
for(int i = 0; i < nodes.count(); i++)
|
|
|
|
// Get currently selected peer address
|
|
|
|
{
|
|
|
|
int detailNodeRow = clientModel->getPeerTableModel()->getRowByNodeId(cachedNodeid);
|
|
|
|
// Get currently selected peer address
|
|
|
|
if(detailNodeRow < 0)
|
|
|
|
NodeId id = nodes.at(i).data(PeerTableModel::NetNodeId).toInt();
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
// Get currently selected peer address
|
|
|
|
// Find possible nodes, ban it and clear the selected node
|
|
|
|
int detailNodeRow = clientModel->getPeerTableModel()->getRowByNodeId(id);
|
|
|
|
const CNodeCombinedStats *stats = clientModel->getPeerTableModel()->getNodeStats(detailNodeRow);
|
|
|
|
if(detailNodeRow < 0)
|
|
|
|
if(stats) {
|
|
|
|
return;
|
|
|
|
g_connman->Ban(stats->nodeStats.addr, BanReasonManuallyAdded, bantime);
|
|
|
|
|
|
|
|
clearSelectedNode();
|
|
|
|
// Find possible nodes, ban it and clear the selected node
|
|
|
|
clientModel->getBanTableModel()->refresh();
|
|
|
|
const CNodeCombinedStats *stats = clientModel->getPeerTableModel()->getNodeStats(detailNodeRow);
|
|
|
|
|
|
|
|
if(stats) {
|
|
|
|
|
|
|
|
g_connman->Ban(stats->nodeStats.addr, BanReasonManuallyAdded, bantime);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
clearSelectedNode();
|
|
|
|
|
|
|
|
clientModel->getBanTableModel()->refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void RPCConsole::unbanSelectedNode()
|
|
|
|
void RPCConsole::unbanSelectedNode()
|
|
|
@ -1007,15 +1018,20 @@ void RPCConsole::unbanSelectedNode()
|
|
|
|
if (!clientModel)
|
|
|
|
if (!clientModel)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
// Get currently selected ban address
|
|
|
|
// Get selected ban addresses
|
|
|
|
QString strNode = GUIUtil::getEntryData(ui->banlistWidget, 0, BanTableModel::Address).toString();
|
|
|
|
QList<QModelIndex> nodes = GUIUtil::getEntryData(ui->banlistWidget, 0);
|
|
|
|
CSubNet possibleSubnet;
|
|
|
|
for(int i = 0; i < nodes.count(); i++)
|
|
|
|
|
|
|
|
|
|
|
|
LookupSubNet(strNode.toStdString().c_str(), possibleSubnet);
|
|
|
|
|
|
|
|
if (possibleSubnet.IsValid() && g_connman)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
g_connman->Unban(possibleSubnet);
|
|
|
|
// Get currently selected ban address
|
|
|
|
clientModel->getBanTableModel()->refresh();
|
|
|
|
QString strNode = nodes.at(i).data(BanTableModel::Address).toString();
|
|
|
|
|
|
|
|
CSubNet possibleSubnet;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LookupSubNet(strNode.toStdString().c_str(), possibleSubnet);
|
|
|
|
|
|
|
|
if (possibleSubnet.IsValid() && g_connman)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
g_connman->Unban(possibleSubnet);
|
|
|
|
|
|
|
|
clientModel->getBanTableModel()->refresh();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|