feat: 1.4.6 unban from the UI, operator allows, day-counter fallback for long windows
Release / Publish tags (push) Successful in 16s
Release / Plan (reuse the published image?) (push) Successful in 4s
Release / ci (push) Successful in 1m47s
Release / Build image (amd64) (push) Successful in 21s
Release / Build image (arm64) (push) Successful in 23s
CI / Format and vet (push) Successful in 27s
CI / Tests (Linux, race detector) (push) Successful in 1m20s
CI / Dependency audit (push) Successful in 31s
CI / Docker image (build and smoke test) (push) Skipped
Release / Gitea release (push) Successful in 5s
Release / Publish tags (push) Successful in 16s
Release / Plan (reuse the published image?) (push) Successful in 4s
Release / ci (push) Successful in 1m47s
Release / Build image (amd64) (push) Successful in 21s
Release / Build image (arm64) (push) Successful in 23s
CI / Format and vet (push) Successful in 27s
CI / Tests (Linux, race detector) (push) Successful in 1m20s
CI / Dependency audit (push) Successful in 31s
CI / Docker image (build and smoke test) (push) Skipped
Release / Gitea release (push) Successful in 5s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1ef5a0ce9f
commit
da333d70f1
25 files changed
+841
-33
No files matched your search
@@ -989,6 +989,61 @@
|
||||
setTimeout(function () { if (n.parentNode) n.parentNode.removeChild(n); }, 2600);
|
||||
}
|
||||
|
||||
// POST/DELETE with a JSON body (same-origin cookie session); resolves with the parsed answer or rejects with its status.
|
||||
function apiSend(method, path, body) {
|
||||
var o = { method: method, credentials: 'same-origin', headers: { Accept: 'application/json' } };
|
||||
if (body !== undefined) { o.body = JSON.stringify(body); o.headers['Content-Type'] = 'application/json'; }
|
||||
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();
|
||||
});
|
||||
}
|
||||
|
||||
// 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) {
|
||||
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 });
|
||||
var fs = el('fieldset', { class: 'unban-opts' }, el('legend', null, t('unban.keep')));
|
||||
UNBAN_CHOICES.forEach(function (c, i) {
|
||||
var id = 'unban-o' + i;
|
||||
var inp = el('input', { type: 'radio', name: 'unban-keep', id: id, value: c[0] });
|
||||
if (i === 0) inp.checked = true;
|
||||
fs.appendChild(el('div', { class: 'unban-opt' }, inp, el('label', { for: id }, t(c[1]))));
|
||||
});
|
||||
var ok = el('button', { type: 'button', class: 'btn btn-primary' }, t('unban.confirm'));
|
||||
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')));
|
||||
dlg.appendChild(fs);
|
||||
dlg.appendChild(err);
|
||||
dlg.appendChild(el('div', { class: 'unban-btns' }, cancel, ok));
|
||||
function close() { dlg.close(); }
|
||||
cancel.addEventListener('click', close);
|
||||
dlg.addEventListener('close', function () {
|
||||
if (dlg.parentNode) dlg.parentNode.removeChild(dlg);
|
||||
if (prev && prev.focus && document.contains(prev)) prev.focus();
|
||||
});
|
||||
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 () {
|
||||
close();
|
||||
toast(t('unban.done', { ip: ip }));
|
||||
if (onDone) onDone();
|
||||
}, function (e) {
|
||||
ok.disabled = false;
|
||||
err.textContent = t(e && e.status === 409 ? 'unban.err.off' : 'unban.err');
|
||||
err.hidden = false;
|
||||
});
|
||||
});
|
||||
document.body.appendChild(dlg);
|
||||
if (dlg.showModal) dlg.showModal(); else dlg.setAttribute('open', '');
|
||||
ok.focus();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- charts library (own SVG, no dependencies)
|
||||
var VIZ = ['--viz-1', '--viz-2', '--viz-3', '--viz-4', '--viz-5', '--viz-6', '--viz-7', '--viz-8'];
|
||||
function vizColor(i, colors) { return 'var(' + ((colors && colors[i % colors.length]) || VIZ[i % VIZ.length]) + ')'; }
|
||||
@@ -2056,7 +2111,7 @@
|
||||
|
||||
window.Urutau = {
|
||||
registerPage: registerPage, registerI18n: registerI18n, t: t, pl: pl, api: api, onEvent: onEvent, openIP: openIP,
|
||||
rangeParams: rangeParams, rangeLabel: rangeLabel, href: hrefFor, toast: toast,
|
||||
rangeParams: rangeParams, rangeLabel: rangeLabel, href: hrefFor, toast: toast, apiSend: apiSend, unbanDialog: unbanDialog,
|
||||
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,
|
||||
charts: charts, help: help, glossary: glossary,
|
||||
|
||||
Reference in new issue
Block a user