Browse Source

Adding ban/unban to peers list

pull/112/head
fekt 2 years ago
parent
commit
a236d83322
  1. 22
      src/mainwindow.cpp
  2. 4
      src/rpc.h

22
src/mainwindow.cpp

@ -1406,13 +1406,13 @@ QString peer2ip(QString peer) {
void MainWindow::setupPeersTab() {
qDebug() << __FUNCTION__;
// Set up context menu on transactions tab
// Set up context menu on peers tab
ui->peersTable->setContextMenuPolicy(Qt::CustomContextMenu);
ui->bannedPeersTable->setContextMenuPolicy(Qt::CustomContextMenu);
// Table right click
QObject::connect(ui->bannedPeersTable, &QTableView::customContextMenuRequested, [=] (QPoint pos) {
QModelIndex index = ui->peersTable->indexAt(pos);
QModelIndex index = ui->bannedPeersTable->indexAt(pos);
if (index.row() < 0) return;
QMenu menu(this);
@ -1440,6 +1440,16 @@ void MainWindow::setupPeersTab() {
});
}
if(!ip.isEmpty()) {
menu.addAction(tr("Unban this peer"), [=] () {
rpc->setban(ip, "remove", [=] (QJsonValue response){
qDebug() << "setban remove " << response;
ui->statusBar->showMessage(tr("Peer unbanned"), 3 * 1000);
rpc->refreshPeers();
});
});
}
menu.exec(ui->bannedPeersTable->viewport()->mapToGlobal(pos));
});
@ -1495,6 +1505,14 @@ void MainWindow::setupPeersTab() {
});
}
menu.addAction(tr("Ban this peer"), [=] () {
rpc->setban(ip, "add", [=] (QJsonValue response){
qDebug() << "setban add " << response;
ui->statusBar->showMessage(tr("Peer banned"), 3 * 1000);
rpc->refreshPeers();
});
});
menu.exec(ui->peersTable->viewport()->mapToGlobal(pos));
});

4
src/rpc.h

@ -66,7 +66,8 @@ public:
void refresh(bool force = false);
void refreshAddresses();
void refreshPeers();
void refreshPeers();
void setban(QString ip, QString command, const std::function<void(QJsonValue)>& cb);
void checkForUpdate(bool silent = true);
void refreshPrice();
@ -143,7 +144,6 @@ private:
void z_sweepstatus (const std::function<void(QJsonValue)>& cb);
void z_consolidationstatus (const std::function<void(QJsonValue)>& cb);
void rescan (qint64 height, const std::function<void(QJsonValue)>& cb);
void setban (QString ip, QString command, const std::function<void(QJsonValue)>& cb);
Connection* conn = nullptr;
std::shared_ptr<QProcess> ehushd = nullptr;

Loading…
Cancel
Save