- etcp_router.h/c: new flag ROUTER_FLAG_ENCRYPTED (0x04), etcp_route_send_encrypted(), inflight/retrans/send_q support - utun_instance.h: e2e_ctx_cache[8] — per-peer sc_context_t cache with derived session key - topo_node.c: topo_node_sign_self() — single point for Ed25519 self-signing of NODEINFO - topo_node.c: fix stale x25519_self_sig after address update (topo_node_sign_self call) - nat_detection.c: fix stale x25519_self_sig after in-place socket meta modification - test_etcp_router_unit: 5 E2E tests (basic round-trip, no NODEINFO drop, tampered, cache reuse, ENCRYPTED+SIGNED combined) - builds clean, 70/70 tests pass
70 lines
2.3 KiB
C++
70 lines
2.3 KiB
C++
#include "flagpainter.h"
|
|
#include <QPainterPath>
|
|
#include <cmath>
|
|
|
|
void FlagPainter::draw(QPainter* p, uint8_t flags, int x, int y, int sz) {
|
|
if (!flags) return;
|
|
int cx = x;
|
|
if (flags & MEMBER_FLAG_SUPERNODE) { drawLightning(p, cx, y, sz); cx += sz + 2; }
|
|
if (flags & MEMBER_FLAG_ADMIN) { drawStar(p, cx, y, sz); cx += sz + 2; }
|
|
if (flags & MEMBER_FLAG_MODER) { drawShield(p, cx, y, sz); cx += sz + 2; }
|
|
}
|
|
|
|
void FlagPainter::drawLightning(QPainter* p, int x, int y, int sz) {
|
|
p->save();
|
|
p->setRenderHint(QPainter::Antialiasing);
|
|
QPainterPath path;
|
|
qreal cx = x + sz / 2.0, t = y + 1.0, b = y + sz - 1.0;
|
|
path.moveTo(cx, t);
|
|
path.lineTo(cx - sz * 0.3, t + sz * 0.55);
|
|
path.lineTo(cx - sz * 0.05, t + sz * 0.5);
|
|
path.lineTo(cx + sz * 0.15, b);
|
|
path.lineTo(cx + sz * 0.1, t + sz * 0.55);
|
|
path.lineTo(cx + sz * 0.35, t + sz * 0.4);
|
|
path.closeSubpath();
|
|
p->setPen(Qt::NoPen);
|
|
p->setBrush(QColor("#FFC107"));
|
|
p->drawPath(path);
|
|
p->restore();
|
|
}
|
|
|
|
void FlagPainter::drawStar(QPainter* p, int x, int y, int sz) {
|
|
p->save();
|
|
p->setRenderHint(QPainter::Antialiasing);
|
|
QPainterPath path;
|
|
qreal cx = x + sz / 2.0, cy = y + sz / 2.0, r = sz / 2.0 - 1.0;
|
|
for (int i = 0; i < 10; i++) {
|
|
qreal a = (i * 36.0 - 90.0) * 3.14159265 / 180.0;
|
|
qreal rr = (i & 1) ? r * 0.42 : r;
|
|
qreal px = cx + rr * cos(a), py = cy + rr * sin(a);
|
|
if (i == 0) path.moveTo(px, py);
|
|
else path.lineTo(px, py);
|
|
}
|
|
path.closeSubpath();
|
|
p->setPen(QPen(QColor("#E65100"), 0.5));
|
|
p->setBrush(QColor("#FFD700"));
|
|
p->drawPath(path);
|
|
p->restore();
|
|
}
|
|
|
|
void FlagPainter::drawShield(QPainter* p, int x, int y, int sz) {
|
|
p->save();
|
|
p->setRenderHint(QPainter::Antialiasing);
|
|
QPainterPath path;
|
|
qreal cx = x + sz / 2.0, t = y + 1.0, b = y + sz - 1.0;
|
|
qreal w = sz * 0.38;
|
|
qreal notch = sz * 0.22;
|
|
path.moveTo(cx - w, t);
|
|
path.lineTo(cx - w, t + notch);
|
|
path.lineTo(cx - w * 0.3, t + notch + 1);
|
|
path.lineTo(cx, b);
|
|
path.lineTo(cx + w * 0.3, t + notch + 1);
|
|
path.lineTo(cx + w, t + notch);
|
|
path.lineTo(cx + w, t);
|
|
path.closeSubpath();
|
|
p->setPen(QPen(QColor("#1565C0"), 0.8));
|
|
p->setBrush(QColor("#2196F3"));
|
|
p->drawPath(path);
|
|
p->restore();
|
|
}
|