From 9f32f3e04f7d8b6254fadd850eebf048a74304f2 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 7 Feb 2021 06:02:17 -0500 Subject: [PATCH] Peers tab tweaks --- src/mainwindow.cpp | 14 +++++++++++++- src/mainwindow.ui | 2 +- src/peerstablemodel.cpp | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 0614c5d..ee7b638 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1116,6 +1116,7 @@ void MainWindow::setupBalancesTab() { QDesktopServices::openUrl(QUrl(url)); }); + //TODO: should this be kept? menu.addAction(tr("Convert Address"), [=] () { QString url; url = "https://dexstats.info/addressconverter.php?fromcoin=HUSH3&address=" + addr; @@ -1135,6 +1136,8 @@ void MainWindow::setupPeersTab() { // Table right click QObject::connect(ui->peersTable, &QTableView::customContextMenuRequested, [=] (QPoint pos) { QModelIndex index = ui->peersTable->indexAt(pos); + // we auto-sort by conntime + //ui->peersTable->setSortingEnabled(true); if (index.row() < 0) return; QMenu menu(this); @@ -1146,6 +1149,14 @@ void MainWindow::setupPeersTab() { QString ip = addr.split(":")[0]; QString as = QString::number(asn); + if(ip.contains("[")) { + // this is actually ipv6, grab it all except the port + auto parts = addr.split(":"); + parts[8]=""; // remove port + ip = parts.join(":"); + ip.chop(1); // remove trailing : + } + menu.addAction(tr("Copy peer address+port"), [=] () { QGuiApplication::clipboard()->setText(addr); ui->statusBar->showMessage(tr("Copied to clipboard"), 3 * 1000); @@ -1167,7 +1178,8 @@ void MainWindow::setupPeersTab() { ui->statusBar->showMessage(tr("Copied to clipboard"), 3 * 1000); }); - if(!ip.isEmpty()) { + // shodan only supports ipv4 addresses + if(!ip.isEmpty() && !ip.contains("[")) { menu.addAction(tr("View host on shodan.io (3rd party service)"), [=] () { QString url = "https://www.shodan.io/host/" + ip; qDebug() << "opening " << url; diff --git a/src/mainwindow.ui b/src/mainwindow.ui index c7f1090..812f10a 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -940,7 +940,7 @@ Peers - + diff --git a/src/peerstablemodel.cpp b/src/peerstablemodel.cpp index f2c4389..ec7183a 100644 --- a/src/peerstablemodel.cpp +++ b/src/peerstablemodel.cpp @@ -162,7 +162,7 @@ int PeersTableModel::columnCount(const QModelIndex&) const QVariant PeersTableModel::headerData(int section, Qt::Orientation orientation, int role) const { //if (role == Qt::TextAlignmentRole && section == 3) return QVariant(Qt::AlignRight | Qt::AlignVCenter); - if (role == Qt::TextAlignmentRole) return QVariant(Qt::AlignRight | Qt::AlignVCenter); + if (role == Qt::TextAlignmentRole) return QVariant(Qt::AlignCenter | Qt::AlignVCenter); if (role == Qt::FontRole) { QFont f;