feat!: Urutau 2.0.0, ultralight probes and a single analysis hub
CI / Format and vet (pull_request) Failing after 53s
CI / Dependency audit (pull_request) Successful in 33s
CI / Tests (Linux, race detector) (pull_request) Successful in 2m1s
CI / Docker images (build and smoke test) (pull_request) Failing after 47s

Each server runs an ultralight probe (scratch image, ~7 MiB RSS) that
tails the logs, ships raw lines to the hub over HTTPS with an on-disk
spool, and applies enforce decisions locally. The hub keeps one node per
probe (primary node = the 1.x data dir, unchanged), does all analysis and
serves the UI. Peer federation is removed. 'urutau import' brings 1.x
data dirs in with hash and count verification. UI: probes page, host
qualified incidents, IPs never wrap, egress heatmap labels, live and
replay globes no longer auto-rotate, replay repeat, live traffic metrics.

BREAKING CHANGE: URUTAU_PEERS, URUTAU_PEER_* and /api/v1/peer/* are gone;
log path variables move from the hub to the probe. See docs/migration-2.0.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas RayanandClaude Opus 5.5 committed 2026-11-15 22:14:50 -03:00
1 parent 23a7a5963a
commit 8546d14cef
130 files changed
+9396 -3311

No files matched your search

+77 -12
View File
@@ -997,13 +997,13 @@
return fetch(path, o).then(function (r) {
if (r.status === 401) { location.href = '/login'; throw mkErr('unauthorized', 401); }
if (!r.ok) throw mkErr('HTTP ' + r.status, r.status);
return r.json();
return r.text().then(function (txt) { try { return txt ? JSON.parse(txt) : {}; } catch (e) { return {}; } });
});
}
// Unban dialog: native <dialog> (focus trap, Esc), a radio group for how long the address stays protected, confirm.
var UNBAN_CHOICES = [['0', 'unban.keep.none'], ['3600', 'unban.keep.1h'], ['86400', 'unban.keep.24h'], ['604800', 'unban.keep.7d']];
function unbanDialog(ip, onDone) {
function unbanDialog(ip, onDone, opts) {
var prev = document.activeElement;
var dlg = el('dialog', { class: 'unban-dlg', 'aria-labelledby': 'unban-h', 'aria-describedby': 'unban-p' });
var err = el('p', { class: 'unban-err', role: 'alert', hidden: true });
@@ -1018,6 +1018,19 @@
var cancel = el('button', { type: 'button', class: 'btn' }, t('unban.cancel'));
dlg.appendChild(el('h2', { id: 'unban-h' }, t('unban.title', { ip: ip })));
dlg.appendChild(el('p', { id: 'unban-p' }, t('unban.explain')));
// each probe enforces its own bans: the operator picks where to lift it (or every host)
var hostSel = el('select', { id: 'unban-host' });
var hostRow = el('div', { class: 'unban-host', hidden: true }, el('label', { for: 'unban-host' }, t('pr.unban.host')), hostSel);
var wantHost = (opts && opts.host) || (state.host !== 'all' ? state.host : 'all');
getSummary(ctx()).then(function (s) {
var hs = (s.hosts || []).map(function (x) { return x.name; });
if (hs.length < 2) return;
hostSel.appendChild(el('option', { value: 'all' }, t('host.all')));
hs.forEach(function (n) { hostSel.appendChild(el('option', { value: n }, n)); });
hostSel.value = hs.indexOf(wantHost) >= 0 ? wantHost : 'all';
hostRow.hidden = false;
}).catch(function () { /* single host */ });
dlg.appendChild(hostRow);
dlg.appendChild(fs);
dlg.appendChild(err);
dlg.appendChild(el('div', { class: 'unban-btns' }, cancel, ok));
@@ -1030,7 +1043,7 @@
ok.addEventListener('click', function () {
var sel = dlg.querySelector('input[name="unban-keep"]:checked');
ok.disabled = true;
apiSend('POST', '/api/v1/enforce/unban', { ip: ip, allow_s: parseInt(sel ? sel.value : '0', 10) || 0 }).then(function () {
apiSend('POST', '/api/v1/enforce/unban', { ip: ip, allow_s: parseInt(sel ? sel.value : '0', 10) || 0, host: hostRow.hidden ? (wantHost !== 'all' ? wantHost : undefined) : hostSel.value }).then(function () {
close();
toast(t('unban.done', { ip: ip }));
if (onDone) onDone();
@@ -1204,19 +1217,33 @@
var mx = 0; (matrix || []).forEach(function (r) { r.forEach(function (v) { if (v > mx) mx = v; }); });
if (!mx) return empty(t('charts.empty'));
var fmt = o.format || nf, wrap = h('div', 'vz vz-heat');
var meas = document.createElement('canvas').getContext('2d');
function textW(x) { meas.font = '11px ' + (cssVar('--font-sans') || 'sans-serif'); return meas.measureText(String(x)).width; }
function fit(x, max) { // ellipsis only beyond max
x = String(x); if (textW(x) <= max) return x;
var lo = 0, hi = x.length; while (lo < hi) { var m = (lo + hi + 1) >> 1; if (textW(x.slice(0, m) + '\u2026') <= max) lo = m; else hi = m - 1; }
return x.slice(0, lo) + '\u2026';
}
function draw(Wpx) {
clear(wrap);
var ny = matrix.length, nx = matrix[0].length, LW = 56, W = Math.max(240, Wpx), cw = (W - LW) / nx, ch = Math.min(26, Math.max(12, cw)), H = ny * ch + 22;
var ny = matrix.length, nx = matrix[0].length, W = Math.max(240, Wpx), stacked = W < 480;
var widest = 0; yl.forEach(function (x) { widest = Math.max(widest, textW(x)); });
// wide: label column sized to the longest name (40% cap); narrow: the label sits above its own strip
var LW = stacked ? 0 : Math.max(56, Math.min(Math.ceil(widest) + 14, Math.floor(W * .4)));
var cw = (W - LW) / nx, ch = Math.min(26, Math.max(12, cw)), lab = stacked ? 15 : 0, rowH = ch + lab, H = ny * rowH + 22;
var svg = svgEl('svg', { viewBox: '0 0 ' + W + ' ' + H, role: 'img', 'aria-label': o.title || '' }), step = Math.ceil(26 / cw);
matrix.forEach(function (row, y) {
var yt = svgEl('text', { x: LW - 6, y: y * ch + ch / 2 + 4, 'text-anchor': 'end', 'class': 'axis' }); yt.textContent = yl[y]; svg.appendChild(yt);
var y0 = y * rowH;
var yt = stacked ? svgEl('text', { x: 2, y: y0 + 11, 'text-anchor': 'start', 'class': 'axis' }) : svgEl('text', { x: LW - 6, y: y0 + ch / 2 + 4, 'text-anchor': 'end', 'class': 'axis' });
yt.textContent = fit(yl[y], stacked ? W - 4 : LW - 10);
var yti = svgEl('title', {}); yti.textContent = String(yl[y]); yt.appendChild(yti); svg.appendChild(yt);
row.forEach(function (v, x) {
var lvl = v ? Math.min(5, 1 + Math.floor(v / mx * 4.999)) : 0;
var r = svgEl('rect', { x: LW + x * cw + 1, y: y * ch + 1, width: Math.max(1, cw - 2), height: ch - 2, rx: 2, 'class': 'vz-cell s' + lvl, tabindex: 0, 'aria-label': yl[y] + ' ' + xl[x] + ': ' + fmt(v) });
var ti = svgEl('title', {}); ti.textContent = yl[y] + ' ' + xl[x] + ': ' + fmt(v); r.appendChild(ti); svg.appendChild(r);
var r = svgEl('rect', { x: LW + x * cw + 1, y: y0 + lab + 1, width: Math.max(1, cw - 2), height: ch - 2, rx: 2, 'class': 'vz-cell s' + lvl, tabindex: 0, 'aria-label': yl[y] + ' ' + xl[x] + ': ' + fmt(v) });
var ti = svgEl('title', {}); ti.textContent = yl[y] + ' \u00b7 ' + xl[x] + ' \u00b7 ' + fmt(v); r.appendChild(ti); svg.appendChild(r);
});
});
for (var x = 0; x < nx; x += step) { var xt = svgEl('text', { x: LW + x * cw + cw / 2, y: ny * ch + 15, 'text-anchor': 'middle', 'class': 'axis' }); xt.textContent = xl[x]; svg.appendChild(xt); }
for (var x = 0; x < nx; x += step) { var first = x === 0 && stacked, xt = svgEl('text', { x: first ? 2 : LW + x * cw + cw / 2, y: ny * rowH + 15, 'text-anchor': first ? 'start' : 'middle', 'class': 'axis' }); xt.textContent = xl[x]; svg.appendChild(xt); }
wrap.appendChild(svg);
}
var box = h('div', null, wrap, srTable(o.title, [''].concat(xl), matrix.map(function (r, y) { return [yl[y]].concat(r.map(fmt)); })));
@@ -1704,8 +1731,9 @@
build: function (root) {
var v = {}, g = grid12();
v.lead = sp(12, h('div'));
v.probes = window.Urutau && window.Urutau.probesPanel ? window.Urutau.probesPanel() : null;
v.hostsBox = h('div', 'hosts');
v.hosts = panel({ title: t('hosts.title'), hint: t('hosts.hint'), help: 'term.peer' }, v.hostsBox);
v.hosts = panel({ title: t('hosts.title'), hint: t('hosts.hint'), help: 'term.probe' }, v.hostsBox);
var thead = h('thead', null, h('tr', null, ['col.host', 'col.source', 'col.state', 'col.lines', 'col.malformed', 'col.lastEvent'].map(function (k) { return el('th', { scope: 'col' }, t(k)); })));
v.tbody = h('tbody');
v.srcEmpty = h('div');
@@ -1713,11 +1741,11 @@
v.geoBox = h('div');
v.geo = panel({ title: t('src.geo.title'), hint: t('src.geo.hint') }, v.geoBox);
v.bl = blocklistPanel();
g.appendChild(v.lead); g.appendChild(sp(12, v.hosts)); g.appendChild(sp(12, v.sources)); g.appendChild(sp(6, v.geo)); g.appendChild(sp(6, v.bl.node)); root.appendChild(g);
g.appendChild(v.lead); if (v.probes) g.appendChild(sp(12, v.probes.node)); g.appendChild(sp(12, v.hosts)); g.appendChild(sp(12, v.sources)); g.appendChild(sp(6, v.geo)); g.appendChild(sp(6, v.bl.node)); root.appendChild(g);
v.bl.sync();
return v;
},
load: function (c, v) { v.bl.sync(); return getSummary(c); },
load: function (c, v) { v.bl.sync(); if (v.probes) v.probes.reload(); return getSummary(c); },
render: function (v, s) {
var srcs = s.sources || [], hosts = s.hosts || [];
var following = srcs.filter(function (r) { return r.state === 'following'; }).length;
@@ -1751,11 +1779,47 @@
dl.appendChild(h('dt', null, t('src.geo.attrib'))); dl.appendChild(h('dd', null, s.attribution || t('src.geo.none')));
v.geoBox.appendChild(dl);
},
dispose: function (v) { v.bl.dispose(); }
dispose: function (v) { v.bl.dispose(); if (v.probes) v.probes.dispose(); }
});
[pOverview, pThreats, pTraffic, pIPs, pSources].forEach(function (p) { pages[p.id] = p; });
// ---------------------------------------------------------------- IPs never wrap
// Any element whose whole text is an IP (v4/v6, optional :port or /prefix) gets .ipv (see style.css): one line, mono, tabular.
// Done centrally so every table, card, feed and drawer behaves the same, whichever script drew it.
var IP4_RE = /^\d{1,3}(?:\.\d{1,3}){3}(?::\d{1,5})?(?:\/\d{1,2})?$/;
var IP6_RE = /^\[?[0-9A-Fa-f:]*:[0-9A-Fa-f:.]*\]?(?::\d{1,5})?(?:\/\d{1,3})?$/;
function looksIP(x) { return x.length >= 7 && x.length <= 64 && (IP4_RE.test(x) || ((x.indexOf('::') >= 0 || x.split(':').length > 3) && IP6_RE.test(x))); }
var IP_SKIP = { SCRIPT: 1, STYLE: 1, TEXTAREA: 1, OPTION: 1, TITLE: 1, INPUT: 1 };
function tagIPs(root) {
if (!root) return;
var w = document.createTreeWalker(root, NodeFilter.SHOW_TEXT), n, hits = [];
while ((n = w.nextNode())) {
var p = n.parentNode, v = n.nodeValue;
if (!p || p.nodeType !== 1 || IP_SKIP[p.tagName] || !v || v.length > 70 || (p.classList && p.classList.contains('ipv'))) continue;
var x = v.trim();
if (looksIP(x)) hits.push([n, p, x]);
}
hits.forEach(function (hh) {
var n = hh[0], p = hh[1], x = hh[2], target = p;
if (p.childNodes.length > 1 || p.tagName === 'TD' || p.tagName === 'TH') { // mixed content: wrap only the address
target = document.createElement('span'); p.replaceChild(target, n); target.appendChild(n);
}
target.classList.add('ipv');
if (x.length > 24) target.classList.add('ipv-long');
if (!target.hasAttribute('title')) target.setAttribute('title', x);
});
}
var ipQueued = false;
function watchIPs() {
new MutationObserver(function () {
if (ipQueued) return;
ipQueued = true;
requestAnimationFrame(function () { ipQueued = false; tagIPs(document.body); });
}).observe(document.body, { childList: true, subtree: true, characterData: true });
tagIPs(document.body);
}
// ---------------------------------------------------------------- url (the source of truth)
function parseHash() {
var raw = location.hash.replace(/^#\/?/, ''), q = '', i = raw.indexOf('?');
@@ -2147,6 +2211,7 @@
});
window.addEventListener('hashchange', route);
window.matchMedia && matchMedia('(prefers-color-scheme: light)').addEventListener && matchMedia('(prefers-color-scheme: light)').addEventListener('change', notifyPage);
watchIPs();
connectLive();
// the host must be validated before a page asks for data with a stale one
shellSummary().catch(function (e) {