LordOS — a free, fast and secure GNU/Linux distribution based on Debian, with its own desktop environment: display server and Wayland compositor in C, a React UI engine on QuickJS, and private native apps.
C cdebiandesktop-environmentebpffirewalllandlocklinuxlinux-distributionopen-sourceprivacyquickjsraspberry-pi-5reactsecuritywaylandwayland-compositor
Monitor map: arcs always visible (per-arc coverage mask, they vanished over land), any traffic moves, the app's rate spread over its hosts, one color per app with separate arcs, the map follows search and filters; ping/raw sockets attributed by their process's cgroup; click below the list clears the selection
Federico Pereira6d2b81234fa7
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 80c0bd1..2e6cd99 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,6 +12,23 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),### Added+- **A curated catalog of AI apps in the LordOS repository (in development).** `apt/catalog.json` lists+ ten apps with their package, summary (en/es/pt), licence, vendor, architectures (amd64 and arm64) and+ a pinned source; `apt/keys/` holds the vendors' APT keys, `apt/recipes/` LordOS's build recipes and+ `apt/build.sh` checks and fetches them (`apt/README.md`, `docs/UPDATES.md` "Mirrored apps+ (catalog)"). Claude Code, Claude Desktop, Visual Studio Code and Cursor come straight from their+ vendors' signed APT repositories ("direct"): `apt/build.sh check` verifies the pinned key+ fingerprint, the signed `InRelease`, the index hash and the package for each architecture. The other+ six are verified on the maintainer's Mac and published in `pool/catalog/` by+ `tools/release/apt-repo.sh build … --catalog`: goose 1.56.0 and opencode 1.19.4 (the vendor's .deb,+ pinned SHA-256), and four packages LordOS builds in `debian:trixie` containers with no network —+ `ollama` 0.40.11 (the official release split into `ollama`, with `ollama.service` enabled on install+ as upstream does, and `ollama-cuda` with the NVIDIA libraries, so a Raspberry Pi never downloads+ them), `llama.cpp` 0.7.0 and `whisper.cpp` 1.9.5 (from the pinned source tag, CPU only, every CPU+ variant built and the best one picked at run time) and `codex-cli` 0.164.0 (OpenAI's static binary,+ its sigstore signature checked with cosign). Vendor packages are never modified; what their+ maintainer scripts do when the Store installs them (VS Code, Claude Desktop and Cursor add their own+ APT source) is documented.- **Root over SSH, as an advanced option.** Settings → Sharing → Advanced lets an administrator allowroot to log in over SSH with a public key only, or with a key or a password, for tests andadministration: the keys are pasted or imported from a `.pub` file and listed with their@@ -136,6 +153,20 @@ of the matching [GitHub release](https://github.com/lordbasex/LordOS/releases),### Fixed+- **Monitor → Network: the map always shows the traffic.** The arc to a country with no traffic at that+ moment was drawn almost transparent, so a selected app's destinations looked unconnected; arcs now stay+ plainly visible. Any traffic moves dots along the arcs (orange out, green in), not only above 256 B/s,+ so a slow app (a ping, a chat) shows its direction too. And the map follows the search and the filters+ like the list does: all apps, the selected app, or only the connections the filters leave.+ Short connections (a page, a download) used to close before their own rate was read, which left the+ arcs still while the app moved megabytes: the app's own rate is now spread over its destinations.+- **Monitor → Network: one color per app on the map.** Each app's arcs have their own color, shown as a+ dot before the app in the list, and apps that reach the same country get separate arcs, so Chromium,+ the Terminal and the Store can be told apart; the moving dots stay orange (out) and green (in).+- **Monitor → Network: `ping` counts under the Terminal.** Ping and raw sockets carry no cgroup of their+ own, so `ping` run in the Terminal showed as a separate, empty app; such sockets now take their+ process's cgroup and appear under the app that ran them.+- **Monitor → Network: a click on the empty space under the list clears the selection.**- **Two failed theme switches in a row could leave the session without a theme.** After a theme wasrefused, the server still took it as the current one, so a second refused switch fell back to it.Now the last theme that loaded stays the fallback.diff --git a/apps/monitor/MapView.jsx b/apps/monitor/MapView.jsxindex 1af7150..f0202f9 100644--- a/apps/monitor/MapView.jsx+++ b/apps/monitor/MapView.jsx@@ -21,9 +21,9 @@ import { C, useCardStyle } from './index.jsx';// moves and when nothing moves. Each dot is a small ready-made image, and each frame repaints only// the small boxes the dots left and entered (the engine's several damaged rectangles, 0.8.2; the// cost is in docs/MONITOR.md). With Reduce motion each busy arc gets two still arrows instead.-const FLOW_FPS = 12, FLOW_FPS_BEHIND = 5, FLOW_ARCS = 12, FLOW_MIN = 256; // FLOW_MIN: bytes per second that count as "moving"-// 0 at FLOW_MIN, 1 from about 4 MB/s-const flowLevel = (rate) => (rate > FLOW_MIN ? Math.max(0, Math.min(1, Math.log10(rate / FLOW_MIN) / 4.2)) : -1);+const FLOW_FPS = 12, FLOW_FPS_BEHIND = 5, FLOW_ARCS = 12, FLOW_MIN = 1; // FLOW_MIN: bytes per second that count as "moving"+// any traffic moves (one slow dot up to 64 B/s), 1 from about 4 MB/s+const flowLevel = (rate) => (rate >= FLOW_MIN ? Math.max(0, Math.min(1, Math.log10(Math.max(1, rate / 64)) / 4.8)) : -1);const bez = (a, k) => { const u = 1 - k; return [u * u * a.x0 + 2 * u * k * a.cx + k * k * a.x1, u * u * a.y0 + 2 * u * k * a.cy + k * k * a.y1]; };// One moving dot as a ready-made 9×9 image (a ring and the direction's color): the engine only@@ -182,6 +182,17 @@ export function MapView({ places, home, selected, onSelect, geoOn, fitKey }) {cc: p.cc, lon: COUNTRY_LL[p.cc][0], lat: COUNTRY_LL[p.cc][1], r: Math.min(11, 3 + 1.6 * Math.sqrt(Math.max(1, p.count))), sel: selected === p.cc, count: p.count,tx: p.rateTx || 0, rx: p.rateRx || 0, idle: (p.rateTx || 0) + (p.rateRx || 0) < FLOW_MIN,}));+ // one arc per app and place, in the app's color; the apps that reach the same place get arcs apart+ // (the busiest one lowest)+ const arcs = [];+ for (const p of places) {+ const ll = COUNTRY_LL[p.cc];+ if (!ll || !p.links) continue;+ [...p.links.values()].sort((a, b) => b.bytes - a.bytes).forEach((l, k) => {+ arcs.push({ cc: p.cc, app: l.app, lon: ll[0], lat: ll[1], lift: Math.min(0.62, 0.22 + 0.09 * k), color: l.color,+ sel: selected === p.cc, tx: l.tx || 0, rx: l.rx || 0, idle: (l.tx || 0) + (l.rx || 0) < FLOW_MIN });+ });+ }const dark = t.mode === 'dark';const card = useCardStyle();const colors = {@@ -189,7 +200,7 @@ export function MapView({ places, home, selected, onSelect, geoOn, fitKey }) {border: rgba(dark ? '#cfd6e6' : '#ffffff', dark ? (v && v.ppd > 6 ? 0.42 : 0.25) : 0.9),accent: rgba(t.accent, 1), homeColor: rgba('#30d158', 1), selColor: rgba('#ffd60a', 1),};- const dataKey = JSON.stringify([dots.map((d) => [d.cc, d.r, d.sel, d.idle]), home, colors]);+ const dataKey = JSON.stringify([dots.map((d) => [d.cc, d.r, d.sel, d.idle]), arcs.map((a) => [a.cc, a.lift, a.color, a.sel, a.idle]), home, colors]);// pedir un cuadro cuando cambia la vista, el tamaño o los datos; retirarlo cuando esté listoconst pending = useRef(0);// Mientras se mueve (arrastrar, dos dedos con inercia, pellizco): a lo sumo un cuadro cada 100 ms@@ -199,16 +210,17 @@ export function MapView({ places, home, selected, onSelect, geoOn, fitKey }) {const [moving, setMoving] = useState(false); // sin etiquetas mientras se mueveconst markMoving = () => { movingAt.current = lord.now(); if (!moving) setMoving(true); };const latest = useRef(null);- latest.current = { w, h, colors, home, dots };+ latest.current = { w, h, colors, home, dots, arcs };const frameRef = useRef(null);frameRef.current = frame;const pollT = useRef(0);// pide un cuadro de la vista vv (q: resolución) y lo va a buscar cuando esté listoconst requestMap = (vv, q) => {- const { w: ww, h: hh, colors: cc, home: hm, dots: dd } = latest.current;+ const { w: ww, h: hh, colors: cc, home: hm, dots: dd, arcs: aa } = latest.current;lastReq.current = lord.now();pending.current = lord.monitor.map({ width: Math.round(ww * q), height: Math.round(hh * q), lon: vv.lon - ww / 2 / vv.ppd,- lat: vv.lat + hh / 2 / vv.ppd, ppd: vv.ppd * q, ...cc, home: hm || null, dots: dd.map((d) => ({ lon: d.lon, lat: d.lat, r: d.r, sel: d.sel, idle: d.idle })) });+ lat: vv.lat + hh / 2 / vv.ppd, ppd: vv.ppd * q, ...cc, home: hm || null, dots: dd.map((d) => ({ lon: d.lon, lat: d.lat, r: d.r, sel: d.sel, idle: d.idle })),+ arcs: aa.map((a) => ({ lon: a.lon, lat: a.lat, lift: a.lift, color: rgba(a.color, 1), sel: a.sel, idle: a.idle })) });clearTimeout(pollT.current);const poll = () => {const f = lord.monitor.mapFrame();@@ -249,9 +261,9 @@ export function MapView({ places, home, selected, onSelect, geoOn, fitKey }) {}if (best || !home) return best?.cc || null;const [hx, hy] = toXY(home.lon, home.lat);- for (const d of dots) { // arcos+ for (const d of arcs) { // arcosconst [x, y] = toXY(d.lon, d.lat);- const len = Math.hypot(x - hx, y - hy), cx = (hx + x) / 2, cy = (hy + y) / 2 - len * 0.3;+ const len = Math.hypot(x - hx, y - hy), cx = (hx + x) / 2, cy = (hy + y) / 2 - len * d.lift;for (let i = 0; i <= 48; i++) {const k = i / 48, u = 1 - k;const px = u * u * hx + 2 * u * k * cx + k * k * x, py = u * u * hy + 2 * u * k * cy + k * k * y;@@ -344,13 +356,13 @@ export function MapView({ places, home, selected, onSelect, geoOn, fitKey }) {const flowArcs = [];if (v && home) {const [hx, hy] = toXY(home.lon, home.lat);- for (const d of [...dots].filter((x) => !x.idle).sort((a, b) => b.tx + b.rx - (a.tx + a.rx)).slice(0, FLOW_ARCS)) {+ for (const d of arcs.filter((x) => !x.idle).sort((a, b) => b.tx + b.rx - (a.tx + a.rx)).slice(0, FLOW_ARCS)) {const [x, y] = toXY(d.lon, d.lat);const len = Math.hypot(x - hx, y - hy);if (len < 6) continue;- const cx = (hx + x) / 2, cy = (hy + y) / 2 - len * 0.3;+ const cx = (hx + x) / 2, cy = (hy + y) / 2 - len * d.lift;if (Math.max(hx, x, cx) < 0 || Math.min(hx, x, cx) > w || Math.max(hy, y, cy) < 0 || Math.min(hy, y, cy) > h) continue; // off screen- flowArcs.push({ cc: d.cc, x0: hx, y0: hy, cx, cy, x1: x, y1: y, tx: d.tx, rx: d.rx });+ flowArcs.push({ cc: `${d.cc}${d.app}`, x0: hx, y0: hy, cx, cy, x1: x, y1: y, tx: d.tx, rx: d.rx });}}diff --git a/apps/monitor/Network.jsx b/apps/monitor/Network.jsxindex bbf599c..6f9d326 100644--- a/apps/monitor/Network.jsx+++ b/apps/monitor/Network.jsx@@ -250,7 +250,7 @@ function Activity({ hist, selected }) {);}-function AppRow({ g, node, ctx, open, selected, onToggle, onSelect, maxBytes, tr, hist, onConfirm }) {+function AppRow({ g, node, ctx, open, selected, onToggle, onSelect, maxBytes, tr, hist, onConfirm, mapColor }) {const t = useTheme();const label = labelOf(tr, g);const total = g.sent + g.recv;@@ -263,6 +263,7 @@ function AppRow({ g, node, ctx, open, selected, onToggle, onSelect, maxBytes, tr<View onClick={(e) => { e.stopPropagation(); onToggle(); }} style={{ width: 14, alignItems: 'center' }}><Text style={{ fontSize: 10, color: selected ? '#fff' : t.textDim }}>{kids || g.listen.length ? (open ? '▾' : direction() === 'rtl' ? '◂' : '▸') : ''}</Text></View>+ <View style={{ width: 8, height: 8, borderRadius: 4, backgroundColor: mapColor || 'transparent' }} /><AppGlyph item={g.item} size={20} /><View style={{ flex: 1, minWidth: 0, gap: 3 }}>{/* the name gets the whole width (two lines at most); the counts go next to the traffic bar */}@@ -362,18 +363,47 @@ function SystemTraffic({ tr, range, setRange, end, setEnd, sysHist }) {// ---- lugares (países con conexiones) -----function placesOf(groups, appKey) {+// Each app's color on the map (its arcs) and in the list (the dot before its icon): the order in which+// apps first reached the internet in this Monitor, so the first twelve are all different and an app+// keeps its color while Monitor is open. Orange and green stay for the moving dots (sent, received).+const MAP_COLORS = ['#0a84ff', '#bf5af2', '#ff375f', '#64d2ff', '#ffd60a', '#5e5ce6', '#66d4cf', '#ac8e68', '#ff6482', '#da8fff', '#a2845e', '#e5e5ea'];+const mapColorOf = new Map();+export function appMapColor(key) {+ if (!mapColorOf.has(key)) mapColorOf.set(key, MAP_COLORS[mapColorOf.size % MAP_COLORS.length]);+ return mapColorOf.get(key);+}++// The map's places: every app's (or the selected app's) internet hosts by country; with a search or a+// filter, only the hosts of the flows it shows (`only`: a Set of "app|address").+// Short connections (a page, a curl, a package download) often close before their own rate is+// measured, while the app's rate (its cgroup counters) is always there: what the hosts' rates don't+// account for is spread over the app's internet hosts by their bytes, so the arcs move whenever the app+// does (an estimate per country, the direction is exact).+function placesOf(groups, appKey, only) {const out = new Map();for (const g of groups) {if (appKey && g.key !== appKey) continue;- for (const h of g.hosts.values()) {- if (h.scope !== 'internet' || !h.cc) continue;- const p = out.get(h.cc) || { cc: h.cc, count: 0, sent: 0, recv: 0, rateTx: 0, rateRx: 0, apps: new Map(), hosts: [] };+ const net = [...g.hosts.values()].filter((h) => h.scope === 'internet' && h.cc);+ const share = (dir) => {+ const own = net.reduce((a, h) => a + (h[dir === 'rx' ? 'rateRx' : 'rateTx'] || 0), 0);+ const left = Math.max(0, (dir === 'rx' ? g.rateRx : g.rateTx) - own || 0);+ const bytes = net.reduce((a, h) => a + (dir === 'rx' ? h.recv : h.sent) + 1, 0);+ return (h) => (left > 0 && bytes > 0 ? left * ((dir === 'rx' ? h.recv : h.sent) + 1) / bytes : 0);+ };+ const extraRx = share('rx'), extraTx = share('tx');+ for (const h of net) {+ if (only && !only.has(`${g.key}|${h.remote}`)) continue;+ const p = out.get(h.cc) || { cc: h.cc, count: 0, sent: 0, recv: 0, rateTx: 0, rateRx: 0, apps: new Map(), hosts: [], links: new Map() };+ const l = p.links.get(g.key) || { app: g.key, color: appMapColor(g.key), tx: 0, rx: 0, bytes: 0 };+ l.tx += (h.rateTx || 0) + extraTx(h);+ l.rx += (h.rateRx || 0) + extraRx(h);+ l.bytes += h.sent + h.recv;+ p.links.set(g.key, l);p.count += h.count;p.sent += h.sent;p.recv += h.recv;- p.rateTx += h.rateTx || 0;- p.rateRx += h.rateRx || 0;+ p.rateTx += (h.rateTx || 0) + extraTx(h);+ p.rateRx += (h.rateRx || 0) + extraRx(h);p.apps.set(g.key, g);p.hosts.push({ ...h, app: g });out.set(h.cc, p);@@ -847,7 +877,7 @@ export function NetworkTab({ last, prefs }) {const maxBytes = Math.max(1, ...apps.map((g) => g.sent + g.recv), ...histRoots.map((g) => g.sent + g.recv));const sel = apps.find((g) => g.key === selected) || histRoots.find((g) => g.key === selected) || null;- const places = placesOf(apps, sel ? sel.key : null);+ const places = placesOf(apps, sel ? sel.key : null, filtered ? new Set(shownFlows.map((f) => `${f.app}|${f.addr}`)) : null);const selPlace = places.find((p) => p.cc === place) || null;const toggle = (key) => setOpen((s0) => { const n = new Set(s0); if (n.has(key)) n.delete(key); else n.add(key); return n; });const ctx = {@@ -909,13 +939,17 @@ export function NetworkTab({ last, prefs }) {if (!g) return null;// filtered, the row adds up what matched; otherwise the app's own totals (the kernel's)const shownG = filtered ? { ...g, recv: n.rx, sent: n.tx, rateRx: n.rateRx, rateTx: n.rateTx } : g;+ const onMap = [...g.hosts.values()].some((h) => h.scope === 'internet' && h.cc);return <AppRow key={n.key} g={shownG} node={n} ctx={ctx} tr={tr} open={open.has(n.key)} selected={selected === g.key} maxBytes={maxBytes} hist={hist.get(g.key)}+ mapColor={onMap ? appMapColor(g.key) : null}onConfirm={(x) => setConfirm(x)} onToggle={() => toggle(n.key)}onSelect={() => { setPlace(null); setHost(null); setSelected(selected === g.key ? null : g.key); }} />;}return <Child key={n.key} node={n} depth={0} path="" ctx={ctx} />;})}{enabled && conns && !roots.length && <Text style={{ fontSize: 12, color: t.textDim, padding: 8 }}>{chips.length || text ? tr('monitor.net.noMatch') : tr('monitor.net.none')}</Text>}+ {/* a click on the empty space under the rows clears the selection (the map shows every app again) */}+ <View style={{ flexGrow: 1, minHeight: 160 }} onClick={() => { if (selected || place || host) { setSelected(null); setPlace(null); setHost(null); } }} /></ScrollView><View style={{ height: 1, backgroundColor: t.separator }} /><SystemTraffic tr={tr} range={range} setRange={setRange} end={end} setEnd={setEnd} sysHist={sysHist} />diff --git a/docs/MONITOR.md b/docs/MONITOR.mdindex 1e151cf..d743757 100644--- a/docs/MONITOR.md+++ b/docs/MONITOR.md@@ -88,8 +88,17 @@ the rest of the tab, and the first generation of the list.**Direction of the traffic.** While bytes move, dots travel along each arc: sent (orange) from"This computer" to the place, received (green) back. The higher the rate, the more dots (1 to 4- each way) and the faster they go (3.4 s to 1 s per trip, on a log scale from 256 B/s to about- 4 MB/s). An idle arc has no dots and is drawn dimmed (`idle` in the map request, `map.c`). The+ each way) and the faster they go (3.4 s to 1 s per trip, on a log scale from 64 B/s to about+ 4 MB/s); any traffic at all moves (one slow dot each way below 64 B/s, 0.8.5). An idle arc has no+ dots and is drawn thinner, still plainly visible (`idle` in the map request, `map.c`). The map+ follows the list: every app's places, the selected app's, or, with a search or a filter (direction,+ protocol, status, chips), only the places of the connections the list shows. Each app has its own+ arc per place, in its own color (the dot before it in the list; the order apps first reached the+ internet, twelve colors), lifted apart when several apps reach the same country (`arcs` in the map+ request: color and lift per arc). A host's own rate misses short connections, so what the app's rate+ doesn't account for is spread over its internet hosts by their bytes. Sockets the kernel reports+ without a cgroup (ping and raw sockets from /proc/net, packet sockets) take their process's+ (`/proc/<pid>/cgroup`, `conn.c`). Thedots are small ready-made images (a ring and the direction's color, drawn once) moved with`lord.setStyle`, no React render per frame: 12 frames per second with the window in front, 5behind it, at most the 12 busiest arcs and only those on screen; the timer stops with the windowdiff --git a/server/src/monitor/conn.c b/server/src/monitor/conn.cindex cf9a3bd..006b6e8 100644--- a/server/src/monitor/conn.c+++ b/server/src/monitor/conn.c@@ -355,7 +355,7 @@ static const char *scope_app_of(uint64_t cg) {return "";}-static struct { int pid; char name[64], exe[PATH_MAX]; } pinfo[256];+static struct { int pid; char name[64], exe[PATH_MAX]; uint64_t cg; } pinfo[256]; /* cg: the process's cgroup id */static int npinfo;static int proc_info(int pid) {@@ -370,6 +370,16 @@ static int proc_info(int pid) {snprintf(p, sizeof p, "/proc/%d/exe", pid);ssize_t k = readlink(p, pinfo[i].exe, sizeof pinfo[i].exe - 1);pinfo[i].exe[k > 0 ? k : 0] = 0;+ /* for sockets the kernel gives no cgroup for (ping and raw sockets from /proc/net, packet sockets):+ * the owning process's own cgroup, "0::/<path>" (cgroup v2) */+ char line[PATH_MAX], path[PATH_MAX + 32];+ pinfo[i].cg = 0;+ snprintf(p, sizeof p, "/proc/%d/cgroup", pid);+ if (mon_read_small(p, line, sizeof line) > 3 && !strncmp(line, "0::/", 4)) {+ line[strcspn(line, "\n")] = 0;+ if (!strstr(line, "/..") && (size_t)snprintf(path, sizeof path, "/sys/fs/cgroup%s", line + 3) < sizeof path)+ pinfo[i].cg = cg_id(AT_FDCWD, path);+ }return i;}@@ -415,7 +425,9 @@ void conn_scan(Buf *b, const Mmdb *geo) {mon_buf_str(b, pq >= 0 ? pinfo[pq].name : "");mon_buf_printf(b, ",\"exe\":");mon_buf_str(b, pq >= 0 ? pinfo[pq].exe : "");- mon_buf_printf(b, ",\"cgApp\":\"\",\"sent\":null,\"recv\":null}");+ mon_buf_printf(b, ",\"cgApp\":");+ mon_buf_str(b, scope_app_of(pq >= 0 ? pinfo[pq].cg : 0));+ mon_buf_printf(b, ",\"sent\":null,\"recv\":null}");n++;continue;}@@ -453,7 +465,7 @@ void conn_scan(Buf *b, const Mmdb *geo) {mon_buf_printf(b, ",\"exe\":");mon_buf_str(b, pi >= 0 ? pinfo[pi].exe : "");mon_buf_printf(b, ",\"cgApp\":");- mon_buf_str(b, scope_app_of(s->cg));+ mon_buf_str(b, scope_app_of(s->cg ? s->cg : pi >= 0 ? pinfo[pi].cg : 0));if (s->bytes) mon_buf_printf(b, ",\"sent\":%llu,\"recv\":%llu}", (unsigned long long)s->sent, (unsigned long long)s->recv);else mon_buf_printf(b, ",\"sent\":null,\"recv\":null}");n++;diff --git a/server/src/monitor/map.c b/server/src/monitor/map.cindex be50440..fff7560 100644--- a/server/src/monitor/map.c+++ b/server/src/monitor/map.c@@ -306,32 +306,55 @@ static void disc(const MapReq *q, uint8_t *out, float cx, float cy, float rad, u}/* Arc: quadratic curve that rises towards the pole, stronger towards the destination. */-static void arc(const MapReq *q, uint8_t *out, float x0, float y0, float x1, float y1, uint32_t c, float width, float alpha) {+/* A quadratic arc from (x0,y0) to (x1,y1), lifted by 30 % of its length, fading in toward the place.+ * Each arc first collects its own coverage (the strongest stamp per pixel, so the overlapping stamps+ * don't darken it) in a mask over its bounding box, then blends once over whatever is below: land,+ * borders and other arcs. (Before 0.8.5 it was blended only where the map was still fainter than the+ * arc, which hid most of an arc over land.) */+static void arc(const MapReq *q, uint8_t *out, float x0, float y0, float x1, float y1, float liftk, uint32_t c, float width, float alpha) {+ static uint8_t *mask;+ static size_t mcap;float len = hypotf(x1 - x0, y1 - y0);if (len < 2) return;- float lift = len * 0.3f, cx = (x0 + x1) / 2, cy = (y0 + y1) / 2 - lift;+ float lift = len * liftk, cx = (x0 + x1) / 2, cy = (y0 + y1) / 2 - lift;+ /* the control point bounds the curve */+ int bx0 = (int)floorf(fminf(fminf(x0, x1), cx) - width - 1), bx1 = (int)ceilf(fmaxf(fmaxf(x0, x1), cx) + width + 1);+ int by0 = (int)floorf(fminf(fminf(y0, y1), cy) - width - 1), by1 = (int)ceilf(fmaxf(fmaxf(y0, y1), cy) + width + 1);+ if (bx0 < 0) bx0 = 0;+ if (by0 < 0) by0 = 0;+ if (bx1 > q->w) bx1 = q->w;+ if (by1 > q->h) by1 = q->h;+ if (bx0 >= bx1 || by0 >= by1) return;+ int bw = bx1 - bx0, bh = by1 - by0;+ size_t need = (size_t)bw * bh;+ if (need > mcap) {+ uint8_t *m = realloc(mask, need);+ if (!m) return;+ mask = m;+ mcap = need;+ }+ memset(mask, 0, need);int steps = (int)(len / 0.8f) + 1;if (steps > 20000) steps = 20000;- float px = x0, py = y0;for (int i = 1; i <= steps; i++) {float t = (float)i / steps, u = 1 - t;float x = u * u * x0 + 2 * u * t * cx + t * t * x1, y = u * u * y0 + 2 * u * t * cy + t * t * y1;- if (!((x < -width && px < -width) || (y < -width && py < -width) || (x > q->w + width && px > q->w + width) || (y > q->h + width && py > q->h + width))) {- float a = alpha * (0.35f + 0.65f * t);- /* circular stamp of radius width/2, only where the pixel is still fainter */- for (int yy = (int)floorf(y - width); yy <= (int)ceilf(y + width); yy++)- for (int xx = (int)floorf(x - width); xx <= (int)ceilf(x + width); xx++) {- if (xx < 0 || yy < 0 || xx >= q->w || yy >= q->h) continue;- float d = hypotf(xx + 0.5f - x, yy + 0.5f - y), k = width / 2 + 0.5f - d;- if (k <= 0) continue;- uint8_t *p = out + ((size_t)yy * q->w + xx) * 4;- float want = (k > 1 ? 1 : k) * a * ((c & 0xff) / 255.0f);- if (p[3] / 255.0f < want) blend(p, c, (k > 1 ? 1 : k) * a * 0.6f);- }- }- px = x;- py = y;+ float a = alpha * (0.45f + 0.55f * t);+ for (int yy = (int)floorf(y - width); yy <= (int)ceilf(y + width); yy++)+ for (int xx = (int)floorf(x - width); xx <= (int)ceilf(x + width); xx++) {+ if (xx < bx0 || yy < by0 || xx >= bx1 || yy >= by1) continue;+ float d = hypotf(xx + 0.5f - x, yy + 0.5f - y), k = width / 2 + 0.5f - d;+ if (k <= 0) continue;+ int v = (int)((k > 1 ? 1 : k) * a * 255 + 0.5f);+ uint8_t *m = mask + (size_t)(yy - by0) * bw + (xx - bx0);+ if (v > *m) *m = (uint8_t)(v > 255 ? 255 : v);+ }}+ for (int yy = 0; yy < bh; yy++)+ for (int xx = 0; xx < bw; xx++) {+ uint8_t m = mask[(size_t)yy * bw + xx];+ if (m) blend(out + ((size_t)(yy + by0) * q->w + (xx + bx0)) * 4, c, m / 255.0f);+ }}/* Meridians and parallels every 30° (every 10° when zoomed), very faint: the sea is map too. */@@ -356,12 +379,19 @@ static void render(const MapReq *q, uint8_t *out) {borders(q, out);}float hx = (float)((q->hlon - q->lon0) * q->ppd), hy = (float)((q->lat0 - q->hlat) * q->ppd);- for (int pass = 0; pass < 2 && q->has_home; pass++) /* selected ones last, on top */+ for (int pass = 0; pass < 2 && q->has_home && q->narcs; pass++) /* each app's arcs */+ for (int i = 0; i < q->narcs; i++) {+ const MapArc *a = &q->arcs[i];+ if (!!a->sel != pass) continue;+ float x = (float)((a->lon - q->lon0) * q->ppd), y = (float)((q->lat0 - a->lat) * q->ppd);+ arc(q, out, hx, hy, x, y, a->lift, a->color, a->sel ? 2.4f : a->idle ? 1.4f : 2.0f, a->sel ? 1.0f : a->idle ? 0.55f : 0.9f);+ }+ for (int pass = 0; pass < 2 && q->has_home && !q->narcs; pass++) /* selected ones last, on top */for (int i = 0; i < q->ndots; i++) {const MapDot *d = &q->dots[i];if (!!d->sel != pass) continue;float x = (float)((d->lon - q->lon0) * q->ppd), y = (float)((q->lat0 - d->lat) * q->ppd);- arc(q, out, hx, hy, x, y, d->sel ? q->sel_color : q->accent, d->sel ? 2.6f : d->idle ? 1.3f : 1.6f, d->sel ? 1.0f : d->idle ? 0.4f : 0.85f);+ arc(q, out, hx, hy, x, y, 0.3f, d->sel ? q->sel_color : q->accent, d->sel ? 2.6f : d->idle ? 1.4f : 1.8f, d->sel ? 1.0f : d->idle ? 0.5f : 0.8f);}for (int pass = 0; pass < 2; pass++)for (int i = 0; i < q->ndots; i++) {diff --git a/server/src/monitor/map.h b/server/src/monitor/map.hindex 7a41402..b9cc608 100644--- a/server/src/monitor/map.h+++ b/server/src/monitor/map.h@@ -12,8 +12,12 @@#define MAP_MAX_W 2048#define MAP_MAX_H 2048#define MAP_MAX_DOTS 256+#define MAP_MAX_ARCS 512typedef struct { float lon, lat, r; int sel, idle; } MapDot; /* idle: no traffic now (dimmed arc) */+/* (0.8.5) one app's arc to a place: its own color and lift (a fraction of the length), so the apps that+ * reach the same country get arcs apart */+typedef struct { float lon, lat, lift; uint32_t color; int sel, idle; } MapArc;typedef struct {int w, h;@@ -23,6 +27,8 @@ typedef struct {double hlon, hlat;int ndots;MapDot dots[MAP_MAX_DOTS];+ int narcs; /* 0: one arc per dot, in the accent color */+ MapArc arcs[MAP_MAX_ARCS];} MapReq;void map_init(const char *assets_dir);diff --git a/server/src/ui/js_monitor.c b/server/src/ui/js_monitor.cindex acd4267..9263202 100644--- a/server/src/ui/js_monitor.c+++ b/server/src/ui/js_monitor.c@@ -269,7 +269,8 @@ static int color_prop(JSContext *c, JSValueConst o, const char *k, uint32_t *out}/* map({ width, height, lon, lat, ppd, land, border, accent, homeColor, selColor,- * home: { lon, lat } | null, dots: [{ lon, lat, r, sel, idle }] }) → request number */+ * home: { lon, lat } | null, dots: [{ lon, lat, r, sel, idle }],+ * arcs?: [{ lon, lat, lift, color, sel, idle }] }) → request number */static JSValue f_map(JSContext *c, JSValueConst t, int argc, JSValueConst *argv) {(void)t;if (argc < 1 || !JS_IsObject(argv[0])) return js_throw_code(c, "sys.badArgument", NULL);@@ -312,6 +313,34 @@ static JSValue f_map(JSContext *c, JSValueConst t, int argc, JSValueConst *argv)JS_FreeValue(c, d);}JS_FreeValue(c, dots);+ /* arcs: [{ lon, lat, lift, color, sel, idle }] (optional, 0.8.5) */+ JSValue arcs = JS_GetPropertyStr(c, o, "arcs");+ n = 0;+ if (JS_IsArray(c, arcs)) {+ JSValue lv = JS_GetPropertyStr(c, arcs, "length");+ JS_ToUint32(c, &n, lv);+ JS_FreeValue(c, lv);+ }+ for (uint32_t i = 0; i < n && q.narcs < MAP_MAX_ARCS; i++) {+ JSValue d = JS_GetPropertyUint32(c, arcs, i);+ double lon, lat, lift;+ uint32_t col;+ if (JS_IsObject(d) && !num_prop(c, d, "lon", -180, 180, &lon) && !num_prop(c, d, "lat", -90, 90, &lat) &&+ !num_prop(c, d, "lift", 0, 1, &lift) && !color_prop(c, d, "color", &col)) {+ MapArc *m = &q.arcs[q.narcs++];+ m->lon = (float)lon;+ m->lat = (float)lat;+ m->lift = (float)lift;+ m->color = col;+ JSValue sv = JS_GetPropertyStr(c, d, "sel"), iv = JS_GetPropertyStr(c, d, "idle");+ m->sel = JS_ToBool(c, sv) > 0;+ m->idle = JS_IsBool(iv) && JS_ToBool(c, iv) > 0;+ JS_FreeValue(c, sv);+ JS_FreeValue(c, iv);+ }+ JS_FreeValue(c, d);+ }+ JS_FreeValue(c, arcs);return JS_NewFloat64(c, (double)map_request(&q));}