|
|
|
@ -10,6 +10,7 @@ |
|
|
|
#include <QDateTime> |
|
|
|
#include <QDateTime> |
|
|
|
#include <QFont> |
|
|
|
#include <QFont> |
|
|
|
#include <QSet> |
|
|
|
#include <QSet> |
|
|
|
|
|
|
|
#include <algorithm> |
|
|
|
#include "../../../lib/platform_compat.h" |
|
|
|
#include "../../../lib/platform_compat.h" |
|
|
|
|
|
|
|
|
|
|
|
extern "C" { |
|
|
|
extern "C" { |
|
|
|
@ -174,7 +175,7 @@ void AccountList::showMemberDetail(quint64 nodeId) { |
|
|
|
|
|
|
|
|
|
|
|
sqlite3_stmt* na = nullptr; |
|
|
|
sqlite3_stmt* na = nullptr; |
|
|
|
sqlite3_prepare_v2(d, |
|
|
|
sqlite3_prepare_v2(d, |
|
|
|
"SELECT family, protocol, address, port FROM node_addresses WHERE node_id=? ORDER BY family, port", |
|
|
|
"SELECT family, protocol, address, port, socket_id FROM node_addresses WHERE node_id=?", |
|
|
|
-1, &na, nullptr); |
|
|
|
-1, &na, nullptr); |
|
|
|
if (na) { |
|
|
|
if (na) { |
|
|
|
sqlite3_bind_int64(na, 1, (sqlite3_int64)nodeId); |
|
|
|
sqlite3_bind_int64(na, 1, (sqlite3_int64)nodeId); |
|
|
|
@ -186,11 +187,45 @@ void AccountList::showMemberDetail(quint64 nodeId) { |
|
|
|
int sz = sqlite3_column_bytes(na, 2); |
|
|
|
int sz = sqlite3_column_bytes(na, 2); |
|
|
|
if (adr && sz > 0) a.addr = QByteArray((const char*)adr, sz); |
|
|
|
if (adr && sz > 0) a.addr = QByteArray((const char*)adr, sz); |
|
|
|
a.port = sqlite3_column_int(na, 3); |
|
|
|
a.port = sqlite3_column_int(na, 3); |
|
|
|
|
|
|
|
a.socket_id = sqlite3_column_int(na, 4); |
|
|
|
if (!a.addr.isEmpty()) m_detailAddrs.append(a); |
|
|
|
if (!a.addr.isEmpty()) m_detailAddrs.append(a); |
|
|
|
} |
|
|
|
} |
|
|
|
sqlite3_finalize(na); |
|
|
|
sqlite3_finalize(na); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* resolve interface names from live sockets and sort */ |
|
|
|
|
|
|
|
if (m_inst) { |
|
|
|
|
|
|
|
for (auto& a : m_detailAddrs) { |
|
|
|
|
|
|
|
if (a.protocol == 1) { |
|
|
|
|
|
|
|
for (struct ETCP_SOCKET* s = m_inst->etcp_sockets; s; s = s->next) { |
|
|
|
|
|
|
|
if ((int)s->sock_id == a.socket_id) { |
|
|
|
|
|
|
|
QString name = QString::fromLatin1(s->name); |
|
|
|
|
|
|
|
int idx = name.lastIndexOf("_v"); |
|
|
|
|
|
|
|
if (idx > 3) a.ifname = name.mid(3, idx - 3); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else if (a.protocol == 2) { |
|
|
|
|
|
|
|
for (struct TCP_SOCKET* ts = m_inst->tcp_sockets; ts; ts = ts->next) { |
|
|
|
|
|
|
|
if ((int)ts->sock_id == a.socket_id) { |
|
|
|
|
|
|
|
QString name = QString::fromLatin1(ts->name); |
|
|
|
|
|
|
|
int idx = name.lastIndexOf("_v"); |
|
|
|
|
|
|
|
if (idx > 3) a.ifname = name.mid(3, idx - 3); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::sort(m_detailAddrs.begin(), m_detailAddrs.end(), |
|
|
|
|
|
|
|
[](const DetailAddress& a, const DetailAddress& b) { |
|
|
|
|
|
|
|
if (a.ifname != b.ifname) return a.ifname < b.ifname; |
|
|
|
|
|
|
|
if (a.addr != b.addr) return a.addr < b.addr; |
|
|
|
|
|
|
|
if (a.protocol != b.protocol) return a.protocol < b.protocol; |
|
|
|
|
|
|
|
return a.port < b.port; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
m_detailTimer->start(); |
|
|
|
m_detailTimer->start(); |
|
|
|
m_linkTimer->start(); |
|
|
|
m_linkTimer->start(); |
|
|
|
updateDetailDisplay(); |
|
|
|
updateDetailDisplay(); |
|
|
|
@ -292,9 +327,16 @@ void AccountList::updateDetailDisplay() { |
|
|
|
if (linkCount > 0) prefix = QString("[%1] ").arg(linkCount); |
|
|
|
if (linkCount > 0) prefix = QString("[%1] ").arg(linkCount); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!a.ifname.isEmpty()) { |
|
|
|
|
|
|
|
lines.append(QString("%1<span style='color:%2;'>●</span> %3 %4") |
|
|
|
|
|
|
|
.arg(prefix, linkColor, proto, a.ifname)); |
|
|
|
|
|
|
|
lines.append(QString(" %1:<span style='color:#FF9800;'>%2</span>") |
|
|
|
|
|
|
|
.arg(addrStr(a.addr.constData(), a.family)).arg(a.port)); |
|
|
|
|
|
|
|
} else { |
|
|
|
lines.append(QString("%1<span style='color:%2;'>●</span> %3:%4:%5") |
|
|
|
lines.append(QString("%1<span style='color:%2;'>●</span> %3:%4:%5") |
|
|
|
.arg(prefix, linkColor, proto, addrStr(a.addr.constData(), a.family)).arg(a.port)); |
|
|
|
.arg(prefix, linkColor, proto, addrStr(a.addr.constData(), a.family)).arg(a.port)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Show ETCP links that are not in DB (non-self) */ |
|
|
|
/* Show ETCP links that are not in DB (non-self) */ |
|
|
|
if (conn) { |
|
|
|
if (conn) { |
|
|
|
|