This commit is contained in:
Mateusz Gruszczyński committed 2026-10-10 11:35:04 +02:00
1 parent f3dd34dae4
commit f213d853e2
28 files changed
+5368 -4692

No files matched your search

+52 -5
View File
@@ -2,7 +2,7 @@
"openapi": "3.0.3",
"info": {
"title": "RustProxy Administration API",
"version": "0.30.0",
"version": "0.30.1",
"description": "Administration API for the active panel origin. Sign in through the panel; the same-origin HttpOnly cookie authenticates all private operations. Mutations also require the exact Origin, X-RustProxy-Request: 1 and a session-bound X-CSRF-Token. Loopback HTTP is the default; Settings can enable HTTPS before using a non-loopback administration bind. This document contains no live configuration or credentials. Object schemas marked extensible are summaries: full configuration validation is authoritative in Rust."
},
"servers": [
@@ -549,7 +549,19 @@
"description": "Off by default. For these origin response HTTP statuses, replace the application response with a RustProxy error page (no-store). Does not change RustProxy-generated routing/security errors.",
"items": {
"type": "integer",
"enum": [400, 401, 403, 404, 408, 413, 429, 500, 502, 503, 504]
"enum": [
400,
401,
403,
404,
408,
413,
429,
500,
502,
503,
504
]
}
}
},
@@ -4737,7 +4749,7 @@
},
"certificate_runtime": {
"type": "object",
"description": "Python/pip/Certbot capability used by managed certificate automation.",
"description": "ACME Python/pip/Certbot capability and versions read from local runtime/package metadata without executing diagnostic commands. Missing metadata returns null.",
"properties": {
"status": {
"type": "string",
@@ -4771,6 +4783,21 @@
},
"certbot": {
"type": "boolean"
},
"python_version": {
"type": "string",
"nullable": true,
"description": "Version declared by the selected runtime (pyvenv.cfg for Python, dist-info/METADATA for pip and Certbot); null if missing or ambiguous."
},
"pip_version": {
"type": "string",
"nullable": true,
"description": "Version declared by the selected runtime (pyvenv.cfg for Python, dist-info/METADATA for pip and Certbot); null if missing or ambiguous."
},
"certbot_version": {
"type": "string",
"nullable": true,
"description": "Version declared by the selected runtime (pyvenv.cfg for Python, dist-info/METADATA for pip and Certbot); null if missing or ambiguous."
}
},
"required": [
@@ -4780,8 +4807,25 @@
"managed_directory",
"python",
"pip",
"certbot"
"certbot",
"python_version",
"pip_version",
"certbot_version"
]
},
"architecture": {
"type": "string",
"description": "Architecture of the RustProxy executable."
},
"operating_system": {
"type": "string",
"nullable": true,
"description": "Host OS release name from the cross-platform sysinfo library, when supported."
},
"kernel_version": {
"type": "string",
"nullable": true,
"description": "Host kernel version from the cross-platform sysinfo library, when available."
}
},
"required": [
@@ -4789,7 +4833,10 @@
"statistics_source",
"data_directory",
"database_path",
"certificate_runtime"
"certificate_runtime",
"architecture",
"operating_system",
"kernel_version"
]
},
"CertificateApiCredential": {
+33
View File
@@ -1,3 +1,33 @@
// Reuse sysinfo's native OS APIs on Linux, BSD, macOS and Windows. The
// diagnostics endpoint must never spawn system commands or parse platform files.
// Host identification is cached because it changes only after a reboot.
fn valid_host_text(value: String) -> Option<String> {
let value = value.trim();
(!value.is_empty() && value.len() <= 128 && !value.chars().any(char::is_control))
.then(|| value.to_owned())
}
fn os_release() -> Option<&'static str> {
static VALUE: std::sync::OnceLock<Option<String>> = std::sync::OnceLock::new();
VALUE.get_or_init(|| {
sysinfo::System::long_os_version()
.or_else(|| {
let name = sysinfo::System::name()?;
Some(match sysinfo::System::os_version() {
Some(version) if !version.is_empty() => format!("{name} {version}"),
_ => name,
})
})
.and_then(valid_host_text)
}).as_deref()
}
fn kernel_release() -> Option<&'static str> {
static VALUE: std::sync::OnceLock<Option<String>> = std::sync::OnceLock::new();
VALUE.get_or_init(|| sysinfo::System::kernel_version().and_then(valid_host_text))
.as_deref()
}
fn status_payload(state: &App) -> Value {
let snapshot = state.config.load_full();
let listeners = json!({
@@ -180,6 +210,9 @@ fn status_payload(state: &App) -> Value {
});
payload["runtime"] = json!({
"platform": system.platform,
"operating_system": os_release(),
"kernel_version": kernel_release(),
"architecture": std::env::consts::ARCH,
"statistics_source": system.source,
"data_directory": state.policy.data_dir.as_ref().map(|path| path.display().to_string()),
"database_path": state.policy.data_dir.as_ref().map(|path| path.join("config.sqlite3").display().to_string()),
+2 -15
View File
@@ -192,21 +192,8 @@ function enhanceEnabledControl(input, hintKey = "entityEnableHint") {
}
window.rustProxyEnableControl = enhanceEnabledControl;
function action(label, fn) { const b = el("button", label, "quiet"); b.type = "button"; b.addEventListener("click", fn); return b; }
function renderAboutRuntime(status = latestStatus) {
const value = status?.runtime?.certificate_runtime || {};
const availability = flag => flag === true ? t("runtimeAvailable") : flag === false ? t("runtimeUnavailable") : t("unavailable");
const mode = value.status === "unavailable" ? t("certificateRuntimeUnavailable") : value.status === "ready" && value.mode === "managed" ? t("certificateRuntimeManaged") : value.status === "ready" && value.mode === "system" ? t("certificateRuntimeSystem") : t("certificateRuntimePreparing");
const modeNode = $("about-acme-mode"), runtimeNode = $("about-python-runtime"), details = $("about-python-details");
if (modeNode) modeNode.textContent = mode;
if (runtimeNode) runtimeNode.textContent = `${t("runtimePython")}: ${availability(value.python)} · ${t("runtimePip")}: ${availability(value.pip)} · ${t("runtimeCertbot")}: ${availability(value.certbot)}`;
if (details) {
const parts = [value.message ? t(value.message) : ""];
if (value.managed_directory) parts.push(`${t("certificateRuntimePath")}: ${value.managed_directory}`);
details.textContent = parts.filter(Boolean).join(" · ");
}
}
function renderStatus(s) {
const firstStatus = latestStatus === null; latestStatus = s; renderAboutRuntime(s); window.rustProxySettings?.render(); if (firstStatus) renderSettings();
const firstStatus = latestStatus === null; latestStatus = s; window.rustProxySettings?.render(); if (firstStatus) renderSettings();
connected = true; $("connection-label").textContent = t("connected"); $("signal").classList.remove("status-error"); const m = s.metrics;
$("metric-ws").textContent = m.websocket_active || 0;
$("metric-ws-h1").textContent = m.websocket_h1_active || 0;
@@ -384,7 +371,7 @@ function stopTunnelRefresh() { if (tunnelRefreshTimer) clearInterval(tunnelRefre
function startTunnelRefresh() { stopTunnelRefresh(); tunnelRefreshTimer = setInterval(() => { if ($("tunnels-dialog")?.open) void loadTunnels(); }, 2000); }
$("login-form").addEventListener("submit", async event => { event.preventDefault(); const form = event.currentTarget; authMessage(""); try { await withFormSubmitState(form, event.submitter, async () => { const username = $("username").value.trim(); const password = $("password").value; if (setupRequired) { if (password !== $("password-confirm").value) throw fieldError("password-confirm", t("passwordMismatch")); await api("/api/auth/setup", { method: "POST", body: JSON.stringify({ token: $("setup-token").value.trim(), username, password }) }); setupRequired = false; syncAuthForm(); } const info = await api("/api/auth/login", { method: "POST", body: JSON.stringify({ username, password }) }); await activate(info); clearTimeout(toastTimer); hideToast(); }); } catch (e) { if (e.code === "auth.already_initialized") { setupRequired = false; syncAuthForm(); } $("password").value = ""; $("password-confirm").value = ""; authMessage(e.message); } });
$("logout").addEventListener("click", async () => { try { await api("/api/auth/logout", { method: "POST" }); lock(); toast(t("locked")); } catch (e) { if (e.status === 401) lock(); toast(e.message, true); } });
$("about-open").addEventListener("click", () => { renderAboutRuntime(); const dialog = $("about-dialog"); if (!dialog.open) dialog.showModal(); });
$("about-open").addEventListener("click", () => { const dialog = $("about-dialog"); if (!dialog.open) dialog.showModal(); });
$("about-close").addEventListener("click", () => $("about-dialog").close());
const mobileMenuToggle = $("mobile-menu-toggle"), dashboardSidebar = document.querySelector(".sidebar");
function setMobileMenu(open) {
+45 -29
View File
@@ -1768,6 +1768,9 @@
aria-controls="settings-page-administration" aria-selected="false"
data-i18n="administration" data-settings-tab="administration"
id="settings-tab-administration" role="tab" tabindex="-1" type="button"></button><button
aria-controls="settings-page-system-info" aria-selected="false"
data-i18n="systemInformation" data-settings-tab="system-info"
id="settings-tab-system-info" role="tab" tabindex="-1" type="button"></button><button
aria-controls="settings-page-certificate-api" aria-selected="false"
data-i18n="certificateApiTitle" data-settings-tab="certificate-api"
id="settings-tab-certificate-api" role="tab" tabindex="-1" type="button"></button><button
@@ -2698,30 +2701,52 @@
<div class="form-actions"><button class="primary" data-i18n="apply"
type="submit">Validate, save and apply</button></div>
</form>
</div>
<div aria-labelledby="settings-tab-system-info" class="settings-page"
data-settings-page="system-info" hidden="" id="settings-page-system-info" role="tabpanel">
<article class="card edit-form runtime-information-card">
<div class="card-heading">
<h2 data-i18n="runtimeInformation">Runtime information</h2><span
class="pill">API</span>
<h2 data-i18n="systemInformation">System information</h2><span class="pill">API</span>
</div>
<p class="fine" data-i18n="runtimeInformationHelp">Reported by the running RustProxy
process and available only from the authenticated administrator status API.</p>
<p class="fine" data-i18n="systemInformationHelp">Live, read-only information from the authenticated RustProxy status API. Unavailable metrics are not estimated.</p>
<h3 data-i18n="systemHostHeading">Operating system and hardware</h3>
<div class="runtime-information-grid">
<div><span class="small-label" data-i18n="runtimePlatform">Platform</span><code
id="runtime-platform">-</code></div>
<div><span class="small-label" data-i18n="statisticsSource">Statistics
source</span><code id="runtime-statistics-source">-</code></div>
<div><span class="small-label" data-i18n="dataDirectory">Data directory</span><code
id="runtime-data-directory">-</code></div>
<div><span class="small-label" data-i18n="databaseLocation">Database</span><code
id="runtime-database-path">-</code></div>
<div><span class="small-label" data-i18n="runtimeAcmeMode">ACME mode</span><code
id="runtime-acme-mode">-</code></div>
<div><span class="small-label" data-i18n="runtimePython">Python</span><code
id="runtime-python">-</code></div>
<div><span class="small-label" data-i18n="runtimePip">pip</span><code
id="runtime-pip">-</code></div>
<div><span class="small-label" data-i18n="runtimeCertbot">Certbot</span><code
id="runtime-certbot">-</code></div>
<div><span class="small-label" data-i18n="runtimePlatform">Platform</span><code id="runtime-platform">-</code></div>
<div><span class="small-label" data-i18n="systemOsVersion">Operating system</span><code id="runtime-operating-system">-</code></div>
<div><span class="small-label" data-i18n="systemKernel">Kernel</span><code id="runtime-kernel-version">-</code></div>
<div><span class="small-label" data-i18n="systemArchitecture">Architecture</span><code id="runtime-architecture">-</code></div>
<div><span class="small-label" data-i18n="systemLogicalCpus">Logical CPUs</span><code id="runtime-logical-cpus">-</code></div>
<div><span class="small-label" data-i18n="systemCpuLoad">CPU usage</span><code id="runtime-cpu-usage">-</code></div>
<div><span class="small-label" data-i18n="systemMemory">RAM used / total</span><code id="runtime-system-memory">-</code></div>
<div><span class="small-label" data-i18n="systemUptime">System uptime</span><code id="runtime-system-uptime">-</code></div>
</div>
<h3 data-i18n="systemProcessHeading">RustProxy process</h3>
<div class="runtime-information-grid">
<div><span class="small-label" data-i18n="systemAppVersion">RustProxy version</span><code id="runtime-version">-</code></div>
<div><span class="small-label" data-i18n="systemProcessUptime">Process uptime</span><code id="runtime-process-uptime">-</code></div>
<div><span class="small-label" data-i18n="systemProcessMemory">Process RAM (RSS)</span><code id="runtime-process-memory">-</code></div>
<div><span class="small-label" data-i18n="systemProcessThreads">Process threads</span><code id="runtime-process-threads">-</code></div>
<div><span class="small-label" data-i18n="systemOpenFds">Open file descriptors</span><code id="runtime-open-fds">-</code></div>
<div><span class="small-label" data-i18n="statisticsSource">Statistics source</span><code id="runtime-statistics-source">-</code></div>
</div>
</article>
<article class="card edit-form runtime-information-card">
<div class="card-heading"><h2 data-i18n="systemCertificateHeading">ACME / Python environment</h2></div>
<p class="fine" data-i18n="systemCertificateHelp">Versions refer to the interpreter and tools actually selected for certificate management, not an arbitrary Python installation.</p>
<div class="runtime-information-grid">
<div><span class="small-label" data-i18n="runtimeAcmeMode">ACME mode</span><code id="runtime-acme-mode">-</code></div>
<div><span class="small-label" data-i18n="systemAcmeStatus">ACME status</span><code id="runtime-acme-status">-</code></div>
<div><span class="small-label" data-i18n="runtimePython">Python</span><code id="runtime-python">-</code></div>
<div><span class="small-label" data-i18n="runtimePip">pip</span><code id="runtime-pip">-</code></div>
<div><span class="small-label" data-i18n="runtimeCertbot">Certbot</span><code id="runtime-certbot">-</code></div>
<div><span class="small-label" data-i18n="certificateRuntimePath">Managed environment</span><code id="runtime-acme-directory">-</code></div>
</div>
</article>
<article class="card edit-form runtime-information-card">
<div class="card-heading"><h2 data-i18n="systemPathsHeading">Data locations</h2></div>
<div class="runtime-information-grid">
<div><span class="small-label" data-i18n="dataDirectory">Data directory</span><code id="runtime-data-directory">-</code></div>
<div><span class="small-label" data-i18n="databaseLocation">Database</span><code id="runtime-database-path">-</code></div>
</div>
</article>
</div>
@@ -3659,18 +3684,9 @@ log_errors = On</code></pre>
<dt data-i18n="aboutLicense">License</dt>
<dd data-i18n="aboutLicenseValue">Open Source</dd>
</div>
<div>
<dt data-i18n="runtimeAcmeMode">ACME mode</dt>
<dd id="about-acme-mode">-</dd>
</div>
<div>
<dt data-i18n="aboutPythonRuntime">Certificate Python runtime</dt>
<dd id="about-python-runtime">-</dd>
</div>
</dl>
<p data-i18n="aboutOpenSourceText">RustProxy is an open-source project. Its source code is publicly
available for inspection, development and community contribution.</p>
<p class="about-python-details" id="about-python-details"></p>
<a class="outline about-repository" href="https://git.linuxiarz.pl/gru/RustProxy" rel="noopener noreferrer"
target="_blank"><span data-i18n="aboutRepository">Official source
repository</span><span>git.linuxiarz.pl/gru/RustProxy</span></a>
+35 -4
View File
@@ -219,13 +219,44 @@ curl --fail --show-error --request POST \
const syncAdminTls = () => { $("admin-certificate").disabled = !$("admin-tls").checked; }; syncAdminTls();
$("admin-status").textContent = adminStatus?.restart_required ? t("restartPending") : adminStatus?.active?.tls ? `${t("administrationActiveHttps")}: ${adminStatus.active.listen}` : `${t("administrationActiveHttp")}: ${adminStatus?.active?.listen || latestStatus?.admin_listen || "-"}`;
const runtime = latestStatus?.runtime || {};
for (const [id, key] of [["runtime-platform", "platform"], ["runtime-statistics-source", "statistics_source"], ["runtime-data-directory", "data_directory"], ["runtime-database-path", "database_path"]]) {
const node = $(id); if (node) node.textContent = runtime[key] || t("unavailable");
}
const system = latestStatus?.system || {};
const hasMetric = value => value !== null && value !== undefined && Number.isFinite(Number(value));
const humanCount = value => hasMetric(value) ? Number(value).toLocaleString(locale()) : t("unavailable");
const humanBytes = value => hasMetric(value) ? bytes(Number(value)) : t("unavailable");
const humanUptime = value => hasMetric(value) ? uptime(Number(value)) : t("unavailable");
const percent = value => hasMetric(value) ? `${Number(value).toLocaleString(locale(), { maximumFractionDigits: 1 })}%` : t("unavailable");
const ram = hasMetric(system.memory_used_bytes) || hasMetric(system.memory_total_bytes)
? `${humanBytes(system.memory_used_bytes)} / ${humanBytes(system.memory_total_bytes)}` : t("unavailable");
for (const [id, value] of [
["runtime-version", latestStatus?.version],
["runtime-platform", runtime.platform],
["runtime-operating-system", runtime.operating_system],
["runtime-kernel-version", runtime.kernel_version],
["runtime-architecture", runtime.architecture],
["runtime-logical-cpus", humanCount(system.logical_cpus)],
["runtime-cpu-usage", percent(system.cpu_percent)],
["runtime-system-memory", ram],
["runtime-system-uptime", humanUptime(system.system_uptime_seconds)],
["runtime-process-uptime", humanUptime(latestStatus?.uptime_seconds)],
["runtime-process-memory", humanBytes(system.process_rss_bytes)],
["runtime-process-threads", humanCount(system.process_threads)],
["runtime-open-fds", humanCount(system.open_fds)],
["runtime-statistics-source", runtime.statistics_source],
["runtime-data-directory", runtime.data_directory],
["runtime-database-path", runtime.database_path]
]) { const node = $(id); if (node) node.textContent = value ?? t("unavailable"); }
const certificateRuntime = runtime.certificate_runtime || {};
const availability = flag => flag === true ? t("runtimeAvailable") : flag === false ? t("runtimeUnavailable") : t("unavailable");
const modeLabel = certificateRuntime.status === "unavailable" ? t("certificateRuntimeUnavailable") : certificateRuntime.status === "ready" && certificateRuntime.mode === "managed" ? t("certificateRuntimeManaged") : certificateRuntime.status === "ready" && certificateRuntime.mode === "system" ? t("certificateRuntimeSystem") : t("certificateRuntimePreparing");
for (const [id, text] of [["runtime-acme-mode", modeLabel], ["runtime-python", availability(certificateRuntime.python)], ["runtime-pip", availability(certificateRuntime.pip)], ["runtime-certbot", availability(certificateRuntime.certbot)]]) { const node = $(id); if (node) node.textContent = text; }
const versioned = (flag, version) => version && flag === true ? `${availability(flag)} · ${version}` : availability(flag);
for (const [id, value] of [
["runtime-acme-mode", modeLabel],
["runtime-acme-status", certificateRuntime.message ? t(certificateRuntime.message) : t("unavailable")],
["runtime-python", versioned(certificateRuntime.python, certificateRuntime.python_version)],
["runtime-pip", versioned(certificateRuntime.pip, certificateRuntime.pip_version)],
["runtime-certbot", versioned(certificateRuntime.certbot, certificateRuntime.certbot_version)],
["runtime-acme-directory", certificateRuntime.managed_directory]
]) { const node = $(id); if (node) node.textContent = value || t("unavailable"); }
const policy = envelope.config.tls?.policy || { tls12: true, tls13: true, cipher_suites: [] };
if (!settingsDirty.has("tls-policy-form")) { $("tls-policy-12").checked = policy.tls12 !== false; $("tls-policy-13").checked = policy.tls13 !== false; $("tls-policy-ciphers").value = (policy.cipher_suites || []).join("\n"); }
+12 -1
View File
@@ -7606,6 +7606,11 @@ body[data-density="compact"] .page-footer {
background: currentColor;
}
/* The legend keys must use the same theme/preset palette as the SVG strokes. */
.stat-chart .stat-chart-legend .legend-h1 i { background: var(--traffic-h1); }
.stat-chart .stat-chart-legend .legend-h2 i { background: var(--traffic-h2); }
.stat-chart .stat-chart-legend .legend-h3 i { background: var(--traffic-h3); }
.stat-chart .stat-chart-legend b {
font-family: var(--mono);
font-weight: 500;
@@ -7809,7 +7814,13 @@ body[data-density="compact"] .page-footer {
}
.runtime-information-card {
margin-top: 12px;
margin-top: 0;
}
.runtime-information-card h3 {
margin: 16px 0 8px;
font-size: 12px;
font-weight: 600;
}
.runtime-information-grid {