fix: host filter accepts all and comma lists; hub no longer drops traefik lines after a copytruncate rotation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
19afd221e2
commit
7b90d9e40f
15 files changed
+329
-85
No files matched your search
+39
-12
@@ -614,7 +614,7 @@
|
||||
var seen = {}, list = [];
|
||||
var rec = state.summary ? state.summary.recent || [] : [];
|
||||
state.live.concat(rec).forEach(function (e) {
|
||||
if (state.host !== 'all' && e.host !== state.host) return;
|
||||
if (!hostHas(state.host, e.host)) return;
|
||||
var key = e.t + '|' + e.ip + '|' + e.cat + '|' + (e.path || e.user || e.jail || '');
|
||||
if (seen[key]) return;
|
||||
seen[key] = 1;
|
||||
@@ -1021,7 +1021,7 @@
|
||||
// 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');
|
||||
var wantHost = (opts && opts.host) || (hostList(state.host).length === 1 ? state.host : 'all');
|
||||
getSummary(ctx()).then(function (s) {
|
||||
var hs = (s.hosts || []).map(function (x) { return x.name; });
|
||||
if (hs.length < 2) return;
|
||||
@@ -1832,7 +1832,7 @@
|
||||
var p = [];
|
||||
if (sl.from !== null && sl.from !== undefined) p.push('from=' + encodeURIComponent(new Date(sl.from * 1000).toISOString()), 'to=' + encodeURIComponent(new Date(sl.to * 1000).toISOString()));
|
||||
else p.push('r=' + sl.range);
|
||||
if (sl.host && sl.host !== 'all') p.push('host=' + encodeURIComponent(sl.host));
|
||||
if (sl.host && sl.host !== 'all') p.push('host=' + encodeURIComponent(sl.host).replace(/%2C/gi, ','));
|
||||
return p;
|
||||
}
|
||||
function buildHash(id, segments, extra, sl) {
|
||||
@@ -1841,6 +1841,14 @@
|
||||
return '#/' + [id].concat((segments || []).map(encodeURIComponent)).join('/') + '?' + parts.join('&');
|
||||
}
|
||||
function hrefFor(id, segments, extra) { return buildHash(id, segments || [], extra || {}); }
|
||||
// host selection: 'all' or a comma list of probe names (host=oracle,hostinger in the URL and in the API)
|
||||
function hostList(v) {
|
||||
var seen = {}, out = [];
|
||||
String(v || '').split(',').forEach(function (n) { n = n.trim(); if (n && n !== 'all' && n.length <= 64 && !seen[n]) { seen[n] = 1; out.push(n); } });
|
||||
return out.slice(0, 16);
|
||||
}
|
||||
function hostJoin(list) { return list.length ? list.join(',') : 'all'; }
|
||||
function hostHas(v, name) { return v === 'all' || !v || hostList(v).indexOf(name) >= 0; }
|
||||
// read r/from/to/host from the URL; absent keys keep the current slice
|
||||
function readSlice(q) {
|
||||
var f = q.get('from'), to = q.get('to'), r = q.get('r') || q.get('range'), ok = false;
|
||||
@@ -1849,7 +1857,7 @@
|
||||
if (isFinite(a) && isFinite(b) && b > a && (b - a) / 1000 <= MAX_SPAN) { state.from = Math.floor(a / 1000); state.to = Math.floor(b / 1000); ok = true; }
|
||||
}
|
||||
if (!ok && r && PRESETS.indexOf(r) >= 0) { state.range = r; state.from = state.to = null; lsSet('urutau.range', r); }
|
||||
if (q.has('host')) { state.host = q.get('host') || 'all'; lsSet('urutau.host', state.host); }
|
||||
if (q.has('host')) { state.host = hostJoin(hostList(q.get('host'))); lsSet('urutau.host', state.host); }
|
||||
}
|
||||
// change the slice: the URL changes, the router does the rest
|
||||
function setShell(over) {
|
||||
@@ -2072,21 +2080,35 @@
|
||||
box.hidden = true;
|
||||
}
|
||||
function hostOpt(value, name, meta, tone) {
|
||||
var on = state.host === value;
|
||||
var sel = hostList(state.host), on = value === 'all' ? !sel.length : sel.indexOf(value) >= 0;
|
||||
var b = el('button', { type: 'button', class: 'fb-opt', 'data-host': value, 'aria-pressed': on ? 'true' : 'false' },
|
||||
h('span', 'fb-dot ' + tone), h('span', 'fb-opt-t', h('span', 'fb-opt-n', name), h('span', 'fb-opt-m', meta)), h('span', 'fb-tick', svgIcon(IC.check)));
|
||||
b.addEventListener('click', function () { closePop(hp, true); if (state.host !== value) setShell({ host: value }); });
|
||||
b.addEventListener('click', function () {
|
||||
// "all" clears the selection; any other row toggles that probe (several can be on); all of them, or none, is "all"
|
||||
var cur = hostList(state.host), next;
|
||||
if (value === 'all') next = [];
|
||||
else {
|
||||
var i = cur.indexOf(value);
|
||||
next = i >= 0 ? cur.filter(function (n) { return n !== value; }) : cur.concat([value]);
|
||||
var names = (state.hostList || []).map(function (x) { return x.name; });
|
||||
if (names.length && names.every(function (n) { return next.indexOf(n) >= 0; })) next = [];
|
||||
}
|
||||
var nv = hostJoin(next);
|
||||
if (value === 'all') closePop(hp, true);
|
||||
if (nv !== state.host) setShell({ host: nv });
|
||||
});
|
||||
return b;
|
||||
}
|
||||
function renderHostPicker() {
|
||||
if (!hp.btn) return;
|
||||
var hosts = state.hostList || [], on = hosts.filter(function (x) { return x.online; }).length;
|
||||
$('#host-picker').hidden = hosts.length < 2;
|
||||
var cur = hosts.filter(function (x) { return x.name === state.host; })[0];
|
||||
hp.label.textContent = state.host === 'all' ? t('host.all') : state.host;
|
||||
var tone = state.host === 'all' ? (on === hosts.length ? 'on' : on ? 'warn' : 'off') : (cur && cur.online ? 'on' : 'off');
|
||||
var sel = hostList(state.host), picked = hosts.filter(function (x) { return sel.indexOf(x.name) >= 0; });
|
||||
var pOn = picked.filter(function (x) { return x.online; }).length;
|
||||
hp.label.textContent = !sel.length ? t('host.all') : sel.join(', ');
|
||||
var tone = !sel.length ? (on === hosts.length ? 'on' : on ? 'warn' : 'off') : (pOn === picked.length && picked.length ? 'on' : pOn ? 'warn' : 'off');
|
||||
hp.dot.className = 'fb-dot ' + tone;
|
||||
hp.count.textContent = state.host === 'all' ? on + '/' + hosts.length : (cur && cur.online ? t('host.online') : t('host.offline'));
|
||||
hp.count.textContent = !sel.length ? on + '/' + hosts.length : (sel.length > 1 ? pOn + '/' + picked.length : (pOn ? t('host.online') : t('host.offline')));
|
||||
hp.count.className = 'fb-count ' + tone;
|
||||
hp.btn.setAttribute('aria-label', t('host.label') + ': ' + hp.label.textContent + ', ' + t('fb.host.status', { n: on, m: hosts.length }));
|
||||
var want = hosts.map(function (x) { return x.name + (x.online ? '1' : '0') + (x.version || ''); }).join('|') + '|' + state.host + '|' + lang;
|
||||
@@ -2126,7 +2148,7 @@
|
||||
var p = $('#slice-text');
|
||||
if (!p) return;
|
||||
clear(p);
|
||||
var parts = [state.host === 'all' ? t('slice.allHosts') : t('slice.host', { name: state.host })];
|
||||
var parts = [state.host === 'all' ? t('slice.allHosts') : t('slice.host', { name: hostList(state.host).join(', ') })];
|
||||
if (current && pages[current.id] && pages[current.id].domain) parts.push(state.domain === 'all' ? t('slice.allDomains') : t('slice.domain', { name: state.domain }));
|
||||
if (state.note) parts.push(state.note);
|
||||
var live = !isCustom();
|
||||
@@ -2306,7 +2328,12 @@
|
||||
function updateHostSelect(s) {
|
||||
var hosts = s.hosts || [];
|
||||
state.hostList = hosts;
|
||||
if (state.host !== 'all' && !hosts.some(function (x) { return x.name === state.host; })) { state.host = 'all'; lsSet('urutau.host', 'all'); }
|
||||
if (state.host !== 'all' && hosts.length) {
|
||||
var known = hostList(state.host).filter(function (n) { return hosts.some(function (x) { return x.name === n; }); });
|
||||
if (known.length === hosts.length) known = [];
|
||||
var kv = hostJoin(known);
|
||||
if (kv !== state.host) { state.host = kv; lsSet('urutau.host', kv); }
|
||||
}
|
||||
renderHostPicker();
|
||||
}
|
||||
function shellSummary() {
|
||||
|
||||
Reference in new issue
Block a user