This commit is contained in:
Mateusz Gruszczyński committed 2026-11-14 21:52:48 +01:00
1 parent f48843e934
commit e2c8099d9c
64 files changed
+5354 -673

No files matched your search

+34
View File
@@ -209,6 +209,8 @@
$("tls-policy-key-exchange").textContent = kxGroups.length ? `${t("tlsPqcKeyExchangeGroups")}: ${kxGroups.join(", ")}` : "";
$("tls-policy-effective").textContent = effective.length ? `${t("tlsEffectiveCiphers")}: ${effective.join(", ")}` : "";
$("tls-policy-available").textContent = available.length ? `${t("tlsAvailableCiphers")}: ${available.join(", ")}` : "";
window.rustProxyTlsConfigurator?.refresh();
renderAlertSettings();
window.rustProxyCertificateApi?.render();
if (authenticated && active === "certificate-api") void window.rustProxyCertificateApi?.load?.();
}
@@ -246,6 +248,38 @@
const locked = !!latestStatus?.administration?.listen_locked;
next.administration = { listen: locked ? null : $("admin-listen").value.trim(), tls: $("admin-tls").checked, certificate_id: $("admin-tls").checked ? ($("admin-certificate").value || null) : null, allowed_hosts: additionalAdminHosts($("admin-hosts").value.split(/[\n,]+/), $("admin-public-origin").value.trim()), public_origin: $("admin-public-origin").value.trim() || null, session_days: Number($("admin-session-days").value), panel_compression: Object.fromEntries(["zstd", "br", "gzip"].map(codec => [codec, $(`admin-compression-${codec}`).checked])) };
}, "administration");
const ALERT_DEFAULTS = { enabled: true, notifications: true, certificate_expiry: true, certificate_warning_days: 14, certificate_error_days: 3, certificate_renewal: true, acme_runtime: true, file_descriptors: true, file_descriptors_warning_percent: 80, file_descriptors_error_percent: 95, geoip: true, prometheus: true, update: true };
const ALERT_CHECKS = { "alerts-enabled": "enabled", "alerts-notifications": "notifications", "alerts-certificate-expiry": "certificate_expiry", "alerts-certificate-renewal": "certificate_renewal", "alerts-acme-runtime": "acme_runtime", "alerts-file-descriptors": "file_descriptors", "alerts-geoip": "geoip", "alerts-prometheus": "prometheus", "alerts-update": "update" };
const ALERT_NUMBERS = { "alerts-certificate-warning": "certificate_warning_days", "alerts-certificate-error": "certificate_error_days", "alerts-fd-warning": "file_descriptors_warning_percent", "alerts-fd-error": "file_descriptors_error_percent" };
function syncAlertSettings() {
const on = $("alerts-enabled").checked;
for (const id of [...Object.keys(ALERT_CHECKS), ...Object.keys(ALERT_NUMBERS)]) if (id !== "alerts-enabled") $(id).disabled = !on;
$("alerts-certificate-warning").disabled = !on || !$("alerts-certificate-expiry").checked;
$("alerts-certificate-error").disabled = !on || !$("alerts-certificate-expiry").checked;
$("alerts-fd-warning").disabled = !on || !$("alerts-file-descriptors").checked;
$("alerts-fd-error").disabled = !on || !$("alerts-file-descriptors").checked;
for (const group of document.querySelectorAll("#alerts-form .alerts-settings-group")) group.classList.toggle("is-off", !on);
}
function renderAlertSettings() {
if (!$("alerts-form")) return;
const value = { ...ALERT_DEFAULTS, ...(envelope?.config?.alerts || {}) };
if (!settingsDirty.has("alerts-form")) {
for (const [id, key] of Object.entries(ALERT_CHECKS)) $(id).checked = value[key] !== false;
for (const [id, key] of Object.entries(ALERT_NUMBERS)) $(id).value = value[key];
}
syncAlertSettings();
const active = Array.isArray(latestStatus?.alerts) ? latestStatus.alerts : null;
$("alerts-active").textContent = active === null ? "" : active.length ? t("alertsTitle").replace("{count}", active.length) + ": " + active.map(alert => window.rustProxyAlerts?.text?.(alert) || alert.kind).join(" · ") : t("appHealthAlertsNone");
}
$("alerts-form").addEventListener("change", syncAlertSettings);
bindSettingsForm("alerts-form", next => {
const value = {};
for (const [id, key] of Object.entries(ALERT_CHECKS)) value[key] = $(id).checked;
for (const [id, key] of Object.entries(ALERT_NUMBERS)) { const number = Number($(id).value); if (!Number.isInteger(number)) throw fieldError($(id), t("alertSettingsNumberInvalid")); value[key] = number; }
if (value.certificate_error_days >= value.certificate_warning_days) throw fieldError($("alerts-certificate-error"), t("alertSettingsCertificateOrder"));
if (value.file_descriptors_error_percent <= value.file_descriptors_warning_percent) throw fieldError($("alerts-fd-error"), t("alertSettingsPercentOrder"));
next.alerts = value;
}, "alerts");
bindSettingsForm("tls-policy-form", next => {
if (!$("tls-policy-12").checked && !$("tls-policy-13").checked) throw fieldError($("tls-policy-12"), t("tlsPolicyVersionRequired"));
if ($("tls-policy-pqc").checked && !$("tls-policy-13").checked) throw fieldError($("tls-policy-13"), t("tlsPqcTls13Required"));