feat: 1.3.0 thirteen new pages, charts, tooltips and error analysis
Release / Plan (reuse the published image?) (push) Successful in 3s
CI / Docker image (build and smoke test) (push) Skipped
CI / Format and vet (push) Successful in 28s
CI / Dependency audit (push) Successful in 20s
CI / Tests (Linux, race detector) (push) Successful in 1m10s
Release / ci (push) Successful in 1m10s
Release / Build image (arm64) (push) Successful in 55s
Release / Build image (amd64) (push) Successful in 1m16s
Release / Publish tags (push) Successful in 14s
Release / Gitea release (push) Skipped

New pages grouped in the rail (Monitor, Investigate, Analyze, Operate,
Reports): Services (SLO, Apdex, latency app vs proxy), Sessions (stage
funnel), Campaigns, Event search, MITRE ATT&CK matrix, Evolution,
Concentration (Pareto, Gini), Survival (Kaplan-Meier per attack
episode, recidivists), Where errors come from (application vs failed
attack vs proxy vs client), Protocols and TLS, Defense (fail2ban, SSH,
blocklist), Integrity, and a printable executive report.

Chart library (donut, radar, stacked area, bars, heatmap, gauge),
glossary with accessible "?" tooltips, self-explanatory category names
(nonexistent page 404), page loader through pages.json.

Unique visitors fixed: real browsers opening a page, one per IP per day,
deduplicated across domains, with non-human clients counted apart.
Anonymous legitimate visits on the Live page (?visits=1, no IP).
Traefik origin, service, protocol and TLS fields parsed. Paths and
Referer paths drop e-mail and token segments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas RayanandClaude Opus 5.5 committed 2026-11-14 22:39:33 -03:00
1 parent b7462c14fa
commit 2ebda1e4d7
79 files changed
+9091 -171

No files matched your search

+186 -34
View File
@@ -15,7 +15,7 @@
var CAT_OK = {};
CATS.forEach(function (c) { CAT_OK[c] = 1; });
var MAX_ARCS = 300, MAX_PENDING = 400, RING_MAX = 800, RING_TRIM = 300;
var MAX_VARCS = 150, MAX_VPENDING = 150, MAX_ARCS = 300, MAX_PENDING = 400, RING_MAX = 800, RING_TRIM = 300;
var WORLD_W = 2000, WORLD_H = 789, LAT_TOP = 84, LAT_BOT = -58;
var DEFAULT_DST = { lat: -23.55, lon: -46.63 };
var RAD = Math.PI / 180, TAU = Math.PI * 2;
@@ -138,7 +138,7 @@
this.paused = false; this.hidden = document.hidden;
this.reduced = !!(window.matchMedia && matchMedia('(prefers-reduced-motion: reduce)').matches);
this.T = 0; this.last = 0; this.raf = 0; this.dirty = true;
this.arcs = []; this.free = []; this.pending = []; this.frameKey = {};
this.arcs = []; this.varcs = []; this.vpending = []; this.free = []; this.pending = []; this.frameKey = {};
this.dests = {}; this.destList = []; this.dots = []; this.more = [];
this.frameAvg = 16; this.quality = 1;
this.W = 0; this.H = 0; this.dpr = 1; this.reserve = 0;
@@ -189,7 +189,7 @@
this.listeners.forEach(function (l) { try { l[0].removeEventListener(l[1], l[2], l[3]); } catch (x) { /* ignore */ } });
this.listeners = [];
if (this.ro) { this.ro.disconnect(); this.ro = null; }
this.arcs = []; this.free = []; this.pending = []; this.dots = []; this.flatCache = null; this.pickCbs = [];
this.arcs = []; this.varcs = []; this.vpending = []; this.free = []; this.pending = []; this.dots = []; this.flatCache = null; this.pickCbs = [];
if (this.cv.parentNode) this.cv.parentNode.removeChild(this.cv);
};
@@ -202,6 +202,8 @@
var rgb = parseColor(css(TOKEN[c]), FALLBACK[c]);
cols[c] = { rgb: rgb, c0: rgba(rgb, 0), c1: rgba(rgb, 1), css: rgba(rgb, 1) };
});
var vrgb = parseColor(tok('--ink-muted', '--muted'), '#9db3bd');
cols.visit = { rgb: vrgb, c0: rgba(vrgb, 0), c1: rgba(vrgb, 1), css: rgba(vrgb, 1) };
this.colors = cols;
this.dark = (bg[0] * 299 + bg[1] * 587 + bg[2] * 114) / 1000 < 128;
this.pal = { text: text, bg: bg, accent: parseColor(css('--accent'), '#38bdf8') };
@@ -211,8 +213,8 @@
M.setTheme = function () { this.readTheme(); this.kick(); };
M.setMode = function (m) { this.mode = m === 'globe' ? 'globe' : 'flat'; this.target = this.mode === 'globe' ? 1 : 0; this.cv.classList.toggle('lv-globe', this.mode === 'globe'); this.dirty = true; this.kick(); };
M.pause = function (p) { this.paused = !!p; if (p) this.pending.length = 0; this.last = 0; this.dirty = true; this.kick(); };
M.clear = function () { this.arcs = []; this.pending.length = 0; this.dots = []; this.more = []; this.dirty = true; this.kick(); };
M.pause = function (p) { this.paused = !!p; if (p) { this.pending.length = 0; this.vpending.length = 0; } this.last = 0; this.dirty = true; this.kick(); };
M.clear = function () { this.arcs = []; this.varcs = []; this.vpending.length = 0; this.pending.length = 0; this.dots = []; this.more = []; this.dirty = true; this.kick(); };
M.setDest = function (host, d, est) {
var cur = this.dests[host];
@@ -260,13 +262,21 @@
// ev: an event as sent by the server ({cat, host, src, dst, cc}); returns whether it can be drawn
M.spawnEvent = function (ev, o) {
if (!this.alive || !ev || !CAT_OK[ev.cat]) return false;
var vis = !!(o && o.visit);
if (!this.alive || !ev || (!vis && !CAT_OK[ev.cat])) return false;
var org = this.originOf(ev);
if (!org) return false;
var host = str(ev.host, 64) || 'local';
var d = this.destFor(host, ev.dst && typeof ev.dst === 'object' ? ev.dst : null);
var hl = !!(o && o.highlight) || !!HOSTILE[ev.cat];
var hl = !vis && (!!(o && o.highlight) || !!HOSTILE[ev.cat]);
if (this.paused || this.hidden) return true;
if (vis) {
if (this.reduced) return true;
if (this.vpending.length >= MAX_VPENDING) this.vpending.shift();
this.vpending.push({ o: org, d: d, cat: 'visit', hl: false, v: true });
this.kick();
return true;
}
if (this.reduced) {
this.dots.push({ lat: org.lat, lon: org.lon, v: vec(org.lat, org.lon), cat: ev.cat });
if (this.dots.length > 160) this.dots.shift();
@@ -353,7 +363,7 @@
M.onVisibility = function () {
this.hidden = document.hidden;
if (this.hidden) { if (this.raf) cancelAnimationFrame(this.raf); this.raf = 0; this.pending.length = 0; }
if (this.hidden) { if (this.raf) cancelAnimationFrame(this.raf); this.raf = 0; this.pending.length = 0; this.vpending.length = 0; }
else { this.last = 0; this.dirty = true; this.kick(); }
};
@@ -473,7 +483,7 @@
};
M.drawFlatLayer = function (g, layerAlpha, add) {
var ox = this.ox, oy = this.oy, mw = this.mw, mh = this.mh, T = this.T, arcs = this.arcs, i;
var ox = this.ox, oy = this.oy, mw = this.mw, mh = this.mh, T = this.T, arcs = this.ordered(), i;
g.globalCompositeOperation = 'source-over';
for (i = 0; i < this.dots.length; i++) { // reduced motion: static dots instead of arcs
var dd = this.dots[i];
@@ -485,12 +495,12 @@
for (i = 0; i < arcs.length; i++) {
var a = arcs[i], age = T - a.born;
if (age < 0) continue;
var col = this.colors[a.cat];
var col = a.visit ? this.colors.visit : this.colors[a.cat];
var x0 = ox + a.u0 * mw, y0 = oy + a.v0 * mh, x1 = ox + a.dest.u0 * mw, y1 = oy + a.dest.v0 * mh;
var dx = x1 - x0, dy = y1 - y0, dist = Math.sqrt(dx * dx + dy * dy);
var cx = (x0 + x1) / 2, cy = (y0 + y1) / 2 - Math.min(dist * 0.42, mh * 0.5) - 4;
var head = ease(clamp(age / a.D, 0, 1)), tail = ease(clamp((age - a.hold) / a.D, 0, 1));
var fade = layerAlpha * (1 - 0.75 * tail);
var fade = layerAlpha * (1 - 0.75 * tail) * (a.visit ? 0.8 : 1);
if (tail < 1 && head > tail) {
// exact sub-curve of the quadratic Bezier between parameters tail..head
var ut = 1 - tail, uh = 1 - head;
@@ -503,18 +513,18 @@
g.strokeStyle = gr;
g.beginPath(); g.moveTo(ax, ay); g.quadraticCurveTo(kx, ky, bx, by);
if (a.hostile) { g.globalAlpha = fade * 0.25; g.lineWidth = 5; g.stroke(); }
g.globalAlpha = fade; g.lineWidth = (a.hostile ? 2.2 : 1.3) + (a.n > 1 ? Math.min(2, Math.log(a.n)) : 0);
g.globalAlpha = fade; g.lineWidth = (a.visit ? 0.9 : a.hostile ? 2.2 : 1.3) + (a.n > 1 ? Math.min(2, Math.log(a.n)) : 0);
g.stroke();
if (head < 1) {
g.fillStyle = col.css;
g.beginPath(); g.arc(bx, by, a.hostile ? 2.8 : 2, 0, TAU); g.fill();
}
}
if (age < 0.7) {
if (age < 0.7 && !a.visit) {
g.globalAlpha = layerAlpha * (1 - age / 0.7) * 0.8; g.strokeStyle = col.css; g.lineWidth = 1;
g.beginPath(); g.arc(x0, y0, 2 + age * 9, 0, TAU); g.stroke();
}
this.drawPulse(g, x1, y1, a, age, col, null, 1, layerAlpha);
if (!a.visit) this.drawPulse(g, x1, y1, a, age, col, null, 1, layerAlpha);
}
g.globalCompositeOperation = 'source-over';
for (i = 0; i < this.destList.length; i++) {
@@ -660,7 +670,7 @@
};
M.drawGlobeLayer = function (g, m, add) {
var cx = this.cx, cy = this.cy, R = this.gR, T = this.T, arcs = this.arcs, i, k;
var cx = this.cx, cy = this.cy, R = this.gR, T = this.T, arcs = this.ordered(), i, k;
g.globalCompositeOperation = 'source-over';
for (i = 0; i < this.dots.length; i++) {
var dd = this.dots[i];
@@ -674,9 +684,9 @@
for (i = 0; i < arcs.length; i++) {
var a = arcs[i], age = T - a.born;
if (age < 0) continue;
var col = this.colors[a.cat];
var col = a.visit ? this.colors.visit : this.colors[a.cat];
var head = ease(clamp(age / a.D, 0, 1)), tail = ease(clamp((age - a.hold) / a.D, 0, 1));
var fade = m * (1 - 0.75 * tail);
var fade = m * (1 - 0.75 * tail) * (a.visit ? 0.8 : 1);
var A = a.a, B = a.b, w = a.w, sw = Math.sin(w);
if (tail < 1 && head > tail) {
var lift = 0.05 + 0.22 * w / Math.PI;
@@ -700,16 +710,16 @@
gr.addColorStop(0, col.c0); gr.addColorStop(1, col.c1);
g.strokeStyle = gr;
if (a.hostile) { g.globalAlpha = fade * 0.25; g.lineWidth = 5; g.stroke(); }
g.globalAlpha = fade; g.lineWidth = (a.hostile ? 2.2 : 1.3) + (a.n > 1 ? Math.min(2, Math.log(a.n)) : 0);
g.globalAlpha = fade; g.lineWidth = (a.visit ? 0.9 : a.hostile ? 2.2 : 1.3) + (a.n > 1 ? Math.min(2, Math.log(a.n)) : 0);
g.stroke();
if (head < 1) { g.fillStyle = col.css; g.beginPath(); g.arc(lx, ly, a.hostile ? 2.8 : 2, 0, TAU); g.fill(); }
}
}
if (age >= a.D) {
if (age >= a.D && !a.visit) {
this.rot(B[0], B[1], B[2]);
if (this.rz > 0.02) this.drawPulse(g, cx + this.rx * R, cy - this.ry * R, a, age, col, Math.atan2(-this.ry, this.rx), this.rz, m);
}
if (age < 0.7) {
if (age < 0.7 && !a.visit) {
this.rot(A[0], A[1], A[2]);
if (this.rz > 0.02) {
g.globalAlpha = m * (1 - age / 0.7) * 0.8; g.strokeStyle = col.css; g.lineWidth = 1;
@@ -753,7 +763,7 @@
M.spawn = function (it) {
var a = this.free.pop() || {};
var o = it.o, d = it.d, hostile = !!it.hl;
a.cat = it.cat; a.hostile = hostile; a.n = 1; a.dest = d;
a.cat = it.cat; a.hostile = hostile; a.n = 1; a.dest = d; a.visit = !!it.v;
a.born = this.T;
a.u0 = (o.lon + 180) / 360; a.v0 = (LAT_TOP - clamp(o.lat, LAT_BOT, LAT_TOP)) / (LAT_TOP - LAT_BOT);
a.a = vec(o.lat, o.lon); a.b = d.v;
@@ -761,8 +771,9 @@
a.D = hostile ? 1.35 : 1.0;
a.hold = hostile ? 1.4 : 0.2;
a.pl = hostile ? 1.9 : 1.1;
if (a.visit) { a.D = 0.75; a.hold = 0; a.pl = 0.1; }
a.life = Math.max(a.D + a.pl, a.D + a.hold + a.D);
this.arcs.push(a);
(a.visit ? this.varcs : this.arcs).push(a);
return a;
};
@@ -782,6 +793,19 @@
if (merged) this.addMore(merged);
};
// legitimate visits: their own queue and cap, always drawn under the attacks
M.stepVisits = function () {
var q = this.vpending, n = 0, budget = q.length > 60 ? 30 : 8;
while (q.length && n < budget && this.varcs.length < Math.round(MAX_VARCS * this.quality)) { this.spawn(q.shift()); n++; }
};
M.ordered = function () {
var o = this.order || (this.order = []), i, j = 0;
for (i = 0; i < this.varcs.length; i++) o[j++] = this.varcs[i];
for (i = 0; i < this.arcs.length; i++) o[j++] = this.arcs[i];
o.length = j;
return o;
};
M.addMore = function (n) {
var s = Math.floor(Date.now() / 1000), m = this.more;
if (m.length && m[m.length - 1][0] === s) m[m.length - 1][1] += n; else m.push([s, n]);
@@ -811,7 +835,7 @@
if (this.frameAvg > 26) this.quality = Math.max(0.35, this.quality - 0.02);
else if (this.frameAvg < 20) this.quality = Math.min(1, this.quality + 0.01);
}
this.stepSpawn();
this.stepSpawn(); this.stepVisits();
}
var df = this.target - this.m, morph = false;
if (Math.abs(df) > 0.003) { this.m += df * (this.reduced ? 1 : Math.min(1, dt * 6.5)); morph = true; } else this.m = this.target;
@@ -826,11 +850,14 @@
if (still && !wasDirty && !morph) return; // nothing changed: leave the loop idle
this.dirty = false;
this.draw();
var arcs = this.arcs;
for (var i = arcs.length - 1; i >= 0; i--) {
if (this.T - arcs[i].born > arcs[i].life) {
this.free.push(arcs[i]);
arcs[i] = arcs[arcs.length - 1]; arcs.pop();
var lists = [this.arcs, this.varcs];
for (var li = 0; li < 2; li++) {
var arcs = lists[li];
for (var i = arcs.length - 1; i >= 0; i--) {
if (this.T - arcs[i].born > arcs[i].life) {
this.free.push(arcs[i]);
arcs[i] = arcs[arcs.length - 1]; arcs.pop();
}
}
}
if (!still || morph || this.dirty) this.kick();
@@ -845,6 +872,14 @@
U.registerI18n({
en: {
'live.title': 'Live',
'live.visits': 'Legitimate traffic',
'live.visit': 'visit',
'live.legend.visits': 'visits',
'live.m.vis': 'Visits, 15 min',
'live.m.pages': 'Pages, 15 min',
'live.unit.pages': 'distinct pages',
'live.devices': 'Devices',
'live.vis.empty': 'anonymous',
'live.mode': 'View',
'live.mode.flat': 'Flat map',
'live.mode.globe': 'Globe',
@@ -886,6 +921,14 @@
},
'pt-BR': {
'live.title': 'Ao vivo',
'live.visits': 'Tráfego legítimo',
'live.visit': 'visita',
'live.legend.visits': 'visitas',
'live.m.vis': 'Visitas, 15 min',
'live.m.pages': 'Páginas, 15 min',
'live.unit.pages': 'páginas distintas',
'live.vis.empty': 'anônima',
'live.devices': 'Dispositivos',
'live.mode': 'Visualização',
'live.mode.flat': 'Mapa plano',
'live.mode.globe': 'Globo',
@@ -951,12 +994,15 @@
this.minute = -1; this.listDirty = true; this.hoverList = false;
this.more = []; this.listeners = []; this.timers = []; this.dn = null; this.dnLang = '';
this.lastEv = null;
this.visitsOn = false; this.es = null; this.vring = []; this.vbk = {}; this.pathLast = new Map(); this.devs = {}; this.devChips = {}; this.offDev = {}; this.seen = {}; this.seenN = 0;
try { this.visitsOn = localStorage.getItem('urutau.live.visits') === '1'; } catch (x) { /* storage blocked */ }
this.build();
this.map = mapApi(new AttackMap(U, this.mapBox, { mode: this.pref(), interactive: true }));
this.map.onMore(function (n) { self.addMore(n); });
this.map.onPick(function (d) { self.toggleHost(d.host); });
this.syncMode(this.pref());
this.applyVisits();
this.unsub = U.onEvent ? U.onEvent(function (e) { self.ingest(e); }) : null;
this.listen(document, 'visibilitychange', function () { self.onVisibility(); });
@@ -984,6 +1030,7 @@
P.destroy = function () {
this.alive = false;
if (this.unsub) { try { this.unsub(); } catch (x) { /* ignore */ } this.unsub = null; }
this.closeStream();
this.timers.forEach(clearInterval); this.timers = [];
this.listeners.forEach(function (l) { try { l[0].removeEventListener(l[1], l[2], l[3]); } catch (x) { /* ignore */ } });
this.listeners = [];
@@ -1003,14 +1050,16 @@
// language changed: rebuild the DOM keeping the map, the filters and the paused state
P.rebuild = function () {
var self = this, hosts = Object.keys(this.hostsSeen), paused = this.paused;
this.hostsSeen = {}; this.hostChips = {};
var self = this, hosts = Object.keys(this.hostsSeen), paused = this.paused, devs = Object.keys(this.devs);
this.hostsSeen = {}; this.hostChips = {}; this.devChips = {}; this.devs = {};
var mapEl = this.map._map.cv, was = this.stage.classList.contains('lv-nopanels');
this.build();
this.mapBox.appendChild(mapEl);
this.map._map.container = this.mapBox;
if (this.map._map.ro) { this.map._map.ro.disconnect(); this.map._map.ro.observe(this.mapBox); }
hosts.forEach(function (h) { self.noteHost(h); });
devs.forEach(function (d) { self.noteDevice(d); });
this.applyVisits();
this.stage.classList.toggle('lv-nopanels', was);
this.syncMode(this.map.getMode());
if (paused) this.setPaused(true);
@@ -1083,15 +1132,24 @@
this.bFs.setAttribute('aria-pressed', 'false');
ctl.appendChild(this.bFs);
}
this.bVis = document.createElement('button');
this.bVis.type = 'button'; this.bVis.className = 'lv-btn lv-vis';
this.bVis.appendChild(this.el('span', 'lv-vis-dot'));
this.bVis.appendChild(this.el('span', '', t('live.visits')));
this.bVis.addEventListener('click', function () { self.setVisits(!self.visitsOn); });
ctl.appendChild(this.bVis);
bar.appendChild(ctl);
this.hostBox = el('div', 'lv-hosts'); this.hostBox.setAttribute('role', 'group'); this.hostBox.setAttribute('aria-label', t('live.hosts'));
bar.appendChild(this.hostBox);
this.devBox = el('div', 'lv-hosts lv-devs'); this.devBox.setAttribute('role', 'group'); this.devBox.setAttribute('aria-label', t('live.devices'));
bar.appendChild(this.devBox);
var notes = el('div', 'lv-notes');
this.nPaused = el('span', 'lv-note', t('live.paused')); this.nPaused.hidden = true;
this.nFilter = el('span', 'lv-note', t('live.filtered')); this.nFilter.hidden = true;
this.nMore = el('span', 'lv-note', ''); this.nMore.hidden = true;
this.nEst = el('span', 'lv-note', t('live.est')); this.nEst.hidden = true;
[this.nPaused, this.nFilter, this.nMore, this.nEst].forEach(function (n) { notes.appendChild(n); });
this.nLeg = el('span', 'lv-note lv-leg'); this.nLeg.appendChild(el('span', 'lv-leg-sw')); this.nLeg.appendChild(el('span', '', t('live.legend.visits')));
[this.nPaused, this.nFilter, this.nMore, this.nEst, this.nLeg].forEach(function (n) { notes.appendChild(n); });
bar.appendChild(notes);
stage.appendChild(bar);
@@ -1105,7 +1163,7 @@
var side = el('div', 'lv-side'); this.side = side;
var mets = el('div', 'lv-metrics');
this.mM = {};
['15m', '1h', 'avg', 'ips', 'new', 'last'].forEach(function (k) { self.mM[k] = self.metric(k); mets.appendChild(self.mM[k]); });
['15m', '1h', 'avg', 'ips', 'new', 'last', 'vis', 'pages'].forEach(function (k) { self.mM[k] = self.metric(k); if (k === 'vis' || k === 'pages') self.mM[k].classList.add('lv-m-visit'); mets.appendChild(self.mM[k]); });
this.spark = document.createElement('canvas'); this.spark.className = 'lv-spark'; this.spark.setAttribute('aria-hidden', 'true');
this.spark.width = 150; this.spark.height = 32;
this.mM['15m'].appendChild(this.spark);
@@ -1195,6 +1253,72 @@
this.map.resize();
};
// ---- legitimate traffic (anonymous visits): its own stream, only while the option is on
P.setVisits = function (on) {
this.visitsOn = on;
try { localStorage.setItem('urutau.live.visits', on ? '1' : '0'); } catch (x) { /* storage blocked */ }
this.applyVisits();
this.minute = -1; this.listDirty = true; this.tick(true);
};
P.applyVisits = function () {
var on = this.visitsOn;
this.bVis.setAttribute('aria-pressed', on ? 'true' : 'false');
this.stage.classList.toggle('lv-vis-on', on);
if (on) this.openStream(); else { this.closeStream(); this.vring = []; this.map.clear(); }
this.map._map.resize();
};
P.openStream = function () {
var self = this;
if (this.es || !window.EventSource) return;
var es = new EventSource('/api/v1/events/stream?visits=1');
es.addEventListener('ev', function (m) {
var e;
try { e = JSON.parse(m.data); } catch (x) { return; }
if (!e || typeof e !== 'object') return;
if (e.kind === 'visit') self.visit(e);
else if (e.kind === 'visit_batch') self.visitBatch(e);
else self.ingest(e);
});
this.es = es;
};
P.closeStream = function () { if (this.es) { this.es.close(); this.es = null; } };
P.noteDevice = function (d) {
if (!d || this.devs[d] || Object.keys(this.devs).length >= 8) return;
var self = this;
this.devs[d] = 1;
var b = document.createElement('button');
b.type = 'button'; b.className = 'lv-chip'; b.setAttribute('aria-pressed', this.offDev[d] ? 'false' : 'true');
b.appendChild(this.el('span', 'lv-chip-l', d));
b.addEventListener('click', function () {
self.offDev[d] = !self.offDev[d];
b.setAttribute('aria-pressed', self.offDev[d] ? 'false' : 'true');
self.listDirty = true;
});
this.devBox.appendChild(b); this.devChips[d] = b;
};
P.vcount = function (n, t, dev, path) {
var m = Math.floor(t / 60), b = this.vbk[m] || (this.vbk[m] = { n: 0 });
b.n += n;
if (path && (this.pathLast.size < 5000 || this.pathLast.has(path))) this.pathLast.set(path, m);
};
P.visit = function (e) {
var s = e.src && typeof e.src === 'object' ? e.src : null, tsec = isNum(e.t) ? e.t : Date.now() / 1000;
var dev = str(e.device, 16), path = str(e.path, 90);
var r = { visit: true, t: tsec, host: str(e.host, 64) || 'local', city: str(s && s.city, 48), cc: cc2(s && s.cc) || cc2(e.cc), domain: str(e.domain, 60), path: path, device: dev, ev: e };
this.noteHost(r.host); if (dev) this.noteDevice(dev);
this.vcount(1, tsec, dev, path);
this.vring.push(r);
if (this.vring.length > 200) this.vring.splice(0, 80);
this.listDirty = true;
if (this.paused || this.hidden || this.offHosts[r.host] || (dev && this.offDev[dev])) return;
var h = this.ctx && this.ctx.host;
if (h && h !== 'all' && h !== r.host) return;
this.map.spawn(e, { visit: true });
};
P.visitBatch = function (e) { if (isNum(e.n) && e.n > 0) this.vcount(Math.min(e.n, 1e6), isNum(e.t) ? e.t : Date.now() / 1000, '', ''); };
P.toggleHost = function (h) {
if (!this.hostChips[h]) return;
this.offHosts[h] = !this.offHosts[h];
@@ -1331,6 +1455,11 @@
else if (e.source === 'fail2ban') what = 'fail2ban [' + str(e.jail, 40) + ']';
var key = tsec + '|' + ip + '|' + e.cat + '|' + what;
if (have) { if (have[key]) return null; have[key] = 1; }
else if (this.es) {
if (this.seen[key]) return null;
this.seen[key] = 1;
if (++this.seenN > 3000) { this.seen = {}; this.seenN = 0; }
}
var r = { t: tsec, key: key, cat: e.cat, host: host, ip: ip, what: what, cc: cc2(s && s.cc) || cc2(e.cc), city: str(s && s.city, 48), ev: e };
this.noteHost(host);
this.ring.push(r);
@@ -1467,6 +1596,16 @@
for (var k in this.bk) if (+k < min - 1500) delete this.bk[k];
};
P.visitMetrics = function (min, fmtN) {
var vn = 0, pg = 0, vi, mm = this.mM, self = this;
for (vi = min - 14; vi <= min; vi++) if (this.vbk[vi]) vn += this.vbk[vi].n;
this.pathLast.forEach(function (last) { if (last >= min - 14) pg++; });
mm.vis.val.textContent = fmtN(vn); this.setSub(mm.vis, this.t('live.legend.visits'), '');
mm.pages.val.textContent = fmtN(pg); this.setSub(mm.pages, this.t('live.unit.pages'), '');
this.pathLast.forEach(function (last, p) { if (last < min - 30) self.pathLast.delete(p); });
for (var vk in this.vbk) if (+vk < min - 40) delete this.vbk[vk];
};
P.regionName = function (cc) {
if (this.U.fmt && this.U.fmt.country) { var n = this.U.fmt.country(cc); if (n) return n; }
var lang = this.ctx.lang || undefined;
@@ -1482,6 +1621,7 @@
var fmtN = this.U.fmt && this.U.fmt.num ? this.U.fmt.num : String;
var fl = this.U.fmt && this.U.fmt.flag ? this.U.fmt.flag : function () { return ''; };
if (min !== this.minute) { this.minute = min; this.computeMetrics(min, fmtN); }
if (this.visitsOn) this.visitMetrics(min, fmtN);
// category and server counts, origins: the 15 minute window (partial minute included)
var a = this.agg(min - 14, min, true), vis = this.agg(min - 14, min, false), c;
CATS.forEach(function (k) {
@@ -1541,8 +1681,20 @@
var box = this.recList, ring = this.ring, n = 0, self = this, i, r;
var fl = this.U.fmt && this.U.fmt.flag ? this.U.fmt.flag : function () { return ''; };
while (box.firstChild) box.removeChild(box.firstChild);
for (i = ring.length - 1; i >= 0 && n < 30; i--) {
r = ring[i];
var merged = ring;
if (this.visitsOn && this.vring.length) merged = ring.concat(this.vring).sort(function (a, b) { return a.t - b.t; });
for (i = merged.length - 1; i >= 0 && n < 30; i--) {
r = merged[i];
if (r.visit) {
if (!this.hostOk(r.host) || (r.device && this.offDev[r.device])) continue;
n++;
var vl = this.el('li', 'lv-ev lv-ev-visit');
vl.appendChild(this.el('time', 'lv-ev-t', new Date(r.t * 1000).toLocaleTimeString(this.ctx.lang || undefined, { hour: '2-digit', minute: '2-digit', second: '2-digit' })));
vl.appendChild(this.el('span', 'lv-tag lv-k-visit', this.t('live.visit')));
vl.appendChild(this.el('span', 'lv-vtxt', [r.city || this.t('live.vis.empty'), r.domain, r.path, r.device].filter(Boolean).join(' \u00B7 ')));
box.appendChild(vl);
continue;
}
if (!this.visible(r)) continue;
n++;
var li = this.el('li', 'lv-ev');