unify TCP_SOCKET into ETCP_SOCKET with is_tcp flag; add local+remote addr to member detail links with arrow display
This commit is contained in:
1 parent
477b4dfc98
commit
544c77efff
19 files changed
+197
-228
No files matched your search
@@ -258,10 +258,12 @@ void AccountList::onMemberDetailData(uint64_t nodeId, const uint8_t* data, int l
|
||||
lk.linkStatus = p[2];
|
||||
lk.tcpReady = p[3] != 0;
|
||||
lk.isServer = p[4] != 0;
|
||||
lk.family = p[5];
|
||||
int addrLen = p[6];
|
||||
lk.addr = QByteArray((const char*)p + 7, qMin(addrLen, 16));
|
||||
memcpy(&lk.port, p + 23, 2);
|
||||
lk.localFamily = p[5];
|
||||
lk.localAddr = QByteArray((const char*)p + 6, 16);
|
||||
memcpy(&lk.localPort, p + 22, 2);
|
||||
lk.family = p[24];
|
||||
lk.addr = QByteArray((const char*)p + 25, 16);
|
||||
memcpy(&lk.port, p + 41, 2);
|
||||
p += MEMBER_DETAIL_LINK_SIZE;
|
||||
m_snapLinks.append(lk);
|
||||
}
|
||||
@@ -314,65 +316,40 @@ void AccountList::updateDetailDisplay() {
|
||||
|
||||
bool isSelf = m_db ? (m_detailNodeId == m_db->myNodeId()) : false;
|
||||
|
||||
for (const auto& a : m_detailAddrs) {
|
||||
QString proto;
|
||||
switch (a.protocol) { case 1: proto = "UDP"; break; case 2: proto = "TCP"; break; default: proto = "UDP/TCP"; break; }
|
||||
QString linkColor = "#9E9E9E"; QString scRole;
|
||||
if (m_snapConnPresent) {
|
||||
for (const auto& lk : m_snapLinks) {
|
||||
if (lk.family == a.family && lk.port == a.port
|
||||
&& lk.addr == a.addr) {
|
||||
linkColor = (lk.linkState == 3 && lk.linkStatus == 1) ? "#4CAF50" : "#E53935";
|
||||
scRole = lk.isServer ? " S" : " C";
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (linkColor == "#9E9E9E" && a.protocol == 2) {
|
||||
for (const auto& lk : m_snapLinks) {
|
||||
if (lk.isTcp && lk.tcpReady) { linkColor = "#4CAF50"; scRole = lk.isServer ? " S" : " C"; break; }
|
||||
}
|
||||
}
|
||||
if (isSelf) {
|
||||
for (const auto& a : m_detailAddrs) {
|
||||
QString proto;
|
||||
switch (a.protocol) { case 1: proto = "UDP"; break; case 2: proto = "TCP"; break; default: proto = "UDP/TCP"; break; }
|
||||
int lc = 0;
|
||||
if (a.protocol == 1) { for (const auto& s : m_snapSocks) { if (s.port == a.port) { lc = s.linkCount; break; } } }
|
||||
else if (a.protocol == 2) lc = m_snapOwnTcpActive;
|
||||
QString prefix = lc > 0 ? QString("[%1] ").arg(lc) : "";
|
||||
if (!a.ifname.isEmpty())
|
||||
lines.append(QString("%1● %2 %3").arg(prefix, proto, a.ifname));
|
||||
else
|
||||
lines.append(QString("%1● %2:%3:%4").arg(prefix, proto, addrStr(a.addr.constData(), a.family)).arg(a.port));
|
||||
}
|
||||
|
||||
QString prefix;
|
||||
if (isSelf) {
|
||||
int linkCount = 0;
|
||||
if (a.protocol == 1) {
|
||||
for (const auto& s : m_snapSocks) {
|
||||
if (s.port == a.port) { linkCount = s.linkCount; break; }
|
||||
}
|
||||
} else if (a.protocol == 2) {
|
||||
linkCount = m_snapOwnTcpActive;
|
||||
}
|
||||
if (linkCount > 0) prefix = QString("[%1] ").arg(linkCount);
|
||||
} else {
|
||||
/* all live links with arrows */
|
||||
for (const auto& lk : m_snapLinks) {
|
||||
QString proto = lk.isTcp ? "TCP" : "UDP";
|
||||
QString lc = (lk.linkState == 3 && lk.linkStatus == 1) ? "#4CAF50" : "#E53935";
|
||||
QString left = QString("%1:%2").arg(addrStr(lk.localAddr.constData(), lk.localFamily)).arg(lk.localPort);
|
||||
QString right = QString("%1:%2").arg(addrStr(lk.addr.constData(), lk.family)).arg(lk.port);
|
||||
lines.append(QString("<span style='color:%1;'>●</span> %2 %3 → %4")
|
||||
.arg(lc, proto, left, right));
|
||||
}
|
||||
|
||||
if (!a.ifname.isEmpty()) {
|
||||
lines.append(QString("%1<span style='color:%2;'>●</span> %3%4 %5")
|
||||
.arg(prefix, linkColor, proto, scRole, 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:%6")
|
||||
.arg(prefix, linkColor, proto, scRole, addrStr(a.addr.constData(), a.family)).arg(a.port));
|
||||
}
|
||||
}
|
||||
|
||||
/* Show snapshot links that are not in DB (non-self) */
|
||||
if (m_snapConnPresent && m_snapLinks.size() > 0) {
|
||||
for (int li = 0; li < m_snapLinks.size(); li++) {
|
||||
const auto& lk = m_snapLinks[li];
|
||||
/* DB addresses without live link */
|
||||
for (const auto& a : m_detailAddrs) {
|
||||
bool matched = false;
|
||||
for (const auto& a : m_detailAddrs) {
|
||||
if (lk.family == a.family && lk.port == a.port
|
||||
&& lk.addr == a.addr) { matched = true; break; }
|
||||
for (const auto& lk : m_snapLinks) {
|
||||
if (lk.family == a.family && lk.port == a.port && lk.addr == a.addr) { matched = true; break; }
|
||||
}
|
||||
if (matched) continue;
|
||||
QString proto = lk.isTcp ? "TCP" : "UDP";
|
||||
QString sc = lk.isServer ? " S" : " C";
|
||||
QString lc = (lk.linkState == 3 && lk.linkStatus == 1) ? "#4CAF50" : "#E53935";
|
||||
lines.append(QString("<span style='color:%1;'>●</span> %2%3:%4:%5 [link]")
|
||||
.arg(lc, proto, sc, addrStr(lk.addr.constData(), lk.family)).arg(lk.port));
|
||||
QString proto;
|
||||
switch (a.protocol) { case 1: proto = "UDP"; break; case 2: proto = "TCP"; break; default: proto = "UDP/TCP"; break; }
|
||||
lines.append(QString("<span style='color:#9E9E9E;'>●</span> %1 %2:%3")
|
||||
.arg(proto, addrStr(a.addr.constData(), a.family)).arg(a.port));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user