fix(fed): sanitize peer rows, cap peer bytes, add --peer-blocklist
CI / Docker image (build and smoke test) (push) Skipped
CI / Format and vet (push) Successful in 24s
CI / Tests (Linux, race detector) (push) Successful in 34s
CI / Dependency audit (push) Successful in 14s
Release / Plan (reuse the published image?) (push) Successful in 3s
Release / ci (push) Skipped
Release / Build image (amd64) (push) Skipped
Release / Build image (arm64) (push) Skipped
Release / Publish tags (push) Successful in 13s
Release / Gitea release (push) Successful in 4s
CI / Docker image (build and smoke test) (push) Skipped
CI / Format and vet (push) Successful in 24s
CI / Tests (Linux, race detector) (push) Successful in 34s
CI / Dependency audit (push) Successful in 14s
Release / Plan (reuse the published image?) (push) Successful in 3s
Release / ci (push) Skipped
Release / Build image (amd64) (push) Skipped
Release / Build image (arm64) (push) Skipped
Release / Publish tags (push) Successful in 13s
Release / Gitea release (push) Successful in 4s
Peer events and summary rows are rebuilt from validated fields (address, country code, category) and the forged/unban flags from peers are ignored. The live relay drops a peer that exceeds about 1 MB/s, also within a single window. --peer-blocklist=off keeps the hub's blocklist to local observations. UI polish: plural forms, blocklist preview and downloads follow the active slice, compact IP cards on phones. Docs for the 1.1.0 interface. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f4b295f582
commit
783b0cba3e
31 files changed
+355
-127
No files matched your search
+14
-12
@@ -54,6 +54,8 @@
|
||||
if (typeof vars !== 'object') vars = { n: vars };
|
||||
return s.replace(/\{(\w+)\}/g, function (m, k) { return Object.prototype.hasOwnProperty.call(vars, k) ? String(vars[k]) : m; });
|
||||
}
|
||||
// plural: picks key.one when count is 1, key.other otherwise
|
||||
function pl(key, count, vars) { vars = vars || {}; if (vars.n === undefined) vars.n = nf(count); return t(key + (count === 1 ? '.one' : '.other'), vars); }
|
||||
function registerI18n(dict) {
|
||||
Object.keys(dict || {}).forEach(function (l) {
|
||||
if (!D[l]) D[l] = {};
|
||||
@@ -485,7 +487,7 @@
|
||||
// ---------------------------------------------------------------- IP table
|
||||
function sumCounts(c) { var s = 0; for (var k in c) s += c[k]; return s; }
|
||||
function ipTable(full) {
|
||||
var st = { sort: 'score', order: 'desc', page: 1, per: full ? 50 : 25, q: '', level: '', banned: false, total: 0, sig: '', ctxKey: '', multi: false, headSig: '' };
|
||||
var st = { sort: 'score', order: 'desc', page: 1, per: window.innerWidth <= 720 ? 25 : (full ? 50 : 25), q: '', level: '', banned: false, total: 0, sig: '', ctxKey: '', multi: false, headSig: '' };
|
||||
var timer = 0, alive = true, onTotal = null;
|
||||
var search = el('input', { type: 'search', autocomplete: 'off', placeholder: t('ips.search'), 'aria-label': t('ips.search') });
|
||||
var levelSel = el('select', { 'aria-label': t('ips.level') });
|
||||
@@ -574,7 +576,7 @@
|
||||
cell('cats', chips, 'nw'); break;
|
||||
}
|
||||
case 'origin': {
|
||||
var org = h('span', 'origin', x.cc ? (flag(x.cc) + ' ' + (x.city ? x.city + ', ' : '') + (x.country || countryName(x.cc))) : '-');
|
||||
var org = h('span', 'origin', x.cc ? (flag(x.cc) + ' ' + (x.city ? x.city + ', ' : '') + countryName(x.cc)) : '-');
|
||||
var tip = [x.asn ? 'AS' + x.asn + (x.as_org ? ' ' + x.as_org : '') : '', x.rdns || ''].filter(Boolean);
|
||||
if (x.cc) tip.unshift(org.textContent);
|
||||
if (tip.length) org.title = tip.join('\n');
|
||||
@@ -592,7 +594,7 @@
|
||||
tbody.appendChild(tr);
|
||||
});
|
||||
var pages = Math.max(1, Math.ceil(st.total / st.per));
|
||||
count.textContent = t('pager.count', nf(st.total));
|
||||
count.textContent = pl('pager.count', st.total, { n: nf(st.total) });
|
||||
page.textContent = full ? t('pager.page', { n: nf(st.page), m: nf(pages) }) : '';
|
||||
prev.disabled = st.page <= 1;
|
||||
next.disabled = st.page >= pages;
|
||||
@@ -847,7 +849,7 @@
|
||||
if (n > bestN) { bestN = n; best = c; }
|
||||
});
|
||||
if (!best) return lead(t('th.lead.none'), t('th.lead.noneBody'), 'neutral');
|
||||
var body = [t('th.lead.body', { n: nf(bestN), m: nf(total), p: pct(bestN, total) })];
|
||||
var body = [pl('th.lead.body', total, { n: nf(bestN), m: nf(total), p: pct(bestN, total) })];
|
||||
if (s.top_domains && s.top_domains.length) body.push(t('th.lead.domain', { name: s.top_domains[0].key }));
|
||||
if (s.countries && s.countries.length) body.push(t('th.lead.origin', { name: countryLabel(s.countries[0].key) }));
|
||||
return lead(t('th.lead.top', { cat: t('cat.' + best) }), body.join(' '), s.totals.hostile_ips > 0 ? 'danger' : 'ok');
|
||||
@@ -971,7 +973,7 @@
|
||||
var v = {};
|
||||
v.lead = h('div');
|
||||
v.tbl = ipTable(true);
|
||||
v.tbl.onTotal(function (n) { setSliceNote(t('slice.ips', nf(n))); });
|
||||
v.tbl.onTotal(function (n) { setSliceNote(pl('slice.ips', n, { n: nf(n) })); });
|
||||
v.ips = panel({ title: t('ips.title'), hint: t('ips.hint') }, v.tbl.node);
|
||||
root.appendChild(v.lead); root.appendChild(v.ips);
|
||||
return v;
|
||||
@@ -986,7 +988,7 @@
|
||||
render: function (v, s) {
|
||||
var T = s.totals;
|
||||
clear(v.lead);
|
||||
v.lead.appendChild(lead(t('ips.lead', { n: nf(T.unique_ips), h: nf(T.hostile_ips), s: nf(T.suspicious_ips) }), t('ips.lead.body', { b: nf(T.active_bans) }), T.hostile_ips > 0 ? 'danger' : T.unique_ips ? 'ok' : 'neutral'));
|
||||
v.lead.appendChild(lead(pl('ips.lead', T.unique_ips, { n: nf(T.unique_ips), h: nf(T.hostile_ips), s: nf(T.suspicious_ips) }), t('ips.lead.body', { b: nf(T.active_bans) }), T.hostile_ips > 0 ? 'danger' : T.unique_ips ? 'ok' : 'neutral'));
|
||||
},
|
||||
dispose: function (v) { v.tbl.dispose(); setSliceNote(''); }
|
||||
});
|
||||
@@ -1005,7 +1007,7 @@
|
||||
h('div', 'toolbar', h('label', 'check', h('span', null, t('blocklist.minScore')), minScore), fam, copy, dlTxt, dlJson), count, msg);
|
||||
var timer = 0, alive = true;
|
||||
function query(extra) {
|
||||
var o = { host: state.host, min_score: minScore.value || '50', family: fam.value };
|
||||
var o = { host: state.host, range: state.range, min_score: minScore.value || '50', family: fam.value };
|
||||
for (var k in extra) o[k] = extra[k];
|
||||
return new URLSearchParams(o).toString();
|
||||
}
|
||||
@@ -1014,10 +1016,10 @@
|
||||
dlJson.setAttribute('href', '/api/v1/blocklist.json?' + query({ download: '1' }));
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(function () {
|
||||
api('/api/v1/blocklist.json', { host: state.host, min_score: minScore.value || '50', family: fam.value }).then(function (j) {
|
||||
api('/api/v1/blocklist.json', { host: state.host, range: state.range, min_score: minScore.value || '50', family: fam.value }).then(function (j) {
|
||||
if (!alive) return;
|
||||
var arr = Array.isArray(j) ? j : (j.items || j.ips || []);
|
||||
count.textContent = t('blocklist.count', nf(typeof j.count === 'number' ? j.count : arr.length));
|
||||
count.textContent = pl('blocklist.count', typeof j.count === 'number' ? j.count : arr.length, { n: nf(typeof j.count === 'number' ? j.count : arr.length) });
|
||||
}).catch(function () { /* optional preview */ });
|
||||
}, 250);
|
||||
}
|
||||
@@ -1029,7 +1031,7 @@
|
||||
return r.text();
|
||||
}).then(function (txt) {
|
||||
var n = txt.split('\n').filter(Boolean).length;
|
||||
return copyText(txt).then(function () { msg.textContent = t('blocklist.copied', nf(n)); });
|
||||
return copyText(txt).then(function () { msg.textContent = pl('blocklist.copied', n, { n: nf(n) }); });
|
||||
}).catch(function () { msg.textContent = t('blocklist.failed'); });
|
||||
});
|
||||
return { node: node, sync: sync, dispose: function () { alive = false; clearTimeout(timer); } };
|
||||
@@ -1073,7 +1075,7 @@
|
||||
var lines = 0, bad = 0;
|
||||
srcs.forEach(function (r) { lines += r.lines || 0; bad += r.malformed || 0; });
|
||||
var online = hosts.filter(function (x) { return x.online; }).length;
|
||||
var title = !srcs.length ? t('src.lead.none') : following === srcs.length ? t('src.lead.all', { n: nf(srcs.length) }) : t('src.lead.some', { a: nf(following), n: nf(srcs.length), x: nf(srcs.length - following) });
|
||||
var title = !srcs.length ? t('src.lead.none') : following === srcs.length ? pl('src.lead.all', srcs.length, { n: nf(srcs.length) }) : t('src.lead.some', { a: nf(following), n: nf(srcs.length), x: nf(srcs.length - following) });
|
||||
clear(v.lead);
|
||||
v.lead.appendChild(lead(title, t('src.lead.body', { h: nf(online), m: nf(hosts.length), l: nf(lines), f: nf(bad) }), !srcs.length ? 'neutral' : following === srcs.length && online === hosts.length ? 'ok' : 'danger'));
|
||||
clear(v.hostsBox);
|
||||
@@ -1278,7 +1280,7 @@
|
||||
}
|
||||
|
||||
window.Urutau = {
|
||||
registerPage: registerPage, registerI18n: registerI18n, t: t, api: api, onEvent: onEvent, openIP: openIP,
|
||||
registerPage: registerPage, registerI18n: registerI18n, t: t, pl: pl, api: api, onEvent: onEvent, openIP: openIP,
|
||||
fmt: { num: nf, pct: pct, ago: ago, bytes: fmtBytes, flag: flag, country: countryName, clock: clock, date: dateTime },
|
||||
world: world, el: el, css: cssVar, setSliceNote: setSliceNote,
|
||||
ui: { panel: panel, stat: stat, lead: lead, empty: empty, badge: badge, bars: bars, chart: chart }
|
||||
|
||||
Reference in new issue
Block a user