|
|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
#include <QCoreApplication> |
|
|
|
|
// nodespage.cpp — Nodes table + dump in settings
|
|
|
|
|
#include "nodespage.h" |
|
|
|
|
#include "addressprofiletext.h" |
|
|
|
|
#include "../db/db_manager.h" |
|
|
|
|
|
|
|
|
|
#include <QVBoxLayout> |
|
|
|
|
@ -49,19 +50,6 @@ QString NodesPage::protoStr(int protocol) {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static QString addrTypeStr(int t) { |
|
|
|
|
switch (t) { |
|
|
|
|
case ADDR_TYPE_NETIF: return "NETIF"; |
|
|
|
|
case ADDR_TYPE_DIRECT: return "DIRECT"; |
|
|
|
|
case ADDR_TYPE_NAT_EIM: return "NAT type=EIM"; |
|
|
|
|
case ADDR_TYPE_NAT_STRICT: return "NAT type=STRICT"; |
|
|
|
|
case ADDR_TYPE_NAT: return "NAT?"; |
|
|
|
|
case ADDR_TYPE_CONTACT: return "CONTACT_REQUIRED"; |
|
|
|
|
case ADDR_TYPE_NAT_EIM_UNVERIFIED: return "NAT type=EIM?"; |
|
|
|
|
default: return QString("?%1").arg(t); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
NodesPage::NodesPage(DbManager* db, QWidget* parent) |
|
|
|
|
: QWidget(parent) |
|
|
|
|
, m_db(db) |
|
|
|
|
@ -209,7 +197,7 @@ void NodesPage::refreshNodes() {
|
|
|
|
|
|
|
|
|
|
sqlite3_stmt* na = nullptr; |
|
|
|
|
sqlite3_prepare_v2(d, |
|
|
|
|
"SELECT family, protocol, address, port, rtt, addr_type, address_kind, nat_mapping, nat_inbound" |
|
|
|
|
"SELECT family, protocol, address, port, rtt, nat_mapping, nat_inbound, nat_source" |
|
|
|
|
" FROM node_addresses WHERE node_id=? ORDER BY family, port", |
|
|
|
|
-1, &na, nullptr); |
|
|
|
|
if (na) { |
|
|
|
|
@ -223,17 +211,11 @@ void NodesPage::refreshNodes() {
|
|
|
|
|
int addrSz = sqlite3_column_bytes(na, 2); |
|
|
|
|
int port = sqlite3_column_int(na, 3); |
|
|
|
|
int rtt = sqlite3_column_int(na, 4); |
|
|
|
|
int addrType = sqlite3_column_int(na, 5); |
|
|
|
|
int kind = sqlite3_column_int(na, 6); |
|
|
|
|
int mapping = sqlite3_column_int(na, 7), inbound = sqlite3_column_int(na, 8); |
|
|
|
|
int mapping = sqlite3_column_int(na, 5), inbound = sqlite3_column_int(na, 6); |
|
|
|
|
int source = sqlite3_column_int(na, 7); |
|
|
|
|
|
|
|
|
|
if (addr && addrSz > 0) { |
|
|
|
|
QString label = addrTypeStr(addrType); |
|
|
|
|
if (kind == TOPO_ADDR_INTERFACE) { |
|
|
|
|
label = QStringLiteral("INTERFACE"); |
|
|
|
|
if (mapping != ADDRESS_MAP_UNKNOWN || inbound != ADDRESS_IN_UNKNOWN) |
|
|
|
|
label += QString(" mapping=%1 inbound=%2").arg(address_mapping_name(mapping), address_inbound_name(inbound)); |
|
|
|
|
} |
|
|
|
|
QString label = addressProfileText(mapping, inbound, source); |
|
|
|
|
dump += QString(" %1:%2 %3 %4 rtt=%5ms\n") |
|
|
|
|
.arg(addrStr(addr, family)) |
|
|
|
|
.arg(port) |
|
|
|
|
|