This commit is contained in:
Mateusz Gruszczyński committed 2026-11-28 20:38:38 +01:00
1 parent 4d1087e357
commit 7514227b3b
40 files changed
+502 -260

No files matched your search

+19 -6
View File
@@ -1305,7 +1305,7 @@
},
"alerts": {
"type": "object",
"description": "Since 0.37.2. General alert settings (Settings → Alerts): enabled, notifications, certificate_expiry, certificate_warning_days (1..90, default 14), certificate_error_days (below warning, default 3), certificate_renewal, acme_runtime, file_descriptors, file_descriptors_warning_percent (default 80), file_descriptors_error_percent (default 95), geoip, prometheus, update. Omitted when all values are defaults.",
"description": "Since 0.37.2. General alert settings (Settings \u2192 Alerts): enabled, notifications, certificate_expiry, certificate_warning_days (1..90, default 14), certificate_error_days (below warning, default 3), certificate_renewal, acme_runtime, file_descriptors, file_descriptors_warning_percent (default 80), file_descriptors_error_percent (default 95), geoip, prometheus, update. Omitted when all values are defaults.",
"additionalProperties": false,
"properties": {
"enabled": {
@@ -2604,7 +2604,7 @@
"items": {
"$ref": "#/components/schemas/CacheRule"
},
"description": "Global cache rules (Cache → Rules)."
"description": "Global cache rules (Cache \u2192 Rules)."
},
"static_ignore_vary_cookie": {
"type": "boolean",
@@ -4111,6 +4111,19 @@
"items": {
"type": "string"
}
},
"enabled": {
"type": "boolean",
"description": "Assignment state; label publications omit it."
},
"certificate_id": {
"type": "string",
"nullable": true,
"description": "Certificate the generated Docker vhost uses, chosen from the agent's allowed certificates (null when none applies)."
},
"certificate_mismatch": {
"type": "boolean",
"description": "True when the certificate was used although it does not cover the hostnames (the assignment allows a mismatch)."
}
},
"required": [
@@ -5095,7 +5108,7 @@
"type": "string",
"maxLength": 64
},
"description": "Account-scoped agent shown by each optional Docker Overview card (card ID → Docker agent ID). A missing card uses all agents."
"description": "Account-scoped agent shown by each optional Docker Overview card (card ID \u2192 Docker agent ID). A missing card uses all agents."
}
},
"required": [
@@ -10711,7 +10724,7 @@
}
}
},
"description": "Sets an HttpOnly SameSite=Strict session cookie. Browser sessions use the configured 7–30 day absolute lifetime. Use the panel sign-in page. No bearer token or URL token is accepted.",
"description": "Sets an HttpOnly SameSite=Strict session cookie. Browser sessions use the configured 7\u201330 day absolute lifetime. Use the panel sign-in page. No bearer token or URL token is accepted.",
"security": [],
"parameters": [
{
@@ -15521,7 +15534,7 @@
}
},
"patch": {
"summary": "Edit one credential’s comment and permissions without rotating the token",
"summary": "Edit one credential\u2019s comment and permissions without rotating the token",
"tags": [
"Certificates"
],
@@ -16506,7 +16519,7 @@
"name": "slot",
"in": "query",
"required": false,
"description": "With kind=html: saved default response to preview — direct_ip, unknown_host, response, fallback or error-<code>",
"description": "With kind=html: saved default response to preview \u2014 direct_ip, unknown_host, response, fallback or error-<code>",
"schema": {
"type": "string"
}
+22 -2
View File
@@ -276,14 +276,34 @@ fn docker_runtime_views(state: &Arc<App>) -> (Vec<Value>, Vec<Value>, Value) {
} else {
Vec::new()
};
routes.push(json!({"agent_id": &agent.id, "service_key": &assignment.service_key, "pool_id": pool_id, "enabled": assignment.enabled, "hosts": hosts}));
let (certificate_id, certificate_mismatch) = crate::docker::assignment_certificate(
agent,
assignment,
&config.tls.certificates,
&hosts,
);
routes.push(json!({"agent_id": &agent.id, "service_key": &assignment.service_key, "pool_id": pool_id, "enabled": assignment.enabled, "hosts": hosts, "certificate_id": certificate_id, "certificate_mismatch": certificate_mismatch}));
}
}
for publication in &publications {
let pool_id =
crate::docker::generated_id(&publication.agent_id, &publication.assignment.service_key);
ids.insert(pool_id.clone());
routes.push(json!({"agent_id": &publication.agent_id, "service_key": &publication.assignment.service_key, "pool_id": pool_id, "source": "labels", "assignment": &publication.assignment, "hosts": &publication.hosts}));
let (certificate_id, certificate_mismatch) = config
.docker_agents
.agents
.iter()
.find(|agent| agent.id == publication.agent_id)
.map(|agent| {
crate::docker::assignment_certificate(
agent,
&publication.assignment,
&config.tls.certificates,
&publication.hosts,
)
})
.unwrap_or((None, false));
routes.push(json!({"agent_id": &publication.agent_id, "service_key": &publication.assignment.service_key, "pool_id": pool_id, "source": "labels", "assignment": &publication.assignment, "hosts": &publication.hosts, "certificate_id": certificate_id, "certificate_mismatch": certificate_mismatch}));
}
let pools = snapshot
.pools
+35 -5
View File
@@ -86,6 +86,7 @@ function translate() {
if (envelope) renderConfig(); renderConfigStorage(); if (latestStatus) { renderFooter(latestStatus); renderDiagnostics(latestStatus, false); window.rustProxyVhosts?.renderStatus(latestStatus); window.rustProxyDocker?.renderStatus(latestStatus); window.rustProxyStreams?.renderStatus(latestStatus); window.rustProxyStreamDashboard?.render(latestStatus); window.rustProxyDockerDashboard?.render(latestStatus, null, false); window.rustProxyBackendDashboard?.render(latestStatus, null, false); window.rustProxyExtraOverview?.render(latestStatus, false); window.rustProxyWideOverview?.render(latestStatus, false); window.rustProxyWebOverview?.render(latestStatus, false); } if (lastLogs) renderLogs(lastLogs);
syncSettingsDirtyIndicators();
window.rustProxyIcons?.refresh?.();
rustProxyAutoId.repaintAll();
}
function toastNode() {
let node = document.getElementById("toast");
@@ -728,7 +729,7 @@ $("export-config").addEventListener("click", () => { const url = URL.createObjec
const rustProxyAutoId = (() => {
const FOLD = { "ł": "l", "đ": "d", "ø": "o", "ß": "ss", "æ": "ae", "œ": "oe", "þ": "th", "ð": "d" };
const states = new WeakMap();
const states = new WeakMap(), registry = new Set();
function slugify(value, max = 64) {
let slug = String(value ?? "").trim().toLowerCase().replace(/^\*\./, "").replace(/[łđøßæœþð]/g, ch => FOLD[ch]).normalize("NFKD").replace(/[̀-ͯ]/g, "");
slug = slug.replace(/[^a-z0-9_-]+/g, "-").replace(/-{2,}/g, "-").replace(/^[-_]+/, "").slice(0, max).replace(/[-_]+$/, "");
@@ -753,34 +754,63 @@ const rustProxyAutoId = (() => {
state.row.hidden = !compact;
state.hint.hidden = compact || !state.auto; state.hint.textContent = t("autoIdHint");
state.reset.hidden = compact || state.auto || state.resettable === false || !wanted || wanted === value; state.reset.textContent = t("autoIdReset");
const reason = typeof state.lockedReason === "function" ? state.lockedReason() : state.lockedReason;
state.lock.hidden = !reason; state.lock.textContent = reason || "";
state.renameNote.hidden = !state.renameKey || !state.open || isLocked; state.renameNote.textContent = state.renameKey ? t(state.renameKey) : "";
}
function regenerate(input, state) { if (!state.auto || locked(input)) return; input.value = suggestion(state); input.setCustomValidity?.(""); paint(input, state); }
function attach(input, options) {
let state = states.get(input);
if (!state) {
state = { auto: true, open: false, holder: input.closest("label") || input.parentElement, hint: document.createElement("small"), reset: document.createElement("button"), row: document.createElement("div"), value: document.createElement("code"), badge: document.createElement("span"), change: document.createElement("button") };
state = { auto: true, open: false, holder: input.closest("label") || input.parentElement, hint: document.createElement("small"), reset: document.createElement("button"), row: document.createElement("div"), value: document.createElement("code"), badge: document.createElement("span"), change: document.createElement("button"), lock: document.createElement("small"), renameNote: document.createElement("small") };
state.lock.className = "fine auto-id-lock"; state.renameNote.className = "fine auto-id-rename-note";
state.holder.classList.add("auto-id-field");
state.hint.className = "fine auto-id-hint"; state.reset.type = "button"; state.reset.className = "quiet auto-id-reset";
state.row.className = "auto-id-row"; state.value.className = "auto-id-value"; state.badge.className = "auto-id-badge"; state.change.type = "button"; state.change.className = "quiet auto-id-change";
state.row.append(state.value, state.badge, state.change); state.holder.append(state.row, state.hint, state.reset);
state.row.append(state.value, state.badge, state.change, state.lock); state.holder.append(state.row, state.hint, state.reset, state.renameNote);
input.addEventListener("input", event => { if (!event.isTrusted) return; state.auto = input.value.trim() === ""; if (state.auto) regenerate(input, state); else paint(input, state); });
input.addEventListener("invalid", () => { if (!state.open) { state.open = true; paint(input, state); } });
input.addEventListener("blur", () => { if (input.value.trim() && input.validity.valid) { state.open = false; paint(input, state); } });
state.change.addEventListener("click", () => { state.open = true; paint(input, state); input.focus(); input.select?.(); });
state.reset.addEventListener("mousedown", event => event.preventDefault());
state.reset.addEventListener("click", () => { state.auto = true; regenerate(input, state); input.dispatchEvent(new Event("input", { bubbles: true })); });
states.set(input, state);
states.set(input, state); registry.add(new WeakRef(input));
for (const source of options.elements || []) source.addEventListener("input", () => { const current = states.get(input); if (current) regenerate(input, current); });
}
state.text = options.text || (() => (options.elements || []).map(node => node.value).find(value => value.trim()) || "");
state.taken = options.taken || (() => []); state.resettable = options.resettable;
if (options.original) {
const refs = options.inUse ? options.inUse(options.original) : [];
if (refs.length) { input.readOnly = true; state.lockedByRefs = true; } else if (state.lockedByRefs) { input.readOnly = false; state.lockedByRefs = false; }
state.lockedReason = refs.length ? () => `${t("idRenameLocked")}: ${refs.slice(0, 4).join(", ")}${refs.length > 4 ? ` +${refs.length - 4}` : ""}` : null;
state.renameKey = refs.length ? null : (options.renameKey || "idRenameHelp");
} else { state.lockedReason = null; state.renameKey = null; if (state.lockedByRefs) { input.readOnly = false; state.lockedByRefs = false; } }
state.auto = !locked(input) && input.value.trim() === ""; state.open = false;
paint(input, state);
return { refresh() { const current = states.get(input); if (current) regenerate(input, current); } };
}
return { slugify, unique, attach };
function repaintAll() { for (const ref of [...registry]) { const input = ref.deref(); if (!input || !input.isConnected) { if (!input) registry.delete(ref); continue; } const state = states.get(input); if (state) paint(input, state); } }
return { slugify, unique, attach, repaintAll };
})();
window.rustProxyAutoId = rustProxyAutoId;
function configReferences(id, keys) {
const config = envelope?.config || {}, found = [], wanted = new Set(keys);
const labelFor = (top, item) => `${t(`refSection_${top}`) === `refSection_${top}` ? top : t(`refSection_${top}`)}: ${item?.id || item?.name || "?"}`;
const walk = (node, top, item) => {
if (Array.isArray(node)) { for (const child of node) walk(child, top, item); return; }
if (!node || typeof node !== "object") return;
for (const [key, value] of Object.entries(node)) {
if (wanted.has(key) && (value === id || (Array.isArray(value) && value.includes(id)))) { const label = labelFor(top, item); if (!found.includes(label)) found.push(label); }
else if (value && typeof value === "object") walk(value, top, item);
}
};
for (const [top, section] of Object.entries(config)) {
if (Array.isArray(section)) for (const item of section) walk(item, top, item);
else if (section && typeof section === "object") for (const [key, value] of Object.entries(section)) { if (Array.isArray(value)) for (const item of value) walk(item, `${top}.${key}`, item); else if (wanted.has(key) && value === id) found.push(key === "default_certificate" ? t("certificateDefaultSni") : t(`refSection_${top}`) === `refSection_${top}` ? top : t(`refSection_${top}`)); else walk(value, top, null); }
}
return found;
}
window.rustProxyConfigReferences = configReferences;
const rustProxyAutoCertificate = (() => {
const states = new WeakMap();
+40 -11
View File
@@ -70,18 +70,32 @@ function certificateUsage(cert) {
vhosts: (config.vhosts || []).filter(item => item.certificate_id === cert.id).map(item => ({ id: item.id, hosts: hostsOf(item), mismatch: item.allow_certificate_mismatch === true, open: () => { setPanel("vhosts"); window.rustProxyVhosts?.edit(item.id); } })),
redirects: (config.redirects || []).filter(item => item.certificate_id === cert.id).map(item => ({ id: item.id, hosts: hostsOf(item), open: () => { setPanel("redirects"); window.rustProxyRedirects?.edit(item.id); } })),
notfound: (config.not_found_hosts || []).filter(item => item.certificate_id === cert.id).map(item => ({ id: item.id, hosts: hostsOf(item), open: () => { setPanel("notfound"); window.rustProxyNotFound?.edit(item.id); } })),
docker: (config.docker_agents?.agents || []).filter(agent => [agent.certificate_id, ...(agent.certificate_ids || [])].includes(cert.id)).map(agent => ({ id: agent.id, hosts: agent.domains || [], open: () => setPanel("settings") }))
dockerVhosts: certificateDockerRoutes().filter(route => route.certificate_id === cert.id).map(route => ({ id: `${route.agent_id} · ${route.service_key}`, hosts: route.hosts || [], mismatch: route.certificate_mismatch === true, docker: true, open: () => { setPanel("docker-vhosts"); const search = $("docker-search"); if (search) { search.value = (route.hosts || [])[0] || route.service_key; search.dispatchEvent(new Event("input", { bubbles: true })); } } })),
docker: (config.docker_agents?.agents || []).filter(agent => [agent.certificate_id, ...(agent.certificate_ids || [])].includes(cert.id)).map(agent => ({ id: agent.id, hosts: agent.domains || [], open: () => { setPanel("settings"); window.rustProxySettings?.select?.("docker-agents"); } }))
};
const legacy = [];
for (const item of config.vhosts || []) if (item.certificate_id === cert.id) legacy.push(`vhost:${item.id}`);
for (const item of config.redirects || []) if (item.certificate_id === cert.id) legacy.push(`redirect:${item.id}`);
for (const item of config.not_found_hosts || []) if (item.certificate_id === cert.id) legacy.push(`404:${item.id}`);
for (const route of certificateDockerRoutes()) if (route.certificate_id === cert.id) legacy.push(`docker:${route.agent_id}/${route.service_key}`);
const admin = config.administration?.certificate_id === cert.id, isDefault = settings.default_certificate === cert.id;
if (admin) legacy.push(t("administration"));
if (isDefault) legacy.push(t("defaultLabel"));
const count = groups.vhosts.length + groups.redirects.length + groups.notfound.length + (admin ? 1 : 0) + (isDefault ? 1 : 0);
const count = groups.vhosts.length + groups.dockerVhosts.length + groups.redirects.length + groups.notfound.length + (admin ? 1 : 0) + (isDefault ? 1 : 0);
return { groups, admin, isDefault, legacy, count, inUse: legacy.length > 0 };
}
let certificateDockerState = { routes: [], loadedAt: 0, loading: false };
function certificateDockerRoutes() {
const fromPanel = window.rustProxyDocker?.routes?.() || [];
if (fromPanel.length) return fromPanel;
const agents = envelope?.config.docker_agents?.agents || [];
if (agents.length && !certificateDockerState.loading && Date.now() - certificateDockerState.loadedAt > 30000) {
certificateDockerState.loading = true;
api("/api/docker").then(data => { certificateDockerState.routes = data.pool_routes || []; certificateDockerState.loadedAt = Date.now(); certificateDockerState.loading = false; if (certificateDockerState.routes.length) renderCertificates(); })
.catch(() => { certificateDockerState.loadedAt = Date.now(); certificateDockerState.loading = false; });
}
return certificateDockerState.routes;
}
function certificateCoverage(cert) {
const inventory = certificateInventory.get(cert.id);
return inventory?.covered_hosts?.length ? inventory.covered_hosts : (cert.covered_hosts || []);
@@ -110,16 +124,16 @@ function formatDate(ms) { try { return new Date(ms).toLocaleDateString(typeof la
function renderCertificateSummary(certificates) {
const box = $("certificate-summary"); if (!box) return;
const settings = envelope?.config.tls || {};
let acme = 0, external = 0, managedFiles = 0, expiring = [], assignments = 0, vhostCount = 0, redirectCount = 0, notfoundCount = 0;
let acme = 0, external = 0, managedFiles = 0, expiring = [], assignments = 0, vhostCount = 0, dockerCount = 0, redirectCount = 0, notfoundCount = 0;
for (const cert of certificates) {
if (cert.issuer) acme++; else if (certificateUsesExternalFiles(cert)) external++; else managedFiles++;
const inventory = certificateInventory.get(cert.id);
if (["warning", "expired"].includes(inventory?.expiry_status)) expiring.push(`${cert.id} · ${inventory?.days_remaining ?? "-"} ${t("certificateDaysShort")}`);
const usage = certificateUsage(cert); assignments += usage.count; vhostCount += usage.groups.vhosts.length; redirectCount += usage.groups.redirects.length; notfoundCount += usage.groups.notfound.length;
const usage = certificateUsage(cert); assignments += usage.count; vhostCount += usage.groups.vhosts.length; dockerCount += usage.groups.dockerVhosts.length; redirectCount += usage.groups.redirects.length; notfoundCount += usage.groups.notfound.length;
}
const tile = (value, titleKey, line, tone, filter) => {
const node = el(filter ? "button" : "div", undefined, `cert-summary-tile${tone ? ` is-${tone}` : ""}`);
if (filter) { node.type = "button"; node.dataset.uiIconName = "none"; node.addEventListener("click", () => { window.rustProxyAcme?.select("installed"); setCertificateFilter(filter); }); }
if (filter) { node.type = "button"; node.dataset.uiIconName = "none"; node.addEventListener("click", () => { window.rustProxyCertificates?.select("installed"); setCertificateFilter(filter); }); }
const title = el("span", t(titleKey)); title.dataset.i18n = titleKey;
node.append(el("b", value), title, el("small", line)); return node;
};
@@ -127,7 +141,7 @@ function renderCertificateSummary(certificates) {
box.replaceChildren(
tile(String(certificates.length), "certificateSummaryCount", `${acme} ACME · ${external} ${t("certificateSummaryExternal")} · ${managedFiles} ${t("certificateSummaryManaged")}`, certificates.length ? "ok" : "", "all"),
tile(String(expiring.length), "certificateSummaryExpiring", expiring.length ? expiring.slice(0, 2).join(", ") : t("certificateSummaryNothingExpiring"), expiring.length ? "warn" : "ok", "expiring"),
tile(String(assignments), "certificateSummaryAssignments", `${vhostCount} vhost · ${redirectCount} ${t("certificateSummaryRedirects")} · ${notfoundCount} 404${settings.default_certificate ? ` · ${t("defaultLabel")}: ${settings.default_certificate}` : ""}`, "", "unassigned"),
tile(String(assignments), "certificateSummaryAssignments", `${vhostCount} vhost${dockerCount ? ` · ${dockerCount} Docker` : ""} · ${redirectCount} ${t("certificateSummaryRedirects")} · ${notfoundCount} 404${settings.default_certificate ? ` · ${t("defaultLabel")}: ${settings.default_certificate}` : ""}`, "", "assigned"),
tile(runtime || "-", "certificateSummaryRuntime", $("acme-runtime-components")?.textContent || "", $("acme-runtime-card")?.dataset.state === "ready" ? "ok" : $("acme-runtime-card")?.dataset.state === "unavailable" ? "bad" : "")
);
}
@@ -141,7 +155,7 @@ function applyCertificateFilter() {
let shown = 0;
for (const row of document.querySelectorAll("#certificate-list > .certificate-row")) {
const matchesQuery = !query || row.dataset.search.includes(query);
const matchesFilter = certificateFilter === "all" || (certificateFilter === "expiring" && row.dataset.expiring === "true") || (certificateFilter === "unassigned" && row.dataset.assigned === "false");
const matchesFilter = certificateFilter === "all" || (certificateFilter === "expiring" && row.dataset.expiring === "true") || (certificateFilter === "unassigned" && row.dataset.assigned === "false") || (certificateFilter === "assigned" && row.dataset.assigned === "true");
row.hidden = !(matchesQuery && matchesFilter); if (!row.hidden) shown++;
}
const empty = $("certificate-list-filtered-empty");
@@ -161,7 +175,7 @@ function renderCertificates() {
box.dataset.certificateId = cert.id;
box.dataset.expiring = String(["warning", "expired"].includes(inventory?.expiry_status));
box.dataset.assigned = String(usage.count > 0);
box.dataset.search = [cert.id, ...coverage, ...bindings, ...usage.groups.vhosts.map(item => item.id), ...usage.groups.redirects.map(item => item.id), ...usage.groups.notfound.map(item => item.id)].join(" ").toLowerCase();
box.dataset.search = [cert.id, ...coverage, ...bindings, ...usage.groups.vhosts.map(item => item.id), ...usage.groups.dockerVhosts.flatMap(item => [item.id, ...item.hosts]), ...usage.groups.redirects.map(item => item.id), ...usage.groups.notfound.map(item => item.id)].join(" ").toLowerCase();
box.open = certificateOpenRows.has(cert.id);
box.addEventListener("toggle", () => { if (box.open) certificateOpenRows.add(cert.id); else certificateOpenRows.delete(cert.id); });
const summary = el("summary", undefined, "certificate-row-summary");
@@ -186,6 +200,7 @@ function renderCertificates() {
const usageCell = el("div", undefined, "certificate-usage-cell");
const usageParts = [];
if (usage.groups.vhosts.length) usageParts.push(`${usage.groups.vhosts.length} vhost`);
if (usage.groups.dockerVhosts.length) usageParts.push(`${usage.groups.dockerVhosts.length} Docker`);
if (usage.groups.redirects.length) usageParts.push(`${usage.groups.redirects.length} ${t("certificateSummaryRedirects")}`);
if (usage.groups.notfound.length) usageParts.push(`${usage.groups.notfound.length} 404`);
if (usage.admin) usageParts.push(t("administration"));
@@ -198,7 +213,7 @@ function renderCertificates() {
const usageSection = el("section", undefined, "certificate-section certificate-usage");
const usageHead = el("h4"); usageHead.append(el("span", t("certificateWhereUsed")), el("span", String(usage.count), "pill"));
usageSection.append(usageHead);
const groupDefs = [["vhosts", "certificateGroupVhosts"], ["redirects", "certificateGroupRedirects"], ["notfound", "certificateGroupNotFound"], ["docker", "certificateGroupDocker"]];
const groupDefs = [["vhosts", "certificateGroupVhosts"], ["dockerVhosts", "certificateGroupDockerVhosts"], ["redirects", "certificateGroupRedirects"], ["notfound", "certificateGroupNotFound"], ["docker", "certificateGroupDocker"]];
let anyUsage = false;
for (const [key, labelKey] of groupDefs) {
const items = usage.groups[key]; if (!items.length) continue; anyUsage = true;
@@ -239,7 +254,7 @@ function renderCertificates() {
["renewalLast", stamp(inventory?.last_renewal_attempt)],
["certificateRenewalError", inventory?.last_renewal_error ? t(inventory.last_renewal_error) : "-"]
]));
if (managed) { const link = el("button", t("certificateRenewalActionsLink"), "quiet"); link.type = "button"; link.dataset.uiIconName = "none"; link.addEventListener("click", () => window.rustProxyAcme?.select("renewal")); renewal.append(link); }
if (managed) { const link = el("button", t("certificateRenewalActionsLink"), "quiet"); link.type = "button"; link.dataset.uiIconName = "none"; link.addEventListener("click", () => window.rustProxyCertificates?.select("renewal")); renewal.append(link); }
const files = el("section", undefined, "certificate-section certificate-files");
files.append(el("h4", t("certificateFiles")), el("p", `${cert.cert_file}\n${cert.key_file}`, "mono certificate-file-paths"));
const buttons = el("div", undefined, "entity-actions");
@@ -260,7 +275,7 @@ function renderCertificates() {
}));
buttons.append(action(t("edit"), () => {
window.rustProxyCertificates?.open("existing"); $("certificate-advanced").open = true;
$("certificate-id").value = cert.id; $("certificate-hosts").value = (cert.hosts || []).join(", ");
$("certificate-id").value = cert.id; $("certificate-hosts").value = (cert.hosts || []).join(", "); attachCertificateId(cert.id);
$("certificate-file-source").value = certificateUsesExternalFiles(cert) ? "external" : "managed";
$("certificate-file").value = cert.cert_file; $("certificate-key").value = cert.key_file;
$("certificate-default").checked = settings.default_certificate === cert.id;
@@ -355,6 +370,13 @@ $("certificate-assign-apply")?.addEventListener("click", async () => {
});
$("certificate-search")?.addEventListener("input", applyCertificateFilter);
for (const button of document.querySelectorAll("[data-certificate-filter]")) button.addEventListener("click", () => setCertificateFilter(button.dataset.certificateFilter));
let certificateEditingId = null;
function attachCertificateId(original = null) {
certificateEditingId = original;
window.rustProxyAutoId.attach($("certificate-id"), { elements: [$("certificate-hosts")], text: () => ($("certificate-hosts").value.split(",").map(v => v.trim()).find(Boolean) || ""), taken: () => (envelope?.config.tls?.certificates || []).map(cert => cert.id).filter(id => id !== original), original, inUse: id => configReferences(id, ["certificate_id", "certificate_ids", "default_certificate"]), renameKey: "idRenameHelpCertificate" });
}
$("certificate-form")?.addEventListener("reset", () => setTimeout(() => attachCertificateId(null)));
attachCertificateId(null);
$("certificate-form").addEventListener("submit", async event => {
event.preventDefault(); const form = event.currentTarget;
if (!envelope || busy) return;
@@ -370,6 +392,13 @@ $("certificate-form").addEventListener("submit", async event => {
hosts: $("certificate-hosts").value.split(",").map(v => v.trim()).filter(Boolean),
cert_file: $("certificate-file").value.trim(), key_file: $("certificate-key").value.trim(),
};
const original = certificateEditingId && next.tls.certificates.some(v => v.id === certificateEditingId) ? certificateEditingId : null;
if (original && original !== cert.id) {
if (next.tls.certificates.some(v => v.id === cert.id)) throw fieldError($("certificate-id"), t("certificateDuplicate"));
if (configReferences(original, ["certificate_id", "certificate_ids", "default_certificate"]).length) throw fieldError($("certificate-id"), t("idRenameLocked"));
next.tls.certificates.find(v => v.id === original).id = cert.id;
if (next.tls.default_certificate === original) next.tls.default_certificate = cert.id;
}
const index = next.tls.certificates.findIndex(v => v.id === cert.id);
if (index >= 0 && next.tls.certificates[index].issuer) throw fieldError($("certificate-id"), t("certManagedReadOnly"));
if (index < 0) next.tls.certificates.push(cert);
+3 -1
View File
@@ -1329,6 +1329,7 @@ dialog .vh-form,
#panel-vhosts .card-heading,
#panel-web-server .card-heading,
#panel-streams .card-heading,
#panel-acl-profiles .card-heading,
.activity-card .card-heading,
.overview-presets-dialog .overview-layout-footer,
.cache-memory-sizing .form-actions {
@@ -1339,7 +1340,8 @@ dialog .vh-form,
#redirect-search,
#vhost-search,
#web-service-search,
#stream-search {
#stream-search,
#acl-profile-search {
width: calc(min(260px, calc(32 * var(--rp-vw))));
min-width: 180px;
}
+38 -5
View File
@@ -1133,7 +1133,7 @@ p,
display: grid;
gap: 14px;
align-items: start;
grid-template-columns: minmax(260px, .72fr) minmax(440px, 1.28fr);
grid-template-columns: minmax(0, 1fr);
}
.host-chip-field>span:first-child {
@@ -1838,10 +1838,6 @@ html[data-dashboard-density=ultra] #panel-overview .dashboard-overview-grid>.car
font: 700 10px var(--mono);
}
.acl-profile-card .entity-details {
white-space: pre-line;
}
.listener-active-summary {
margin-top: 10px;
padding: 10px 12px;
@@ -3099,3 +3095,40 @@ h2+.fine {
.vh-live-summary.vh-live-summary-tab[hidden] {
display: none;
}
.vh-grid>[data-row-start] {
grid-column-start: 1;
}
#acl-profile-list {
display: grid;
gap: 10px;
}
.acl-profile-card .vhost-detail-strip {
grid-template-columns: repeat(4, minmax(0, 1fr));
}
.acl-profile-card .vhost-detail b {
overflow-wrap: anywhere;
}
@media (min-width: 761px) {
.acl-profile-card .vhost-card-head {
align-items: center;
}
}
.acl-profile-dialog {
width: calc((calc(min(1080px, 100vw - 28px))) / var(--ui-scale, 1));
}
.acl-profile-dialog #acl-profile-form>.card-heading {
display: flex;
align-items: center;
gap: 10px;
}
.acl-profile-dialog #acl-profile-form>.card-heading>h2 {
margin: 0 auto 0 0;
}
+14 -1
View File
@@ -844,6 +844,7 @@
#panel-vhosts .card-heading,
.backend-card-heading,
#panel-streams .card-heading,
#panel-acl-profiles .card-heading,
.acl-policy-preview-head,
.acl-policy-step-head {
align-items: stretch;
@@ -859,7 +860,8 @@
#notfound-search,
#redirect-search,
#vhost-search,
#stream-search {
#stream-search,
#acl-profile-search {
flex: 1 1 auto;
width: auto;
min-width: 0;
@@ -1130,6 +1132,7 @@
@media (max-width:760px) {
.redirect-card .vhost-detail-strip,
.acl-profile-card .vhost-detail-strip,
.redirect-rule .vh-grid,
.listener-choices,
.docker-health-grid,
@@ -1983,6 +1986,8 @@
}
.auto-id-hint,
.auto-id-lock,
.auto-id-rename-note,
.auto-cert-hint {
display: block;
margin-top: 3px;
@@ -1999,6 +2004,8 @@
}
.auto-id-hint[hidden],
.auto-id-lock[hidden],
.auto-id-rename-note[hidden],
.auto-cert-hint[hidden],
.auto-id-reset[hidden] {
display: none;
@@ -2014,12 +2021,18 @@
.auto-id-row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
min-height: 32px;
padding: 0 2px;
}
.auto-id-row>.auto-id-lock {
flex: 1 0 100%;
margin-top: -4px;
}
.auto-id-value {
font-family: var(--mono, monospace);
font-size: 13px;
+2 -2
View File
@@ -438,7 +438,7 @@
const remove = action(t("remove"), () => { row.remove(); setSettingsDirty("docker-agents-form"); }), actions = el("div", undefined, "entity-actions docker-agent-heading-actions");
const testWrap = el("span", undefined, "docker-agent-test-wrap"), testButton = el("button", t("dockerTestConnection"), "outline docker-agent-test"), testResult = el("div", "", "docker-agent-test-result"); testButton.type = "button"; testResult.hidden = true; testResult.setAttribute("role", "status"); testWrap.append(testButton, testResult);
actions.append(enabledLabel, stateBadge, testWrap, remove); head.append(title, actions);
const id = input(value.id, "text", "docker-agent-id"); id.maxLength = 64; id.required = true; id.pattern = "[A-Za-z0-9_\\-]{1,64}"; if (agent) id.readOnly = true;
const id = input(value.id, "text", "docker-agent-id"); id.maxLength = 64; id.required = true; id.pattern = "[A-Za-z0-9_\\-]{1,64}";
const name = input(value.name, "text", "docker-agent-name"); name.maxLength = 96; name.required = true;
name.addEventListener("input", () => { titleText.textContent = name.value.trim() || id.value.trim() || t("dockerAgentNew"); });
const endpoint = input(value.endpoint, "url", "docker-agent-endpoint"); endpoint.required = true; endpoint.placeholder = "https://10.0.0.20:9876";
@@ -530,7 +530,7 @@
row.addEventListener("invalid", () => { row.open = true; }, true);
const syncSummary = () => { sumEndpoint.textContent = endpoint.value.trim() || "-"; sumId.textContent = id.value.trim(); };
endpoint.addEventListener("input", () => { updateSecurityBadge(row); syncSummary(); }); fingerprint.addEventListener("input", () => updateSecurityBadge(row)); id.addEventListener("input", syncSummary); updateSecurityBadge(row);
window.rustProxyAutoId.attach(id, { elements: [name], taken: () => [...(cfg().agents || []).map(item => item.id), ...[...document.querySelectorAll("#docker-agent-settings-list .docker-agent-id")].filter(node => node !== id).map(node => node.value.trim())].filter(Boolean) });
window.rustProxyAutoId.attach(id, { elements: [name], taken: () => [...(cfg().agents || []).map(item => item.id), ...[...document.querySelectorAll("#docker-agent-settings-list .docker-agent-id")].filter(node => node !== id).map(node => node.value.trim())].filter(Boolean).filter(value => !agent?.id || value !== agent.id), original: agent?.id || null, inUse: () => [], renameKey: "idRenameHelpDockerAgent" });
return row;
}
function renderSettings() {
+2 -1
View File
@@ -340,7 +340,8 @@ main {
vertical-align: top;
padding: 7px 10px;
border: 1px solid #e0e5ea;
line-height: 1.5
line-height: 1.5;
overflow-wrap: break-word
}
.reader-table th {
+3 -3
View File
@@ -75,8 +75,8 @@
function load(item = defaults()) {
editing = item.id || null; revision = envelope?.revision ?? null; dirty = false;
$("notfound-editing").textContent = editing || t("notfoundNewLabel");
$("notfound-id").value = item.id || ""; $("notfound-id").disabled = Boolean(editing); $("notfound-name").value = item.name || "";
window.rustProxyAutoId.attach($("notfound-id"), { elements: [$("notfound-name")], taken: () => (envelope?.config.not_found_hosts || []).map(value => value.id) });
$("notfound-id").value = item.id || ""; $("notfound-id").disabled = false; $("notfound-name").value = item.name || "";
window.rustProxyAutoId.attach($("notfound-id"), { elements: [$("notfound-name")], taken: () => (envelope?.config.not_found_hosts || []).map(value => value.id).filter(value => value !== editing), original: editing, inUse: () => [], renameKey: "idRenameHelpNotFound" });
$("notfound-enabled").checked = item.enabled !== false; syncEnabledControl(); $("notfound-http2").checked = item.http2_enabled !== false; $("notfound-http3").checked = item.http3_enabled !== false;
const hostHolder = $("notfound-hosts-editor"); hostHolder.replaceChildren(); readHosts = window.rustProxyIntegrations.hostnames(hostHolder, item.frontend?.hosts || [], { labelKey: "notfoundHosts", helpKey: "vhHostsHelp", requiredKey: "notfoundHostsRequired", onChange: () => { changed(); notFoundAutoCertificate?.refresh(); syncSummary(); } });
listenerChoices(item.frontend?.listener_ids || []); certificateChoices(item.certificate_id);
@@ -159,7 +159,7 @@
$("notfound-variant").addEventListener("change", () => chooseKind("cloudflare")); $("notfound-html").addEventListener("input", schedulePreview);
for (const tab of $("notfound-tabs").querySelectorAll("button[data-tab]")) tab.addEventListener("click", () => activateTab(tab.dataset.tab));
$("notfound-id").addEventListener("input", syncSummary);
form.addEventListener("submit", async event => { event.preventDefault(); if (!envelope || busy) return; const invalid = [...form.elements].find(input => input.willValidate && !input.checkValidity()); if (invalid) { invalid.reportValidity(); return; } if (revision !== envelope.revision) { toast(t("stale"), true); return; } try { const item = collect(), next = structuredClone(envelope.config.not_found_hosts || []); if (!editing && next.some(value => value.id === item.id)) throw new Error(t("notfoundDuplicate")); const index = next.findIndex(value => value.id === editing); if (index < 0) next.push(item); else next[index] = item; if (await saveSection("not-found-hosts", next)) { dirty = false; editing = item.id; dialog.close(); render(); } } catch (error) { toast(error.message, true); } });
form.addEventListener("submit", async event => { event.preventDefault(); if (!envelope || busy) return; const invalid = [...form.elements].find(input => input.willValidate && !input.checkValidity()); if (invalid) { invalid.reportValidity(); return; } if (revision !== envelope.revision) { toast(t("stale"), true); return; } try { const item = collect(), next = structuredClone(envelope.config.not_found_hosts || []); if (next.some(value => value.id === item.id && value.id !== editing)) throw new Error(t("notfoundDuplicate")); const index = next.findIndex(value => value.id === editing); if (index < 0) next.push(item); else next[index] = item; if (await saveSection("not-found-hosts", next)) { dirty = false; editing = item.id; dialog.close(); render(); } } catch (error) { toast(error.message, true); } });
$("notfound-new").addEventListener("click", () => { window.rustProxyDrafts.prepare(); load(); }); $("notfound-search").addEventListener("input", render); $("notfound-sort")?.addEventListener("change", event => { listPrefs.sort = event.target.value; void saveListPrefs(); render(); }); $("notfound-sort-direction")?.addEventListener("click", () => { listPrefs.descending = !listPrefs.descending; syncSortDirection(); void saveListPrefs(); render(); }); $("notfound-close").addEventListener("click", closeEditor); $("notfound-reset").addEventListener("click", async () => { if (await allowDiscard()) load(editing ? structuredClone((envelope?.config.not_found_hosts || []).find(item => item.id === editing) || defaults()) : defaults()); }); dialog.addEventListener("cancel", event => { event.preventDefault(); closeEditor(); });
window.rustProxyDrafts.register("notfound", { labelKey: "notfound", isOpen: () => dialog.open, isDirty: () => dirty, suspend: suspendDraft, restore: restoreDraft, close: () => { dirty = false; if (dialog.open) dialog.close(); } });
window.rustProxyNotFound = { render, edit(id) { const item = (envelope?.config.not_found_hosts || []).find(entry => entry.id === id); if (!item) return false; window.rustProxyDrafts.prepare(); load(structuredClone(item)); return true; }, applyPreferences, reset() { dialog.close(); editing = null; revision = null; dirty = false; listPrefs = { sort: "id", descending: false }; list.replaceChildren(); $("notfound-search").value = ""; if ($("notfound-sort")) $("notfound-sort").value = listPrefs.sort; syncSortDirection(); } };
+126 -114
View File
@@ -1098,8 +1098,15 @@
<div class="card-heading">
<div><span class="small-label" data-i18n="aclProfilesReusable">REUSABLE POLICY</span>
<h2 data-i18n="aclProfiles">ACL profiles</h2>
</div><button class="outline" data-i18n="aclProfileNew" id="acl-profile-new"
type="button">New profile</button>
</div>
<div class="vhost-list-tools">
<label class="sr-only" data-i18n="aclProfileSearch" for="acl-profile-search">Search
ACL profiles</label>
<input autocomplete="off" data-i18n-aria="aclProfileSearch"
data-i18n-placeholder="aclProfileSearchPlaceholder" id="acl-profile-search"
type="search" /><button class="outline" data-i18n="aclProfileNew"
id="acl-profile-new" type="button">New profile</button>
</div>
</div>
<div class="entity-list" id="acl-profile-list"></div>
<details id="acl-dns-status" class="acl-profile-attached">
@@ -1111,115 +1118,6 @@
<div id="acl-dns-status-list" class="entity-list" aria-live="polite"></div>
</details>
</article>
<form class="card edit-form" id="acl-profile-form">
<div class="card-heading">
<div><span class="small-label" id="acl-profile-editing"></span>
<h2 data-i18n="aclProfileEditor">Profile configuration</h2>
</div>
</div>
<div class="field-grid">
<label><span data-i18n="aclProfileName">Display name</span><input id="acl-profile-name"
maxlength="96" required /></label>
<label class="auto-id-field"><span data-i18n="aclProfileId">Profile ID</span><input
id="acl-profile-id" maxlength="64" pattern="[A-Za-z0-9_\-]{1,64}"
required /></label>
</div>
<section class="acl-policy-builder" aria-labelledby="acl-policy-mode-label">
<div class="acl-policy-step-head">
<div><span class="acl-policy-step">1</span>
<div><strong id="acl-policy-mode-label" data-i18n="aclProfilePolicyMode">Choose
the base policy</strong>
<p class="fine" data-i18n="aclProfilePolicyModeHelp">Start with a simple
allow-list or block-list. Use custom mode only when you need mixed
allow and deny rules.</p>
</div>
</div>
</div>
<div class="acl-policy-modes" id="acl-profile-mode-options">
<label class="acl-policy-mode-card"><input checked name="acl-profile-mode"
type="radio" value="allow_exceptions" /><span><b
data-i18n="aclProfileModeAllowExceptions">Block by default</b><small
data-i18n="aclProfileModeAllowExceptionsHelp">Allow selected countries
OR selected IP/CIDR ranges.</small></span></label>
<label class="acl-policy-mode-card"><input name="acl-profile-mode" type="radio"
value="block_exceptions" /><span><b
data-i18n="aclProfileModeBlockExceptions">Allow by default</b><small
data-i18n="aclProfileModeBlockExceptionsHelp">Block selected countries
OR selected IP/CIDR ranges.</small></span></label>
<label class="acl-policy-mode-card acl-policy-mode-custom"><input
name="acl-profile-mode" type="radio" value="custom" /><span><b
data-i18n="aclProfileModeCustom">Custom</b><small
data-i18n="aclProfileModeCustomHelp">Control default, country mode and
every IP action manually.</small></span></label>
</div>
<div class="acl-policy-custom-controls" id="acl-profile-custom-controls" hidden>
<label><span data-i18n="aclDefault">Default action</span><select
id="acl-profile-default">
<option data-i18n="deny" value="deny">Deny</option>
<option data-i18n="allow" value="allow">Allow</option>
</select></label>
<label><span data-i18n="vhCountryMode">Country access</span><select
id="acl-profile-country-mode">
<option data-i18n="vhOff" value="off">Off</option>
<option data-i18n="vhCountryBlock" value="block">Block listed countries
</option>
<option data-i18n="vhCountryAllow" value="allow">Allow only listed countries
</option>
</select></label>
</div>
</section>
<section class="acl-policy-builder">
<div class="acl-policy-step-head">
<div><span class="acl-policy-step">2</span>
<div><strong data-i18n="aclProfileCountryExceptions">Country exceptions</strong>
<p class="fine" id="acl-profile-country-help"></p>
</div>
</div><label class="acl-policy-switch"><input class="switch"
id="acl-profile-country-enabled" type="checkbox" /><span
data-i18n="aclProfileUseCountries">Use
countries</span></label>
</div>
<label class="acl-policy-country-list" id="acl-profile-country-field"><span
id="acl-profile-country-label"
data-i18n="vhCountryList">Countries</span><textarea id="acl-profile-countries"
rows="4" maxlength="1024" spellcheck="false"
placeholder="CN&#10;PL"></textarea></label>
</section>
<section class="acl-policy-builder">
<div class="acl-policy-step-head">
<div><span class="acl-policy-step">3</span>
<div><strong data-i18n="aclProfileIpExceptions">IP / CIDR exceptions</strong>
<p class="fine" id="acl-profile-ip-help"></p>
</div>
</div><button class="quiet" data-i18n="aclProfileAddIpException"
id="acl-profile-rule-add" type="button">Add
IP exception</button>
</div>
<div class="acl-profile-rule-rows" id="acl-profile-rule-rows"></div>
<details class="acl-profile-bulk" id="acl-profile-bulk">
<summary data-i18n="aclProfileBulkRules">Paste / import rules</summary>
<label><span data-i18n="aclProfileRules">IP rules — one “allow|deny CIDR” per
line</span><textarea id="acl-profile-rules" rows="6" spellcheck="false"
placeholder="allow 10.0.0.0/8&#10;allow 203.0.113.5/32"></textarea></label>
<p class="fine" data-i18n="aclProfileBulkHelp">Whitespace and invisible Unicode
separators are normalized during import.</p>
<button class="quiet" data-i18n="aclProfileImportRules"
id="acl-profile-import-rules" type="button">Import rules</button>
</details>
</section>
<section class="acl-policy-preview" aria-live="polite">
<div class="acl-policy-preview-head"><span data-i18n="aclProfilePreview">Effective
policy</span><b id="acl-profile-preview-default"></b></div>
<div class="acl-policy-preview-flow" id="acl-profile-preview-flow"></div>
<p class="fine" id="acl-profile-preview-note"></p>
</section>
<p class="fine" data-i18n="aclProfileCombineHelp">Country and IP exceptions use OR inside
this profile. Explicit deny rules and blocked countries win; attached profile, vhost and
location policies must still all pass.</p>
<div class="form-actions"><button class="primary" data-i18n="apply" type="submit">Validate,
save and apply</button><button class="quiet" data-i18n="clear"
id="acl-profile-reset" type="button">Clear</button></div>
</form>
</div>
</section>
@@ -1279,6 +1177,8 @@
data-i18n="certificateFilterAll" type="button">All</button>
<button aria-pressed="false" data-certificate-filter="expiring"
data-i18n="certificateFilterExpiring" type="button">Expiring</button>
<button aria-pressed="false" data-certificate-filter="assigned"
data-i18n="certificateFilterAssigned" type="button">Assigned</button>
<button aria-pressed="false" data-certificate-filter="unassigned"
data-i18n="certificateFilterUnassigned" type="button">Unassigned</button>
</div>
@@ -1451,9 +1351,10 @@
<summary data-i18n="certAdvanced"></summary>
<form class="edit-form" id="certificate-form">
<h3 data-i18n="addCertificate"></h3>
<label data-i18n="certificateId" for="certificate-id"></label><input
id="certificate-id" maxlength="64" pattern="[A-Za-z0-9_.\-]+"
placeholder="app" required="" />
<label class="certificate-id-field" for="certificate-id"><span
data-i18n="certificateId"></span><input id="certificate-id"
maxlength="64" pattern="[A-Za-z0-9_.\-]+" placeholder="app"
required="" /></label>
<label data-i18n="certLegacyNames" for="certificate-hosts"></label><input
id="certificate-hosts" placeholder="app.localhost" />
<label data-i18n="certificateFileSource"
@@ -5516,6 +5417,117 @@ log_errors = On</code></pre>
<article class="card location-help-content" id="location-help-body"></article>
</dialog>
<dialog aria-labelledby="acl-profile-editor-title" class="vhost-dialog acl-profile-dialog" id="acl-profile-dialog">
<form class="card edit-form vh-form" id="acl-profile-form">
<div class="card-heading">
<h2 data-i18n="aclProfileEditor" id="acl-profile-editor-title">Profile configuration</h2><span
class="pill" id="acl-profile-editing"></span><button class="quiet" data-i18n="close"
id="acl-profile-close" type="button">Close</button>
</div>
<div class="field-grid">
<label><span data-i18n="aclProfileName">Display name</span><input id="acl-profile-name"
maxlength="96" required /></label>
<label class="auto-id-field"><span data-i18n="aclProfileId">Profile ID</span><input
id="acl-profile-id" maxlength="64" pattern="[A-Za-z0-9_\-]{1,64}"
required /></label>
</div>
<section class="acl-policy-builder" aria-labelledby="acl-policy-mode-label">
<div class="acl-policy-step-head">
<div><span class="acl-policy-step">1</span>
<div><strong id="acl-policy-mode-label" data-i18n="aclProfilePolicyMode">Choose
the base policy</strong>
<p class="fine" data-i18n="aclProfilePolicyModeHelp">Start with a simple
allow-list or block-list. Use custom mode only when you need mixed
allow and deny rules.</p>
</div>
</div>
</div>
<div class="acl-policy-modes" id="acl-profile-mode-options">
<label class="acl-policy-mode-card"><input checked name="acl-profile-mode"
type="radio" value="allow_exceptions" /><span><b
data-i18n="aclProfileModeAllowExceptions">Block by default</b><small
data-i18n="aclProfileModeAllowExceptionsHelp">Allow selected countries
OR selected IP/CIDR ranges.</small></span></label>
<label class="acl-policy-mode-card"><input name="acl-profile-mode" type="radio"
value="block_exceptions" /><span><b
data-i18n="aclProfileModeBlockExceptions">Allow by default</b><small
data-i18n="aclProfileModeBlockExceptionsHelp">Block selected countries
OR selected IP/CIDR ranges.</small></span></label>
<label class="acl-policy-mode-card acl-policy-mode-custom"><input
name="acl-profile-mode" type="radio" value="custom" /><span><b
data-i18n="aclProfileModeCustom">Custom</b><small
data-i18n="aclProfileModeCustomHelp">Control default, country mode and
every IP action manually.</small></span></label>
</div>
<div class="acl-policy-custom-controls" id="acl-profile-custom-controls" hidden>
<label><span data-i18n="aclDefault">Default action</span><select
id="acl-profile-default">
<option data-i18n="deny" value="deny">Deny</option>
<option data-i18n="allow" value="allow">Allow</option>
</select></label>
<label><span data-i18n="vhCountryMode">Country access</span><select
id="acl-profile-country-mode">
<option data-i18n="vhOff" value="off">Off</option>
<option data-i18n="vhCountryBlock" value="block">Block listed countries
</option>
<option data-i18n="vhCountryAllow" value="allow">Allow only listed countries
</option>
</select></label>
</div>
</section>
<section class="acl-policy-builder">
<div class="acl-policy-step-head">
<div><span class="acl-policy-step">2</span>
<div><strong data-i18n="aclProfileCountryExceptions">Country exceptions</strong>
<p class="fine" id="acl-profile-country-help"></p>
</div>
</div><label class="acl-policy-switch"><input class="switch"
id="acl-profile-country-enabled" type="checkbox" /><span
data-i18n="aclProfileUseCountries">Use
countries</span></label>
</div>
<label class="acl-policy-country-list" id="acl-profile-country-field"><span
id="acl-profile-country-label"
data-i18n="vhCountryList">Countries</span><textarea id="acl-profile-countries"
rows="4" maxlength="1024" spellcheck="false"
placeholder="CN&#10;PL"></textarea></label>
</section>
<section class="acl-policy-builder">
<div class="acl-policy-step-head">
<div><span class="acl-policy-step">3</span>
<div><strong data-i18n="aclProfileIpExceptions">IP / CIDR exceptions</strong>
<p class="fine" id="acl-profile-ip-help"></p>
</div>
</div><button class="quiet" data-i18n="aclProfileAddIpException"
id="acl-profile-rule-add" type="button">Add
IP exception</button>
</div>
<div class="acl-profile-rule-rows" id="acl-profile-rule-rows"></div>
<details class="acl-profile-bulk" id="acl-profile-bulk">
<summary data-i18n="aclProfileBulkRules">Paste / import rules</summary>
<label><span data-i18n="aclProfileRules">IP rules — one “allow|deny CIDR” per
line</span><textarea id="acl-profile-rules" rows="6" spellcheck="false"
placeholder="allow 10.0.0.0/8&#10;allow 203.0.113.5/32"></textarea></label>
<p class="fine" data-i18n="aclProfileBulkHelp">Whitespace and invisible Unicode
separators are normalized during import.</p>
<button class="quiet" data-i18n="aclProfileImportRules"
id="acl-profile-import-rules" type="button">Import rules</button>
</details>
</section>
<section class="acl-policy-preview" aria-live="polite">
<div class="acl-policy-preview-head"><span data-i18n="aclProfilePreview">Effective
policy</span><b id="acl-profile-preview-default"></b></div>
<div class="acl-policy-preview-flow" id="acl-profile-preview-flow"></div>
<p class="fine" id="acl-profile-preview-note"></p>
</section>
<p class="fine" data-i18n="aclProfileCombineHelp">Country and IP exceptions use OR inside
this profile. Explicit deny rules and blocked countries win; attached profile, vhost and
location policies must still all pass.</p>
<div class="form-actions"><button class="primary" data-i18n="apply" type="submit">Validate,
save and apply</button><button class="quiet" data-i18n="vhCancel"
id="acl-profile-reset" type="button">Cancel</button></div>
</form>
</dialog>
<dialog aria-labelledby="redirect-editor-title" class="vhost-dialog" id="redirect-dialog">
<form class="card vh-form" id="redirect-form" novalidate="">
<div class="card-heading">
+1
View File
@@ -132,6 +132,7 @@
const grid = el("div", undefined, "vh-grid"); body.append(grid); const b = item.binding || {};
const id = field(grid, "listener-id", "listenerId", item.id, "text", { required: true, maxLength: 64, pattern: "[A-Za-z0-9_\\-]{1,64}" });
const name = field(grid, "listener-name", "listenerName", item.name, "text", { maxLength: 96 });
window.rustProxyAutoId.attach(id, { elements: [name], taken: () => [...$("named-listener-rows").querySelectorAll('input[name="listener-id"]')].filter(node => node !== id).map(node => node.value.trim()).filter(Boolean), original: fresh ? null : item.id, inUse: value => configReferences(value, ["listener_ids"]), renameKey: "idRenameHelpListener" });
const scope = field(grid, "listener-scope", "listenerScope", item.scope || "internal", "select", { values: [["internal", "listenerInternal"], ["public", "listenerPublic"]] });
const currentAddresses = [b.address, ...(item.additional_addresses || [])].filter(Boolean);
const startupAddress = b.tls ? latestStatus?.listeners?.locked_https : latestStatus?.listeners?.locked_http;
+40 -36
View File
@@ -573,12 +573,12 @@
rules.placeholder = custom ? "allow 10.0.0.0/8\ndeny 10.21.0.0/16" : "10.0.0.0/8\n203.0.113.5";
syncRuleRows(convertRules); renderPreview();
}
function attachAclProfileId() { window.rustProxyAutoId.attach($("acl-profile-id"), { elements: [$("acl-profile-name")], taken: () => (envelope?.config.acl_profiles || []).map(value => value.id) }); }
function attachAclProfileId() { window.rustProxyAutoId.attach($("acl-profile-id"), { elements: [$("acl-profile-name")], taken: () => (envelope?.config.acl_profiles || []).map(value => value.id).filter(value => value !== editing), original: editing, inUse: id => configReferences(id, ["acl_profile_id", "acl_profile_ids"]), renameKey: "idRenameHelpAclProfile" }); }
function clear() {
editing = null; dirty = false; form.reset(); setMode("allow_exceptions"); aclDefault.value = "deny"; countryMode.value = "off"; countryEnabled.checked = false; countriesInput.value = ""; $("acl-profile-id").readOnly = false; attachAclProfileId(); $("acl-profile-editing").textContent = t("aclProfileNew"); renderRuleRows([]); rules.value = ""; syncPolicy();
}
function edit(profile) {
editing = profile.id; dirty = false; $("acl-profile-id").value = profile.id; $("acl-profile-id").readOnly = true; $("acl-profile-name").value = profile.name || profile.id; attachAclProfileId();
editing = profile.id; dirty = false; $("acl-profile-id").value = profile.id; $("acl-profile-id").readOnly = false; $("acl-profile-name").value = profile.name || profile.id; attachAclProfileId();
const cMode = profile.country_access?.mode || "off"; aclDefault.value = profile.acl?.default || (cMode === "allow" ? "deny" : "allow"); countryMode.value = cMode;
countryEnabled.checked = cMode !== "off"; countriesInput.value = (profile.country_access?.countries || []).join("\n");
setMode(inferMode(profile)); renderRuleRows(profile.acl?.rules || []); $("acl-profile-editing").textContent = t("aclProfileEdit"); dirty = false; syncPolicy();
@@ -587,16 +587,6 @@
edit(profile); editing = null; $("acl-profile-id").readOnly = false; $("acl-profile-id").value = ""; $("acl-profile-name").value = ""; attachAclProfileId();
$("acl-profile-editing").textContent = t("aclProfileNew"); dirty = true; $("acl-profile-name").focus();
}
function friendlySummary(profile) {
const mode = inferMode(profile), countries = profile.country_access?.countries || [], rulesList = profile.acl?.rules || [];
if (mode === "allow_exceptions" || mode === "block_exceptions") {
const allowMode = mode === "allow_exceptions", parts = [];
if (countries.length && profile.country_access?.mode !== "off") parts.push(`${t(allowMode ? "aclProfileCountriesShortAllow" : "aclProfileCountriesShortBlock")}: ${countries.join(", ")}`);
if (rulesList.length) parts.push(`${t(allowMode ? "aclProfileIpsShortAllow" : "aclProfileIpsShortBlock")}: ${rulesList.map(rule => rule.network).join(", ")}`);
return [`${t(allowMode ? "aclProfileModeAllowExceptions" : "aclProfileModeBlockExceptions")}`, parts.join(" · ") || t("aclProfilePreviewNoExceptions")];
}
return [`${t("aclProfileModeCustom")}: ${t("aclDefault")} ${t(profile.acl?.default || "allow")}`, `${rulesList.length} ${t("aclProfileIpRulesShort")} · ${t("vhCountryMode")}: ${t(profile.country_access?.mode === "block" ? "vhCountryBlock" : profile.country_access?.mode === "allow" ? "vhCountryAllow" : "vhOff")}`];
}
function refreshTranslations() {
$("acl-profile-editing").textContent = t(editing ? "aclProfileEdit" : "aclProfileNew");
for (const row of ruleRows.children) {
@@ -617,28 +607,32 @@
function render() {
if (!envelope) return;
const profiles = envelope.config.acl_profiles || [], list = $("acl-profile-list");
const cards = profiles.map(profile => {
const box = el("div", undefined, "entity acl-profile-card");
const top = el("div", undefined, "entity-top"); top.append(el("span", profile.name || profile.id, "entity-title"), el("small", profile.id)); box.append(top);
const pieces = friendlySummary(profile);
const usesProfile = value => value.acl_profile_id === profile.id || (value.acl_profile_ids || []).includes(profile.id);
const users = (envelope.config.vhosts || []).filter(usesProfile).map(v => v.id);
for (const agent of envelope.config.docker_agents?.agents || []) {
if (usesProfile(agent)) users.push(`docker-agent:${agent.id}`);
for (const assignment of agent.assignments || []) if (usesProfile(assignment)) users.push(`docker:${agent.id}/${assignment.hostname || assignment.service_key}`);
}
box.append(el("p", pieces.filter(Boolean).join("\n"), "entity-details"));
if (users.length) {
const attached = el("details", undefined, "acl-profile-attached");
attached.append(el("summary", `${t("aclProfileAttached")} (${users.length})`), el("p", users.join(", "), "entity-details"));
box.append(attached);
}
const actions = el("div", undefined, "entity-actions"); actions.append(action(t("edit"), () => edit(profile)), action(t("copyEntry"), () => copyProfile(profile)), action(t("remove"), async () => {
const query = ($("acl-profile-search")?.value || "").trim().toLowerCase();
const usersOf = profile => window.rustProxyConfigReferences(profile.id, ["acl_profile_id", "acl_profile_ids"]);
const shown = profiles.filter(profile => !query || [profile.id, profile.name, ...(profile.acl?.rules || []).map(rule => rule.network), ...(profile.country_access?.countries || []), ...usersOf(profile)].join(" ").toLowerCase().includes(query));
const cards = shown.map(profile => {
const box = el("article", undefined, "vhost-card acl-profile-card acl-profile-row"); box.dataset.aclProfile = profile.id;
const mode = inferMode(profile), users = usersOf(profile), rulesList = profile.acl?.rules || [], countries = profile.country_access?.countries || [];
const head = el("div", undefined, "vhost-card-head"), identity = el("div", undefined, "vhost-card-identity"), title = el("div", undefined, "vhost-title-line");
const modePill = el("span", t(mode === "allow_exceptions" ? "aclProfileModeAllowExceptions" : mode === "block_exceptions" ? "aclProfileModeBlockExceptions" : "aclProfileModeCustom"), `pill${profile.acl?.default === "deny" ? " warn" : " live"}`);
title.append(el("strong", profile.name || profile.id, "entity-title"), modePill, el("span", users.length ? `${t("aclProfileAttached")}: ${users.length}` : t("aclProfileNotUsed"), users.length ? "pill live" : "pill"));
identity.append(title, el("div", profile.id, "vhost-hosts")); head.append(identity);
const actions = el("div", undefined, "entity-actions"); actions.append(action(t("edit"), () => { edit(profile); openEditor(); }), action(t("copyEntry"), () => { copyProfile(profile); openEditor(); }), action(t("remove"), async () => {
if (users.length) { toast(`${t("aclProfileInUse")}: ${users.join(", ")}`, true); return; }
if (!(await appConfirm(t("confirmDelete"), { danger: true }))) return; const next = structuredClone(envelope.config); next.acl_profiles = (next.acl_profiles || []).filter(item => item.id !== profile.id); if (await saveSection("acl-profiles", next.acl_profiles || [])) clear();
})); box.append(actions); return box;
if (!(await appConfirm(t("confirmDelete"), { danger: true }))) return; const next = structuredClone(envelope.config); next.acl_profiles = (next.acl_profiles || []).filter(item => item.id !== profile.id); if (await saveSection("acl-profiles", next.acl_profiles || [])) { if (editing === profile.id && aclDialog?.open) aclDialog.close(); clear(); }
}));
head.append(actions); box.append(head);
const details = el("div", undefined, "vhost-detail-strip");
const countryMode = profile.country_access?.mode || "off";
for (const [key, value] of [
["aclDefault", t(profile.acl?.default === "deny" ? "deny" : "allow")],
["aclProfileIpRulesShort", rulesList.length ? rulesList.map(rule => `${t(rule.action === "deny" ? "aclDeny" : "aclAllow")} ${rule.network}`).join(", ") : "-"],
["vhCountryMode", countryMode === "off" || !countries.length ? "-" : `${t(countryMode === "block" ? "vhCountryBlock" : "vhCountryAllow")}: ${countries.join(", ")}`],
["aclProfileAttached", users.join(", ") || "-"]
]) { const cell = el("div", undefined, "vhost-detail"); const valueNode = el("b", value); valueNode.title = value; cell.append(el("span", t(key), "small-label"), valueNode); details.append(cell); }
box.append(details); return box;
});
list.replaceChildren(...(cards.length ? cards : [el("p", t("aclProfilesEmpty"), "empty")]));
list.replaceChildren(...(cards.length ? cards : [el("p", t(query && profiles.length ? "aclProfileSearchEmpty" : "aclProfilesEmpty"), "empty")]));
if (!dirty && editing) { const current = profiles.find(p => p.id === editing); if (current) edit(current); else clear(); }
}
form.addEventListener("input", event => { dirty = true; if (event.target !== rules) { syncRulesText(); syncPolicy(); } });
@@ -676,12 +670,22 @@
const profile = { id, name, acl: { default: finalDefault, rules: aclRules }, country_access: { mode: finalCountryMode, countries } };
const next = structuredClone(envelope.config); next.acl_profiles ||= [];
const index = next.acl_profiles.findIndex(item => item.id === editing);
if (index < 0) { if (next.acl_profiles.some(item => item.id === id)) throw fieldError($("acl-profile-id"), t("aclProfileDuplicate")); next.acl_profiles.push(profile); } else next.acl_profiles[index] = profile;
if (await saveSection("acl-profiles", next.acl_profiles || [])) { editing = id; dirty = false; render(); }
if (next.acl_profiles.some(item => item.id === id && item.id !== editing)) throw fieldError($("acl-profile-id"), t("aclProfileDuplicate")); if (index < 0) next.acl_profiles.push(profile); else next.acl_profiles[index] = profile;
if (await saveSection("acl-profiles", next.acl_profiles || [])) { dirty = false; editing = null; if (aclDialog?.open) aclDialog.close(); clear(); render(); }
});
} catch (error) { toast(error.message, true); if (error.fieldTarget?.focus) error.fieldTarget.focus(); }
});
$("acl-profile-new").addEventListener("click", clear); $("acl-profile-reset").addEventListener("click", clear);
window.rustProxyAclProfiles = { render, reset: clear, refreshTranslations };
const aclDialog = $("acl-profile-dialog");
function openEditor() { if (aclDialog && !aclDialog.open) aclDialog.showModal(); }
async function closeEditor() {
if (dirty && !(await appConfirm(t("aclProfileUnsaved"), { danger: true, confirmLabel: t("discardAction") }))) return;
dirty = false; if (aclDialog?.open) aclDialog.close(); clear();
}
$("acl-profile-new").addEventListener("click", () => { clear(); openEditor(); $("acl-profile-name").focus(); });
$("acl-profile-search")?.addEventListener("input", () => render());
$("acl-profile-reset").addEventListener("click", () => void closeEditor());
$("acl-profile-close")?.addEventListener("click", () => void closeEditor());
aclDialog?.addEventListener("cancel", event => { event.preventDefault(); void closeEditor(); });
window.rustProxyAclProfiles = { render, reset: () => { dirty = false; if (aclDialog?.open) aclDialog.close(); clear(); }, refreshTranslations };
clear(); if (envelope) render();
})();
+3 -3
View File
@@ -229,9 +229,9 @@
function load(item = defaults()) {
editing = item.id || null; revision = envelope?.revision ?? null; dirty = false;
$("redirect-editing").textContent = editing ? editing : t("redirectNewLabel");
$("redirect-id").value = item.id || ""; $("redirect-id").disabled = Boolean(editing);
$("redirect-id").value = item.id || ""; $("redirect-id").disabled = false;
$("redirect-name").value = item.name || "";
window.rustProxyAutoId.attach($("redirect-id"), { elements: [$("redirect-name")], taken: () => (envelope?.config.redirects || []).map(value => value.id) });
window.rustProxyAutoId.attach($("redirect-id"), { elements: [$("redirect-name")], taken: () => (envelope?.config.redirects || []).map(value => value.id).filter(value => value !== editing), original: editing, inUse: () => [], renameKey: "idRenameHelpRedirect" });
const hostHolder = $("redirect-hosts-editor"); hostHolder.replaceChildren(); readRedirectHosts = window.rustProxyIntegrations.hostnames(hostHolder, item.frontend?.hosts || [], { labelKey: "redirectHosts", helpKey: "vhHostsHelp", requiredKey: "redirectHostsRequired", onChange: () => { changed(); redirectAutoCertificate?.refresh(); syncSummary(); ruleBoxes().forEach(syncRule); } });
$("redirect-enabled").checked = item.enabled !== false; syncEnabledControl(); $("redirect-http2").checked = item.http2_enabled !== false; $("redirect-http3").checked = item.http3_enabled !== false;
listenerChoices(item.frontend?.listener_ids || []); certificateChoices(item.certificate_id);
@@ -326,7 +326,7 @@
event.preventDefault(); if (!envelope || busy) return; const invalid = [...form.elements].find(input => input.willValidate && !input.checkValidity());
if (invalid) { const group = invalid.closest(".vh-group[data-tab]"); if (group) activateTab(group.dataset.tab); const row = invalid.closest("details"); if (row) row.open = true; invalid.reportValidity(); return; }
if (revision !== envelope.revision) { toast(t("stale"), true); return; }
try { const item = collect(), next = structuredClone(envelope.config.redirects || []); if (!editing && next.some(value => value.id === item.id)) throw new Error(t("redirectDuplicate")); const index = next.findIndex(value => value.id === editing); if (index < 0) next.push(item); else next[index] = item; if (await saveSection("redirects", next)) { dirty = false; editing = item.id; dialog.close(); render(); } } catch (error) { toast(error.message, true); }
try { const item = collect(), next = structuredClone(envelope.config.redirects || []); if (next.some(value => value.id === item.id && value.id !== editing)) throw new Error(t("redirectDuplicate")); const index = next.findIndex(value => value.id === editing); if (index < 0) next.push(item); else next[index] = item; if (await saveSection("redirects", next)) { dirty = false; editing = item.id; dialog.close(); render(); } } catch (error) { toast(error.message, true); }
});
for (const tab of $("redirect-tabs").querySelectorAll("button[data-tab]")) tab.addEventListener("click", () => activateTab(tab.dataset.tab));
$("redirect-id").addEventListener("input", syncSummary);
+4 -3
View File
@@ -180,9 +180,10 @@
$("stream-editing").textContent = t(editing ? "streamEditLabel" : "streamNewLabel");
let g = group("streamEditor", "details");
const streamName = field(g, "name", "streamName", value.name, "text", { maxLength: 96 });
const streamIdInput = field(g, "id", "streamId", value.id, "text", { required: true, maxLength: 64, pattern: "[A-Za-z0-9_\\-]{1,64}", readOnly: Boolean(editing) });
window.rustProxyAutoId.attach(streamIdInput, { elements: [streamName], taken: () => (envelope?.config.streams || []).map(item => item.id) });
const streamIdInput = field(g, "id", "streamId", value.id, "text", { required: true, maxLength: 64, pattern: "[A-Za-z0-9_\\-]{1,64}" });
window.rustProxyAutoId.attach(streamIdInput, { elements: [streamName], taken: () => (envelope?.config.streams || []).map(item => item.id).filter(id => id !== editing), original: editing, inUse: () => [], renameKey: "idRenameHelpStream" });
const protocol = field(g, "protocol", "streamProtocol", value.protocol || "tcp", "select", { values: [["tcp", "streamTcp"], ["udp", "streamUdp"]] });
protocol.closest("label")?.setAttribute("data-row-start", "");
const enabledControl = field(g, "enabled", "vhEnabled", value.enabled !== false, "checkbox", { switch: true });
window.rustProxyEnableControl(enabledControl);
const enabledLabel = enabledControl.closest("label");
@@ -373,7 +374,7 @@
if (revision !== envelope.revision) { toast(t("stale"), true); return; }
try {
const value = collect(), next = structuredClone(envelope.config); next.streams ||= [];
if (!editing && next.streams.some(stream => stream.id === value.id)) throw new Error(t("streamDuplicate"));
if (next.streams.some(stream => stream.id === value.id && stream.id !== editing)) throw new Error(t("streamDuplicate"));
if (!editing && next.streams.length >= 128) throw new Error(t("streamLimit"));
const index = next.streams.findIndex(stream => stream.id === editing); if (index < 0) next.streams.push(value); else next.streams[index] = value;
if (await saveSection("streams", next.streams || [])) { dirty = false; load(value, false); dialog.close(); render(); }
+3 -2
View File
@@ -60,10 +60,11 @@ window.rustProxyPhpProfiles = ({ defaults, mapLines, lines, parseFastCgiParams,
input.required = true; input.readOnly = readonly; wrapper.append(input); editor.append(wrapper); return input;
};
const nameInput = namedInput("phpProfileName", profile.name);
const idInput = namedInput("phpProfileId", profile.id, !creating);
const idInput = namedInput("phpProfileId", profile.id);
window.rustProxyAutoId.attach(idInput, {
elements: [nameInput],
taken: () => (envelope?.config.php_fpm_profiles || []).map(item => item.id)
taken: () => (envelope?.config.php_fpm_profiles || []).map(item => item.id).filter(id => creating || id !== profile.id),
original: creating ? null : profile.id, inUse: id => configReferences(id, ["php_profile_id"]), renameKey: "idRenameHelpProfile"
});
if (creating && nameInput.value) nameInput.dispatchEvent(new Event("input"));
idInput.closest("label").append(el("small", t("phpProfileIdHelp"), "fine fastcgi-profile-identity-help"));
+2 -2
View File
@@ -407,9 +407,9 @@
item.hardening = Object.assign(defaults().hardening, item.hardening || {});
editing = value?.id || null;
$("web-service-id").value = item.id || "";
$("web-service-id").readOnly = !!editing;
$("web-service-id").readOnly = false;
$("web-service-name").value = item.name || "";
window.rustProxyAutoId.attach($("web-service-id"), { elements: [$("web-service-name")], taken: () => (envelope?.config.web_services || []).map(value => value.id) });
window.rustProxyAutoId.attach($("web-service-id"), { elements: [$("web-service-name")], taken: () => (envelope?.config.web_services || []).map(value => value.id).filter(value => value !== editing), original: editing || null, inUse: id => configReferences(id, ["web_service_id"]), renameKey: "idRenameHelpWebService" });
$("web-service-root").value = item.document_root || "";
populateSettings(item);
$("web-service-preset").value = "custom";
+20 -10
View File
@@ -308,23 +308,33 @@ pub fn label_publications(
(publications, issues)
}
pub fn assignment_certificate(
agent: &Agent,
assignment: &Assignment,
certificates: &[crate::tls::Certificate],
hosts: &[String],
) -> (Option<String>, bool) {
let certificate_list = agent.certificate_list();
if certificate_list.is_empty() {
(None, false)
} else if let Some(id) = select_certificate(&certificate_list, certificates, hosts) {
(Some(id), false)
} else if assignment.allow_certificate_mismatch {
(certificate_list.first().cloned(), true)
} else {
(None, false)
}
}
fn build_vhost(
agent: &Agent,
assignment: &Assignment,
inventory: Option<&Inventory>,
certificates: &[crate::tls::Certificate],
) -> Result<crate::vhost::Vhost> {
let certificate_list = agent.certificate_list();
let hosts = assignment_hosts(assignment, agent)?;
let (certificate_id, allow_certificate_mismatch) = if certificate_list.is_empty() {
(None, false)
} else if let Some(id) = select_certificate(&certificate_list, certificates, &hosts) {
(Some(id), false)
} else if assignment.allow_certificate_mismatch {
(certificate_list.first().cloned(), true)
} else {
(None, false)
};
let (certificate_id, allow_certificate_mismatch) =
assignment_certificate(agent, assignment, certificates, &hosts);
let target = inventory
.and_then(|inventory| {
inventory