v0.43.0
This commit is contained in:
1 parent
9a6c21fa04
commit
5b6d4a7903
41 files changed
+3299
-677
No files matched your search
@@ -16457,6 +16457,106 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/pages/preview": {
|
||||
"get": {
|
||||
"summary": "Preview a local page (404 hosts) as the proxy would render it",
|
||||
"tags": [
|
||||
"Configuration"
|
||||
],
|
||||
"operationId": "get_api_pages_preview",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "kind",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"welcome",
|
||||
"empty",
|
||||
"html",
|
||||
"builtin",
|
||||
"cloudflare",
|
||||
"cloudflare_welcome",
|
||||
"cloudflare_placeholder"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "status",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 200,
|
||||
"maximum": 599,
|
||||
"default": 404
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "host",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"description": "404 host ID; with kind=html previews that host's saved custom HTML",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "slot",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"description": "With kind=html: saved default response to preview — direct_ip, unknown_host, response, fallback or error-<code>",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "vhost",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"description": "With slot: read the per-vhost default responses of this vhost instead of the global ones",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Rendered page body, served with a sandbox Content-Security-Policy (opaque origin, no scripts) and framing limited to the panel",
|
||||
"content": {
|
||||
"text/html": {
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"text/plain": {
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Invalid kind or status"
|
||||
},
|
||||
"401": {
|
||||
"description": "Authentication required"
|
||||
},
|
||||
"403": {
|
||||
"description": "Invalid origin"
|
||||
},
|
||||
"404": {
|
||||
"description": "No saved custom HTML for this 404 host or default response"
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"AdminSession": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/certificate-api/{key_id}/regenerate": {
|
||||
"post": {
|
||||
"summary": "Regenerate an existing bearer token, preserving its settings and Key ID",
|
||||
|
||||
@@ -337,3 +337,82 @@ struct CertificateDeploy {
|
||||
cert_pem: String,
|
||||
key_pem: String,
|
||||
}
|
||||
|
||||
/// Query for the local page preview used by the 404 host editor.
|
||||
#[derive(Default, Deserialize)]
|
||||
#[serde(default, deny_unknown_fields)]
|
||||
struct PagePreviewQuery {
|
||||
kind: String,
|
||||
status: Option<u16>,
|
||||
/// 404 host ID whose saved custom HTML is previewed.
|
||||
host: Option<String>,
|
||||
/// Saved custom HTML of a default response: `direct_ip`, `unknown_host`,
|
||||
/// `response`, `fallback` or `error-<code>`; with `vhost` for per-vhost pages.
|
||||
slot: Option<String>,
|
||||
vhost: Option<String>,
|
||||
}
|
||||
|
||||
/// Renders a built-in local page (or the saved custom HTML of a 404 host)
|
||||
/// exactly as `Page::render` serves it. The session guard sends this response
|
||||
/// with a sandbox CSP, so the document runs in an opaque origin without
|
||||
/// scripts and may only be framed by the panel itself.
|
||||
async fn page_preview(
|
||||
State(state): State<Arc<App>>,
|
||||
Query(query): Query<PagePreviewQuery>,
|
||||
) -> Result<Response, ApiError> {
|
||||
let kind: crate::pages::Kind = serde_json::from_value(Value::String(query.kind.clone()))
|
||||
.map_err(|_| ApiError(StatusCode::BAD_REQUEST, "invalid page kind".into()))?;
|
||||
let html = if matches!(kind, crate::pages::Kind::Html) {
|
||||
let snapshot = state.config.load_full();
|
||||
let config = &snapshot.envelope.config;
|
||||
let saved = if let Some(id) = query.host.as_deref() {
|
||||
config
|
||||
.not_found_hosts
|
||||
.iter()
|
||||
.find(|host| host.id == id)
|
||||
.map(|host| &host.page)
|
||||
} else {
|
||||
let slot = query.slot.as_deref().unwrap_or_default();
|
||||
let error = slot
|
||||
.strip_prefix("error-")
|
||||
.and_then(|code| code.parse::<u16>().ok());
|
||||
match query.vhost.as_deref() {
|
||||
Some(id) => config.vhosts.iter().find(|vhost| vhost.id == id).and_then(|vhost| {
|
||||
match (slot, error) {
|
||||
("response", _) => vhost.pages.response.as_ref(),
|
||||
("fallback", _) => vhost.pages.fallback.as_ref(),
|
||||
(_, Some(code)) => vhost.pages.errors.get(&code),
|
||||
_ => None,
|
||||
}
|
||||
}),
|
||||
None => match (slot, error) {
|
||||
("direct_ip", _) => config.pages.direct_ip.as_ref(),
|
||||
("unknown_host", _) => config.pages.unknown_host.as_ref(),
|
||||
(_, Some(code)) => config.pages.errors.get(&code),
|
||||
_ => None,
|
||||
},
|
||||
}
|
||||
};
|
||||
saved
|
||||
.filter(|page| matches!(page.kind, crate::pages::Kind::Html))
|
||||
.map(|page| page.html.clone())
|
||||
.ok_or_else(|| ApiError(StatusCode::NOT_FOUND, "saved custom page not found".into()))?
|
||||
} else {
|
||||
String::new()
|
||||
};
|
||||
let page = crate::pages::Page {
|
||||
kind,
|
||||
status: Some(query.status.unwrap_or(404)),
|
||||
html,
|
||||
};
|
||||
page.validate_local_response()
|
||||
.map_err(|error| ApiError(StatusCode::BAD_REQUEST, error.to_string()))?;
|
||||
let mut response = page.render(StatusCode::NOT_FOUND);
|
||||
*response.status_mut() = StatusCode::OK;
|
||||
response.extensions_mut().insert(PagePreview);
|
||||
Ok(response)
|
||||
}
|
||||
|
||||
/// Marks a sandboxed page preview for the session guard.
|
||||
#[derive(Clone, Copy)]
|
||||
struct PagePreview;
|
||||
@@ -187,6 +187,7 @@ pub fn router(state: Arc<App>) -> Router {
|
||||
.route("/api/acl/dns-status", get(dns_acl_status))
|
||||
.route("/api/web-services/htaccess-warnings", get(web_service_htaccess_warnings))
|
||||
.route("/api/system-info", get(system_info))
|
||||
.route("/api/pages/preview", get(page_preview))
|
||||
.route("/api/backends", get(backend_status))
|
||||
.route("/api/alerts", get(alerts_status))
|
||||
.route("/api/docker", get(docker_status))
|
||||
|
||||
@@ -406,6 +406,15 @@ async fn guard(State(state): State<Arc<App>>, mut request: Request, next: Next)
|
||||
}
|
||||
}
|
||||
}
|
||||
if response.extensions().get::<PagePreview>().is_some() && response.status().is_success() {
|
||||
// Rendered page previews may contain operator HTML: no scripts, an
|
||||
// opaque origin, and framing only by the panel itself.
|
||||
response.headers_mut().insert("content-security-policy", HeaderValue::from_static(
|
||||
"sandbox; default-src 'none'; style-src 'unsafe-inline'; img-src data:; font-src data:; base-uri 'none'; form-action 'none'; frame-ancestors 'self'"));
|
||||
response
|
||||
.headers_mut()
|
||||
.insert("x-frame-options", HeaderValue::from_static("SAMEORIGIN"));
|
||||
}
|
||||
if matches!(path.as_str(), "/docs" | "/docs/") && response.status().is_success() {
|
||||
response.headers_mut().insert("content-security-policy", HeaderValue::from_static(
|
||||
"default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; connect-src 'self'; img-src 'self' data:; font-src 'self'; object-src 'none'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'"));
|
||||
|
||||
@@ -3859,6 +3859,102 @@ mod tests {
|
||||
assert!(newest_log_files(std::iter::once(("x".into(), "x".into(), 1)), 0).is_empty());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn page_preview_is_sandboxed_and_reads_only_saved_custom_html() {
|
||||
let mut config = config::demo_config("127.0.0.1:9000".parse().unwrap());
|
||||
config.not_found_hosts = serde_json::from_value(json!([{
|
||||
"id":"custom",
|
||||
"frontend":{"hosts":["custom.localhost"],"listener_ids":["http"]},
|
||||
"page":{"kind":"html","status":404,"html":"<h1>Saved page</h1><script>alert(1)</script>"}
|
||||
}, {
|
||||
"id":"parked",
|
||||
"frontend":{"hosts":["parked.localhost"],"listener_ids":["http"]},
|
||||
"page":{"kind":"cloudflare","status":404}
|
||||
}]))
|
||||
.unwrap();
|
||||
config.pages.unknown_host = Some(crate::pages::Page {
|
||||
kind: crate::pages::Kind::Html,
|
||||
status: Some(404),
|
||||
html: "<p>Global unknown host</p>".into(),
|
||||
});
|
||||
config.pages.errors.insert(
|
||||
502,
|
||||
crate::pages::Page {
|
||||
kind: crate::pages::Kind::Html,
|
||||
status: None,
|
||||
html: "<p>Global 502</p>".into(),
|
||||
},
|
||||
);
|
||||
let vhost_id = config.vhosts[0].id.clone();
|
||||
config.vhosts[0].pages.fallback = Some(crate::pages::Page {
|
||||
kind: crate::pages::Kind::Html,
|
||||
status: Some(404),
|
||||
html: "<p>Vhost fallback</p>".into(),
|
||||
});
|
||||
let (router, _store, _dir, secret, _) = fixture_with_config(config).await;
|
||||
let cookie = format!("{}={secret}", auth::COOKIE_NAME);
|
||||
let get = |path: &str, authenticated: bool| {
|
||||
let mut builder = request(path);
|
||||
if authenticated {
|
||||
builder = builder.header("cookie", &cookie);
|
||||
}
|
||||
router.clone().oneshot(builder.body(Body::empty()).unwrap())
|
||||
};
|
||||
let anonymous = get("/api/pages/preview?kind=welcome", false).await.unwrap();
|
||||
assert_eq!(anonymous.status(), StatusCode::UNAUTHORIZED);
|
||||
for path in [
|
||||
"/api/pages/preview?kind=welcome",
|
||||
"/api/pages/preview?kind=cloudflare&status=410",
|
||||
"/api/pages/preview?kind=builtin&status=503",
|
||||
"/api/pages/preview?kind=cloudflare_placeholder",
|
||||
"/api/pages/preview?kind=html&host=custom&status=404",
|
||||
] {
|
||||
let response = get(path, true).await.unwrap();
|
||||
assert_eq!(response.status(), StatusCode::OK, "{path}");
|
||||
let csp = response.headers()["content-security-policy"].to_str().unwrap();
|
||||
assert!(csp.starts_with("sandbox;"), "{path}: {csp}");
|
||||
assert!(!csp.contains("script-src"), "{path}: {csp}");
|
||||
assert!(csp.contains("frame-ancestors 'self'"), "{path}: {csp}");
|
||||
assert_eq!(response.headers()["x-frame-options"], "SAMEORIGIN");
|
||||
assert_eq!(
|
||||
response.headers()["cache-control"],
|
||||
"private, no-store, no-cache, no-transform"
|
||||
);
|
||||
let body = axum::body::to_bytes(response.into_body(), 256 * 1024)
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(!body.is_empty(), "{path}");
|
||||
if path.contains("kind=html") {
|
||||
assert!(String::from_utf8_lossy(&body).contains("Saved page"));
|
||||
}
|
||||
}
|
||||
for (path, expected) in [
|
||||
("/api/pages/preview?kind=html&slot=unknown_host".to_string(), "Global unknown host"),
|
||||
("/api/pages/preview?kind=html&slot=error-502&status=502".to_string(), "Global 502"),
|
||||
(format!("/api/pages/preview?kind=html&vhost={vhost_id}&slot=fallback"), "Vhost fallback"),
|
||||
] {
|
||||
let response = get(&path, true).await.unwrap();
|
||||
assert_eq!(response.status(), StatusCode::OK, "{path}");
|
||||
assert!(response.headers()["content-security-policy"].to_str().unwrap().starts_with("sandbox;"));
|
||||
let body = axum::body::to_bytes(response.into_body(), 256 * 1024).await.unwrap();
|
||||
assert!(String::from_utf8_lossy(&body).contains(expected), "{path}");
|
||||
}
|
||||
for (path, status) in [
|
||||
("/api/pages/preview?kind=html&slot=direct_ip", StatusCode::NOT_FOUND),
|
||||
("/api/pages/preview?kind=html&slot=error-404", StatusCode::NOT_FOUND),
|
||||
("/api/pages/preview?kind=html&vhost=missing&slot=fallback", StatusCode::NOT_FOUND),
|
||||
("/api/pages/preview?kind=html&host=parked", StatusCode::NOT_FOUND),
|
||||
("/api/pages/preview?kind=html&host=missing", StatusCode::NOT_FOUND),
|
||||
("/api/pages/preview?kind=html", StatusCode::NOT_FOUND),
|
||||
("/api/pages/preview?kind=bogus", StatusCode::BAD_REQUEST),
|
||||
("/api/pages/preview?kind=welcome&status=99", StatusCode::BAD_REQUEST),
|
||||
("/api/pages/preview?kind=welcome&extra=1", StatusCode::BAD_REQUEST),
|
||||
] {
|
||||
let response = get(path, true).await.unwrap();
|
||||
assert_eq!(response.status(), status, "{path}");
|
||||
assert_eq!(response.headers()["x-frame-options"], "DENY", "{path}");
|
||||
}
|
||||
}
|
||||
#[tokio::test]
|
||||
async fn system_info_and_compact_live_status_reuse_existing_admin_session() {
|
||||
let (router, store, _dir, secret, _) = fixture().await;
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
$("certificate-acme-editor").hidden = !acme;
|
||||
$("certificate-upload-form").hidden = provider !== "import";
|
||||
$("certificate-advanced").hidden = provider !== "existing";
|
||||
$("certificate-provider-hint").textContent = t(`providerHint_${provider}`);
|
||||
const hint = $("certificate-provider-hint"); hint.dataset.i18n = `providerHint_${provider}`; hint.textContent = t(hint.dataset.i18n);
|
||||
for (const node of document.querySelectorAll("[data-acme-provider]")) {
|
||||
const visible = acme && (node.dataset.acmeProvider === provider || (node.dataset.acmeProvider === "dns" && provider !== "http01"));
|
||||
node.hidden = !visible;
|
||||
|
||||
@@ -119,6 +119,8 @@ function clearFormFieldErrors(form) { form?.querySelectorAll(".field-invalid,[ar
|
||||
function showFieldError(error, form = null) {
|
||||
let target = error?.fieldTarget; if (typeof target === "string") target = $(target);
|
||||
if (!target || (form && !form.contains(target))) return false;
|
||||
for (let holder = target.closest?.("details"); holder; holder = holder.parentElement?.closest("details")) holder.open = true;
|
||||
target.closest?.(".listener-card.is-collapsed")?.querySelector(".listener-card-head")?.click();
|
||||
const focusTarget = target.matches?.("input,select,textarea,button") ? target : target.querySelector?.("input,select,textarea,button");
|
||||
target.classList?.add("field-invalid"); target.setAttribute?.("aria-invalid", "true");
|
||||
const clear = () => clearFieldError(target); target.addEventListener?.("input", clear, { once: true }); target.addEventListener?.("change", clear, { once: true });
|
||||
@@ -517,7 +519,7 @@ function parseRules(text, target = null) {
|
||||
}
|
||||
function renderConfig() {
|
||||
if (!envelope) return; window.rustProxyCachePanel?.configure(); renderCertificates(); renderSettings(); window.rustProxyPages?.render(); window.rustProxyAclProfiles?.render(); window.rustProxyVhosts?.render(); window.rustProxyWebServer?.render(); window.rustProxyDocker?.render(); window.rustProxyRedirects?.render(); window.rustProxyNotFound?.render(); window.rustProxyStreams?.render(); const config = envelope.config; if (!settingsDirty.has("config-editor")) $("config-editor").value = JSON.stringify(config, null, 2);
|
||||
$("host-policy-list").replaceChildren(...(config.host_policies || []).map((policy, index) => { const box = el("div", undefined, "entity"); box.append(el("span", policy.hosts.join(", "), "entity-title"), el("p", `${t("aclDefault")}: ${t(policy.acl.default || "deny")}\n${rulesText(policy.acl)}`, "entity-details")); const buttons = el("div", undefined, "entity-actions"); buttons.append(action(t("edit"), () => { $("policy-hosts").value = policy.hosts.join(", "); $("policy-default").value = policy.acl.default || "deny"; $("policy-rules").value = rulesText(policy.acl); const editor = $("security-policy-editor"); if (editor) { editor.open = true; editor.scrollIntoView({ block: "nearest" }); } }), action(t("remove"), async () => { if (await appConfirm(t("confirmDelete"), { danger: true })) { const next = structuredClone(config); next.host_policies.splice(index, 1); await saveSection("host-policies", next.host_policies); } })); box.append(buttons); return box; }));
|
||||
$("host-policy-list").replaceChildren(...(config.host_policies || []).map((policy, index) => { const box = el("div", undefined, "entity"); box.append(el("span", policy.hosts.join(", "), "entity-title"), el("p", `${t("aclDefault")}: ${t(policy.acl.default || "deny")}\n${rulesText(policy.acl)}`, "entity-details")); const buttons = el("div", undefined, "entity-actions"); buttons.append(action(t("edit"), () => { $("policy-hosts").value = policy.hosts.join(", "); $("policy-default").value = policy.acl.default || "deny"; $("policy-rules").value = rulesText(policy.acl); window.rustProxySecurityPage?.syncPolicy(); const editor = $("security-policy-editor"); if (editor) { editor.open = true; editor.scrollIntoView({ block: "nearest" }); } }), action(t("remove"), async () => { if (await appConfirm(t("confirmDelete"), { danger: true })) { const next = structuredClone(config); next.host_policies.splice(index, 1); await saveSection("host-policies", next.host_policies); } })); box.append(buttons); return box; }));
|
||||
if (!config.host_policies?.length) $("host-policy-list").append(el("p", t("noPolicies"), "empty"));
|
||||
if ($("security-policy-count")) $("security-policy-count").textContent = String((config.host_policies || []).length);
|
||||
}
|
||||
|
||||
@@ -230,6 +230,7 @@ function setCacheColdPresetSelection(kind) {
|
||||
if (badge) badge.textContent = `${t("cachePresetSelected")}: ${selectedCacheColdPreset ? t("cachePresetRecommended") : t("cachePresetCustom")}`;
|
||||
}
|
||||
function updateCacheMemorySizing() {
|
||||
window.rustProxySettingsFlow?.renderCache?.();
|
||||
const detected = effectiveCacheMemory(), badge = $("cache-memory-detected"), warning = $("cache-memory-warning");
|
||||
if (!badge || !warning) return;
|
||||
const buttons = document.querySelectorAll("[data-cache-memory-preset]");
|
||||
@@ -311,6 +312,7 @@ function setTransformPresetSelection(kind) {
|
||||
if (badge) badge.textContent = `${t("cachePresetSelected")}: ${transformPresetName(selectedTransformPreset)}`;
|
||||
}
|
||||
function updateTransformResourceSizing() {
|
||||
window.rustProxySettingsFlow?.renderTransform?.();
|
||||
const warning = $("transform-memory-warning"); if (!warning) return;
|
||||
const memoryMiB = Number($("transform-memory-budget")?.value), bodyKiB = Number($("transform-max-body")?.value), inflight = Number($("transform-max-inflight")?.value);
|
||||
const detected = effectiveCacheMemory();
|
||||
|
||||
@@ -687,24 +687,28 @@ html[data-chart-style] {
|
||||
}
|
||||
|
||||
html[data-corner-style=square] {
|
||||
--rp-radius-nested: 0px;
|
||||
--rp-radius-surface: 0px;
|
||||
--rp-radius-control: 0px;
|
||||
--rp-progress-radius: 0px;
|
||||
}
|
||||
|
||||
html[data-corner-style=subtle] {
|
||||
--rp-radius-nested: 3px;
|
||||
--rp-radius-surface: 5px;
|
||||
--rp-radius-control: 4px;
|
||||
--rp-progress-radius: 2px;
|
||||
}
|
||||
|
||||
html[data-corner-style=rounded] {
|
||||
--rp-radius-nested: 6px;
|
||||
--rp-radius-surface: 12px;
|
||||
--rp-radius-control: 8px;
|
||||
--rp-progress-radius: 4px;
|
||||
}
|
||||
|
||||
html[data-corner-style=extra] {
|
||||
--rp-radius-nested: 8px;
|
||||
--rp-radius-surface: 18px;
|
||||
--rp-radius-control: 12px;
|
||||
--rp-progress-radius: 999px;
|
||||
|
||||
+299
-31
@@ -146,7 +146,8 @@ html[data-interface-icons="true"] .nav>span:first-of-type,
|
||||
.web-service-page[hidden],
|
||||
.settings-page[hidden],
|
||||
#panel-tls .certificate-page[hidden],
|
||||
#panel-tls .certificate-editor-card[hidden] {
|
||||
#panel-tls .certificate-editor-card[hidden],
|
||||
.check[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
@@ -832,15 +833,273 @@ progress::-moz-progress-bar {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.pages-editors {
|
||||
border-top: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.page-editor {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(105px, .9fr) minmax(115px, 1fr) minmax(105px, 1fr);
|
||||
gap: 6px;
|
||||
align-items: center;
|
||||
padding: 7px 0;
|
||||
min-width: 0;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.page-editor-summary {
|
||||
display: grid;
|
||||
grid-template-columns: 10px minmax(0, 1fr) minmax(0, max-content);
|
||||
align-items: center;
|
||||
gap: 4px 10px;
|
||||
width: 100%;
|
||||
min-height: 0;
|
||||
height: auto;
|
||||
padding: 9px 10px;
|
||||
border: 0;
|
||||
border-radius: 0 !important;
|
||||
background: transparent;
|
||||
color: var(--text);
|
||||
font: inherit;
|
||||
text-align: left;
|
||||
white-space: normal;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.page-editor-summary:hover {
|
||||
background: var(--panel2);
|
||||
}
|
||||
|
||||
.page-editor-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border: 1px solid var(--muted);
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.page-editor.is-custom .page-editor-dot {
|
||||
border-color: var(--green);
|
||||
background: var(--green);
|
||||
}
|
||||
|
||||
.page-editor.is-previewed>.page-editor-summary {
|
||||
background: var(--panel2);
|
||||
box-shadow: inset 3px 0 0 var(--accent);
|
||||
}
|
||||
|
||||
.page-editor-head {
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.page-editor-head .page-label {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.page-when {
|
||||
margin: 0;
|
||||
color: var(--muted);
|
||||
font-size: 11.5px;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.pages-errors>.page-when {
|
||||
margin: 0 0 8px;
|
||||
}
|
||||
|
||||
.page-editor-badges {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-end;
|
||||
gap: 4px;
|
||||
max-width: 260px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.page-kind-pill,
|
||||
.page-status-pill {
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.page-kind-pill:not(.live) {
|
||||
border-color: var(--line);
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.page-status-pill[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.page-editor-controls {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
padding: 4px 10px 12px 30px;
|
||||
background: var(--panel2);
|
||||
box-shadow: inset 3px 0 0 var(--accent);
|
||||
}
|
||||
|
||||
.page-editor-controls[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.page-kind-chips {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.page-kind-chips>.page-kind-chip {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.page-kind-chip {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-height: 30px;
|
||||
padding: 4px 11px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--rp-radius-control, 0px);
|
||||
background: var(--panel);
|
||||
color: var(--text);
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.page-kind-chip input {
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.page-kind-chip:hover {
|
||||
border-color: var(--muted);
|
||||
}
|
||||
|
||||
.page-kind-chip.is-selected {
|
||||
border-color: var(--accent);
|
||||
box-shadow: inset 0 0 0 1px var(--accent);
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.page-kind-chip:has(input:focus-visible) {
|
||||
outline: 2px solid var(--accent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.page-kind-help {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.page-editor-fields {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(190px, 260px));
|
||||
gap: 8px 12px;
|
||||
}
|
||||
|
||||
.page-variant-field[hidden],
|
||||
.page-mode[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
:is(.page-variant-field, .page-status-field) {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.pages-workspace {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
|
||||
gap: 14px;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.pages-editors {
|
||||
display: grid;
|
||||
align-content: start;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.page-preview-pane {
|
||||
position: sticky;
|
||||
top: 10px;
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
padding: 10px;
|
||||
border: 1px solid var(--line);
|
||||
background: var(--bg);
|
||||
}
|
||||
|
||||
.page-preview-head {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px 8px;
|
||||
}
|
||||
|
||||
.page-preview-head strong {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.page-preview-open {
|
||||
margin-left: auto;
|
||||
color: var(--accent);
|
||||
font-size: 11px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.page-preview-open::after {
|
||||
content: " ↗";
|
||||
}
|
||||
|
||||
.page-preview-open[hidden],
|
||||
.page-preview-pane iframe[hidden],
|
||||
.page-preview-note[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.page-preview-pane iframe {
|
||||
width: 100%;
|
||||
height: 380px;
|
||||
border: 1px solid var(--line);
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.page-preview-note {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#global-pages-fields,
|
||||
.vh-pages-grid {
|
||||
container-type: inline-size;
|
||||
}
|
||||
|
||||
@container (max-width: 820px) {
|
||||
.pages-workspace {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.page-preview-pane {
|
||||
position: static;
|
||||
}
|
||||
|
||||
.page-editor-summary {
|
||||
grid-template-columns: 10px minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.page-editor-badges {
|
||||
grid-column: 2;
|
||||
justify-content: flex-start;
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.page-editor-controls {
|
||||
padding-left: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.page-label {
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
@@ -882,14 +1141,23 @@ progress::-moz-progress-bar {
|
||||
|
||||
|
||||
.pages-errors {
|
||||
margin: 12px 0;
|
||||
margin: 14px 0 6px;
|
||||
}
|
||||
|
||||
.pages-errors>summary {
|
||||
font-size: 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 6px 0;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.pages-errors .page-editor-list {
|
||||
border-top: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.window-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -1749,23 +2017,27 @@ html[data-interface-icons="true"] :is(button, a, summary)>svg.ui-icon {
|
||||
}
|
||||
|
||||
#php-fpm-profiles-list .fastcgi-profile-summary {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 6px 8px;
|
||||
cursor: pointer;
|
||||
padding: 4px 6px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
#php-fpm-profiles-list .fastcgi-profile-endpoint {
|
||||
flex: 1 1 100%;
|
||||
color: var(--muted);
|
||||
font: 11px var(--mono);
|
||||
}
|
||||
|
||||
#php-fpm-profiles-list .fastcgi-profile-title {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
#php-fpm-profiles-list .fastcgi-profile-handler {
|
||||
display: inline-block;
|
||||
margin-inline-start: 12px;
|
||||
padding: 1px 6px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--rp-radius-control, 3px);
|
||||
color: var(--muted);
|
||||
font-size: 10px;
|
||||
#php-fpm-profiles-list .fastcgi-profile-title {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
#php-fpm-profiles-list details[open]>.fastcgi-profile-summary {
|
||||
@@ -1774,26 +2046,31 @@ html[data-interface-icons="true"] :is(button, a, summary)>svg.ui-icon {
|
||||
}
|
||||
|
||||
#php-fpm-profiles-list .fastcgi-profile-editor {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: 10px;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
#php-fpm-profiles-list .fastcgi-profile-editor>label {
|
||||
#php-fpm-profiles-list .fastcgi-profile-section>.vh-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
#php-fpm-profiles-list .fastcgi-profile-section label {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
grid-row: auto;
|
||||
}
|
||||
|
||||
#php-fpm-profiles-list .fastcgi-profile-editor>label> :is(input, select, textarea) {
|
||||
#php-fpm-profiles-list .fastcgi-profile-section label> :is(input, select, textarea) {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
#php-fpm-profiles-list .fastcgi-profile-editor>label.fastcgi-profile-identity {
|
||||
#php-fpm-profiles-list .fastcgi-profile-section label.fastcgi-profile-identity {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
@@ -1814,23 +2091,14 @@ html[data-interface-icons="true"] :is(button, a, summary)>svg.ui-icon {
|
||||
}
|
||||
|
||||
|
||||
#php-fpm-profiles-list .fastcgi-profile-editor .fastcgi-profile-php-heading {
|
||||
padding-top: 6px;
|
||||
border-top: 1px solid var(--line);
|
||||
}
|
||||
|
||||
#php-fpm-profiles-list .fastcgi-profile-editor .fastcgi-profile-php-heading strong {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.fastcgi-php-only-local[hidden],
|
||||
#php-fpm-profiles-list .fastcgi-php-only[hidden],
|
||||
#php-fpm-profiles-list .fastcgi-profile-php-heading[hidden] {
|
||||
#php-fpm-profiles-list .fastcgi-profile-section[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
@media (max-width: 650px) {
|
||||
#php-fpm-profiles-list .fastcgi-profile-editor {
|
||||
#php-fpm-profiles-list .fastcgi-profile-section>.vh-grid {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
}
|
||||
@@ -609,11 +609,6 @@ html[data-theme=cream] :is(.card, .stat, dialog) {
|
||||
font: 10px var(--mono);
|
||||
}
|
||||
|
||||
.redirect-rule legend {
|
||||
padding: 0 .4rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.traffic-protocol-legend {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
@@ -1333,11 +1328,6 @@ html[data-chart-style] :is(#workspace, dialog) svg polyline {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.stream-backend-row>legend {
|
||||
font-weight: 650;
|
||||
padding: 0 .35rem;
|
||||
}
|
||||
|
||||
.dashboard-widget-toggle:focus-visible,
|
||||
.file-log-tab:focus-visible {
|
||||
outline: 2px solid var(--accent);
|
||||
@@ -2056,11 +2046,44 @@ html:is([data-corner-style=square], [data-corner-style=subtle], [data-corner-sty
|
||||
border-radius: var(--rp-radius-surface) !important;
|
||||
}
|
||||
|
||||
html:is([data-corner-style=square], [data-corner-style=subtle], [data-corner-style=rounded], [data-corner-style=extra]) :is(button:not(.nav):not(.file-log-tab):not(.vhost-backend-trigger):not(.location-tab), input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea, .pill, .vhost-backend-protocol-badge, .overview-widget-type, .quiet, .outline, .primary, .code, .command, .dashboard-widget-toggle, .settings-tabs button, .overview-inline-restore),
|
||||
html:is([data-corner-style=square], [data-corner-style=subtle], [data-corner-style=rounded], [data-corner-style=extra]) :is(button:not(.nav):not(.file-log-tab):not(.vhost-backend-trigger):not(.location-tab):not(.draft-dock-open):not(.draft-dock-remove), input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea, .pill, .vhost-backend-protocol-badge, .overview-widget-type, .quiet, .outline, .primary, .code, .command, .dashboard-widget-toggle, .settings-tabs button, .overview-inline-restore),
|
||||
html:is([data-corner-style=square], [data-corner-style=subtle], [data-corner-style=rounded], [data-corner-style=extra]) :is(.nav, .file-log-tab, .vhost-backend-trigger, .backend-column-options, .docker-service-quick-actions a, .docker-service-quick-actions button, .docker-view-toggle, .provider-picker, .renewal-meta-item) {
|
||||
border-radius: var(--rp-radius-control) !important;
|
||||
}
|
||||
|
||||
/* Corner style coverage for editor/settings surfaces that have no radius of their own. */
|
||||
html:is([data-corner-style=square], [data-corner-style=subtle], [data-corner-style=rounded], [data-corner-style=extra]) :is(.acl-policy-mode-card, .acl-policy-builder, .acl-policy-preview, .settings-shortcuts, .top-log-menu-items, .listener-active-summary, .listener-active-item, .listener-card, .named-listener-row, .host-chip-editor, .vhost-chart, .vhost-detail-strip, .vhost-live-metric, .vh-www-panel, .vh-enable-control, .lb-simulator, .rt-tester, .hdr-card, .hdr-preview, .hdr-preview-col, .location-header-direction, .vh-header-empty, .docker-service-row, .docker-agent-summary, .lb-equivalent pre, .policy-visual>p.fine, .location-doc-intro, .docker-agent-security, .policy-action, .policy-condition-builder, .hdr-row, .vh-www-domain-pair, .vh-location, .location-conditions, .location-group, .location-preview, .redirect-tester, .redirect-rule-table, .notfound-preview, .notfound-preview iframe, .page-preview-pane, .page-preview-pane iframe, .page-editor, .settings-flow-step, .settings-flow-example pre, .settings-timeline-step, .security-summary-tile, .acl-simulator, .page-kind-chip) {
|
||||
border-radius: var(--rp-radius-surface) !important;
|
||||
}
|
||||
|
||||
html:is([data-corner-style=square], [data-corner-style=subtle], [data-corner-style=rounded], [data-corner-style=extra]) :is(#acl-profile-preview-default, .acl-policy-condition, .acl-policy-step, .chart-style-swatches, .listener-active-feature, .host-chip, .vh-www-host-count, .vh-enable-state, .hdr-tag, .notfound-preview-head a, .entity-actions a) {
|
||||
border-radius: var(--rp-radius-control) !important;
|
||||
}
|
||||
|
||||
html:is([data-corner-style=square], [data-corner-style=subtle], [data-corner-style=rounded], [data-corner-style=extra]) .vh-location>.location-summary {
|
||||
border-radius: calc(var(--rp-radius-surface) - 1px);
|
||||
}
|
||||
|
||||
html:is([data-corner-style=square], [data-corner-style=subtle], [data-corner-style=rounded], [data-corner-style=extra]) .vh-location[open]>.location-summary {
|
||||
border-bottom-right-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
}
|
||||
|
||||
/* The sparkline runs edge to edge at the bottom of the chart box. */
|
||||
html:is([data-corner-style=square], [data-corner-style=subtle], [data-corner-style=rounded], [data-corner-style=extra]) .vhost-chart svg {
|
||||
border-bottom-right-radius: max(0px, calc(var(--rp-radius-surface) - 1px));
|
||||
border-bottom-left-radius: max(0px, calc(var(--rp-radius-surface) - 1px));
|
||||
}
|
||||
|
||||
/* Filled cells meet the strip corners; clip them to the strip shape. */
|
||||
html:is([data-corner-style=square], [data-corner-style=subtle], [data-corner-style=rounded], [data-corner-style=extra]) .vhost-detail-strip {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
html:is([data-corner-style=square], [data-corner-style=subtle], [data-corner-style=rounded], [data-corner-style=extra]) .chart-style-swatches {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#panel-overview .stat-meter>.overview-meter {
|
||||
position: relative;
|
||||
display: block;
|
||||
@@ -4080,4 +4103,17 @@ html[data-dashboard-density=ultra] #panel-overview .docker-load-list {
|
||||
border-radius: var(--rp-radius-surface, 0px);
|
||||
background: color-mix(in srgb, var(--accent) 8%, transparent);
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
/* Nested surfaces: a block inside a dialog, card or floating panel uses a
|
||||
smaller radius than its container, and the dialog body itself is not a
|
||||
second framed block inside the dialog. */
|
||||
html[data-corner-style] :is(dialog, .card, .stat, .settings-page, .settings-tabs, .draft-dock, .top-log-menu-items, .metric-info-popover, .backend-column-options) * {
|
||||
--rp-radius-surface: var(--rp-radius-nested, 0px);
|
||||
}
|
||||
|
||||
html[data-corner-style] dialog>:is(.card, form.card, article.card) {
|
||||
border-color: transparent;
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
box-shadow: none;
|
||||
}
|
||||
+247
-132
@@ -615,7 +615,6 @@
|
||||
.acl-policy-condition span,
|
||||
.listener-active-address,
|
||||
.acl-profile-attached p,
|
||||
.stream-backend-status-row>span:first-child,
|
||||
.docker-agent-security .fine,
|
||||
.docker-runtime .fine,
|
||||
#panel-tls .certificate-operation-heading strong,
|
||||
@@ -700,20 +699,22 @@
|
||||
/* Vhost editor: heading and tabs stay on top, only the fields scroll and the
|
||||
save bar is a plain footer. No sticky positioning inside the scrolled area,
|
||||
so long Custom Location editors cannot push the bar into the content. */
|
||||
#vhost-dialog[open] {
|
||||
/* Tabbed editors: heading, summary and tabs stay on top, only the fields
|
||||
scroll, and the save bar is the dialog footer. */
|
||||
:is(#vhost-dialog, #redirect-dialog, #notfound-dialog, #stream-dialog)[open] {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#vhost-dialog>#vhost-form {
|
||||
:is(#vhost-dialog, #redirect-dialog, #notfound-dialog, #stream-dialog)>form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 0 1 auto;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
#vhost-form>#vhost-fields {
|
||||
:is(#vhost-fields, #redirect-fields, #notfound-fields, #stream-fields) {
|
||||
flex: 0 1 auto;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
@@ -721,16 +722,12 @@
|
||||
overscroll-behavior: contain;
|
||||
}
|
||||
|
||||
#vhost-form>.card-heading,
|
||||
#vhost-form>.vh-tabs,
|
||||
#vhost-form>.vh-live-summary,
|
||||
#vhost-form>.form-actions,
|
||||
#vhost-form>.fine {
|
||||
:is(#vhost-form, #redirect-form, #notfound-form, #stream-form)>:is(.card-heading, .vh-tabs, .vh-live-summary, .form-actions, .fine) {
|
||||
flex: none;
|
||||
position: static;
|
||||
}
|
||||
|
||||
#vhost-form>.form-actions {
|
||||
:is(#vhost-form, #redirect-form, #notfound-form, #stream-form)>.form-actions {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
@@ -1277,6 +1274,7 @@ p,
|
||||
}
|
||||
|
||||
.vh-www-choice {
|
||||
border-radius: var(--rp-radius-surface, 0px);
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
@@ -1398,34 +1396,129 @@ p,
|
||||
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
|
||||
}
|
||||
|
||||
.redirect-rules,
|
||||
.stream-backend-list {
|
||||
display: grid;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.redirect-rule {
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--rp-radius-surface, 12px);
|
||||
padding: 1rem;
|
||||
margin: 0;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.redirect-rule-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
padding-top: 8px;
|
||||
border-top: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.redirect-card .vhost-detail-strip {
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
/* Redirect rule rows reuse the Custom location routing table. */
|
||||
.redirect-rule-cards {
|
||||
grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
|
||||
}
|
||||
|
||||
.redirect-target-choices {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.redirect-target-choices .vh-www-choice {
|
||||
padding: 8px 10px;
|
||||
}
|
||||
|
||||
.redirect-target-choices small {
|
||||
color: var(--muted);
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.redirect-rule-toolbar {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.redirect-rule-toolbar>p {
|
||||
flex: 1 1 320px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.redirect-tester {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
margin-top: 12px;
|
||||
padding: 10px 12px;
|
||||
border: 1px dashed var(--line);
|
||||
}
|
||||
|
||||
.redirect-tester input {
|
||||
font-family: var(--mono);
|
||||
}
|
||||
|
||||
.redirect-test-result {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: baseline;
|
||||
gap: 4px;
|
||||
margin: 0;
|
||||
min-height: 18px;
|
||||
font-size: 12px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.redirect-test-result.is-match strong {
|
||||
color: var(--green);
|
||||
}
|
||||
|
||||
.redirect-test-result code {
|
||||
font: 600 12px var(--mono);
|
||||
}
|
||||
|
||||
.redirect-rule-table {
|
||||
display: grid;
|
||||
margin-top: 10px;
|
||||
border: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.redirect-rule-line {
|
||||
display: grid;
|
||||
grid-template-columns: 22px 10px 76px minmax(0, 1fr) 40px minmax(0, 1.6fr) minmax(0, .9fr);
|
||||
align-items: center;
|
||||
gap: 4px 10px;
|
||||
padding: 7px 12px;
|
||||
font-size: 12px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.redirect-rule-line+.redirect-rule-line {
|
||||
border-top: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.redirect-rule-line.is-disabled {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.redirect-rule-line.is-disabled .loc-state,
|
||||
.loc-state.is-off {
|
||||
background: var(--line);
|
||||
}
|
||||
|
||||
.redirect-rule-status {
|
||||
color: var(--accent);
|
||||
font: 600 11px var(--mono);
|
||||
}
|
||||
|
||||
.redirect-rule-target {
|
||||
font: 11px var(--mono);
|
||||
}
|
||||
|
||||
.redirect-rule-more {
|
||||
display: block;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.entity-actions button.danger-quiet {
|
||||
color: var(--red);
|
||||
border-color: var(--danger-line-strong);
|
||||
}
|
||||
|
||||
.vh-tab-count {
|
||||
color: var(--muted);
|
||||
font-family: var(--mono);
|
||||
}
|
||||
|
||||
.frontend-protocol-controls {
|
||||
margin-block-start: 16px;
|
||||
padding-block-start: 12px;
|
||||
@@ -1816,38 +1909,6 @@ html[data-dashboard-density=ultra] #panel-overview .dashboard-overview-grid>.car
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.stream-backend-pool {
|
||||
display: grid;
|
||||
gap: .8rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.stream-backend-row {
|
||||
min-width: 0;
|
||||
border: 1px solid var(--line, #454d59);
|
||||
border-radius: var(--rp-radius-surface, .65rem);
|
||||
padding: .85rem;
|
||||
}
|
||||
|
||||
.stream-backend-row>.quiet {
|
||||
margin-top: .6rem;
|
||||
}
|
||||
|
||||
.stream-backend-status {
|
||||
display: grid;
|
||||
gap: .4rem;
|
||||
padding: .75rem 0;
|
||||
}
|
||||
|
||||
.stream-backend-status-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: .5rem;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
font-size: .85em;
|
||||
}
|
||||
|
||||
.vh-enable-control.vh-enable-no-hint {
|
||||
grid-template-rows: auto;
|
||||
}
|
||||
@@ -2306,10 +2367,6 @@ html.app-loading,
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.stream-backend-row>.vh-grid {
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.vh-form :is(input, select, textarea):disabled {
|
||||
opacity: .55;
|
||||
cursor: not-allowed;
|
||||
@@ -2421,93 +2478,103 @@ h2+.fine {
|
||||
}
|
||||
}
|
||||
|
||||
.redirect-flow {
|
||||
/* Stream backends: routing-table rows in the editor and the card. */
|
||||
.stream-backend-toolbar {
|
||||
align-items: end;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.stream-backend-toolbar>label {
|
||||
min-width: min(280px, 100%);
|
||||
}
|
||||
|
||||
.stream-health-list {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto minmax(0, 1.4fr);
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
margin-top: 12px;
|
||||
padding: 10px 12px;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.stream-health-backend {
|
||||
margin-left: 6px;
|
||||
color: var(--accent);
|
||||
font: 600 12px var(--mono);
|
||||
}
|
||||
|
||||
.stream-backend-status .redirect-rule-line {
|
||||
grid-template-columns: 22px 10px minmax(0, .8fr) minmax(0, 1fr) 46px minmax(0, 1.4fr) minmax(0, .8fr);
|
||||
}
|
||||
|
||||
.loc-state.is-unknown {
|
||||
background: var(--muted);
|
||||
opacity: .55;
|
||||
}
|
||||
|
||||
.loc-state.is-ok {
|
||||
background: var(--green);
|
||||
}
|
||||
|
||||
.loc-state.is-bad {
|
||||
background: var(--red);
|
||||
}
|
||||
|
||||
.stream-backend-live {
|
||||
color: var(--muted);
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
/* 404 host response choice cards and sandboxed preview. */
|
||||
.notfound-kinds {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.notfound-kinds small {
|
||||
color: var(--muted);
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.notfound-kind-wide {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.notfound-preview {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
margin-top: 10px;
|
||||
padding: 10px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--rp-radius-surface, 0);
|
||||
background: var(--bg);
|
||||
}
|
||||
|
||||
.redirect-flow-from,
|
||||
.redirect-flow-to {
|
||||
.notfound-preview-head {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.redirect-flow-to {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 3px;
|
||||
}
|
||||
|
||||
.redirect-flow-arrow {
|
||||
color: var(--muted);
|
||||
font-size: 16px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.redirect-host-chip {
|
||||
max-width: 100%;
|
||||
padding: 2px 6px;
|
||||
.notfound-preview-head a {
|
||||
padding: 3px 9px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--rp-radius-control, 0);
|
||||
font: 11px/1.45 var(--mono);
|
||||
color: var(--text);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.redirect-target {
|
||||
font: 12px/1.45 var(--mono);
|
||||
font-weight: 600;
|
||||
color: var(--green);
|
||||
overflow-wrap: anywhere;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.redirect-target-more {
|
||||
font-size: 11px;
|
||||
color: var(--muted);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.redirect-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px 18px;
|
||||
margin-top: 10px;
|
||||
font-size: 11px;
|
||||
color: var(--muted);
|
||||
.notfound-preview iframe {
|
||||
width: 100%;
|
||||
height: 320px;
|
||||
border: 1px solid var(--line);
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.redirect-meta-item {
|
||||
.notfound-preview iframe[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.entity-actions a.notfound-card-preview {
|
||||
display: inline-flex;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.redirect-meta-item b {
|
||||
color: var(--text);
|
||||
font-weight: 600;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.redirect-flow {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.redirect-flow-arrow {
|
||||
transform: rotate(90deg);
|
||||
justify-self: start;
|
||||
}
|
||||
align-items: center;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.lb-editor {
|
||||
@@ -3002,3 +3069,51 @@ h2+.fine {
|
||||
opacity: .55;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
/* Web Service type and FastCGI source choices reuse the Vhost www cards. */
|
||||
.web-service-kinds {
|
||||
grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
|
||||
}
|
||||
|
||||
.web-service-php-sources {
|
||||
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
|
||||
}
|
||||
|
||||
.web-service-kinds .web-service-php-app {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.vh-www-choice.is-disabled {
|
||||
opacity: .5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.web-service-php-profile-summary {
|
||||
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
||||
}
|
||||
|
||||
.web-service-php-profile-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
/* Editor dialogs: the title row is followed directly by the tabs. Live
|
||||
summaries are shown inside the relevant tab (Backend health, Backends);
|
||||
the identifier is in the title pill and hostnames in the Frontend tab. */
|
||||
:is(#vhost-form, #redirect-form, #notfound-form, #stream-form)>.vh-live-summary {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.vh-live-summary.vh-live-summary-tab {
|
||||
margin: 0 0 8px;
|
||||
padding: 7px 10px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--rp-radius-surface, 0px);
|
||||
background: var(--panel2);
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.vh-live-summary.vh-live-summary-tab[hidden] {
|
||||
display: none;
|
||||
}
|
||||
@@ -21,16 +21,18 @@
|
||||
.settings-shortcuts {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid var(--line);
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
flex: 1 1 320px;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 10px;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.settings-shortcuts>div {
|
||||
flex: 1;
|
||||
min-width: 170px;
|
||||
.settings-shortcuts>p {
|
||||
flex: 1 1 220px;
|
||||
max-width: 420px;
|
||||
margin: 0;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.acme-card {
|
||||
@@ -388,14 +390,10 @@
|
||||
padding-block: 0;
|
||||
}
|
||||
|
||||
#panel-settings .settings-shortcuts {
|
||||
grid-column: 1/-1;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#panel-settings .settings-filter-row {
|
||||
grid-column: 1/-1;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: end;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
@@ -1374,19 +1372,6 @@ html[data-dashboard-density=normal] #panel-overview .stat>span,
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
#panel-settings #settings-tabs button:is([data-settings-tab=listeners], [data-settings-tab=policies], [data-settings-tab=logging], [data-settings-tab=administration], [data-settings-tab=certificate-api]) {
|
||||
margin-top: 7px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#panel-settings #settings-tabs button:is([data-settings-tab=listeners], [data-settings-tab=policies], [data-settings-tab=logging], [data-settings-tab=administration], [data-settings-tab=certificate-api])::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: -5px;
|
||||
right: 8px;
|
||||
left: 8px;
|
||||
border-top: 1px solid var(--line);
|
||||
}
|
||||
}
|
||||
|
||||
#cache-form .cache-section-title {
|
||||
@@ -3088,6 +3073,18 @@ html[data-dashboard-density=normal] #panel-overview .stat>span,
|
||||
.docs-link {
|
||||
font-size: 12px;
|
||||
justify-self: start;
|
||||
color: var(--accent);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.docs-link::after {
|
||||
content: " ↗";
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.docs-link:hover,
|
||||
.docs-link:focus-visible {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.system-info-page {
|
||||
@@ -3552,13 +3549,11 @@ html[data-dashboard-density=normal] #panel-overview .stat>span,
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.docker-security-grid .docker-wide-field,
|
||||
.docker-diagnostics-grid .docker-wide-field {
|
||||
.docker-security-grid .docker-wide-field {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.docker-security-grid .docker-subheading,
|
||||
.docker-diagnostics-grid .docker-subheading {
|
||||
.docker-security-grid .docker-subheading {
|
||||
grid-column: 1 / -1;
|
||||
margin: 8px 0 0;
|
||||
padding-top: 8px;
|
||||
@@ -3570,8 +3565,7 @@ html[data-dashboard-density=normal] #panel-overview .stat>span,
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.docker-security-grid .docker-subheading:first-child,
|
||||
.docker-diagnostics-grid .docker-subheading:first-child {
|
||||
.docker-security-grid .docker-subheading:first-child {
|
||||
margin-top: 0;
|
||||
padding-top: 0;
|
||||
border-top: 0;
|
||||
@@ -3849,4 +3843,603 @@ html[data-dashboard-density=normal] #panel-overview .stat>span,
|
||||
.cache-guide-card {
|
||||
padding: 11px;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Settings navigation: grouped list, active item marked like other editors. */
|
||||
.settings-nav-group {
|
||||
padding: 10px 10px 4px;
|
||||
color: var(--muted);
|
||||
font: 10px var(--mono);
|
||||
letter-spacing: .1em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.settings-nav-group:first-child {
|
||||
padding-top: 2px;
|
||||
}
|
||||
|
||||
.settings-nav-group[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#panel-settings #settings-tabs button[aria-selected=true] {
|
||||
border-color: transparent;
|
||||
background: var(--panel2);
|
||||
color: var(--text);
|
||||
box-shadow: inset 3px 0 0 var(--green);
|
||||
font-weight: 650;
|
||||
}
|
||||
|
||||
/* Sub-tabs inside a settings page and the certificate views use the same
|
||||
underlined tabs as the Vhost editor. */
|
||||
#panel-settings .settings-tabs.sub-tabs,
|
||||
#panel-tls .settings-tabs.certificate-tabs {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
gap: 2px;
|
||||
padding: 0;
|
||||
margin-bottom: 12px;
|
||||
border: 0;
|
||||
border-bottom: 1px solid var(--line);
|
||||
background: transparent;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
#panel-settings .settings-tabs.sub-tabs button,
|
||||
#panel-tls .settings-tabs.certificate-tabs button {
|
||||
width: auto;
|
||||
min-width: 0;
|
||||
margin-bottom: -1px;
|
||||
padding: 8px 12px;
|
||||
border: 0;
|
||||
border-bottom: 2px solid transparent;
|
||||
background: transparent;
|
||||
color: var(--muted);
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
#panel-settings .settings-tabs.sub-tabs button:hover,
|
||||
#panel-tls .settings-tabs.certificate-tabs button:hover {
|
||||
background: var(--panel2);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
#panel-settings .settings-tabs.sub-tabs button[aria-selected=true],
|
||||
#panel-tls .settings-tabs.certificate-tabs button[aria-selected=true] {
|
||||
border-bottom-color: var(--green);
|
||||
background: transparent;
|
||||
color: var(--text);
|
||||
font-weight: 650;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
html:is([data-corner-style=square], [data-corner-style=subtle], [data-corner-style=rounded], [data-corner-style=extra]) :is(#panel-settings .settings-tabs.sub-tabs, #panel-tls .settings-tabs.certificate-tabs) {
|
||||
border-radius: 0 !important;
|
||||
}
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.settings-nav-group {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.settings-shortcuts>p {
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
|
||||
/* Docker agents in Settings: routing-table rows with sections. */
|
||||
#docker-agent-settings-list {
|
||||
gap: 9px;
|
||||
}
|
||||
|
||||
.docker-agent-row.entity,
|
||||
.docker-agent-row.entity:first-child,
|
||||
.docker-agent-row.entity:last-child {
|
||||
padding: 0;
|
||||
border: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.docker-agent-summary-row {
|
||||
grid-template-columns: 12px minmax(0, 1fr) minmax(0, 1.1fr) auto auto;
|
||||
}
|
||||
|
||||
.docker-agent-summary-title {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.docker-agent-summary-title h3 {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.docker-agent-summary-id {
|
||||
color: var(--muted);
|
||||
font: 11px var(--mono);
|
||||
}
|
||||
|
||||
.docker-agent-summary-badges {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.docker-agent-summary-badges .docker-agent-status-badge {
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.docker-agent-summary-badges .check {
|
||||
margin-top: 0 !important;
|
||||
}
|
||||
|
||||
.docker-agent-body {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.docker-agent-sections {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.docker-agent-section .docker-agent-grid {
|
||||
margin-top: 0;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.docker-agent-section .docker-agent-grid>:is(.docker-profile-field, .docker-agent-listener-field, .docker-agent-security, .docker-checkbox-field) {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.docker-agent-section .docker-agent-security {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.docker-agent-row .docker-agent-diagnostics:empty {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.docker-agent-actions .entity-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.docker-agent-sections,
|
||||
.docker-agent-section .docker-agent-grid {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.docker-agent-summary-row {
|
||||
grid-template-columns: 12px minmax(0, 1fr) auto;
|
||||
}
|
||||
|
||||
.docker-agent-summary-endpoint,
|
||||
.docker-agent-summary-security {
|
||||
grid-column: 2 / -1;
|
||||
}
|
||||
}
|
||||
|
||||
.listener-sections {
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
.listener-section .vh-grid {
|
||||
grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
|
||||
gap: 9px;
|
||||
}
|
||||
|
||||
.listener-section .host-chip-field {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.listener-section .check {
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
.listener-section .listener-protocol-settings-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.listener-sections {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
/* Help text in agent rows uses the regular help style, not the compact
|
||||
monospace .entity caption. */
|
||||
.docker-agent-row small {
|
||||
font: 11px/1.45 inherit;
|
||||
font-family: inherit;
|
||||
font-size: 11px;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.docker-agent-row .docker-provision summary small {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
#docker-agent-settings-list .docker-agent-section .docker-agent-grid>.auto-id-field.auto-id-field {
|
||||
grid-row: auto;
|
||||
display: grid;
|
||||
grid-template-rows: none;
|
||||
align-content: start;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
#docker-agent-settings-list .docker-agent-section .docker-agent-grid>.auto-id-field.auto-id-field>span:first-child {
|
||||
align-self: start;
|
||||
}
|
||||
|
||||
/* Visual request flows (cache, transformation) and the cache freshness timeline. */
|
||||
.settings-page-intro {
|
||||
margin: 0 0 8px;
|
||||
}
|
||||
|
||||
.settings-flow {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
margin: 0 0 var(--ui-gap);
|
||||
padding: 12px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--rp-radius-surface, 0px);
|
||||
background: var(--panel2);
|
||||
container-type: inline-size;
|
||||
}
|
||||
|
||||
.settings-flow-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) repeat(calc(var(--flow-steps, 5) - 1), 18px minmax(0, 1fr));
|
||||
align-items: stretch;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.settings-flow-step {
|
||||
display: grid;
|
||||
align-content: start;
|
||||
justify-items: start;
|
||||
gap: 3px;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
padding: 10px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--rp-radius-surface, 0px);
|
||||
background: var(--panel);
|
||||
color: var(--text);
|
||||
font: inherit;
|
||||
text-align: left;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
button.settings-flow-step {
|
||||
cursor: pointer;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
button.settings-flow-step:hover,
|
||||
button.settings-flow-step:focus-visible {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.settings-flow-step.is-on {
|
||||
border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
|
||||
box-shadow: inset 0 2px 0 var(--accent);
|
||||
}
|
||||
|
||||
.settings-flow-step b {
|
||||
font-size: 13px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.settings-flow-step small {
|
||||
color: var(--muted);
|
||||
font-size: 11.5px;
|
||||
line-height: 1.35;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.settings-flow-step .pill {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.settings-flow-icon {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
fill: none;
|
||||
stroke: var(--accent);
|
||||
stroke-width: 1.6;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
}
|
||||
|
||||
.settings-flow-arrow {
|
||||
align-self: center;
|
||||
justify-self: center;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.settings-flow.is-disabled .settings-flow-step {
|
||||
opacity: .55;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.settings-flow-legend {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px 18px;
|
||||
}
|
||||
|
||||
.settings-flow-legend-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin: 0;
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.settings-flow-disabled {
|
||||
margin: 0;
|
||||
color: var(--red);
|
||||
}
|
||||
|
||||
.settings-flow-disabled[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.settings-flow-example-tabs {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.settings-flow-example-tabs button {
|
||||
min-height: 26px;
|
||||
padding: 2px 10px;
|
||||
border: 1px solid var(--line);
|
||||
background: transparent;
|
||||
color: var(--muted);
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.settings-flow-example-tabs button.active {
|
||||
border-color: var(--accent);
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.settings-flow-example {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.settings-flow-example>div {
|
||||
display: grid;
|
||||
align-content: start;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.settings-flow-example pre {
|
||||
margin: 0;
|
||||
padding: 8px 10px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--rp-radius-surface, 0px);
|
||||
background: var(--panel);
|
||||
font-family: var(--mono);
|
||||
font-size: 12px;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
#transform-form .transform-operations-grid {
|
||||
grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
#transform-form .transform-operations-grid>label.check {
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(0, 1fr);
|
||||
align-items: center;
|
||||
gap: 3px 10px;
|
||||
margin: 0;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--rp-radius-surface, 0px);
|
||||
background: var(--panel2);
|
||||
}
|
||||
|
||||
#transform-form .transform-operations-grid>label.check>span {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
#transform-form .switch-help {
|
||||
grid-column: 2;
|
||||
margin: 0;
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.settings-timeline {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
|
||||
gap: 8px;
|
||||
margin: 0 0 var(--ui-gap);
|
||||
}
|
||||
|
||||
.settings-timeline-step {
|
||||
display: grid;
|
||||
gap: 3px;
|
||||
padding: 9px 10px;
|
||||
border: 1px solid var(--line);
|
||||
border-left-width: 3px;
|
||||
border-radius: var(--rp-radius-surface, 0px);
|
||||
background: var(--panel2);
|
||||
}
|
||||
|
||||
.settings-timeline-step small {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.settings-timeline-step.is-ok {
|
||||
border-left-color: var(--green);
|
||||
}
|
||||
|
||||
.settings-timeline-step.is-warn {
|
||||
border-left-color: var(--warn-line, var(--accent));
|
||||
}
|
||||
|
||||
.settings-timeline-step.is-bad {
|
||||
border-left-color: var(--red);
|
||||
}
|
||||
|
||||
@container (max-width: 760px) {
|
||||
.settings-flow-row {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.settings-flow-arrow {
|
||||
transform: rotate(90deg);
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.settings-flow-example {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
/* Security page: summary tiles, default-decision cards, policy simulator. */
|
||||
.security-summary {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
|
||||
gap: 14px;
|
||||
margin: 0 0 14px;
|
||||
}
|
||||
|
||||
.security-summary-tile {
|
||||
display: grid;
|
||||
align-content: start;
|
||||
justify-items: start;
|
||||
gap: 2px;
|
||||
height: auto;
|
||||
min-height: 0;
|
||||
padding: 12px 14px;
|
||||
border: 1px solid var(--line);
|
||||
border-left: 3px solid var(--line);
|
||||
border-radius: var(--rp-radius-surface, 0px);
|
||||
background: var(--panel);
|
||||
color: var(--text);
|
||||
font: inherit;
|
||||
text-align: left;
|
||||
white-space: normal;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.security-summary-tile:hover {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.security-summary-tile.is-ok {
|
||||
border-left-color: var(--green);
|
||||
}
|
||||
|
||||
.security-summary-tile.is-warn {
|
||||
border-left-color: var(--warn-line, var(--accent));
|
||||
}
|
||||
|
||||
.security-summary-tile b {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.security-summary-tile span {
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.security-summary-tile small {
|
||||
color: var(--muted);
|
||||
font-size: 11.5px;
|
||||
}
|
||||
|
||||
#host-policy-form .policy-default-select {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#host-policy-form .policy-default-cards {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.acl-simulator {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--rp-radius-surface, 0px);
|
||||
background: var(--panel2);
|
||||
}
|
||||
|
||||
.acl-simulator>label {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.acl-simulator-results {
|
||||
display: grid;
|
||||
}
|
||||
|
||||
.acl-simulator-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(110px, auto) minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 6px 0;
|
||||
border-top: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.acl-simulator-row code {
|
||||
font-family: var(--mono);
|
||||
font-size: 12px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.acl-simulator-note {
|
||||
margin: 6px 0 0;
|
||||
}
|
||||
|
||||
.acl-simulator-error {
|
||||
margin: 0;
|
||||
color: var(--red);
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
#host-policy-form .policy-default-cards {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.acl-simulator-row {
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
}
|
||||
|
||||
.acl-simulator-row .fine {
|
||||
grid-column: 1 / -1;
|
||||
grid-row: 2;
|
||||
}
|
||||
}
|
||||
|
||||
/* Rules & headers: one card with tabs, like HTTP connections. */
|
||||
.policy-settings-card [data-policy-settings-page]>form {
|
||||
margin-top: 14px;
|
||||
}
|
||||
@@ -457,11 +457,7 @@
|
||||
min-width: 520px;
|
||||
}
|
||||
|
||||
/* HTTP policies are nested in the Docker service "Headers" section and use the
|
||||
same disclosure row as the other Docker service sections. */
|
||||
.docker-headers-editor .docker-policy-editor {
|
||||
margin-top: 12px;
|
||||
}
|
||||
/* Docker service "HTTP policies" uses the same disclosure row as the other sections. */
|
||||
|
||||
.docker-policy-editor>.http-policy-editor {
|
||||
margin-top: 10px;
|
||||
|
||||
@@ -886,9 +886,17 @@
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.backend-table-tools {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.backend-column-picker {
|
||||
position: static;
|
||||
}
|
||||
|
||||
.backend-column-options {
|
||||
right: auto;
|
||||
left: 0;
|
||||
right: 0;
|
||||
left: auto;
|
||||
}
|
||||
|
||||
.vhost-card-head .entity-actions {
|
||||
@@ -1103,7 +1111,6 @@
|
||||
max-height: calc((calc(55dvh - 230px)) / var(--ui-scale, 1));
|
||||
}
|
||||
|
||||
.page-editor,
|
||||
.h3-editor .vh-grid {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
@@ -1893,6 +1900,7 @@
|
||||
.docker-service-editor[open]:not(.docker-service-metrics)>.docker-protocol-editor,
|
||||
.docker-service-editor[open]:not(.docker-service-metrics)>.docker-security-editor,
|
||||
.docker-service-editor[open]:not(.docker-service-metrics)>.docker-diagnostics-editor,
|
||||
.docker-service-editor[open]:not(.docker-service-metrics)>.docker-policy-editor,
|
||||
.docker-service-editor[open]:not(.docker-service-metrics)>.docker-timeout-editor {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
+52
-28
@@ -169,6 +169,7 @@
|
||||
const endpoint = row.querySelector(".docker-agent-endpoint")?.value || "", fingerprint = row.querySelector(".docker-agent-fingerprint")?.value || "";
|
||||
const info = securityInfo({ endpoint, tls_fingerprint_sha256: fingerprint }, null), badge = row.querySelector(".docker-agent-security-badge");
|
||||
if (badge) { badge.textContent = t(info.key); badge.className = `pill docker-agent-security-badge ${info.cls}`.trim(); }
|
||||
const summaryBadge = row.querySelector(".docker-agent-summary-security"); if (summaryBadge) { summaryBadge.textContent = t(info.key); summaryBadge.className = `pill docker-agent-summary-security ${info.cls}`.trim(); }
|
||||
const hint = row.querySelector(".docker-agent-security-hint"); if (hint) hint.textContent = info.detail;
|
||||
}
|
||||
|
||||
@@ -429,7 +430,7 @@
|
||||
}
|
||||
function agentSettingsRow(agent = null, options = {}) {
|
||||
const value = agent || { id: "", name: "", enabled: true, endpoint: "https://127.0.0.1:9876", token: "", tls_fingerprint_sha256: null, domains: [], poll_interval_seconds: 30, certificate_ids: [], acl_profile_id: null, default_target_ip: null, listener_ids: [firstListener()], assignments: [] };
|
||||
const row = el("div", undefined, "docker-agent-settings entity"); row.dataset.originalId = agent?.id || ""; row._assignments = structuredClone(value.assignments || []);
|
||||
const row = el("details", undefined, "docker-agent-settings entity vh-location docker-agent-row"); row.open = !agent || !!options.provision; row.dataset.originalId = agent?.id || ""; row._assignments = structuredClone(value.assignments || []);
|
||||
const head = el("div", undefined, "card-heading"), title = el("div"), titleText = el("h3", value.name || value.id || t("dockerAgentNew")); title.append(el("span", t("dockerAgent"), "small-label"), titleText);
|
||||
const enabled = input("", "checkbox", "docker-agent-enabled switch"); enabled.checked = value.enabled !== false;
|
||||
const enabledLabel = el("label", undefined, "check"); enabledLabel.append(enabled, el("span", t("enabled")));
|
||||
@@ -502,21 +503,43 @@
|
||||
} catch (error) { showBubble(`${t("dockerTestFailed")}: ${error.message}`, "error"); }
|
||||
finally { testButton.disabled = false; }
|
||||
});
|
||||
const grid = el("div", undefined, "field-grid docker-agent-grid");
|
||||
// Collapsed: one row (state, name/ID, endpoint, transport security, status, Enabled).
|
||||
// Expanded: provisioning, diagnostics and four sections holding every field.
|
||||
const section = (number, key, cls) => { const box = el("section", undefined, `location-card docker-agent-section ${cls}`), heading = el("h4", undefined, "location-card-title"), grid = el("div", undefined, "field-grid docker-agent-grid"); heading.append(el("span", number, "location-step"), el("span", t(key))); box.append(heading, grid); return [box, grid]; };
|
||||
const [connectionBox, connectionGrid] = section("1", "dockerAgentSectionConnection", "docker-agent-connection");
|
||||
const [authBox, authGrid] = section("2", "dockerAgentSectionAuth", "docker-agent-auth");
|
||||
const [domainBox, domainGrid] = section("3", "dockerAgentSectionDomains", "docker-agent-domain-section");
|
||||
const [publishBox, publishGrid] = section("4", "dockerAgentSectionPublish", "docker-agent-publish");
|
||||
const idField = labeled("dockerAgentId", id);
|
||||
grid.append(labeled("dockerAgentName", name), idField, labeled("dockerAgentEndpoint", endpoint, t("dockerAgentEndpointHelp")), labeled("dockerAgentToken", token), labeled("dockerTlsFingerprint", fingerprint, t("dockerTlsFingerprintHelp")), labeled("dockerPollInterval", poll, t("dockerPollIntervalHelp")), domainsField, certificateField, labeled("dockerDefaultTarget", target.node, t("dockerDefaultTargetHelp")), defaultAclField, labelField);
|
||||
const listenerField = el("div", undefined, "docker-agent-listener-field"); listenerField.append(el("span", t("dockerListeners"), "docker-agent-field-label"));
|
||||
const listenerControl = window.rustProxyIntegrations.bindings(listenerField, value.listener_ids || [], !agent); listenerField.querySelector(".listener-choices")?.classList.add("docker-agent-listener-choices"); row._readListeners = listenerControl.read; grid.append(listenerField);
|
||||
connectionGrid.append(labeled("dockerAgentName", name), idField, labeled("dockerAgentEndpoint", endpoint, t("dockerAgentEndpointHelp")), labeled("dockerPollInterval", poll, t("dockerPollIntervalHelp")));
|
||||
const security = el("div", undefined, "docker-agent-security"), secBadge = el("span", "", "pill docker-agent-security-badge"), secHint = el("span", "", "fine docker-agent-security-hint"); security.append(secBadge, secHint);
|
||||
authGrid.append(labeled("dockerAgentToken", token), labeled("dockerTlsFingerprint", fingerprint, t("dockerTlsFingerprintHelp")), security);
|
||||
domainGrid.append(domainsField, certificateField);
|
||||
const listenerField = el("div", undefined, "docker-agent-listener-field"); listenerField.append(el("span", t("dockerListeners"), "docker-agent-field-label"));
|
||||
const listenerControl = window.rustProxyIntegrations.bindings(listenerField, value.listener_ids || [], !agent); listenerField.querySelector(".listener-choices")?.classList.add("docker-agent-listener-choices"); row._readListeners = listenerControl.read;
|
||||
publishGrid.append(listenerField, labeled("dockerDefaultTarget", target.node, t("dockerDefaultTargetHelp")), defaultAclField, labelField);
|
||||
const diagnostics = el("div", undefined, "docker-agent-diagnostics"); diagnostics.dataset.agentId = agent?.id || ""; renderAgentDiagnostics(diagnostics);
|
||||
endpoint.addEventListener("input", () => updateSecurityBadge(row)); fingerprint.addEventListener("input", () => updateSecurityBadge(row)); row.append(head, provision, diagnostics, security, grid); updateSecurityBadge(row);
|
||||
const summary = el("summary", undefined, "location-summary docker-agent-summary-row");
|
||||
const sumState = el("span", undefined, `loc-state ${state?.ok ? "is-ok" : state ? "is-bad" : "is-unknown"}`), sumTitle = el("span", undefined, "docker-agent-summary-title"), sumEndpoint = el("span", value.endpoint || "-", "loc-path docker-agent-summary-endpoint"), sumSecurity = el("span", "", "pill docker-agent-summary-security"), sumBadges = el("span", undefined, "docker-agent-summary-badges");
|
||||
const sumId = el("code", value.id || "", "docker-agent-summary-id"); sumTitle.append(titleText, sumId);
|
||||
sumBadges.append(stateBadge, enabledLabel); summary.append(sumState, sumTitle, sumEndpoint, sumSecurity, sumBadges);
|
||||
title.remove(); head.remove();
|
||||
const body = el("div", undefined, "location-body docker-agent-body"), sections = el("div", undefined, "location-cards docker-agent-sections");
|
||||
sections.append(connectionBox, authBox, domainBox, publishBox);
|
||||
const footer = el("div", undefined, "redirect-rule-actions docker-agent-actions"); actions.replaceChildren(testWrap, remove); footer.append(actions);
|
||||
body.append(provision, diagnostics, sections, footer);
|
||||
row.append(summary, body);
|
||||
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) });
|
||||
return row;
|
||||
}
|
||||
function renderSettings() {
|
||||
const target = $("docker-agent-settings-list"); if (!target || !envelope) return;
|
||||
if (settingsDirty.has("docker-agents-form")) { renderSettingsDiagnostics(); return; }
|
||||
target.replaceChildren(...(cfg().agents || []).map(agent => agentSettingsRow(agent))); if (!target.children.length) target.append(el("p", t("dockerNoAgents"), "empty"));
|
||||
const openRows = new Set([...target.querySelectorAll(".docker-agent-settings[open]")].map(row => row.dataset.originalId).filter(Boolean));
|
||||
target.replaceChildren(...(cfg().agents || []).map(agent => { const row = agentSettingsRow(agent); if (openRows.has(agent.id)) row.open = true; return row; })); if (!target.children.length) target.append(el("p", t("dockerNoAgents"), "empty"));
|
||||
renderAlertSettings();
|
||||
if (!settingsObservationsRequested && authenticated && (cfg().agents || []).length) { settingsObservationsRequested = true; void refresh(false); }
|
||||
}
|
||||
@@ -875,31 +898,32 @@
|
||||
basic_auth: collectBasicAuth(row),
|
||||
};
|
||||
}
|
||||
// "Headers": diagnostic response headers and the vhost's HTTP policy rules.
|
||||
// The policy editor stays collapsed inside this section until it is needed.
|
||||
function headersEditor(assignment, row) {
|
||||
const details = el("details", undefined, "docker-diagnostics-editor docker-headers-editor"), summary = el("summary"), state = el("small", "", "fine");
|
||||
summary.append(el("span", t("dockerHeaders")), state); details.append(summary);
|
||||
function diagnosticsEditor(assignment) {
|
||||
const details = el("details", undefined, "docker-diagnostics-editor"), summary = el("summary"), state = el("small", "", "fine"); summary.append(el("span", t("dockerDiagnostics")), state); details.append(summary);
|
||||
const grid = el("div", undefined, "field-grid docker-diagnostics-grid");
|
||||
const box = (cls, value) => { const node = input("", "checkbox", `${cls} switch`); node.checked = value === true; return node; };
|
||||
const timing = box("docker-timing-headers", assignment?.timing_headers), backend = box("docker-backend-header", assignment?.backend_header), backendTiming = box("docker-backend-timing-header", assignment?.backend_timing_header);
|
||||
grid.append(el("h4", t("dockerDiagnostics"), "docker-subheading docker-wide-field"), el("p", t("dockerDiagnosticsHelp"), "fine docker-wide-field"),
|
||||
checkboxField("vhTimingHeaders", timing), checkboxField("vhBackendHeader", backend), checkboxField("vhBackendTimingHeader", backendTiming));
|
||||
const policyBox = el("details", undefined, "docker-policy-editor"), policySummary = el("summary"), policyState = el("small", "", "fine");
|
||||
policySummary.append(el("span", t("policyTitle")), policyState); policyBox.append(policySummary);
|
||||
let sync = () => { };
|
||||
const policy = window.rustProxyPolicy.create({ value: assignment?.policy || {}, scope: "vhost", onChange: () => { row.classList.add("is-dirty"); sync(); } });
|
||||
policyBox.append(policy.node); row._readPolicy = () => policy.read();
|
||||
details.append(grid, policyBox);
|
||||
let ruleCount = (assignment?.policy?.rules || []).length;
|
||||
sync = () => {
|
||||
const rules = policy.node.querySelector(".policy-visual:not([hidden]) .policy-rules");
|
||||
if (rules) ruleCount = rules.querySelectorAll(":scope > .policy-rule").length;
|
||||
const rulesText = ruleCount ? t("dockerPolicyRuleCount").replace("{count}", ruleCount) : t("dockerPolicyNone");
|
||||
policyState.textContent = rulesText;
|
||||
grid.append(checkboxField("vhTimingHeaders", timing), checkboxField("vhBackendHeader", backend), checkboxField("vhBackendTimingHeader", backendTiming));
|
||||
details.append(grid);
|
||||
const sync = () => {
|
||||
const enabled = [[timing, "Server-Timing"], [backend, "X-RustProxy-Backend"], [backendTiming, "X-RustProxy-Backend-Time"]].filter(([control]) => control.checked).map(([, label]) => label);
|
||||
state.textContent = enabled.length || ruleCount ? [...enabled, ...(ruleCount ? [rulesText] : [])].join(" · ") : t("dockerHeadersHelp");
|
||||
state.textContent = enabled.length ? enabled.join(" · ") : t("dockerDiagnosticsHelp");
|
||||
};
|
||||
details.addEventListener("change", sync); sync();
|
||||
return details;
|
||||
}
|
||||
// HTTP policies: an ordinary Docker service section, like Security or Proxy timeouts.
|
||||
function policyEditor(assignment, row) {
|
||||
const details = el("details", undefined, "docker-policy-editor"), summary = el("summary"), state = el("small", "", "fine");
|
||||
summary.append(el("span", t("policyTitle")), state); details.append(summary);
|
||||
let ruleCount = (assignment?.policy?.rules || []).length;
|
||||
const sync = () => {
|
||||
const rules = details.querySelector(".policy-visual:not([hidden]) .policy-rules");
|
||||
if (rules) ruleCount = rules.querySelectorAll(":scope > .policy-rule").length;
|
||||
state.textContent = ruleCount ? t("dockerPolicyRuleCount").replace("{count}", ruleCount) : t("dockerPolicyNone");
|
||||
};
|
||||
const policy = window.rustProxyPolicy.create({ value: assignment?.policy || {}, scope: "vhost", onChange: () => { row.classList.add("is-dirty"); sync(); } });
|
||||
details.append(policy.node); row._readPolicy = () => policy.read();
|
||||
details.addEventListener("input", sync); details.addEventListener("change", sync); sync();
|
||||
return details;
|
||||
}
|
||||
@@ -1084,7 +1108,7 @@
|
||||
protocolOptions.append(h1, checkboxField("dockerHttp2Enabled", h2Enabled), checkboxField("dockerHttp3Enabled", h3Enabled));
|
||||
protocolBox.append(protocolSummary, protocolOptions);
|
||||
route.append(hostField, aliases.node, backendIpSettings, labeled("dockerBackendScheme", scheme), switches); syncHostHelp();
|
||||
editor.append(route, protocolBox, aclEditor(assignment, agent), securityEditor(assignment), cacheEditor(assignment, agent, key, cacheEnabled, () => expandedHost(host.value.trim() || technical, domainSelect.value)), headersEditor(assignment, row), timeoutEditor(assignment), healthEditor(assignment), passiveHealthEditor(assignment));
|
||||
editor.append(route, protocolBox, aclEditor(assignment, agent), securityEditor(assignment), cacheEditor(assignment, agent, key, cacheEnabled, () => expandedHost(host.value.trim() || technical, domainSelect.value)), diagnosticsEditor(assignment), policyEditor(assignment, row), timeoutEditor(assignment), healthEditor(assignment), passiveHealthEditor(assignment));
|
||||
const actions = el("div", undefined, "docker-service-actions"); apply = el("button", t("dockerApplyService"), "outline docker-apply"); apply.type = "button"; apply.disabled = !publish.checked; apply.addEventListener("click", async () => { apply.disabled = true; try { await saveAssignment(agent.id, row, true); } catch (error) { toast(error.message, true); } finally { if (row.isConnected) apply.disabled = !publish.checked; } }); actions.append(apply); editor.append(actions);
|
||||
function updateHint() { syncCertificateHint(); editorHint.textContent = hintFor({ hostname: host.value.trim(), domain: domainSelect.value, targetLabel: target.selectedOptions?.[0]?.textContent || t("dockerBackendIpAuto"), scheme: scheme.value, h2: h2Enabled.checked, h3: h3Enabled.checked, aliasCount: aliases.count() }); } updateHint();
|
||||
for (const control of [host, aliases.input, target, scheme]) { control.addEventListener("input", updateHint); control.addEventListener("change", updateHint); }
|
||||
|
||||
+78
-14
@@ -37,10 +37,41 @@
|
||||
const h2 = $("notfound-http2"), h3 = $("notfound-http3");
|
||||
control.onChange(() => { const caps = control.capabilities(); h2.disabled = !caps.http2; h3.disabled = !caps.http3; if (!caps.http2) h2.checked = false; if (!caps.http3) h3.checked = false; });
|
||||
}
|
||||
const CLOUDFLARE_KINDS = ["cloudflare", "cloudflare_welcome", "cloudflare_placeholder"];
|
||||
const kindGroup = mode => CLOUDFLARE_KINDS.includes(mode) ? "cloudflare" : mode;
|
||||
function syncMode() {
|
||||
const mode = $("notfound-mode").value;
|
||||
populateStatuses();
|
||||
$("notfound-html-field").hidden = mode !== "html";
|
||||
for (const radio of form.querySelectorAll('input[name="notfound-kind"]')) { radio.checked = radio.value === kindGroup(mode); radio.closest(".vh-www-choice").classList.toggle("is-selected", radio.checked); }
|
||||
$("notfound-variant-field").hidden = !CLOUDFLARE_KINDS.includes(mode);
|
||||
if (CLOUDFLARE_KINDS.includes(mode)) $("notfound-variant").value = mode;
|
||||
schedulePreview();
|
||||
}
|
||||
function chooseKind(group) {
|
||||
const mode = group === "cloudflare" ? (CLOUDFLARE_KINDS.includes($("notfound-variant").value) ? $("notfound-variant").value : "cloudflare") : group;
|
||||
$("notfound-mode").value = mode; syncMode();
|
||||
}
|
||||
// Preview of the selected page through the sandboxed /api/pages/preview.
|
||||
let previewTimer = null;
|
||||
function previewUrl(mode = $("notfound-mode").value, status = $("notfound-status").value, host = editing) {
|
||||
const params = new URLSearchParams({ kind: mode, status: String(status || 404) });
|
||||
if (mode === "html") { if (!host) return ""; params.set("host", host); }
|
||||
return `/api/pages/preview?${params}`;
|
||||
}
|
||||
function schedulePreview() { clearTimeout(previewTimer); previewTimer = setTimeout(updatePreview, 150); }
|
||||
function updatePreview() {
|
||||
const frame = $("notfound-preview-frame"), open = $("notfound-preview-open"), note = $("notfound-preview-note"); if (!frame) return;
|
||||
const mode = $("notfound-mode").value, saved = (envelope?.config.not_found_hosts || []).find(item => item.id === editing);
|
||||
const savedHtml = saved?.page?.kind === "html" ? saved.page.html : null;
|
||||
let noteKey = "";
|
||||
if (mode === "html" && savedHtml === null) noteKey = "notfoundPreviewHtmlUnsaved";
|
||||
else if (mode === "html" && savedHtml !== $("notfound-html").value) noteKey = "notfoundPreviewHtmlSaved";
|
||||
else if (mode === "empty") noteKey = "notfoundPreviewEmpty";
|
||||
note.hidden = !noteKey; if (noteKey) { note.dataset.i18n = noteKey; note.textContent = t(noteKey); }
|
||||
const url = mode === "html" && savedHtml === null ? "" : previewUrl(mode);
|
||||
frame.hidden = !url || !dialog.open; open.hidden = !url;
|
||||
if (url) { open.href = url; if (frame.dataset.src !== url && dialog.open) { frame.dataset.src = url; frame.src = url; } }
|
||||
}
|
||||
function load(item = defaults()) {
|
||||
editing = item.id || null; revision = envelope?.revision ?? null; dirty = false;
|
||||
@@ -48,14 +79,26 @@
|
||||
$("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-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(); } });
|
||||
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);
|
||||
notFoundAutoCertificate = window.rustProxyAutoCertificate.attach($("notfound-certificate"), { auto: !editing, hosts: () => { try { return readHosts(); } catch { return []; } }, certificates: () => envelope?.config.tls?.certificates || [] }); notFoundAutoCertificate.refresh();
|
||||
$("notfound-mode").value = item.page?.kind || "welcome"; populateStatuses(item.page?.status ?? 404); $("notfound-html").value = item.page?.html || ""; syncMode(); dialog.showModal();
|
||||
$("notfound-mode").value = item.page?.kind || "welcome"; populateStatuses(item.page?.status ?? 404); $("notfound-html").value = item.page?.html || "";
|
||||
const frame = $("notfound-preview-frame"); frame.removeAttribute("src"); delete frame.dataset.src;
|
||||
activateTab("details"); syncSummary(); dialog.showModal(); syncMode();
|
||||
}
|
||||
function activateTab(name) {
|
||||
for (const node of $("notfound-tabs").querySelectorAll("button[data-tab]")) { const on = node.dataset.tab === name; node.classList.toggle("active", on); node.setAttribute("aria-pressed", String(on)); }
|
||||
for (const group of $("notfound-fields").querySelectorAll(".vh-group[data-tab]")) group.hidden = group.dataset.tab !== name;
|
||||
$("notfound-fields").scrollTop = 0; if (name === "response") updatePreview();
|
||||
}
|
||||
const activeTab = () => $("notfound-tabs").querySelector("button.active")?.dataset.tab || "details";
|
||||
function syncSummary() {
|
||||
const hosts = (() => { try { return readHosts(); } catch { return []; } })();
|
||||
$("notfound-summary").textContent = [value("notfound-id") || t("notfoundNewLabel"), hosts.join(", ")].filter(Boolean).join(" · ");
|
||||
}
|
||||
function suspendDraft() {
|
||||
const state = {
|
||||
editing, revision, label: $("notfound-editing").textContent, controls: window.rustProxyDrafts.captureControls(form),
|
||||
editing, revision, label: $("notfound-editing").textContent, tab: activeTab(), controls: window.rustProxyDrafts.captureControls(form),
|
||||
hosts: window.rustProxyDrafts.takeChildren($("notfound-hosts-editor")), listeners: window.rustProxyDrafts.takeChildren($("notfound-listeners")),
|
||||
readBindings, readHosts
|
||||
};
|
||||
@@ -64,7 +107,7 @@
|
||||
function restoreDraft(state) {
|
||||
window.rustProxyDrafts.restoreChildren($("notfound-hosts-editor"), state.hosts); window.rustProxyDrafts.restoreChildren($("notfound-listeners"), state.listeners);
|
||||
readBindings = state.readBindings; readHosts = state.readHosts; editing = state.editing; revision = state.revision; dirty = true; $("notfound-editing").textContent = state.label;
|
||||
window.rustProxyDrafts.restoreControls(form, state.controls); syncEnabledControl(); syncMode(); if (!dialog.open) dialog.showModal();
|
||||
window.rustProxyDrafts.restoreControls(form, state.controls); syncEnabledControl(); syncSummary(); activateTab(state.tab || "details"); if (!dialog.open) dialog.showModal(); syncMode();
|
||||
}
|
||||
function closeEditor() { if (dirty) return window.rustProxyDrafts.dock("notfound"); if (dialog.open) dialog.close(); return true; }
|
||||
|
||||
@@ -76,26 +119,47 @@
|
||||
if (kind === "html" && !html.trim()) throw new Error(t("notfoundHtmlRequired"));
|
||||
return { id, name, enabled: yes("notfound-enabled"), http2_enabled: yes("notfound-http2"), http3_enabled: yes("notfound-http3"), frontend: { hosts, listener_ids }, certificate_id: value("notfound-certificate") || null, page: { kind, status, html: kind === "html" ? html : "" } };
|
||||
}
|
||||
const modeKey = kind => `notfoundMode${kind.replace(/(^|_)([a-z])/g, (_, prefix, c) => c.toUpperCase())}`;
|
||||
function listenerLabel(id) {
|
||||
const endpoint = (envelope?.config.listeners?.endpoints || []).find(item => item.id === id);
|
||||
if (!endpoint) return id;
|
||||
const address = endpoint.binding?.address || "";
|
||||
return `${endpoint.binding?.tls ? "HTTPS" : "HTTP"} ${address.replace(/^0\.0\.0\.0|^\[::\]/, "")}`.trim();
|
||||
}
|
||||
async function toggleEnabled(item) {
|
||||
if (busy) return;
|
||||
if (item.enabled !== false && !(await appConfirm(t("notfoundDisableConfirm"), { danger: true, confirmLabel: t("redirectDisable") }))) return;
|
||||
const next = structuredClone(envelope.config.not_found_hosts || []), index = next.findIndex(value => value.id === item.id); if (index < 0) return;
|
||||
next[index].enabled = item.enabled === false;
|
||||
if (await saveSection("not-found-hosts", next)) render();
|
||||
}
|
||||
function render() {
|
||||
if (!envelope) return; const query = ($("notfound-search").value || "").trim().toLowerCase();
|
||||
const entries = (envelope.config.not_found_hosts || []).filter(item => !query || [item.id, item.name, ...(item.frontend?.hosts || [])].join(" ").toLowerCase().includes(query));
|
||||
const sortValue = item => ({ id: String(item.id || "").toLowerCase(), name: String(item.name || item.id || "").toLowerCase(), hostname: String(item.frontend?.hosts?.[0] || "").toLowerCase(), status: Number(item.page?.status ?? 404), mode: String(item.page?.kind || "welcome"), listeners: (item.frontend?.listener_ids || []).join(" ").toLowerCase(), certificate: String(item.certificate_id || "").toLowerCase() }[listPrefs.sort]);
|
||||
entries.sort((left, right) => { const a = sortValue(left), b = sortValue(right); const result = typeof a === "number" && typeof b === "number" ? a - b : compareText(a, b); return listPrefs.descending ? -result : result; });
|
||||
list.replaceChildren(...entries.map(item => {
|
||||
const card = el("article", undefined, "vhost-card redirect-card"), head = el("div", undefined, "vhost-card-head"), identity = el("div", undefined, "vhost-card-identity"), title = el("div", undefined, "vhost-title-line");
|
||||
title.append(el("strong", item.name || item.id, "entity-title")); if (item.enabled === false) title.append(el("span", t("vhDisabled"), "pill")); identity.append(title); head.append(identity);
|
||||
const actions = el("div", undefined, "entity-actions"); actions.append(action(t("edit"), () => { window.rustProxyDrafts.prepare(); load(structuredClone(item)); }), action(t("copyEntry"), () => { window.rustProxyDrafts.prepare(); const copy = structuredClone(item); copy.id = ""; copy.name = ""; copy.frontend = { ...(copy.frontend || {}), hosts: [] }; copy.certificate_id = null; load(copy); }), action(t("remove"), async () => { if (busy || !(await appConfirm(t("confirmDelete"), { danger: true }))) return; const next = (envelope.config.not_found_hosts || []).filter(value => value.id !== item.id); if (await saveSection("not-found-hosts", next)) { if (editing === item.id) dialog.close(); render(); } })); head.append(actions); card.append(head);
|
||||
const flow = el("div", undefined, "redirect-flow"), from = el("div", undefined, "redirect-flow-from"), to = el("div", undefined, "redirect-flow-to");
|
||||
for (const host of item.frontend?.hosts || []) from.append(el("span", host, "redirect-host-chip"));
|
||||
to.append(el("span", `${item.page?.status ?? 404} ${STATUS_NAMES[item.page?.status ?? 404] || ""}`.trim(), "redirect-target"), el("span", t(`notfoundMode${(item.page?.kind || "welcome").replace(/(^|_)([a-z])/g, (_, prefix, c) => c.toUpperCase())}`), "redirect-target-more"));
|
||||
flow.append(from, el("span", "→", "redirect-flow-arrow"), to); card.append(flow);
|
||||
const meta = el("div", undefined, "redirect-meta");
|
||||
for (const [k, v] of [["redirectListeners", (item.frontend?.listener_ids || []).join(", ") || "-"], ["vhCertificate", item.certificate_id || t("vhCertificateDefault")]]) { const node = el("span", undefined, "redirect-meta-item"); node.append(el("span", t(k)), el("b", v)); meta.append(node); }
|
||||
card.append(meta); return card;
|
||||
const card = el("article", undefined, "vhost-card redirect-card notfound-card"), head = el("div", undefined, "vhost-card-head"), identity = el("div", undefined, "vhost-card-identity"), title = el("div", undefined, "vhost-title-line");
|
||||
card.dataset.notfoundCard = item.id;
|
||||
const kind = item.page?.kind || "welcome", status = item.page?.status ?? 404;
|
||||
title.append(el("strong", item.name || item.id, "entity-title"), el("span", t(item.enabled === false ? "notfoundStateOff" : "notfoundStateOn"), item.enabled === false ? "pill" : "pill live"), el("span", `${status} · ${t(modeKey(kind))}`, kind === "welcome" ? "pill" : "pill warn"));
|
||||
identity.append(title, el("div", `${item.id} · ${(item.frontend?.hosts || []).join(", ") || "-"}`, "vhost-hosts")); head.append(identity);
|
||||
const actions = el("div", undefined, "entity-actions"); const toggle = action(t(item.enabled === false ? "redirectEnable" : "redirectDisable"), () => toggleEnabled(item)); if (item.enabled !== false) toggle.classList.add("danger-quiet");
|
||||
const preview = el("a", t("notfoundPreview"), "quiet notfound-card-preview"); preview.href = previewUrl(kind, status, item.id); preview.target = "_blank"; preview.rel = "noopener noreferrer";
|
||||
actions.append(toggle, action(t("edit"), () => { window.rustProxyDrafts.prepare(); load(structuredClone(item)); }), action(t("copyEntry"), () => { window.rustProxyDrafts.prepare(); const copy = structuredClone(item); copy.id = ""; copy.name = ""; copy.frontend = { ...(copy.frontend || {}), hosts: [] }; copy.certificate_id = null; load(copy); }), action(t("remove"), async () => { if (busy || !(await appConfirm(t("confirmDelete"), { danger: true }))) return; const next = (envelope.config.not_found_hosts || []).filter(value => value.id !== item.id); if (await saveSection("not-found-hosts", next)) { if (editing === item.id) dialog.close(); render(); } })); head.append(actions); card.append(head);
|
||||
const editButton = [...actions.children].find(node => node.textContent === t("edit")); editButton?.after(preview);
|
||||
const details = el("div", undefined, "vhost-detail-strip");
|
||||
const protocols = ["HTTP/1.1", item.http2_enabled !== false ? "HTTP/2" : "", item.http3_enabled !== false ? "HTTP/3" : ""].filter(Boolean).join(" · ");
|
||||
for (const [key, shown] of [["redirectListeners", (item.frontend?.listener_ids || []).map(listenerLabel).join(" · ") || "-"], ["vhCertificate", item.certificate_id || t("vhCertificateDefault")], ["notfoundResponseTab", `${status} ${STATUS_NAMES[status] || ""}`.trim()], ["vhProtocols", protocols]]) { const cell = el("div", undefined, "vhost-detail"); cell.append(el("span", t(key), "small-label"), el("b", shown)); details.append(cell); }
|
||||
card.append(details); return card;
|
||||
}));
|
||||
if (!entries.length) list.append(el("p", t(query ? "notfoundSearchEmpty" : "notfoundEmpty"), "fine"));
|
||||
}
|
||||
form.addEventListener("input", changed); form.addEventListener("change", changed); $("notfound-mode").addEventListener("change", syncMode); $("notfound-status").addEventListener("change", syncMode);
|
||||
for (const radio of form.querySelectorAll('input[name="notfound-kind"]')) radio.addEventListener("change", () => { if (radio.checked) chooseKind(radio.value); });
|
||||
$("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); } });
|
||||
$("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(); } });
|
||||
|
||||
+277
-180
@@ -954,7 +954,7 @@
|
||||
</select></label><button class="quiet backend-sort-direction"
|
||||
data-i18n-aria="backendSortAscending" id="docker-vhost-sort-direction"
|
||||
type="button">↑</button><label class="check compact-check docker-live-switch"
|
||||
title="Refresh this view from RustProxy memory every 5 seconds"><input class="switch"
|
||||
data-i18n-title="dockerLiveViewHelp" title="Refresh this view from RustProxy memory every 5 seconds"><input class="switch"
|
||||
id="docker-live-refresh" type="checkbox" /><span data-i18n="dockerLiveView">Live
|
||||
view</span></label><button class="primary" data-i18n="dockerPublishedOpen"
|
||||
id="docker-published-open" type="button">Published apps</button><button class="outline"
|
||||
@@ -2069,32 +2069,30 @@
|
||||
</article>
|
||||
</section>
|
||||
<section class="panel" hidden="" id="panel-settings">
|
||||
<div class="settings-shortcuts">
|
||||
<div><b data-i18n="security">Security</b>
|
||||
<p class="fine" data-i18n="settingsSecurityHint">Accounts and ACLs are global; SSL and
|
||||
response policies also have per-vhost controls.</p>
|
||||
</div><button class="outline" data-i18n="security" id="settings-security-open"
|
||||
type="button">Security</button><button class="quiet" data-i18n="vhosts"
|
||||
id="settings-vhost-open" type="button">Vhosts</button>
|
||||
</div>
|
||||
<div class="settings-filter-row">
|
||||
<label class="settings-filter"><span class="small-label" data-i18n="settingsSearch">Find
|
||||
settings</span><input autocomplete="off"
|
||||
data-i18n-placeholder="settingsSearchPlaceholder" id="settings-search"
|
||||
placeholder="Search settings..." type="search" /></label>
|
||||
<span class="fine" id="settings-search-status" role="status"></span>
|
||||
<div class="settings-shortcuts">
|
||||
<p class="fine" data-i18n="settingsSecurityHint">Accounts and ACLs are global; SSL and
|
||||
response policies also have per-vhost controls.</p><button class="outline"
|
||||
data-i18n="security" id="settings-security-open" type="button">Security</button><button
|
||||
class="quiet" data-i18n="vhosts" id="settings-vhost-open" type="button">Vhosts</button>
|
||||
</div>
|
||||
</div>
|
||||
<nav aria-label="Settings" class="settings-tabs" id="settings-tabs" role="tablist"><button
|
||||
<nav aria-label="Settings" class="settings-tabs" data-i18n-aria="settings" id="settings-tabs" role="tablist"><span aria-hidden="true" class="settings-nav-group" data-i18n="settingsGroupPanel">Panel</span><button
|
||||
aria-controls="settings-page-appearance" aria-selected="false" data-i18n="appearance"
|
||||
data-settings-tab="appearance" id="settings-tab-appearance" role="tab" tabindex="-1"
|
||||
type="button"></button><button aria-controls="settings-page-listeners" aria-selected="false"
|
||||
type="button"></button><span aria-hidden="true" class="settings-nav-group" data-i18n="settingsGroupNetwork">Network & input</span><button aria-controls="settings-page-listeners" aria-selected="false"
|
||||
data-i18n="listeners" data-settings-tab="listeners" id="settings-tab-listeners" role="tab"
|
||||
tabindex="-1" type="button"></button><button aria-controls="settings-page-connections"
|
||||
aria-selected="false" data-i18n="httpConnections" data-settings-tab="connections"
|
||||
id="settings-tab-connections" role="tab" tabindex="-1" type="button"></button><button
|
||||
aria-controls="settings-page-docker-agents" aria-selected="false" data-i18n="dockerAgents"
|
||||
data-settings-tab="docker-agents" id="settings-tab-docker-agents" role="tab" tabindex="-1"
|
||||
type="button"></button><button aria-controls="settings-page-policies" aria-selected="false"
|
||||
type="button"></button><span aria-hidden="true" class="settings-nav-group" data-i18n="settingsGroupTraffic">Traffic & responses</span><button aria-controls="settings-page-policies" aria-selected="false"
|
||||
data-i18n="policyRulesTitle" data-settings-tab="policies" id="settings-tab-policies"
|
||||
role="tab" tabindex="-1" type="button">Rules & headers</button><button
|
||||
aria-controls="settings-page-cache" aria-selected="false" data-i18n="cacheSettings"
|
||||
@@ -2106,7 +2104,7 @@
|
||||
data-i18n="forwardingSettings" data-settings-tab="forwarding" id="settings-tab-forwarding"
|
||||
role="tab" tabindex="-1" type="button"></button><button aria-controls="settings-page-pages"
|
||||
aria-selected="false" data-i18n="globalPages" data-settings-tab="pages"
|
||||
id="settings-tab-pages" role="tab" tabindex="-1" type="button"></button><button
|
||||
id="settings-tab-pages" role="tab" tabindex="-1" type="button"></button><span aria-hidden="true" class="settings-nav-group" data-i18n="settingsGroupObservability">Observability</span><button
|
||||
aria-controls="settings-page-logging" aria-selected="false" data-i18n="logging"
|
||||
data-settings-tab="logging" id="settings-tab-logging" role="tab" tabindex="-1"
|
||||
type="button"></button><button aria-controls="settings-page-geoip" aria-selected="false"
|
||||
@@ -2116,23 +2114,23 @@
|
||||
id="settings-tab-prometheus" role="tab" tabindex="-1" type="button"></button><button
|
||||
aria-controls="settings-page-alerts" aria-selected="false" data-i18n="alertSettingsTitle"
|
||||
data-settings-tab="alerts" id="settings-tab-alerts" role="tab" tabindex="-1"
|
||||
type="button"></button><span aria-hidden="true" class="settings-nav-group" data-i18n="settingsGroupAdministration">Administration</span><button
|
||||
aria-controls="settings-page-security" aria-selected="false" data-i18n="security"
|
||||
data-settings-tab="security" id="settings-tab-security" role="tab" tabindex="-1"
|
||||
type="button"></button><button 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
|
||||
role="tab" tabindex="-1" type="button"></button><button aria-controls="settings-page-manual-config"
|
||||
aria-selected="false" data-i18n="manualConfig" data-settings-tab="manual-config"
|
||||
id="settings-tab-manual-config" role="tab" tabindex="-1" type="button"></button><span aria-hidden="true" class="settings-nav-group" data-i18n="settingsGroupTls">TLS & certificates</span><button
|
||||
aria-controls="settings-page-tls-policy" aria-selected="false" data-i18n="tlsPolicy"
|
||||
data-settings-tab="tls-policy" id="settings-tab-tls-policy" role="tab" tabindex="-1"
|
||||
type="button"></button><button aria-controls="settings-page-manual-config"
|
||||
aria-selected="false" data-i18n="manualConfig" data-settings-tab="manual-config"
|
||||
id="settings-tab-manual-config" role="tab" tabindex="-1" type="button"></button><button
|
||||
aria-controls="settings-page-security" aria-selected="false" data-i18n="security"
|
||||
data-settings-tab="security" id="settings-tab-security" role="tab" tabindex="-1"
|
||||
type="button"></button></nav>
|
||||
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></nav>
|
||||
<div class="settings-pages" id="settings-pages">
|
||||
<div aria-labelledby="settings-tab-appearance" class="settings-page"
|
||||
data-settings-page="appearance" hidden="" id="settings-page-appearance" role="tabpanel">
|
||||
@@ -2519,12 +2517,11 @@
|
||||
</div>
|
||||
<section aria-labelledby="settings-tab-policies" class="settings-page"
|
||||
data-settings-page="policies" hidden="" id="settings-page-policies" role="tabpanel">
|
||||
<div class="card edit-form">
|
||||
<div class="card edit-form policy-settings-card">
|
||||
<div class="card-heading">
|
||||
<h2 data-i18n="policyRulesTitle">Rules & headers</h2><span class="pill live"
|
||||
data-i18n="hotApply">LIVE APPLY</span>
|
||||
<h2 data-i18n="policyRulesTitle">Rules & headers</h2>
|
||||
</div>
|
||||
<nav aria-label="Rules and headers" class="settings-tabs sub-tabs"
|
||||
<nav aria-label="Rules and headers" class="settings-tabs sub-tabs" data-i18n-aria="policyRulesTitle"
|
||||
id="policy-settings-tabs" role="tablist">
|
||||
<button aria-selected="true" data-policy-settings-tab="block-allow"
|
||||
data-i18n="globalBlockAllow" type="button">Global block / allow</button>
|
||||
@@ -2538,13 +2535,12 @@
|
||||
<button aria-selected="false" data-policy-settings-tab="response"
|
||||
data-i18n="responseSettings" type="button">Client response</button>
|
||||
</nav>
|
||||
</div>
|
||||
<div data-policy-settings-page="block-allow">
|
||||
<form class="card edit-form global-policy-form" id="global-security-form">
|
||||
<form class="edit-form embedded-settings-form global-policy-form" id="global-security-form">
|
||||
<div class="card-heading">
|
||||
<div><span class="small-label" data-i18n="globalPolicyScope">PUBLIC HTTP
|
||||
LISTENERS</span>
|
||||
<h2 data-i18n="globalBlockAllow">Global block / allow</h2>
|
||||
<h3 data-i18n="globalBlockAllow">Global block / allow</h3>
|
||||
</div><span class="pill live" data-i18n="hotApply">LIVE APPLY</span>
|
||||
</div>
|
||||
<p class="fine" data-i18n="globalPolicyHelp">These rules apply before routing to the
|
||||
@@ -2676,11 +2672,11 @@
|
||||
</form>
|
||||
</div>
|
||||
<div data-policy-settings-page="security-headers" hidden="">
|
||||
<form class="card edit-form global-policy-form" id="global-security-headers-form">
|
||||
<form class="edit-form embedded-settings-form global-policy-form" id="global-security-headers-form">
|
||||
<div class="card-heading">
|
||||
<div><span class="small-label" data-i18n="globalPolicyScope">PUBLIC HTTP
|
||||
LISTENERS</span>
|
||||
<h2 data-i18n="globalSecurityHeaders">Security headers</h2>
|
||||
<h3 data-i18n="globalSecurityHeaders">Security headers</h3>
|
||||
</div><span class="pill live" data-i18n="hotApply">LIVE APPLY</span>
|
||||
</div>
|
||||
<p class="fine" data-i18n="globalHeadersSecurityHelp">Global response-header
|
||||
@@ -2731,9 +2727,9 @@
|
||||
</form>
|
||||
</div>
|
||||
<div data-policy-settings-page="headers" hidden="">
|
||||
<form class="card edit-form" id="headers-form">
|
||||
<form class="edit-form embedded-settings-form" id="headers-form">
|
||||
<div class="card-heading">
|
||||
<h2 data-i18n="customHeaders">Global custom headers</h2><span class="pill live"
|
||||
<h3 data-i18n="customHeaders">Global custom headers</h3><span class="pill live"
|
||||
data-i18n="hotApply">LIVE APPLY</span>
|
||||
</div>
|
||||
<p class="fine" data-i18n="globalHeadersHelp">Request rules go to the backend;
|
||||
@@ -2756,9 +2752,9 @@
|
||||
</form>
|
||||
</div>
|
||||
<div data-policy-settings-page="policy" hidden="">
|
||||
<form class="card edit-form" id="policy-form">
|
||||
<form class="edit-form embedded-settings-form" id="policy-form">
|
||||
<div class="card-heading">
|
||||
<h2 data-i18n="policyTitle">HTTP policies</h2>
|
||||
<h3 data-i18n="policyTitle">HTTP policies</h3>
|
||||
<span class="pill live" data-i18n="hotApply">LIVE APPLY</span>
|
||||
</div>
|
||||
<div id="global-policy-rules-root"></div>
|
||||
@@ -2767,9 +2763,9 @@
|
||||
</form>
|
||||
</div>
|
||||
<div data-policy-settings-page="response" hidden="">
|
||||
<form class="card edit-form" id="response-form">
|
||||
<form class="edit-form embedded-settings-form" id="response-form">
|
||||
<div class="card-heading">
|
||||
<h2 data-i18n="responseSettings">Client response</h2><span class="pill live"
|
||||
<h3 data-i18n="responseSettings">Client response</h3><span class="pill live"
|
||||
data-i18n="hotApply">LIVE APPLY</span>
|
||||
</div>
|
||||
<label data-i18n="serverHeader" for="server-mode">Server header</label><select
|
||||
@@ -2813,6 +2809,7 @@
|
||||
type="submit">Apply response settings</button></div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<div aria-labelledby="settings-tab-cache" class="settings-page" data-settings-page="cache"
|
||||
hidden="" id="settings-page-cache" role="tabpanel">
|
||||
@@ -2825,6 +2822,11 @@
|
||||
<span class="pill live" data-i18n="hotApply">LIVE APPLY</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="fine settings-page-intro" data-i18n="cacheFlowIntro">Backend responses stored
|
||||
in memory (HOT) and optionally on disk (COLD). Select a step to open its
|
||||
settings.</p>
|
||||
<section class="settings-flow cache-flow" id="cache-flow"
|
||||
aria-label="Cache request flow" data-i18n-aria="cacheFlowTitle"></section>
|
||||
<nav aria-label="Cache settings" class="settings-tabs sub-tabs" id="cache-settings-tabs"
|
||||
role="tablist">
|
||||
<button aria-selected="true" data-cache-settings-tab="general"
|
||||
@@ -2970,6 +2972,7 @@
|
||||
|
||||
</div>
|
||||
<div data-cache-settings-page="resilience" hidden>
|
||||
<div class="settings-timeline" id="cache-resilience-timeline"></div>
|
||||
<h3 class="subheading" data-i18n="cacheCollapseTitle">Request collapsing</h3>
|
||||
<label class="check"><input class="switch" id="cache-collapse-enabled"
|
||||
type="checkbox" /><span data-i18n="cacheCollapseEnable">Collapse concurrent
|
||||
@@ -3194,6 +3197,8 @@
|
||||
<p class="fine" data-i18n="transformHelp">Transformation happens after upstream decoding
|
||||
and before cache storage and client compression. Each vhost must opt in separately.
|
||||
</p>
|
||||
<section class="settings-flow transform-flow" id="transform-flow"
|
||||
aria-label="Response transformation flow" data-i18n-aria="transformFlowTitle"></section>
|
||||
<div class="card soft-card cache-memory-sizing">
|
||||
<div class="card-heading">
|
||||
<h3 data-i18n="transformResourcePresetTitle">Resource preset</h3>
|
||||
@@ -3234,19 +3239,19 @@
|
||||
<div class="switch-grid transform-operations-grid">
|
||||
<label class="check"><input class="switch" id="transform-javascript"
|
||||
type="checkbox" /><span data-i18n="transformJavascript">JavaScript
|
||||
minification</span></label>
|
||||
minification</span><small class="switch-help" data-i18n="transformJavascriptHelp"></small></label>
|
||||
<label class="check"><input class="switch" id="transform-css"
|
||||
type="checkbox" /><span data-i18n="transformCss">CSS
|
||||
minification</span></label>
|
||||
minification</span><small class="switch-help" data-i18n="transformCssHelp"></small></label>
|
||||
<label class="check"><input class="switch" id="transform-html"
|
||||
type="checkbox" /><span data-i18n="transformHtml">HTML
|
||||
minification</span></label>
|
||||
minification</span><small class="switch-help" data-i18n="transformHtmlHelp"></small></label>
|
||||
<label class="check"><input class="switch" id="transform-svg"
|
||||
type="checkbox" /><span data-i18n="transformSvg">SVG
|
||||
optimization</span></label>
|
||||
optimization</span><small class="switch-help" data-i18n="transformSvgHelp"></small></label>
|
||||
<label class="check"><input class="switch" id="transform-json"
|
||||
type="checkbox" /><span data-i18n="transformJson">JSON
|
||||
compaction</span></label>
|
||||
compaction</span><small class="switch-help" data-i18n="transformJsonHelp"></small></label>
|
||||
</div>
|
||||
<label data-i18n="transformExtensions" for="transform-extensions">Allowed file
|
||||
extensions, one per line</label>
|
||||
@@ -4124,7 +4129,39 @@
|
||||
<button class="outline" data-i18n="securityAuditOpen" id="security-audit-open"
|
||||
type="button">Administration audit</button>
|
||||
</div>
|
||||
<div class="security-summary" id="security-summary"></div>
|
||||
<div class="security-stack">
|
||||
<article class="card security-account-card" id="security-account-card" tabindex="-1">
|
||||
<div class="card-heading">
|
||||
<div><span class="small-label" data-i18n="currentSession">CURRENT SESSION</span>
|
||||
<h2 class="session-user" id="session-user"></h2>
|
||||
</div>
|
||||
<button class="outline" data-i18n="revokeAll" id="revoke-sessions"
|
||||
type="button">Sign out all sessions</button>
|
||||
</div>
|
||||
<p class="fine" id="session-expiry"></p>
|
||||
<p class="fine security-note" data-i18n="recoveryHelp">Lost access? Run rust-proxy
|
||||
admin reset-password locally. Existing sessions will be revoked.</p>
|
||||
<details class="security-editor" id="security-password-editor">
|
||||
<summary><span data-i18n="changePassword">Change password</span><small
|
||||
class="fine" data-i18n="securityPasswordHint">Requires the current
|
||||
password and signs out all sessions.</small></summary>
|
||||
<form class="edit-form security-inline-form" id="password-form">
|
||||
<label data-i18n="currentPassword" for="current-password">Current
|
||||
password</label><input autocomplete="current-password"
|
||||
id="current-password" maxlength="128" required="" type="password" />
|
||||
<label data-i18n="newPassword" for="new-password">New password (12-128 UTF-8
|
||||
bytes)</label><input autocomplete="new-password" id="new-password"
|
||||
maxlength="128" minlength="12" required="" type="password" />
|
||||
<label data-i18n="confirmPassword" for="new-password-confirm">Confirm
|
||||
password</label><input autocomplete="new-password"
|
||||
id="new-password-confirm" maxlength="128" minlength="12" required=""
|
||||
type="password" />
|
||||
<div class="form-actions"><button class="primary" data-i18n="savePassword"
|
||||
type="submit">Change and sign out</button></div>
|
||||
</form>
|
||||
</details>
|
||||
</article>
|
||||
<article class="card edit-form certificate-api-card" id="api-tokens-card" tabindex="-1">
|
||||
<div class="card-heading">
|
||||
<h2 data-i18n="generalApiTokensTitle">API tokens (RO/RW)</h2>
|
||||
@@ -4187,38 +4224,7 @@
|
||||
<pre class="metrics-example" id="api-token-example"></pre>
|
||||
</details>
|
||||
</article>
|
||||
<article class="card security-account-card">
|
||||
<div class="card-heading">
|
||||
<div><span class="small-label" data-i18n="currentSession">CURRENT SESSION</span>
|
||||
<h2 class="session-user" id="session-user"></h2>
|
||||
</div>
|
||||
<button class="outline" data-i18n="revokeAll" id="revoke-sessions"
|
||||
type="button">Sign out all sessions</button>
|
||||
</div>
|
||||
<p class="fine" id="session-expiry"></p>
|
||||
<p class="fine security-note" data-i18n="recoveryHelp">Lost access? Run rust-proxy
|
||||
admin reset-password locally. Existing sessions will be revoked.</p>
|
||||
<details class="security-editor" id="security-password-editor">
|
||||
<summary><span data-i18n="changePassword">Change password</span><small
|
||||
class="fine" data-i18n="securityPasswordHint">Requires the current
|
||||
password and signs out all sessions.</small></summary>
|
||||
<form class="edit-form security-inline-form" id="password-form">
|
||||
<label data-i18n="currentPassword" for="current-password">Current
|
||||
password</label><input autocomplete="current-password"
|
||||
id="current-password" maxlength="128" required="" type="password" />
|
||||
<label data-i18n="newPassword" for="new-password">New password (12-128 UTF-8
|
||||
bytes)</label><input autocomplete="new-password" id="new-password"
|
||||
maxlength="128" minlength="12" required="" type="password" />
|
||||
<label data-i18n="confirmPassword" for="new-password-confirm">Confirm
|
||||
password</label><input autocomplete="new-password"
|
||||
id="new-password-confirm" maxlength="128" minlength="12" required=""
|
||||
type="password" />
|
||||
<div class="form-actions"><button class="primary" data-i18n="savePassword"
|
||||
type="submit">Change and sign out</button></div>
|
||||
</form>
|
||||
</details>
|
||||
</article>
|
||||
<article class="card security-policy-card">
|
||||
<article class="card security-policy-card" id="security-policy-card" tabindex="-1">
|
||||
<div class="card-heading">
|
||||
<div><span class="small-label" data-i18n="securityAccessControl">ACCESS
|
||||
CONTROL</span>
|
||||
@@ -4238,15 +4244,30 @@
|
||||
comma-separated</label><input id="policy-hosts"
|
||||
placeholder="app.localhost" required="" />
|
||||
<label data-i18n="aclDefault" for="policy-default">Default
|
||||
decision</label><select id="policy-default">
|
||||
decision</label><select id="policy-default" class="policy-default-select">
|
||||
<option data-i18n="deny" value="deny">Deny</option>
|
||||
<option data-i18n="allow" value="allow">Allow</option>
|
||||
</select>
|
||||
<div class="vh-www-choices policy-default-cards" id="policy-default-cards" role="radiogroup"
|
||||
aria-label="Default decision" data-i18n-aria="aclDefault">
|
||||
<label class="vh-www-choice"><input name="policy-default-card" type="radio" value="allow" /><span
|
||||
class="vh-www-choice-copy"><b data-i18n="policyDefaultAllowTitle">Allow by default</b><small
|
||||
data-i18n="policyDefaultAllowHelp">block only the listed deny CIDRs</small></span></label>
|
||||
<label class="vh-www-choice"><input name="policy-default-card" type="radio" value="deny" /><span
|
||||
class="vh-www-choice-copy"><b data-i18n="policyDefaultDenyTitle">Deny by default</b><small
|
||||
data-i18n="policyDefaultDenyHelp">allow only the listed allow CIDRs</small></span></label>
|
||||
</div>
|
||||
<label data-i18n="aclRules" for="policy-rules">Rules: allow/deny followed by
|
||||
CIDR, one per line</label><textarea id="policy-rules"
|
||||
placeholder="allow 127.0.0.1/32" rows="4" spellcheck="false"></textarea>
|
||||
<p class="fine" data-i18n="aclHelp">Deny wins. Route allow never overrides
|
||||
host deny. The socket client IP is used.</p>
|
||||
<section class="acl-simulator" id="policy-simulator" aria-live="polite">
|
||||
<label for="policy-simulator-ips"><span data-i18n="policySimulatorTitle">How will it decide?</span>
|
||||
<input id="policy-simulator-ips" placeholder="10.1.2.3, 203.0.113.9, 2001:db8::5"
|
||||
spellcheck="false" autocomplete="off" /></label>
|
||||
<div class="acl-simulator-results" id="policy-simulator-results"></div>
|
||||
</section>
|
||||
<div class="form-actions"><button class="primary" data-i18n="savePolicy"
|
||||
type="submit">Apply host policy</button></div>
|
||||
</form>
|
||||
@@ -4805,7 +4826,10 @@ curl -sS -D - -o /dev/null \
|
||||
<fieldset class="vh-group vh-wide">
|
||||
<legend data-i18n="webServicePresetTitle">Configuration preset</legend>
|
||||
<div class="vh-grid">
|
||||
<label><span data-i18n="webServicePreset">Preset</span><select id="web-service-preset">
|
||||
<div class="vh-wide vh-www-choices web-service-kinds" id="web-service-kinds" role="radiogroup"
|
||||
aria-labelledby="web-service-kind-title"></div>
|
||||
<span hidden id="web-service-kind-title" data-i18n="webServiceKindTitle">Service type</span>
|
||||
<label id="web-service-preset-field"><span data-i18n="webServicePreset">Preset</span><select id="web-service-preset">
|
||||
<option data-i18n="webServicePresetCustom" value="custom">Custom</option>
|
||||
<option data-i18n="webServicePresetStatic" value="static">Static site</option>
|
||||
<option data-i18n="webServicePresetSpa" value="spa">SPA</option>
|
||||
@@ -4837,6 +4861,9 @@ curl -sS -D - -o /dev/null \
|
||||
service ID/name and PHP-FPM endpoint are not replaced.</p>
|
||||
</div>
|
||||
</fieldset>
|
||||
<section class="vh-wide vh-setting-section web-service-setting-section">
|
||||
<h3 data-i18n="webServiceGeneralSection">General settings</h3>
|
||||
<div class="vh-grid">
|
||||
<label><span data-i18n="webServiceName">Name</span><input id="web-service-name" maxlength="96"
|
||||
required="" /></label>
|
||||
<label class="auto-id-field"><span data-i18n="webServiceId">Service ID</span><input
|
||||
@@ -4850,6 +4877,8 @@ curl -sS -D - -o /dev/null \
|
||||
used when PHP-FPM is enabled.</small></label>
|
||||
<label class="check"><input class="switch" id="web-service-listing" type="checkbox" /><span
|
||||
data-i18n="webServiceDirectoryListing">Directory listing</span></label>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<div class="vh-grid web-service-page" data-web-service-page="routing" hidden>
|
||||
<label class="vh-wide"><span data-i18n="webServiceTryFiles">try_files</span><textarea
|
||||
@@ -4995,8 +5024,10 @@ curl -sS -D - -o /dev/null \
|
||||
<section class="vh-wide vh-setting-section web-service-setting-section">
|
||||
<h3 data-i18n="webServicePhpSourceSection">FastCGI configuration source and endpoint</h3>
|
||||
<div class="vh-grid">
|
||||
<label class="vh-wide"><span data-i18n="phpProfileSelect">FastCGI configuration
|
||||
source</span>
|
||||
<div class="vh-wide vh-www-choices web-service-php-sources" id="web-service-php-sources"
|
||||
role="radiogroup" aria-labelledby="web-service-php-sources-title"></div>
|
||||
<span hidden id="web-service-php-sources-title" data-i18n="phpProfileSelect">FastCGI configuration source</span>
|
||||
<label class="vh-wide" id="web-service-php-profile-field"><span data-i18n="phpProfileLabel">Profile</span>
|
||||
<select id="web-service-php-profile">
|
||||
<option value="" data-i18n="phpProfileLocal">Local configuration</option>
|
||||
</select>
|
||||
@@ -5004,7 +5035,10 @@ curl -sS -D - -o /dev/null \
|
||||
locally.
|
||||
Profile changes apply to all attached Web Services.</small>
|
||||
</label>
|
||||
<div class="vh-wide"><button type="button" class="outline" id="web-service-php-profiles"
|
||||
<div class="vh-wide vhost-detail-strip web-service-php-profile-summary" hidden
|
||||
id="web-service-php-profile-summary"></div>
|
||||
<div class="vh-wide web-service-php-profile-actions"><button type="button" class="outline" hidden
|
||||
id="web-service-php-profile-edit" data-i18n="phpProfileEdit">Edit profile</button><button type="button" class="outline" id="web-service-php-profiles"
|
||||
data-i18n="phpProfileManage">Manage FastCGI profiles</button></div>
|
||||
<div class="vh-wide php-switch-row"><label class="check php-switch-label"><input
|
||||
class="switch" id="web-service-php-enabled" type="checkbox" /><span
|
||||
@@ -5357,49 +5391,65 @@ log_errors = On</code></pre>
|
||||
id="redirect-editing">NEW</span><button class="quiet" data-i18n="close" id="redirect-close"
|
||||
type="button">Close</button>
|
||||
</div>
|
||||
<fieldset class="vh-group editor-identity-section">
|
||||
<legend data-i18n="hostIdentitySection">Host and domains</legend>
|
||||
<div class="vh-grid">
|
||||
<label><span data-i18n="redirectName">Display name</span><input id="redirect-name"
|
||||
maxlength="96" /></label>
|
||||
<label class="auto-id-field"><span data-i18n="redirectId">Redirect ID</span><input id="redirect-id"
|
||||
maxlength="64" pattern="[A-Za-z0-9_\-]{1,64}" required="" /></label>
|
||||
<label class="check"><input class="switch" id="redirect-enabled" type="checkbox" /><span
|
||||
data-i18n="enabled">Enabled</span></label>
|
||||
<div class="vh-wide" id="redirect-hosts-editor"></div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<section class="vh-group">
|
||||
<div class="card-heading">
|
||||
<div><span class="small-label" data-i18n="redirectFrontend">FRONTEND</span>
|
||||
<h3 data-i18n="redirectListeners">Listeners</h3>
|
||||
<div class="vh-live-summary" id="redirect-summary"></div>
|
||||
<nav aria-label="Redirect configuration" class="vh-tabs" data-i18n-aria="redirectEditor"
|
||||
id="redirect-tabs"><button data-tab="details" data-i18n="redirectTabDetails"
|
||||
type="button">Details</button><button data-tab="frontend" data-i18n="redirectFrontendTab"
|
||||
type="button">Frontend</button><button data-tab="rules" type="button"><span
|
||||
data-i18n="redirectRules">Rules</span> <span class="vh-tab-count"
|
||||
id="redirect-rule-count"></span></button></nav>
|
||||
<div class="editor-fields" id="redirect-fields">
|
||||
<fieldset class="vh-group editor-identity-section" data-tab="details">
|
||||
<legend data-i18n="hostIdentitySection">Host and domains</legend>
|
||||
<div class="vh-grid">
|
||||
<label><span data-i18n="redirectName">Display name</span><input id="redirect-name"
|
||||
maxlength="96" /></label>
|
||||
<label class="auto-id-field"><span data-i18n="redirectId">Redirect ID</span><input
|
||||
id="redirect-id" maxlength="64" pattern="[A-Za-z0-9_\-]{1,64}" required="" /></label>
|
||||
<label class="check"><input class="switch" id="redirect-enabled" type="checkbox" /><span
|
||||
data-i18n="enabled">Enabled</span></label>
|
||||
<div class="vh-wide" id="redirect-hosts-editor"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="vh-grid editor-frontend-certificate">
|
||||
<label><span data-i18n="vhCertificate">Certificate</span><select
|
||||
id="redirect-certificate"></select></label>
|
||||
</div>
|
||||
<div class="redirect-listeners" id="redirect-listeners"></div>
|
||||
<div class="frontend-protocol-controls">
|
||||
<span class="small-label" data-i18n="vhProtocols">Protocols</span>
|
||||
<div class="protocol-toggle-row"><label class="check"><input class="switch" id="redirect-http2"
|
||||
type="checkbox" /><span data-i18n="vhHttp2Enabled">Enable HTTP/2 for this
|
||||
host</span></label><label class="check"><input class="switch" id="redirect-http3"
|
||||
type="checkbox" /><span data-i18n="vhHttp3Enabled">Enable HTTP/3 for this
|
||||
host</span></label></div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="vh-group">
|
||||
<div class="card-heading">
|
||||
<div><span class="small-label" data-i18n="redirectBehavior">BEHAVIOR</span>
|
||||
<h3 data-i18n="redirectRules">Rules</h3>
|
||||
</div><button class="quiet" data-i18n="redirectAddRule" id="redirect-rule-add" type="button">Add
|
||||
rule</button>
|
||||
</div>
|
||||
<p class="fine" data-i18n="redirectRulesHelp">Longest matching path wins. 307/308 preserve the request
|
||||
method; 301/302/303 may change it in clients.</p>
|
||||
<div class="redirect-rules" id="redirect-rules"></div>
|
||||
</section>
|
||||
</fieldset>
|
||||
<section class="vh-group" data-tab="frontend">
|
||||
<div class="card-heading">
|
||||
<div><span class="small-label" data-i18n="redirectFrontend">FRONTEND</span>
|
||||
<h3 data-i18n="redirectListeners">Listeners</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="vh-grid editor-frontend-certificate">
|
||||
<label><span data-i18n="vhCertificate">Certificate</span><select
|
||||
id="redirect-certificate"></select></label>
|
||||
</div>
|
||||
<div class="redirect-listeners" id="redirect-listeners"></div>
|
||||
<div class="frontend-protocol-controls">
|
||||
<span class="small-label" data-i18n="vhProtocols">Protocols</span>
|
||||
<div class="protocol-toggle-row"><label class="check"><input class="switch" id="redirect-http2"
|
||||
type="checkbox" /><span data-i18n="vhHttp2Enabled">Enable HTTP/2 for this
|
||||
host</span></label><label class="check"><input class="switch" id="redirect-http3"
|
||||
type="checkbox" /><span data-i18n="vhHttp3Enabled">Enable HTTP/3 for this
|
||||
host</span></label></div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="vh-group" data-tab="rules">
|
||||
<div class="location-toolbar redirect-rule-toolbar">
|
||||
<div class="location-add-menu" id="redirect-rule-menu"><button aria-expanded="false"
|
||||
aria-haspopup="true" class="primary" data-i18n="redirectAddRule" id="redirect-rule-add"
|
||||
type="button">Add rule</button>
|
||||
<div class="location-templates" hidden="" id="redirect-rule-templates"></div>
|
||||
</div>
|
||||
<p class="fine" data-i18n="redirectRulesHelp">Longest matching path wins. 307/308 preserve the
|
||||
request method; 301/302/303 may change it in clients.</p>
|
||||
</div>
|
||||
<div class="vh-locations redirect-rules" id="redirect-rules"></div>
|
||||
<section class="redirect-tester" id="redirect-tester">
|
||||
<label><span data-i18n="redirectTestUrl">Test a URL against the unsaved rules</span><input
|
||||
autocomplete="off" id="redirect-test-url" maxlength="4096" spellcheck="false"
|
||||
type="text" /></label>
|
||||
<p class="redirect-test-result" id="redirect-test-result" aria-live="polite"></p>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
<div class="form-actions"><button class="primary" data-i18n="apply" type="submit">Validate, save and
|
||||
apply</button><button class="quiet" data-i18n="vhReset" id="redirect-reset" type="button">Discard
|
||||
changes</button><button class="quiet" data-editor-cancel="redirect" data-i18n="vhCancel"
|
||||
@@ -5416,66 +5466,113 @@ log_errors = On</code></pre>
|
||||
id="notfound-editing">NEW</span><button class="quiet" data-i18n="close" id="notfound-close"
|
||||
type="button">Close</button>
|
||||
</div>
|
||||
<fieldset class="vh-group editor-identity-section">
|
||||
<legend data-i18n="hostIdentitySection">Host and domains</legend>
|
||||
<div class="vh-grid">
|
||||
<label><span data-i18n="notfoundName">Display name</span><input id="notfound-name"
|
||||
maxlength="96" /></label>
|
||||
<label class="auto-id-field"><span data-i18n="notfoundId">Host ID</span><input id="notfound-id"
|
||||
maxlength="64" pattern="[A-Za-z0-9_\-]{1,64}" required="" /></label>
|
||||
<label class="check"><input class="switch" id="notfound-enabled" type="checkbox" /><span
|
||||
data-i18n="enabled">Enabled</span></label>
|
||||
<div class="vh-wide" id="notfound-hosts-editor"></div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<section class="vh-group">
|
||||
<div class="card-heading">
|
||||
<div><span class="small-label" data-i18n="notfoundFrontend">FRONTEND</span>
|
||||
<h3 data-i18n="redirectListeners">Listeners</h3>
|
||||
<div class="vh-live-summary" id="notfound-summary"></div>
|
||||
<nav aria-label="404 host configuration" class="vh-tabs" data-i18n-aria="notfoundEditor"
|
||||
id="notfound-tabs"><button data-tab="details" data-i18n="redirectTabDetails"
|
||||
type="button">Details</button><button data-tab="frontend" data-i18n="redirectFrontendTab"
|
||||
type="button">Frontend</button><button data-tab="response" data-i18n="notfoundResponseTab"
|
||||
type="button">Response</button></nav>
|
||||
<div class="editor-fields" id="notfound-fields">
|
||||
<fieldset class="vh-group editor-identity-section" data-tab="details">
|
||||
<legend data-i18n="hostIdentitySection">Host and domains</legend>
|
||||
<div class="vh-grid">
|
||||
<label><span data-i18n="notfoundName">Display name</span><input id="notfound-name"
|
||||
maxlength="96" /></label>
|
||||
<label class="auto-id-field"><span data-i18n="notfoundId">Host ID</span><input
|
||||
id="notfound-id" maxlength="64" pattern="[A-Za-z0-9_\-]{1,64}" required="" /></label>
|
||||
<label class="check"><input class="switch" id="notfound-enabled" type="checkbox" /><span
|
||||
data-i18n="enabled">Enabled</span></label>
|
||||
<div class="vh-wide" id="notfound-hosts-editor"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="vh-grid editor-frontend-certificate">
|
||||
<label><span data-i18n="vhCertificate">Certificate</span><select
|
||||
id="notfound-certificate"></select></label>
|
||||
</div>
|
||||
<div id="notfound-listeners"></div>
|
||||
<div class="frontend-protocol-controls">
|
||||
<span class="small-label" data-i18n="vhProtocols">Protocols</span>
|
||||
<div class="protocol-toggle-row"><label class="check"><input class="switch" id="notfound-http2"
|
||||
type="checkbox" /><span data-i18n="vhHttp2Enabled">Enable HTTP/2 for this
|
||||
host</span></label><label class="check"><input class="switch" id="notfound-http3"
|
||||
type="checkbox" /><span data-i18n="vhHttp3Enabled">Enable HTTP/3 for this
|
||||
host</span></label></div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="vh-group">
|
||||
<div class="card-heading">
|
||||
<div><span class="small-label" data-i18n="notfoundBehavior">RESPONSE</span>
|
||||
<h3 data-i18n="notfoundResponse">Local response</h3>
|
||||
</fieldset>
|
||||
<section class="vh-group" data-tab="frontend">
|
||||
<div class="card-heading">
|
||||
<div><span class="small-label" data-i18n="notfoundFrontend">FRONTEND</span>
|
||||
<h3 data-i18n="redirectListeners">Listeners</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="vh-grid">
|
||||
<label><span data-i18n="notfoundMode">Response type</span><select id="notfound-mode">
|
||||
<option data-i18n="notfoundModeWelcome" value="welcome">RustProxy placeholder</option>
|
||||
<option data-i18n="notfoundModeBuiltin" value="builtin">Application-style status page
|
||||
</option>
|
||||
<option data-i18n="notfoundModeCloudflare" value="cloudflare">Cloudflare-style (offline,
|
||||
RustProxy-branded)</option>
|
||||
<option data-i18n="notfoundModeCloudflareWelcome" value="cloudflare_welcome">Cloudflare-style welcome page</option>
|
||||
<option data-i18n="notfoundModeCloudflarePlaceholder" value="cloudflare_placeholder">Cloudflare-style placeholder</option>
|
||||
<option data-i18n="notfoundModeEmpty" value="empty">Status only / empty</option>
|
||||
<option data-i18n="notfoundModeHtml" value="html">Custom HTML</option>
|
||||
</select></label>
|
||||
<label><span data-i18n="notfoundStatus">HTTP status</span><select id="notfound-status"
|
||||
required></select></label>
|
||||
<label class="vh-wide" id="notfound-html-field"><span data-i18n="notfoundHtml">Custom
|
||||
HTML</span><textarea id="notfound-html" maxlength="32768" rows="12"
|
||||
spellcheck="false"></textarea></label>
|
||||
</div>
|
||||
<p class="fine" data-i18n="notfoundResponseHelp">The host never opens an upstream connection. The
|
||||
built-in placeholder is no-store and intentionally omits optional RustProxy diagnostic/server
|
||||
headers.</p>
|
||||
</section>
|
||||
<div class="vh-grid editor-frontend-certificate">
|
||||
<label><span data-i18n="vhCertificate">Certificate</span><select
|
||||
id="notfound-certificate"></select></label>
|
||||
</div>
|
||||
<div id="notfound-listeners"></div>
|
||||
<div class="frontend-protocol-controls">
|
||||
<span class="small-label" data-i18n="vhProtocols">Protocols</span>
|
||||
<div class="protocol-toggle-row"><label class="check"><input class="switch"
|
||||
id="notfound-http2" type="checkbox" /><span data-i18n="vhHttp2Enabled">Enable
|
||||
HTTP/2 for this host</span></label><label class="check"><input class="switch"
|
||||
id="notfound-http3" type="checkbox" /><span data-i18n="vhHttp3Enabled">Enable
|
||||
HTTP/3 for this host</span></label></div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="vh-group vh-setting-section notfound-response" data-tab="response">
|
||||
<h3 data-i18n="notfoundResponse">Local response</h3>
|
||||
<div class="vh-www-choices notfound-kinds" id="notfound-kinds" role="radiogroup"
|
||||
aria-label="Response type" data-i18n-aria="notfoundMode">
|
||||
<label class="vh-www-choice"><input name="notfound-kind" type="radio" value="welcome" /><span
|
||||
class="vh-www-choice-copy"><b data-i18n="notfoundModeWelcome">RustProxy
|
||||
placeholder</b><small data-i18n="notfoundKindWelcomeHelp">A neutral “nothing
|
||||
here” page.</small></span></label>
|
||||
<label class="vh-www-choice"><input name="notfound-kind" type="radio" value="builtin" /><span
|
||||
class="vh-www-choice-copy"><b data-i18n="notfoundModeBuiltin">Application-style status
|
||||
page</b><small data-i18n="notfoundKindBuiltinHelp">The built-in error
|
||||
page.</small></span></label>
|
||||
<label class="vh-www-choice"><input name="notfound-kind" type="radio" value="cloudflare" /><span
|
||||
class="vh-www-choice-copy"><b data-i18n="notfoundKindCloudflare">Cloudflare style
|
||||
(offline)</b><small data-i18n="notfoundKindCloudflareHelp">Status page, welcome page
|
||||
or placeholder.</small></span></label>
|
||||
<label class="vh-www-choice"><input name="notfound-kind" type="radio" value="empty" /><span
|
||||
class="vh-www-choice-copy"><b data-i18n="notfoundModeEmpty">Status only /
|
||||
empty</b><small data-i18n="notfoundKindEmptyHelp">No body, only the
|
||||
status.</small></span></label>
|
||||
<label class="vh-www-choice notfound-kind-wide"><input name="notfound-kind" type="radio"
|
||||
value="html" /><span class="vh-www-choice-copy"><b data-i18n="notfoundModeHtml">Custom
|
||||
HTML</b><small data-i18n="notfoundKindHtmlHelp">Paste the page markup (no external
|
||||
resources).</small></span></label>
|
||||
</div>
|
||||
<div class="vh-grid">
|
||||
<label hidden="" id="notfound-mode-field"><span data-i18n="notfoundMode">Response
|
||||
type</span><select id="notfound-mode">
|
||||
<option data-i18n="notfoundModeWelcome" value="welcome">RustProxy placeholder</option>
|
||||
<option data-i18n="notfoundModeBuiltin" value="builtin">Application-style status page
|
||||
</option>
|
||||
<option data-i18n="notfoundModeCloudflare" value="cloudflare">Cloudflare-style
|
||||
(offline, RustProxy-branded)</option>
|
||||
<option data-i18n="notfoundModeCloudflareWelcome" value="cloudflare_welcome">
|
||||
Cloudflare-style welcome page</option>
|
||||
<option data-i18n="notfoundModeCloudflarePlaceholder" value="cloudflare_placeholder">
|
||||
Cloudflare-style placeholder</option>
|
||||
<option data-i18n="notfoundModeEmpty" value="empty">Status only / empty</option>
|
||||
<option data-i18n="notfoundModeHtml" value="html">Custom HTML</option>
|
||||
</select></label>
|
||||
<label id="notfound-variant-field"><span data-i18n="notfoundCloudflareVariant">Cloudflare
|
||||
variant</span><select id="notfound-variant">
|
||||
<option data-i18n="notfoundVariantError" value="cloudflare">Status page</option>
|
||||
<option data-i18n="notfoundVariantWelcome" value="cloudflare_welcome">Welcome
|
||||
page</option>
|
||||
<option data-i18n="notfoundVariantPlaceholder" value="cloudflare_placeholder">
|
||||
Placeholder</option>
|
||||
</select></label>
|
||||
<label><span data-i18n="notfoundStatus">HTTP status</span><select id="notfound-status"
|
||||
required></select></label>
|
||||
<label class="vh-wide" id="notfound-html-field"><span data-i18n="notfoundHtml">Custom
|
||||
HTML</span><textarea id="notfound-html" maxlength="32768" rows="12"
|
||||
spellcheck="false"></textarea></label>
|
||||
</div>
|
||||
<div class="notfound-preview" id="notfound-preview">
|
||||
<div class="notfound-preview-head"><span class="small-label"
|
||||
data-i18n="notfoundPreview">Preview</span><a class="quiet notfound-preview-open"
|
||||
data-i18n="notfoundPreviewOpen" id="notfound-preview-open" rel="noopener noreferrer"
|
||||
target="_blank">Open in a new tab</a></div>
|
||||
<iframe id="notfound-preview-frame" loading="lazy" referrerpolicy="no-referrer"
|
||||
sandbox="" title="Preview"></iframe>
|
||||
<p class="fine" hidden="" id="notfound-preview-note"></p>
|
||||
</div>
|
||||
<p class="fine" data-i18n="notfoundResponseHelp">The host never opens an upstream connection. The
|
||||
built-in placeholder is no-store and intentionally omits optional RustProxy diagnostic/server
|
||||
headers.</p>
|
||||
</section>
|
||||
</div>
|
||||
<div class="form-actions"><button class="primary" data-i18n="apply" type="submit">Validate, save and
|
||||
apply</button><button class="quiet" data-i18n="vhReset" id="notfound-reset" type="button">Discard
|
||||
changes</button><button class="quiet" data-editor-cancel="notfound" data-i18n="vhCancel"
|
||||
|
||||
@@ -173,6 +173,14 @@
|
||||
if (!enabled.checked) badges.push([t("vhDisabled"), "danger"]);
|
||||
headBadges.replaceChildren(...badges.map(([text, cls]) => el("span", text, `pill ${cls}`.trim())));
|
||||
};
|
||||
// Two sections like the other editors: identity/addresses and protocols.
|
||||
const listenerSection = (key, cls) => { const box = el("section", undefined, `location-card listener-section ${cls}`), heading = el("h4", undefined, "location-card-title"), sectionGrid = el("div", undefined, "vh-grid"); heading.append(label("span", key)); box.append(heading, sectionGrid); return [box, sectionGrid]; };
|
||||
const [identityBox, identityGrid] = listenerSection("listenerSectionIdentity", "listener-identity"), [protocolBox, protocolGrid] = listenerSection("listenerSectionProtocols", "listener-protocols");
|
||||
identityGrid.append(...[id, name, scope].map(control => control.closest("label")), grid.querySelector(".host-chip-field"));
|
||||
protocolGrid.append(...[enabled, tls, h2, h2c, h3].map(control => control.closest("label")));
|
||||
identityGrid.append(...grid.children);
|
||||
protocolBox.append(protocolActions);
|
||||
const listenerSections = el("div", undefined, "location-cards listener-sections"); listenerSections.append(identityBox, protocolBox); grid.replaceWith(listenerSections);
|
||||
for (const input of [tls, h2, h2c, h3]) input.addEventListener("change", sync);
|
||||
for (const type of ["input", "change", "keyup"]) row.addEventListener(type, syncHead); body.addEventListener("click", () => setTimeout(syncHead));
|
||||
sync();
|
||||
|
||||
+124
-22
@@ -5,8 +5,21 @@
|
||||
const codes = [400, 401, 403, 404, 408, 413, 429, 500, 502, 503, 504];
|
||||
const STATUS_NAMES = { 200: "OK", 204: "No Content", 400: "Bad Request", 401: "Unauthorized", 403: "Forbidden", 404: "Not Found", 408: "Request Timeout", 410: "Gone", 413: "Payload Too Large", 429: "Too Many Requests", 500: "Internal Server Error", 502: "Bad Gateway", 503: "Service Unavailable", 504: "Gateway Timeout" };
|
||||
const statusLabel = code => `${code} ${STATUS_NAMES[code] || ""}`.trim();
|
||||
function pageEditor(parent, key, value = null) {
|
||||
const row = el("div", undefined, "page-editor"), heading = label("strong", key, "page-label"); row.append(heading);
|
||||
const CLOUDFLARE_KINDS = ["cloudflare", "cloudflare_welcome", "cloudflare_placeholder"];
|
||||
const PAGE_KIND_CARDS = [["", "pageInherit", "pageKindInheritHelp"], ["welcome", "pageWelcome", "notfoundKindWelcomeHelp"], ["builtin", "pageBuiltin", "notfoundKindBuiltinHelp"], ["cloudflare", "notfoundKindCloudflare", "notfoundKindCloudflareHelp"], ["empty", "pageEmpty", "notfoundKindEmptyHelp"], ["html", "pageHtml", "notfoundKindHtmlHelp"]];
|
||||
let pageCardSerial = 0;
|
||||
// One default-response slot rendered as a compact row: the summary line shows
|
||||
// the slot, when it is used and its current response; the selected row opens
|
||||
// its controls (response type chips, Cloudflare variant, status, own HTML).
|
||||
// options: slot (preview/saved HTML key), vhostId, scope, title (literal row
|
||||
// title), whenKey, naturalStatus, onSelect, onChange.
|
||||
function pageEditor(parent, key, value = null, options = {}) {
|
||||
const row = el("div", undefined, "page-editor"), heading = options.title ? el("b", options.title, "page-label") : label("b", key, "page-label");
|
||||
const summary = el("button", undefined, "page-editor-summary"); summary.type = "button"; summary.setAttribute("aria-expanded", "false");
|
||||
const copy = el("span", undefined, "page-editor-head"); copy.append(heading); if (options.whenKey) copy.append(label("small", options.whenKey, "page-when"));
|
||||
const kindPill = el("span", "", "pill page-kind-pill"), statusPill = el("span", "", "pill page-status-pill");
|
||||
const badges = el("span", undefined, "page-editor-badges"); badges.append(kindPill, statusPill); summary.append(el("span", undefined, "page-editor-dot"), copy, badges);
|
||||
row.append(summary); row.dataset.pageSlot = options.slot || "";
|
||||
const mode = el("select"), status = el("select"), html = el("textarea"), file = el("input");
|
||||
mode.setAttribute("aria-label", t(key)); mode.className = "page-mode";
|
||||
mode.append(option("", "pageInherit"), option("welcome", "pageWelcome"), option("builtin", "pageBuiltin"), option("cloudflare", "pageCloudflare"), option("cloudflare_welcome", "pageCloudflareWelcome"), option("cloudflare_placeholder", "pageCloudflarePlaceholder"), option("empty", "pageEmpty"), option("html", "pageHtml"));
|
||||
@@ -17,35 +30,111 @@
|
||||
status.value = value?.status ?? ""; html.value = value?.html || ""; html.rows = 5; html.maxLength = 32768; html.spellcheck = false; html.className = "page-html"; html.setAttribute("aria-label", t("pageHtmlSource"));
|
||||
file.type = "file"; file.accept = ".html,.htm,text/html,text/plain"; file.setAttribute("aria-label", t("pageUploadHtml"));
|
||||
const source = el("div", undefined, "page-source"); source.append(label("span", "pageUploadHtml", "fine"), file, html);
|
||||
function sync() { if (mode.value && status.value === "204") mode.value = "empty"; status.disabled = !mode.value; source.hidden = mode.value !== "html"; }
|
||||
for (const event of ["change", "input"]) { mode.addEventListener(event, sync); status.addEventListener(event, sync); }
|
||||
file.addEventListener("change", async () => { try { const chosen = file.files[0]; if (!chosen) return; if (chosen.size > 32768) throw new Error(t("pageTooLarge")); html.value = await chosen.text(); html.dispatchEvent(new Event("input", { bubbles: true })); } catch (error) { toast(error.message, true); } finally { file.value = ""; } });
|
||||
row.append(mode, status, source); parent.append(row); sync();
|
||||
const controls = el("div", undefined, "page-editor-controls"); controls.hidden = true;
|
||||
// Chips drive the (hidden) select, which stays the single source of truth.
|
||||
const name = `page-kind-${++pageCardSerial}`, chips = el("div", undefined, "page-kind-chips"); chips.setAttribute("role", "radiogroup"); chips.setAttribute("aria-label", t(key));
|
||||
for (const [kind, titleKey, helpKey] of PAGE_KIND_CARDS) {
|
||||
const chip = el("label", undefined, "page-kind-chip"), radio = el("input"); radio.type = "radio"; radio.name = name; radio.value = kind;
|
||||
chip.append(radio, label("span", titleKey)); chip.title = t(helpKey); chip.dataset.i18nTitle = helpKey; chips.append(chip);
|
||||
radio.addEventListener("change", () => { if (!radio.checked) return; mode.value = kind === "cloudflare" ? variant.value : kind; mode.dispatchEvent(new Event("change", { bubbles: true })); });
|
||||
}
|
||||
const help = el("p", "", "fine page-kind-help");
|
||||
const variant = el("select"); variant.className = "page-variant"; variant.append(option("cloudflare", "notfoundVariantError"), option("cloudflare_welcome", "notfoundVariantWelcome"), option("cloudflare_placeholder", "notfoundVariantPlaceholder"));
|
||||
variant.addEventListener("change", () => { mode.value = variant.value; mode.dispatchEvent(new Event("change", { bubbles: true })); });
|
||||
const variantField = el("label", undefined, "page-variant-field"); variantField.append(label("span", "notfoundCloudflareVariant"), variant);
|
||||
const statusField = el("label", undefined, "page-status-field"); statusField.append(label("span", "pageStatus"), status);
|
||||
const fields = el("div", undefined, "page-editor-fields"); fields.append(variantField, statusField);
|
||||
mode.hidden = true; controls.append(chips, help, mode, fields, source);
|
||||
row.append(controls);
|
||||
function sync() {
|
||||
if (mode.value && status.value === "204") mode.value = "empty"; status.disabled = !mode.value; source.hidden = mode.value !== "html";
|
||||
const group = CLOUDFLARE_KINDS.includes(mode.value) ? "cloudflare" : mode.value;
|
||||
for (const radio of chips.querySelectorAll("input")) { radio.checked = radio.value === group; radio.closest(".page-kind-chip").classList.toggle("is-selected", radio.checked); }
|
||||
variantField.hidden = group !== "cloudflare"; if (group === "cloudflare") variant.value = mode.value;
|
||||
const helpKey = PAGE_KIND_CARDS.find(([kind]) => kind === group)?.[2] || "pageKindInheritHelp"; help.dataset.i18n = helpKey; help.textContent = t(helpKey);
|
||||
kindPill.textContent = mode.selectedOptions[0]?.textContent || ""; kindPill.classList.toggle("live", !!mode.value);
|
||||
statusPill.textContent = mode.value && status.value ? statusLabel(Number(status.value)) : ""; statusPill.hidden = !statusPill.textContent;
|
||||
row.classList.toggle("is-custom", !!mode.value);
|
||||
options.onChange?.(api);
|
||||
}
|
||||
for (const event of ["change", "input"]) { mode.addEventListener(event, sync); status.addEventListener(event, sync); html.addEventListener(event, () => options.onChange?.(api)); }
|
||||
file.addEventListener("change", async () => { try { const chosen = file.files[0]; if (!chosen) return; if (chosen.size > 32768) throw new Error(t("pageTooLarge")); html.value = await chosen.text(); html.dispatchEvent(new Event("input", { bubbles: true })); } catch (error) { toast(error.message, true); } });
|
||||
summary.addEventListener("click", () => { if (!controls.hidden && row.classList.contains("is-previewed")) { api.setOpen(false); return; } options.onSelect?.(api); api.setOpen(true); });
|
||||
controls.addEventListener("focusin", () => options.onSelect?.(api));
|
||||
parent.append(row);
|
||||
function setMode(kind) {
|
||||
if (mode.value === kind && (kind || !status.value)) return;
|
||||
mode.value = kind;
|
||||
if (!kind) status.value = "";
|
||||
mode.dispatchEvent(new Event("change", { bubbles: true }));
|
||||
}
|
||||
const styled = () => mode.value === "cloudflare" || mode.value === "cloudflare_welcome" || mode.value === "cloudflare_placeholder";
|
||||
const styled = () => CLOUDFLARE_KINDS.includes(mode.value);
|
||||
const bodyless = () => mode.value === "empty" && status.value === "204";
|
||||
return {
|
||||
row, setCloudflare: () => {
|
||||
const api = {
|
||||
row, key, slot: options.slot || "", scope: options.scope || "global", vhostId: options.vhostId || null, naturalStatus: options.naturalStatus || 404,
|
||||
title: () => heading.textContent,
|
||||
setOpen(open) { controls.hidden = !open; row.classList.toggle("is-open", open); summary.setAttribute("aria-expanded", String(open)); },
|
||||
state: () => ({ kind: mode.value, status: status.value ? Number(status.value) : null, html: html.value }),
|
||||
setCloudflare: () => {
|
||||
if (bodyless() || styled()) return;
|
||||
if (mode.value === "welcome" && key !== "customErrorPages") {
|
||||
setMode(key === "pageUnknownHost" || key === "pageMissingPath" ? "cloudflare_placeholder" : "cloudflare_welcome");
|
||||
} else setMode("cloudflare");
|
||||
}, reset: () => setMode(""),
|
||||
isCloudflare: () => styled() || bodyless(),
|
||||
read() { if (!mode.value) return null; const markup = mode.value === "html" ? html.value : ""; if (new TextEncoder().encode(markup).length > 32768) throw new Error(t("pageTooLarge")); return { kind: mode.value, status: status.value ? Number(status.value) : null, html: markup }; }
|
||||
read() { if (!mode.value) return null; const markup = mode.value === "html" ? html.value : ""; if (new TextEncoder().encode(markup).length > 32768) { api.setOpen(true); throw new Error(t("pageTooLarge")); } return { kind: mode.value, status: status.value ? Number(status.value) : null, html: markup }; }
|
||||
};
|
||||
sync();
|
||||
return api;
|
||||
}
|
||||
// One shared preview for all slots of an editor: the selected slot is shown
|
||||
// through the sandboxed /api/pages/preview (saved HTML for custom pages).
|
||||
function previewPane(parent, savedPage) {
|
||||
const pane = el("aside", undefined, "page-preview-pane"), headRow = el("div", undefined, "page-preview-head"), titleNode = el("strong", ""), open = el("a", t("notfoundPreviewOpen"), "page-preview-open");
|
||||
open.dataset.i18n = "notfoundPreviewOpen"; open.target = "_blank"; open.rel = "noopener noreferrer";
|
||||
headRow.append(label("span", "notfoundPreview", "small-label"), titleNode, open);
|
||||
const frame = el("iframe"); frame.setAttribute("sandbox", ""); frame.referrerPolicy = "no-referrer"; frame.title = t("notfoundPreview"); frame.loading = "lazy";
|
||||
const note = el("p", "", "fine page-preview-note");
|
||||
pane.append(headRow, frame, note); parent.append(pane);
|
||||
let current = null, timer = null;
|
||||
const inheritKey = editor => editor.scope === "vhost" ? "pagePreviewInheritVhost" : { direct_ip: "pagePreviewInheritDirectIp", unknown_host: "pagePreviewInheritUnknown" }[editor.slot] || "pagePreviewInheritError";
|
||||
function render() {
|
||||
if (!current) return;
|
||||
const state = current.state(), status = state.status || current.naturalStatus;
|
||||
titleNode.textContent = current.title();
|
||||
for (const node of parent.querySelectorAll(".page-editor.is-previewed")) node.classList.remove("is-previewed");
|
||||
current.row.classList.add("is-previewed");
|
||||
let url = "", noteKey = "";
|
||||
if (!state.kind) noteKey = inheritKey(current);
|
||||
else if (state.kind === "empty") noteKey = "notfoundPreviewEmpty";
|
||||
else if (state.kind === "html") {
|
||||
const saved = savedPage(current);
|
||||
if (saved?.kind !== "html") noteKey = "pagePreviewHtmlUnsaved";
|
||||
else {
|
||||
const params = new URLSearchParams({ kind: "html", status: String(status), slot: current.slot }); if (current.vhostId) params.set("vhost", current.vhostId);
|
||||
url = `/api/pages/preview?${params}`; if (saved.html !== state.html) noteKey = "notfoundPreviewHtmlSaved";
|
||||
}
|
||||
} else url = `/api/pages/preview?${new URLSearchParams({ kind: state.kind, status: String(status) })}`;
|
||||
note.hidden = !noteKey; if (noteKey) { note.dataset.i18n = noteKey; note.textContent = t(noteKey); }
|
||||
frame.hidden = !url; open.hidden = !url;
|
||||
if (url) { open.href = url; if (frame.dataset.src !== url) { frame.dataset.src = url; frame.src = url; } }
|
||||
}
|
||||
return {
|
||||
select(editor) { current = editor; render(); },
|
||||
changed(editor) { if (editor === current) { clearTimeout(timer); timer = setTimeout(render, 150); } }
|
||||
};
|
||||
}
|
||||
function errorsEditor(parent, values = {}) {
|
||||
const details = el("details", undefined, "pages-errors"); details.append(label("summary", "customErrorPages")); parent.append(details);
|
||||
const rows = new Map(); for (const code of codes) { const group = el("div"); details.append(group); const editor = pageEditor(group, "customErrorPages", values[code]); editor.row.querySelector("strong").removeAttribute("data-i18n"); editor.row.querySelector("strong").textContent = statusLabel(code); rows.set(code, editor); }
|
||||
function errorsEditor(parent, values = {}, context = {}) {
|
||||
const details = el("details", undefined, "pages-errors"), summary = el("summary"), count = el("span", "", "pill");
|
||||
summary.append(label("span", "customErrorPages"), count); details.append(summary, label("p", "pageErrorsWhen", "fine page-when")); parent.append(details);
|
||||
const list = el("div", undefined, "page-editor-list"); details.append(list);
|
||||
const rows = new Map(); for (const code of codes) { const editor = pageEditor(list, "customErrorPages", values[code], { ...context, slot: `error-${code}`, naturalStatus: code, title: statusLabel(code) }); rows.set(code, editor); }
|
||||
const updateCount = () => { const custom = [...rows.values()].filter(editor => editor.state().kind).length; count.textContent = `${custom} / ${codes.length}`; count.classList.toggle("live", custom > 0); };
|
||||
details.addEventListener("change", updateCount); updateCount();
|
||||
if ([...rows.values()].some(editor => editor.state().kind)) details.open = true;
|
||||
return {
|
||||
setAllCloudflare() { for (const editor of rows.values()) editor.setCloudflare(); details.open = true; },
|
||||
resetAll() { for (const editor of rows.values()) editor.reset(); details.open = false; },
|
||||
setAllCloudflare() { for (const editor of rows.values()) editor.setCloudflare(); details.open = true; updateCount(); },
|
||||
resetAll() { for (const editor of rows.values()) editor.reset(); details.open = false; updateCount(); },
|
||||
allCloudflare: () => [...rows.values()].every(editor => editor.isCloudflare()),
|
||||
read() { return Object.fromEntries([...rows].map(([code, editor]) => [code, editor.read()]).filter(([, page]) => page)); }
|
||||
};
|
||||
@@ -62,7 +151,16 @@
|
||||
parent.append(wrapper);
|
||||
return toggle;
|
||||
}
|
||||
function vhostEditor(parent, values = {}) {
|
||||
function workspace(parent, savedPage) {
|
||||
const box = el("div", undefined, "pages-workspace"), editors = el("div", undefined, "pages-editors"); box.append(editors); parent.append(box);
|
||||
const preview = previewPane(box, savedPage); let open = null;
|
||||
const select = editor => { if (open && open !== editor) open.setOpen(false); open = editor; preview.select(editor); };
|
||||
return { editors, context: { onSelect: select, onChange: editor => preview.changed(editor) }, preview: { select(editor) { select(editor); editor.setOpen(true); }, changed: preview.changed } };
|
||||
}
|
||||
function vhostEditor(outer, values = {}, options = {}) {
|
||||
const vhostId = options.vhostId || "";
|
||||
const savedVhostPage = editor => { const pages = (envelope?.config.vhosts || []).find(item => item.id === vhostId)?.pages; if (!pages || !vhostId) return null; return editor.slot.startsWith("error-") ? pages.errors?.[Number(editor.slot.slice(6))] : pages[editor.slot]; };
|
||||
const space = workspace(outer, savedVhostPage), parent = space.editors, context = { ...space.context, scope: "vhost", vhostId };
|
||||
let applying = false;
|
||||
const bulk = bulkCloudflareSwitch(parent, checked => {
|
||||
applying = true;
|
||||
@@ -80,7 +178,7 @@
|
||||
} finally { applying = false; }
|
||||
syncBulk();
|
||||
});
|
||||
const response = pageEditor(parent, "pageStaticHost", values.response), fallback = pageEditor(parent, "pageMissingPath", values.fallback);
|
||||
const response = pageEditor(parent, "pageStaticHost", values.response, { ...context, slot: "response", naturalStatus: 200, whenKey: "pageStaticHostWhen" }), fallback = pageEditor(parent, "pageMissingPath", values.fallback, { ...context, slot: "fallback", naturalStatus: 404, whenKey: "pageMissingPathWhen" });
|
||||
const interception = el("section", undefined, "php-origin-errors");
|
||||
const toggle = el("label", undefined, "check"), enabled = document.createElement("input");
|
||||
enabled.type = "checkbox"; enabled.className = "switch"; enabled.checked = (values.intercept_statuses || []).length > 0;
|
||||
@@ -94,7 +192,7 @@
|
||||
const sync = () => { statuses.disabled = !enabled.checked; };
|
||||
enabled.addEventListener("change", sync); sync();
|
||||
interception.append(toggle, codesLabel, hint); parent.append(interception);
|
||||
const errors = errorsEditor(parent, values.errors);
|
||||
const errors = errorsEditor(parent, values.errors, context);
|
||||
const syncBulk = () => {
|
||||
const selected = statuses.value.split(/[\s,]+/).filter(Boolean);
|
||||
bulk.checked = response.isCloudflare() && fallback.isCloudflare() && errors.allCloudflare()
|
||||
@@ -105,6 +203,7 @@
|
||||
parent.addEventListener("input", onEditorChange);
|
||||
syncBulk();
|
||||
parent.append(label("p", "pagesSafetyHint", "fine"));
|
||||
space.preview.select(response);
|
||||
return {
|
||||
read: () => {
|
||||
const selectedTokens = enabled.checked ? statuses.value.split(/[\s,]+/).filter(Boolean) : [];
|
||||
@@ -130,7 +229,10 @@
|
||||
} finally { applying = false; }
|
||||
globalSync();
|
||||
});
|
||||
const ip = pageEditor(parent, "pageDirectIp", values.direct_ip), unknown = pageEditor(parent, "pageUnknownHost", values.unknown_host), errors = errorsEditor(parent, values.errors);
|
||||
const savedGlobalPage = editor => { const pages = envelope?.config.pages || {}; return editor.slot.startsWith("error-") ? pages.errors?.[Number(editor.slot.slice(6))] : pages[editor.slot]; };
|
||||
const space = workspace(parent, savedGlobalPage), context = space.context;
|
||||
const ip = pageEditor(space.editors, "pageDirectIp", values.direct_ip, { ...context, slot: "direct_ip", naturalStatus: 200, whenKey: "pageDirectIpWhen" }), unknown = pageEditor(space.editors, "pageUnknownHost", values.unknown_host, { ...context, slot: "unknown_host", naturalStatus: 404, whenKey: "pageUnknownHostWhen" }), errors = errorsEditor(space.editors, values.errors, context);
|
||||
space.preview.select(ip);
|
||||
globalSync = event => { if (!applying && event?.target !== bulk) bulk.checked = ip.isCloudflare() && unknown.isCloudflare() && errors.allCloudflare(); };
|
||||
parent.addEventListener("change", globalSync);
|
||||
parent.addEventListener("input", globalSync);
|
||||
@@ -371,7 +473,7 @@
|
||||
const row = el("div", undefined, "acl-rule acl-profile-rule");
|
||||
const actionLabel = el("label", undefined, "acl-profile-rule-action-field"); actionLabel.append(i18n("span", "aclAction"));
|
||||
const actionSelect = el("select"); actionSelect.className = "acl-profile-rule-action";
|
||||
for (const actionValue of ["allow", "deny"]) { const option = el("option", t(actionValue === "allow" ? "aclAllow" : "vhDeny")); option.value = actionValue; actionSelect.append(option); }
|
||||
for (const actionValue of ["allow", "deny"]) { const option = el("option", t(actionValue === "allow" ? "aclAllow" : "aclDeny")); option.value = actionValue; actionSelect.append(option); }
|
||||
actionSelect.value = value.action || fallbackAction; actionLabel.append(actionSelect);
|
||||
const actionBadge = el("span", "", "acl-profile-rule-action-badge"); actionLabel.append(actionBadge);
|
||||
const typeLabel = el("label"); typeLabel.append(i18n("span", "aclRuleType"));
|
||||
@@ -427,7 +529,7 @@
|
||||
const select = row.querySelector(".acl-profile-rule-action"), badge = row.querySelector(".acl-profile-rule-action-badge");
|
||||
if (!custom && convert) select.value = expected;
|
||||
select.hidden = !custom; badge.hidden = custom;
|
||||
if (!custom) { badge.textContent = t(expected === "allow" ? "aclAllow" : "vhDeny"); badge.classList.toggle("is-allow", expected === "allow"); badge.classList.toggle("is-deny", expected === "deny"); }
|
||||
if (!custom) { badge.textContent = t(expected === "allow" ? "aclAllow" : "aclDeny"); badge.classList.toggle("is-allow", expected === "allow"); badge.classList.toggle("is-deny", expected === "deny"); }
|
||||
}
|
||||
syncRulesText();
|
||||
}
|
||||
@@ -512,7 +614,7 @@
|
||||
const select = row.querySelector(".acl-profile-rule-action");
|
||||
if (select?.options?.length >= 2) {
|
||||
select.options[0].textContent = t("aclAllow");
|
||||
select.options[1].textContent = t("vhDeny");
|
||||
select.options[1].textContent = t("aclDeny");
|
||||
}
|
||||
const remove = row.querySelector(".acl-profile-rule-remove");
|
||||
if (remove) remove.textContent = t("remove");
|
||||
|
||||
@@ -320,8 +320,8 @@
|
||||
<polyline class="traffic-line traffic-line-transform" id="sparkline-transform" points="0,120 600,120">
|
||||
</polyline>
|
||||
</svg>
|
||||
<div class="traffic-protocol-legend" aria-label="Request rate by HTTP protocol and transformed response rate">
|
||||
<span class="legend-total"><i></i>Total <b id="rate-total">0.0/s</b></span>
|
||||
<div class="traffic-protocol-legend" aria-label="Request rate by HTTP protocol and transformed response rate" data-i18n-aria="trafficLegendAria">
|
||||
<span class="legend-total"><i></i><span data-i18n="trafficLegendTotal">Total</span> <b id="rate-total">0.0/s</b></span>
|
||||
<span class="legend-h1"><i></i>HTTP/1.1 <b id="rate-h1">0.0/s</b></span>
|
||||
<span class="legend-h2"><i></i>HTTP/2 <b id="rate-h2">0.0/s</b></span>
|
||||
<span class="legend-h3"><i></i>HTTP/3 <b id="rate-h3">0.0/s</b></span>
|
||||
|
||||
+253
-53
@@ -3,7 +3,7 @@
|
||||
const form = $("redirect-form"), dialog = $("redirect-dialog"), list = $("redirect-list"), rules = $("redirect-rules");
|
||||
if (!form || !dialog || !list || !rules) return;
|
||||
const sortColumns = ["id", "name", "hostname", "status", "target", "rules", "listeners", "certificate"];
|
||||
let redirectAutoCertificate = null, editing = null, revision = null, dirty = false, readRedirectBindings = () => [], readRedirectHosts = () => [], listPrefs = { sort: "id", descending: false };
|
||||
let redirectAutoCertificate = null, editing = null, revision = null, dirty = false, readRedirectBindings = () => [], readRedirectHosts = () => [], listPrefs = { sort: "id", descending: false }, ruleSerial = 0;
|
||||
function normalizeListPrefs(preferences) { return { sort: sortColumns.includes(preferences?.redirect_list_sort) ? preferences.redirect_list_sort : "id", descending: preferences?.redirect_list_descending === true }; }
|
||||
function syncSortDirection() { const control = $("redirect-sort-direction"); if (!control) return; control.textContent = listPrefs.descending ? "↓" : "↑"; control.setAttribute("aria-label", t(listPrefs.descending ? "backendSortDescending" : "backendSortAscending")); }
|
||||
function applyPreferences(preferences) { listPrefs = normalizeListPrefs(preferences); if ($("redirect-sort")) $("redirect-sort").value = listPrefs.sort; syncSortDirection(); render(); }
|
||||
@@ -11,42 +11,204 @@
|
||||
const syncEnabledControl = window.rustProxyEnableControl($("redirect-enabled"));
|
||||
const yes = id => $(id).checked;
|
||||
const value = id => $(id).value.trim();
|
||||
const option = (value, key) => { const node = el("option", t(key)); node.value = value; return node; };
|
||||
const i18n = (node, key) => { node.dataset.i18n = key; return node; };
|
||||
const text = (tag, key, cls) => i18n(el(tag, t(key), cls), key);
|
||||
const option = (value, key) => { const node = text("option", key); node.value = value; return node; };
|
||||
const pluralKey = (base, count) => { let kind = "other"; try { kind = new Intl.PluralRules(locale()).select(count); } catch { } return `${base}${kind === "one" ? "One" : kind === "few" ? "Few" : "Many"}`; };
|
||||
const defaults = () => ({
|
||||
id: "", name: "", enabled: true, http2_enabled: true, http3_enabled: true,
|
||||
frontend: { hosts: [], listener_ids: [] }, certificate_id: null,
|
||||
rules: [{ id: "root", enabled: true, source_scheme: "any", match_type: "prefix", path_prefix: "/", target_type: "url", target: "https://example.com/", target_scheme: "preserve", path_mode: "append", query_mode: "preserve", status_code: 308, cache_seconds: 0 }]
|
||||
});
|
||||
|
||||
function addRule(rule = {}, index = rules.children.length) {
|
||||
const data = { ...defaults().rules[0], ...rule };
|
||||
const box = el("fieldset", undefined, "redirect-rule"); box.dataset.redirectRule = "1";
|
||||
const legend = el("legend", `${t("redirectRule")} ${index + 1}`); box.append(legend);
|
||||
const grid = el("div", undefined, "vh-grid");
|
||||
const input = (labelKey, name, type = "text") => { const label = el("label"); label.append(el("span", t(labelKey))); const node = el("input"); node.type = type; node.dataset.field = name; label.append(node); grid.append(label); return node; };
|
||||
const select = (labelKey, name, values) => { const label = el("label"); label.append(el("span", t(labelKey))); const node = el("select"); node.dataset.field = name; for (const [v, k] of values) node.append(option(v, k)); label.append(node); grid.append(label); return node; };
|
||||
const check = (labelKey, name) => { const label = el("label", undefined, "check"); const node = el("input"); node.type = "checkbox"; node.dataset.field = name; label.append(node, el("span", t(labelKey))); grid.append(label); return node; };
|
||||
const id = input("redirectRuleId", "id"); id.required = true; id.maxLength = 64; id.pattern = "[A-Za-z0-9_\\-]{1,64}"; id.value = data.id;
|
||||
const enabled = check("enabled", "enabled"); enabled.classList.add("switch"); enabled.checked = data.enabled !== false;
|
||||
const sourceScheme = select("redirectSourceScheme", "source_scheme", [["any", "redirectSchemeAny"], ["http", "redirectSchemeHttp"], ["https", "redirectSchemeHttps"]]); sourceScheme.value = data.source_scheme;
|
||||
const matchType = select("redirectMatchType", "match_type", [["prefix", "redirectMatchPrefix"], ["exact", "redirectMatchExact"]]); matchType.value = data.match_type;
|
||||
const prefix = input("redirectSourcePath", "path_prefix"); prefix.required = true; prefix.maxLength = 512; prefix.value = data.path_prefix;
|
||||
const targetType = select("redirectTargetType", "target_type", [["url", "redirectTargetUrl"], ["host", "redirectTargetHost"], ["path", "redirectTargetPath"]]); targetType.value = data.target_type;
|
||||
const target = input("redirectTarget", "target"); target.required = true; target.maxLength = 2048; target.value = data.target;
|
||||
const targetScheme = select("redirectTargetScheme", "target_scheme", [["preserve", "redirectSchemePreserve"], ["http", "redirectSchemeHttp"], ["https", "redirectSchemeHttps"]]); targetScheme.value = data.target_scheme;
|
||||
const pathMode = select("redirectPathMode", "path_mode", [["append", "redirectPathAppend"], ["strip_prefix", "redirectPathStrip"], ["replace", "redirectPathReplace"]]); pathMode.value = data.path_mode;
|
||||
const queryMode = select("redirectQueryMode", "query_mode", [["preserve", "redirectQueryPreserve"], ["drop", "redirectQueryDrop"]]); queryMode.value = data.query_mode;
|
||||
const status = select("redirectStatus", "status_code", [["301", "redirect301"], ["302", "redirect302"], ["303", "redirect303"], ["307", "redirect307"], ["308", "redirect308"]]); status.value = String(data.status_code);
|
||||
const cache = input("redirectCacheSeconds", "cache_seconds", "number"); cache.min = "0"; cache.max = "31536000"; cache.step = "1"; cache.value = String(data.cache_seconds || 0);
|
||||
const remove = el("button", t("remove"), "quiet"); remove.type = "button"; remove.addEventListener("click", () => { box.remove(); renumber(); changed(); });
|
||||
const actions = el("div", undefined, "vh-wide redirect-rule-actions"); actions.append(remove); grid.append(actions); box.append(grid); rules.append(box); syncRule(box); targetType.addEventListener("change", () => syncRule(box));
|
||||
// ---- Editor tabs -------------------------------------------------------
|
||||
function activateTab(name) {
|
||||
for (const node of $("redirect-tabs").querySelectorAll("button[data-tab]")) { const on = node.dataset.tab === name; node.classList.toggle("active", on); node.setAttribute("aria-pressed", String(on)); }
|
||||
for (const group of $("redirect-fields").querySelectorAll(".vh-group[data-tab]")) group.hidden = group.dataset.tab !== name;
|
||||
$("redirect-fields").scrollTop = 0;
|
||||
}
|
||||
const activeTab = () => $("redirect-tabs").querySelector("button.active")?.dataset.tab || "details";
|
||||
|
||||
// ---- Rule rows: one line of the rule table, expanded = When / Where ----
|
||||
const ruleBoxes = () => [...rules.querySelectorAll('[data-redirect-rule="1"]')];
|
||||
const nextRuleId = base => { const used = new Set(ruleBoxes().map(box => box.querySelector('[data-field="id"]').value.trim())); if (!used.has(base)) return base; let index = 2; while (used.has(`${base}-${index}`)) index++; return `${base}-${index}`; };
|
||||
function addRule(rule = {}, open = false) {
|
||||
const data = { ...defaults().rules[0], ...rule }, serial = ++ruleSerial;
|
||||
const box = el("details", undefined, "vh-location redirect-rule"); box.dataset.redirectRule = "1"; box.open = open;
|
||||
const summary = el("summary", undefined, "location-summary redirect-rule-summary");
|
||||
const sumOrder = el("span", "", "loc-order"), sumState = el("span", undefined, "loc-state"), sumId = el("span", "", "loc-id"), sumMatch = el("span", "", "loc-match"), sumPath = el("span", "", "loc-path"), sumAction = el("span", "", "loc-action"), sumChips = el("span", undefined, "loc-chips");
|
||||
sumState.setAttribute("role", "img"); summary.append(sumOrder, sumState, sumId, sumMatch, sumPath, sumAction, sumChips);
|
||||
const body = el("div", undefined, "vh-grid location-body"); box.append(summary, body);
|
||||
const headline = el("p", "", "vh-wide location-headline"); body.append(headline);
|
||||
const card = (cls, number, key) => { const section = el("section", undefined, `location-card ${cls}`), head = el("h4", undefined, "location-card-title"), grid = el("div", undefined, "vh-grid location-card-grid"); head.append(el("span", number, "location-step"), text("span", key)); section.append(head, grid); return [section, grid]; };
|
||||
const [whenCard, whenGrid] = card("location-when", "1", "redirectStepWhen"), [whereCard, whereGrid] = card("location-what", "2", "redirectStepWhere");
|
||||
const cards = el("div", undefined, "vh-wide location-cards redirect-rule-cards"); cards.append(whenCard, whereCard); body.append(cards);
|
||||
const input = (grid, labelKey, name, type = "text", cls = "") => { const label = el("label", undefined, cls); label.append(text("span", labelKey)); const node = el("input"); node.type = type; node.dataset.field = name; label.append(node); grid.append(label); return node; };
|
||||
const select = (grid, labelKey, name, values, cls = "") => { const label = el("label", undefined, cls); label.append(text("span", labelKey)); const node = el("select"); node.dataset.field = name; for (const [v, k] of values) node.append(option(v, k)); label.append(node); grid.append(label); return node; };
|
||||
const id = input(whenGrid, "redirectRuleId", "id"); id.required = true; id.maxLength = 64; id.pattern = "[A-Za-z0-9_\\-]{1,64}"; id.value = data.id;
|
||||
const enabledLabel = el("label", undefined, "check"), enabled = el("input", undefined, "switch"); enabled.type = "checkbox"; enabled.dataset.field = "enabled"; enabled.checked = data.enabled !== false; enabledLabel.append(enabled, text("span", "enabled")); whenGrid.append(enabledLabel);
|
||||
const sourceScheme = select(whenGrid, "redirectSourceScheme", "source_scheme", [["any", "redirectSchemeAny"], ["http", "redirectSchemeHttp"], ["https", "redirectSchemeHttps"]]); sourceScheme.value = data.source_scheme;
|
||||
const matchType = select(whenGrid, "redirectMatchType", "match_type", [["prefix", "redirectMatchPrefix"], ["exact", "redirectMatchExact"]]); matchType.value = data.match_type;
|
||||
const prefix = input(whenGrid, "redirectSourcePath", "path_prefix", "text", "vh-wide"); prefix.required = true; prefix.maxLength = 512; prefix.value = data.path_prefix; prefix.spellcheck = false;
|
||||
// Target type as three choice cards; the radio group carries data-field="target_type".
|
||||
const choices = el("div", undefined, "vh-wide vh-www-choices redirect-target-choices"); choices.setAttribute("role", "radiogroup"); choices.setAttribute("aria-label", t("redirectTargetType"));
|
||||
const kindInputs = [];
|
||||
for (const [kind, key, helpKey] of [["url", "redirectTargetUrl", "redirectTargetUrlHelp"], ["host", "redirectTargetHost", "redirectTargetHostHelp"], ["path", "redirectTargetPath", "redirectTargetPathHelp"]]) {
|
||||
const choice = el("label", undefined, "vh-www-choice"), radio = el("input"); radio.type = "radio"; radio.name = `redirect-target-type-${serial}`; radio.value = kind; radio.dataset.field = "target_type"; radio.checked = data.target_type === kind;
|
||||
const copy = el("span", undefined, "vh-www-choice-copy"); copy.append(text("b", key), text("small", helpKey));
|
||||
choice.append(radio, copy); choices.append(choice); kindInputs.push(radio);
|
||||
}
|
||||
if (!kindInputs.some(radio => radio.checked)) kindInputs[0].checked = true;
|
||||
whereGrid.append(choices);
|
||||
const targetScheme = select(whereGrid, "redirectTargetScheme", "target_scheme", [["preserve", "redirectSchemePreserve"], ["http", "redirectSchemeHttp"], ["https", "redirectSchemeHttps"]]); targetScheme.value = data.target_scheme;
|
||||
const target = input(whereGrid, "redirectTarget", "target", "text", "vh-wide redirect-target-field"); target.required = true; target.maxLength = 2048; target.value = data.target; target.spellcheck = false;
|
||||
const pathMode = select(whereGrid, "redirectPathMode", "path_mode", [["append", "redirectPathAppend"], ["strip_prefix", "redirectPathStrip"], ["replace", "redirectPathReplace"]]); pathMode.value = data.path_mode;
|
||||
const queryMode = select(whereGrid, "redirectQueryMode", "query_mode", [["preserve", "redirectQueryPreserve"], ["drop", "redirectQueryDrop"]]); queryMode.value = data.query_mode;
|
||||
const status = select(whereGrid, "redirectStatus", "status_code", [["301", "redirect301"], ["302", "redirect302"], ["303", "redirect303"], ["307", "redirect307"], ["308", "redirect308"]]); status.value = String(data.status_code);
|
||||
const cache = input(whereGrid, "redirectCacheSeconds", "cache_seconds", "number"); cache.min = "0"; cache.max = "31536000"; cache.step = "1"; cache.value = String(data.cache_seconds || 0);
|
||||
const actions = el("div", undefined, "vh-wide redirect-rule-actions");
|
||||
const duplicate = el("button", undefined, "quiet"); duplicate.type = "button"; i18n(duplicate, "copyEntry").textContent = t("copyEntry");
|
||||
duplicate.addEventListener("click", () => { const copy = readRule(box); copy.id = nextRuleId(`${copy.id}-copy`); const added = addRule(copy, true); box.after(added); renumber(); changed(); added.querySelector('[data-field="id"]').focus(); });
|
||||
const remove = el("button", undefined, "quiet"); remove.type = "button"; i18n(remove, "remove").textContent = t("remove");
|
||||
remove.addEventListener("click", () => { box.remove(); renumber(); changed(); });
|
||||
actions.append(duplicate, remove); body.append(actions);
|
||||
box._summary = { sumOrder, sumState, sumId, sumMatch, sumPath, sumAction, sumChips, headline };
|
||||
box.addEventListener("invalid", () => { box.open = true; activateTab("rules"); }, true);
|
||||
box.addEventListener("input", () => syncRule(box)); box.addEventListener("change", () => syncRule(box));
|
||||
rules.append(box); syncRule(box); return box;
|
||||
}
|
||||
const kindOf = box => box.querySelector('[data-field="target_type"]:checked')?.value || "url";
|
||||
function syncRule(box) {
|
||||
const kind = box.querySelector('[data-field="target_type"]').value;
|
||||
const scheme = box.querySelector('[data-field="target_scheme"]').closest("label"); scheme.hidden = kind !== "host";
|
||||
const kind = kindOf(box);
|
||||
box.querySelector('[data-field="target_scheme"]').closest("label").hidden = kind !== "host";
|
||||
const target = box.querySelector('[data-field="target"]'); target.placeholder = kind === "url" ? "https://app.example.com/" : kind === "host" ? "app.example.com:8443" : "/new-path";
|
||||
const targetLabel = target.closest("label").querySelector("span"), labelKey = { url: "redirectTargetLabelUrl", host: "redirectTargetLabelHost", path: "redirectTargetLabelPath" }[kind];
|
||||
if (targetLabel.dataset.i18n !== labelKey) { targetLabel.dataset.i18n = labelKey; targetLabel.textContent = t(labelKey); }
|
||||
for (const choice of box.querySelectorAll(".vh-www-choice")) choice.classList.toggle("is-selected", choice.querySelector("input").checked);
|
||||
const rule = readRule(box), s = box._summary;
|
||||
s.sumId.textContent = rule.id || "—"; s.sumMatch.textContent = t(rule.match_type === "exact" ? "redirectMatchExact" : "redirectMatchPrefix").toLowerCase(); s.sumPath.textContent = rule.path_prefix || "/";
|
||||
s.sumAction.textContent = `${rule.status_code} → ${describeTarget(rule)}`;
|
||||
s.sumState.classList.toggle("is-off", !rule.enabled); box.classList.toggle("is-disabled", !rule.enabled); s.sumState.setAttribute("aria-label", t(rule.enabled ? "enabled" : "vhDisabled"));
|
||||
s.sumChips.replaceChildren(...ruleChips(rule).map(label => el("span", label, "loc-chip")));
|
||||
const host = sampleHost(), sample = `${rule.source_scheme === "https" ? "https" : "http"}://${host}${samplePath(rule)}`;
|
||||
const location = ruleLocation(normalizeRule(rule), sample);
|
||||
s.headline.textContent = location ? `${sample} → ${rule.status_code} ${location}` : `${sample} → ${rule.status_code} ${describeTarget(rule)}`;
|
||||
updateRuleCount(); runTester();
|
||||
}
|
||||
function renumber() { [...rules.children].forEach((box, i) => { const legend = box.querySelector("legend"); if (legend) legend.textContent = `${t("redirectRule")} ${i + 1}`; }); }
|
||||
function describeTarget(rule) {
|
||||
const target = rule.target || "—";
|
||||
if (rule.target_type === "host") return `${rule.target_scheme === "preserve" ? "" : `${rule.target_scheme}://`}${target}`;
|
||||
return target;
|
||||
}
|
||||
function ruleChips(rule) {
|
||||
const chips = [];
|
||||
if (rule.source_scheme !== "any") chips.push(t(rule.source_scheme === "http" ? "redirectChipHttpOnly" : "redirectChipHttpsOnly"));
|
||||
if (rule.path_mode !== "append") chips.push(t(rule.path_mode === "strip_prefix" ? "redirectChipStrip" : "redirectChipReplace"));
|
||||
if (rule.query_mode === "drop") chips.push(t("redirectChipNoQuery"));
|
||||
if (rule.cache_seconds > 0) chips.push(`${t("redirectChipCache")} ${rule.cache_seconds} s`);
|
||||
return chips;
|
||||
}
|
||||
function renumber() { ruleBoxes().forEach((box, index) => { box._summary.sumOrder.textContent = String(index + 1); }); updateRuleCount(); runTester(); }
|
||||
function updateRuleCount() { const count = $("redirect-rule-count"); if (count) count.textContent = `· ${ruleBoxes().length}`; }
|
||||
function readRule(box) {
|
||||
const get = name => box.querySelector(`[data-field="${name}"]`);
|
||||
return { id: get("id").value.trim(), enabled: get("enabled").checked, source_scheme: get("source_scheme").value, match_type: get("match_type").value, path_prefix: get("path_prefix").value.trim(), target_type: kindOf(box), target: get("target").value.trim(), target_scheme: get("target_scheme").value, path_mode: get("path_mode").value, query_mode: get("query_mode").value, status_code: Number(get("status_code").value), cache_seconds: Number(get("cache_seconds").value) || 0 };
|
||||
}
|
||||
|
||||
// ---- Rule templates (only pre-fill ordinary fields) ---------------------
|
||||
const firstExactHost = () => { try { return readRedirectHosts().find(host => !host.startsWith("*")) || ""; } catch { return ""; } };
|
||||
function showTemplates(open) { $("redirect-rule-templates").hidden = !open; $("redirect-rule-add").setAttribute("aria-expanded", String(open)); }
|
||||
function buildTemplates() {
|
||||
const box = $("redirect-rule-templates"); box.replaceChildren();
|
||||
const template = (key, helpKey, make) => {
|
||||
const choice = el("button", undefined, "location-template"); choice.type = "button"; choice.append(text("b", key), text("span", helpKey, "fine"));
|
||||
choice.addEventListener("click", () => { showTemplates(false); const added = addRule(make(), true); renumber(); changed(); added.scrollIntoView({ block: "nearest" }); added.querySelector('[data-field="target"]').focus(); });
|
||||
box.append(choice);
|
||||
};
|
||||
template("redirectTplDomain", "redirectTplDomainHelp", () => ({ id: nextRuleId("domain"), match_type: "prefix", path_prefix: "/", target_type: "host", target: "", target_scheme: "https", path_mode: "append", query_mode: "preserve", status_code: 301 }));
|
||||
template("redirectTplHttps", "redirectTplHttpsHelp", () => ({ id: nextRuleId("https"), source_scheme: "http", match_type: "prefix", path_prefix: "/", target_type: "host", target: firstExactHost(), target_scheme: "https", path_mode: "append", query_mode: "preserve", status_code: 308 }));
|
||||
template("redirectTplPage", "redirectTplPageHelp", () => ({ id: nextRuleId("page"), match_type: "exact", path_prefix: "/old-page", target_type: "url", target: "", path_mode: "replace", query_mode: "preserve", status_code: 301 }));
|
||||
template("redirectTplDirectory", "redirectTplDirectoryHelp", () => ({ id: nextRuleId("directory"), match_type: "prefix", path_prefix: "/docs/", target_type: "host", target: "", target_scheme: "preserve", path_mode: "strip_prefix", query_mode: "preserve", status_code: 301 }));
|
||||
template("redirectTplBlank", "redirectTplBlankHelp", () => ({ id: nextRuleId(`rule-${ruleBoxes().length + 1}`) }));
|
||||
}
|
||||
|
||||
// ---- Draft tester: mirrors src/redirect/mod.rs matching and Location ---
|
||||
function routingPath(raw) {
|
||||
if (!raw.startsWith("/")) return null;
|
||||
const bytes = [], source = new TextEncoder().encode(raw);
|
||||
for (let index = 0; index < source.length; index++) {
|
||||
const byte = source[index];
|
||||
if (byte === 0x25) {
|
||||
const hex = String.fromCharCode(source[index + 1] || 0, source[index + 2] || 0);
|
||||
if (!/^[0-9a-fA-F]{2}$/.test(hex)) return null;
|
||||
const decoded = parseInt(hex, 16); index += 2;
|
||||
if (decoded === 0x2f) { if (bytes.at(-1) !== 0x2f) bytes.push(0x2f); continue; }
|
||||
if (decoded < 32 || decoded === 127 || [0x5c, 0x25, 0x3f, 0x23, 0x3b].includes(decoded)) return null;
|
||||
bytes.push(decoded); continue;
|
||||
}
|
||||
if (byte <= 32 || byte === 127 || [0x5c, 0x3f, 0x23, 0x3b].includes(byte)) return null;
|
||||
if (byte !== 0x2f || bytes.at(-1) !== 0x2f) bytes.push(byte);
|
||||
}
|
||||
let path; try { path = new TextDecoder("utf-8", { fatal: true }).decode(new Uint8Array(bytes)); } catch { return null; }
|
||||
return path.split("/").some(segment => segment === "." || segment === "..") ? null : path;
|
||||
}
|
||||
function normalizeRule(rule) {
|
||||
let prefix = rule.path_prefix || "/";
|
||||
if (prefix.length > 1) prefix = prefix.replace(/\/+$/, "") || "/";
|
||||
return { ...rule, path_prefix: routingPath(prefix) ?? prefix };
|
||||
}
|
||||
const prefixMatches = (prefix, path) => prefix === "/" || path === prefix || (path.startsWith(prefix) && (path.slice(prefix.length).startsWith("/") || prefix.endsWith("/")));
|
||||
const schemeMatches = (scheme, tls) => scheme === "any" || (scheme === "http" && !tls) || (scheme === "https" && tls);
|
||||
function joinPaths(base, suffix) {
|
||||
if (!suffix || suffix === "/") return base || "/";
|
||||
const root = base || "/";
|
||||
return root === "/" ? `/${suffix.replace(/^\/+/, "")}` : `${root.replace(/\/+$/, "")}/${suffix.replace(/^\/+/, "")}`;
|
||||
}
|
||||
function ruleLocation(rule, sampleUrl) {
|
||||
let url; try { url = new URL(sampleUrl); } catch { return ""; }
|
||||
const tls = url.protocol === "https:", requestPath = url.pathname, requestQuery = url.search.slice(1);
|
||||
const suffix = rule.path_mode === "replace" ? "" : rule.path_mode === "append" ? requestPath : (requestPath.startsWith(rule.path_prefix) ? requestPath.slice(rule.path_prefix.length) : "");
|
||||
let prefix = "", basePath = "/", staticQuery = "", fragment = "";
|
||||
if (rule.target_type === "url") {
|
||||
let target; try { target = new URL(rule.target); } catch { return ""; }
|
||||
if (!["http:", "https:"].includes(target.protocol)) return "";
|
||||
prefix = `${target.protocol}//${target.host}`; basePath = target.pathname; staticQuery = target.search.slice(1); fragment = target.hash.slice(1);
|
||||
} else if (rule.target_type === "host") {
|
||||
if (!rule.target) return "";
|
||||
const scheme = rule.target_scheme === "preserve" ? (tls ? "https" : "http") : rule.target_scheme;
|
||||
prefix = `${scheme}://${rule.target}`; basePath = "/";
|
||||
} else {
|
||||
if (!rule.target.startsWith("/")) return "";
|
||||
prefix = `${tls ? "https" : "http"}://${url.host}`; basePath = rule.target;
|
||||
}
|
||||
let location = prefix + (rule.path_mode === "replace" ? basePath : joinPaths(basePath, suffix));
|
||||
const sourceQuery = rule.query_mode === "preserve" ? requestQuery : "";
|
||||
if (staticQuery && sourceQuery) location += `?${staticQuery}&${sourceQuery}`; else if (staticQuery) location += `?${staticQuery}`; else if (sourceQuery) location += `?${sourceQuery}`;
|
||||
if (fragment) location += `#${fragment}`;
|
||||
return location;
|
||||
}
|
||||
function hostMatches(pattern, host) { pattern = pattern.toLowerCase(); host = host.toLowerCase(); return pattern === host || (pattern.startsWith("*.") && host.endsWith(pattern.slice(1)) && host.length > pattern.length - 1); }
|
||||
const sampleHost = () => { try { const hosts = readRedirectHosts(); const exact = hosts.find(host => !host.startsWith("*")); return exact || (hosts[0] ? `www${hosts[0].slice(1)}` : "example.com"); } catch { return "example.com"; } };
|
||||
const samplePath = rule => rule.match_type === "exact" ? (rule.path_prefix || "/") : `${(rule.path_prefix || "/").replace(/\/+$/, "")}/example`.replace(/^$/, "/");
|
||||
function runTester() {
|
||||
const field = $("redirect-test-url"), out = $("redirect-test-result"); if (!field || !out) return;
|
||||
const raw = field.value.trim(); out.replaceChildren(); out.className = "redirect-test-result";
|
||||
if (!raw) { out.append(text("span", "redirectTestHint", "fine")); return; }
|
||||
let url; try { url = new URL(raw.startsWith("/") ? `http://${sampleHost()}${raw}` : (/^[a-z][a-z0-9+.-]*:\/\//i.test(raw) ? raw : `http://${raw}`)); } catch { out.append(text("span", "redirectTestInvalid", "rt-no")); return; }
|
||||
if (!["http:", "https:"].includes(url.protocol)) { out.append(text("span", "redirectTestInvalid", "rt-no")); return; }
|
||||
const hosts = (() => { try { return readRedirectHosts(); } catch { return []; } })();
|
||||
if (hosts.length && !hosts.some(pattern => hostMatches(pattern, url.hostname))) { out.append(el("span", `${url.hostname}: ${t("redirectTestOtherHost")}`, "rt-no")); return; }
|
||||
const path = routingPath(url.pathname); if (path === null) { out.append(text("span", "redirectTestInvalid", "rt-no")); return; }
|
||||
const tls = url.protocol === "https:";
|
||||
const candidates = ruleBoxes().map((box, index) => ({ index, rule: normalizeRule(readRule(box)) })).filter(item => item.rule.enabled);
|
||||
candidates.sort((a, b) => b.rule.path_prefix.length - a.rule.path_prefix.length || (a.rule.match_type === b.rule.match_type ? 0 : a.rule.match_type === "exact" ? -1 : 1));
|
||||
const winner = candidates.find(item => schemeMatches(item.rule.source_scheme, tls) && (item.rule.match_type === "exact" ? path === item.rule.path_prefix : prefixMatches(item.rule.path_prefix, path)));
|
||||
if (!winner) { out.append(text("span", "redirectTestNoRule", "rt-no")); return; }
|
||||
const location = ruleLocation(winner.rule, url.href);
|
||||
out.classList.add("is-match");
|
||||
out.append(el("strong", `${t("redirectRule")} ${winner.index + 1} · ${winner.rule.id}`), el("span", ` → ${winner.rule.status_code} `), el("code", location || "—"), el("span", ` · ${winner.rule.cache_seconds > 0 ? `max-age=${winner.rule.cache_seconds}` : "no-store"}`, "fine"));
|
||||
}
|
||||
|
||||
function changed() { dirty = true; }
|
||||
async function allowDiscard() { return !dirty || await appConfirm(t("redirectUnsaved"), { danger: true, confirmLabel: t("discardAction") }); }
|
||||
function listenerChoices(selected = []) {
|
||||
@@ -65,26 +227,30 @@
|
||||
for (const cert of envelope?.config.tls?.certificates || []) { const node = el("option", cert.id); node.value = cert.id; select.append(node); }
|
||||
select.value = selected || "";
|
||||
}
|
||||
function syncSummary() {
|
||||
const hosts = (() => { try { return readRedirectHosts(); } catch { return []; } })();
|
||||
$("redirect-summary").textContent = [value("redirect-id") || t("redirectNewLabel"), hosts.join(", ")].filter(Boolean).join(" · ");
|
||||
}
|
||||
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-name").value = item.name || "";
|
||||
window.rustProxyAutoId.attach($("redirect-id"), { elements: [$("redirect-name")], taken: () => (envelope?.config.redirects || []).map(value => value.id) });
|
||||
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(); } });
|
||||
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);
|
||||
redirectAutoCertificate = window.rustProxyAutoCertificate.attach($("redirect-certificate"), { auto: !editing, hosts: () => { try { return readRedirectHosts(); } catch { return []; } }, certificates: () => envelope?.config.tls?.certificates || [] }); redirectAutoCertificate.refresh();
|
||||
rules.replaceChildren(); for (const [i, rule] of (item.rules?.length ? item.rules : defaults().rules).entries()) addRule(rule, i);
|
||||
dialog.showModal();
|
||||
}
|
||||
function readRule(box) {
|
||||
const get = name => box.querySelector(`[data-field="${name}"]`);
|
||||
return { id: get("id").value.trim(), enabled: get("enabled").checked, source_scheme: get("source_scheme").value, match_type: get("match_type").value, path_prefix: get("path_prefix").value.trim(), target_type: get("target_type").value, target: get("target").value.trim(), target_scheme: get("target_scheme").value, path_mode: get("path_mode").value, query_mode: get("query_mode").value, status_code: Number(get("status_code").value), cache_seconds: Number(get("cache_seconds").value) || 0 };
|
||||
rules.replaceChildren(); showTemplates(false); buildTemplates();
|
||||
const values = item.rules?.length ? item.rules : defaults().rules;
|
||||
for (const rule of values) addRule(rule, false);
|
||||
if (!editing && ruleBoxes().length === 1) ruleBoxes()[0].open = true;
|
||||
renumber(); $("redirect-test-url").value = ""; runTester(); syncSummary();
|
||||
activateTab("details"); dialog.showModal();
|
||||
}
|
||||
function suspendDraft() {
|
||||
const state = {
|
||||
editing, revision, label: $("redirect-editing").textContent, controls: window.rustProxyDrafts.captureControls(form),
|
||||
editing, revision, label: $("redirect-editing").textContent, tab: activeTab(), controls: window.rustProxyDrafts.captureControls(form),
|
||||
hosts: window.rustProxyDrafts.takeChildren($("redirect-hosts-editor")), listeners: window.rustProxyDrafts.takeChildren($("redirect-listeners")), rules: window.rustProxyDrafts.takeChildren(rules),
|
||||
readRedirectBindings, readRedirectHosts
|
||||
};
|
||||
@@ -93,7 +259,7 @@
|
||||
function restoreDraft(state) {
|
||||
window.rustProxyDrafts.restoreChildren($("redirect-hosts-editor"), state.hosts); window.rustProxyDrafts.restoreChildren($("redirect-listeners"), state.listeners); window.rustProxyDrafts.restoreChildren(rules, state.rules);
|
||||
readRedirectBindings = state.readRedirectBindings; readRedirectHosts = state.readRedirectHosts; editing = state.editing; revision = state.revision; dirty = true; $("redirect-editing").textContent = state.label;
|
||||
window.rustProxyDrafts.restoreControls(form, state.controls); syncEnabledControl(); if (!dialog.open) dialog.showModal();
|
||||
window.rustProxyDrafts.restoreControls(form, state.controls); syncEnabledControl(); buildTemplates(); renumber(); syncSummary(); activateTab(state.tab || "details"); if (!dialog.open) dialog.showModal();
|
||||
}
|
||||
function closeEditor() { if (dirty) return window.rustProxyDrafts.dock("redirect"); if (dialog.open) dialog.close(); return true; }
|
||||
|
||||
@@ -101,9 +267,36 @@
|
||||
const id = value("redirect-id"), name = value("redirect-name") || id, hosts = readRedirectHosts();
|
||||
const listener_ids = readRedirectBindings();
|
||||
if (!hosts.length) throw new Error(t("redirectHostsRequired")); if (!listener_ids.length) throw new Error(t("redirectListenersRequired"));
|
||||
const values = [...rules.querySelectorAll('[data-redirect-rule="1"]')].map(readRule); if (!values.length) throw new Error(t("redirectRulesRequired"));
|
||||
const values = ruleBoxes().map(readRule); if (!values.length) throw new Error(t("redirectRulesRequired"));
|
||||
return { id, name, enabled: yes("redirect-enabled"), http2_enabled: yes("redirect-http2"), http3_enabled: yes("redirect-http3"), frontend: { hosts, listener_ids }, certificate_id: value("redirect-certificate") || null, rules: values };
|
||||
}
|
||||
|
||||
// ---- List --------------------------------------------------------------
|
||||
function listenerLabel(id) {
|
||||
const endpoint = (envelope?.config.listeners?.endpoints || []).find(item => item.id === id);
|
||||
if (!endpoint) return id;
|
||||
const address = endpoint.binding?.address || "";
|
||||
return `${endpoint.binding?.tls ? "HTTPS" : "HTTP"} ${address.replace(/^0\.0\.0\.0|^\[::\]/, "")}`.trim();
|
||||
}
|
||||
function ruleTable(item) {
|
||||
const table = el("div", undefined, "redirect-rule-table");
|
||||
const ordered = item.rules || [];
|
||||
for (const [index, rule] of ordered.slice(0, 8).entries()) {
|
||||
const row = el("div", undefined, `redirect-rule-line${rule.enabled === false ? " is-disabled" : ""}`);
|
||||
const state = el("span", undefined, `loc-state${rule.enabled === false ? " is-off" : ""}`); state.setAttribute("role", "img"); state.setAttribute("aria-label", t(rule.enabled === false ? "vhDisabled" : "enabled"));
|
||||
row.append(el("span", String(index + 1), "loc-order"), state, el("span", t(rule.match_type === "exact" ? "redirectMatchExact" : "redirectMatchPrefix").toLowerCase(), "loc-match"), el("span", rule.path_prefix || "/", "loc-path"), el("span", String(rule.status_code), "redirect-rule-status"), el("span", describeTarget(rule), "redirect-rule-target"), el("span", ruleChips(rule).join(" · ") || "", "fine"));
|
||||
table.append(row);
|
||||
}
|
||||
if (ordered.length > 8) table.append(el("div", `+${ordered.length - 8}`, "redirect-rule-line redirect-rule-more"));
|
||||
return table;
|
||||
}
|
||||
async function toggleEnabled(item) {
|
||||
if (busy) return;
|
||||
if (item.enabled !== false && !(await appConfirm(t("redirectDisableConfirm"), { danger: true, confirmLabel: t("redirectDisable") }))) return;
|
||||
const next = structuredClone(envelope.config.redirects || []), index = next.findIndex(value => value.id === item.id); if (index < 0) return;
|
||||
next[index].enabled = item.enabled === false;
|
||||
if (await saveSection("redirects", next)) render();
|
||||
}
|
||||
function render() {
|
||||
if (!envelope) return; const query = ($("redirect-search").value || "").trim().toLowerCase();
|
||||
const entries = (envelope.config.redirects || []).filter(item => !query || [item.id, item.name, ...(item.frontend?.hosts || []), ...(item.rules || []).map(rule => rule.target)].join(" ").toLowerCase().includes(query));
|
||||
@@ -119,32 +312,39 @@
|
||||
}[listPrefs.sort]);
|
||||
entries.sort((left, right) => { const a = sortValue(left), b = sortValue(right); const result = typeof a === "number" && typeof b === "number" ? a - b : compareText(a, b); return listPrefs.descending ? -result : result; });
|
||||
list.replaceChildren(...entries.map(item => {
|
||||
const card = el("article", undefined, "vhost-card redirect-card"); const head = el("div", undefined, "vhost-card-head"), identity = el("div", undefined, "vhost-card-identity"), title = el("div", undefined, "vhost-title-line");
|
||||
title.append(el("strong", item.name || item.id, "entity-title")); if (item.enabled === false) title.append(el("span", t("vhDisabled"), "pill")); identity.append(title); head.append(identity);
|
||||
const actions = el("div", undefined, "entity-actions"); actions.append(action(t("edit"), () => { window.rustProxyDrafts.prepare(); load(structuredClone(item)); }), action(t("copyEntry"), () => { window.rustProxyDrafts.prepare(); const copy = structuredClone(item); copy.id = ""; copy.name = ""; copy.frontend = { ...(copy.frontend || {}), hosts: [] }; copy.certificate_id = null; load(copy); }), action(t("remove"), async () => { if (busy || !(await appConfirm(t("confirmDelete"), { danger: true }))) return; const next = (envelope.config.redirects || []).filter(value => value.id !== item.id); if (await saveSection("redirects", next)) { if (editing === item.id) dialog.close(); render(); } })); head.append(actions); card.append(head);
|
||||
const targets = [...new Set((item.rules || []).filter(rule => rule.enabled !== false).map(rule => rule.target).filter(Boolean))];
|
||||
const flow = el("div", undefined, "redirect-flow"), from = el("div", undefined, "redirect-flow-from"), to = el("div", undefined, "redirect-flow-to");
|
||||
for (const host of item.frontend?.hosts || []) from.append(el("span", host, "redirect-host-chip"));
|
||||
if (!targets.length) to.append(el("span", "-", "redirect-target"));
|
||||
for (const target of targets.slice(0, 3)) to.append(el("span", target, "redirect-target"));
|
||||
if (targets.length > 3) to.append(el("span", `+${targets.length - 3}`, "redirect-target-more"));
|
||||
flow.append(from, el("span", "→", "redirect-flow-arrow"), to); card.append(flow);
|
||||
const meta = el("div", undefined, "redirect-meta");
|
||||
for (const [k, v] of [["redirectRules", String((item.rules || []).length)], ["redirectListeners", (item.frontend?.listener_ids || []).join(", ") || "-"], ["vhCertificate", item.certificate_id || t("vhCertificateDefault")]]) { const node = el("span", undefined, "redirect-meta-item"); node.append(el("span", t(k)), el("b", v)); meta.append(node); }
|
||||
card.append(meta); return card;
|
||||
const card = el("article", undefined, "vhost-card redirect-card"); card.dataset.redirectCard = item.id;
|
||||
const head = el("div", undefined, "vhost-card-head"), identity = el("div", undefined, "vhost-card-identity"), title = el("div", undefined, "vhost-title-line");
|
||||
const ruleCount = (item.rules || []).length, enabledRules = (item.rules || []).filter(rule => rule.enabled !== false).length;
|
||||
title.append(el("strong", item.name || item.id, "entity-title"), el("span", t(item.enabled === false ? "redirectStateOff" : "redirectStateOn"), item.enabled === false ? "pill" : "pill live"), el("span", `${ruleCount} ${t(pluralKey("redirectRule", ruleCount))}`, "pill warn"));
|
||||
identity.append(title, el("div", `${item.id} · ${(item.frontend?.hosts || []).join(", ") || "-"}`, "vhost-hosts")); head.append(identity);
|
||||
const actions = el("div", undefined, "entity-actions");
|
||||
const toggle = action(t(item.enabled === false ? "redirectEnable" : "redirectDisable"), () => toggleEnabled(item)); if (item.enabled !== false) toggle.classList.add("danger-quiet");
|
||||
actions.append(toggle, action(t("edit"), () => { window.rustProxyDrafts.prepare(); load(structuredClone(item)); }), action(t("copyEntry"), () => { window.rustProxyDrafts.prepare(); const copy = structuredClone(item); copy.id = ""; copy.name = ""; copy.frontend = { ...(copy.frontend || {}), hosts: [] }; copy.certificate_id = null; load(copy); }), action(t("remove"), async () => { if (busy || !(await appConfirm(t("confirmDelete"), { danger: true }))) return; const next = (envelope.config.redirects || []).filter(value => value.id !== item.id); if (await saveSection("redirects", next)) { if (editing === item.id) dialog.close(); render(); } })); head.append(actions); card.append(head);
|
||||
const details = el("div", undefined, "vhost-detail-strip");
|
||||
const protocols = ["HTTP/1.1", item.http2_enabled !== false ? "HTTP/2" : "", item.http3_enabled !== false ? "HTTP/3" : ""].filter(Boolean).join(" · ");
|
||||
for (const [key, shown] of [["redirectListeners", (item.frontend?.listener_ids || []).map(listenerLabel).join(" · ") || "-"], ["vhCertificate", item.certificate_id || t("vhCertificateDefault")], ["vhProtocols", protocols], ["redirectRules", `${enabledRules} ${t("redirectRulesEnabled")} · ${ruleCount - enabledRules} ${t("redirectRulesDisabled")}`]]) { const cell = el("div", undefined, "vhost-detail"); cell.append(el("span", t(key), "small-label"), el("b", shown)); details.append(cell); }
|
||||
card.append(details, ruleTable(item)); return card;
|
||||
}));
|
||||
if (!entries.length) list.append(el("p", t(query ? "redirectSearchEmpty" : "redirectEmpty"), "fine"));
|
||||
}
|
||||
form.addEventListener("input", changed); form.addEventListener("change", changed);
|
||||
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; }
|
||||
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); }
|
||||
});
|
||||
$("redirect-new").addEventListener("click", () => { window.rustProxyDrafts.prepare(); load(); }); $("redirect-search").addEventListener("input", render); $("redirect-sort")?.addEventListener("change", event => { listPrefs.sort = event.target.value; void saveListPrefs(); render(); }); $("redirect-sort-direction")?.addEventListener("click", () => { listPrefs.descending = !listPrefs.descending; syncSortDirection(); void saveListPrefs(); render(); }); $("redirect-rule-add").addEventListener("click", () => { addRule({ id: `rule-${rules.children.length + 1}` }); changed(); });
|
||||
for (const tab of $("redirect-tabs").querySelectorAll("button[data-tab]")) tab.addEventListener("click", () => activateTab(tab.dataset.tab));
|
||||
$("redirect-id").addEventListener("input", syncSummary);
|
||||
$("redirect-new").addEventListener("click", () => { window.rustProxyDrafts.prepare(); load(); }); $("redirect-search").addEventListener("input", render); $("redirect-sort")?.addEventListener("change", event => { listPrefs.sort = event.target.value; void saveListPrefs(); render(); }); $("redirect-sort-direction")?.addEventListener("click", () => { listPrefs.descending = !listPrefs.descending; syncSortDirection(); void saveListPrefs(); render(); });
|
||||
$("redirect-rule-add").addEventListener("click", () => showTemplates($("redirect-rule-templates").hidden));
|
||||
const menu = $("redirect-rule-menu");
|
||||
menu.addEventListener("keydown", event => { if (event.key === "Escape" && !$("redirect-rule-templates").hidden) { event.preventDefault(); event.stopPropagation(); showTemplates(false); $("redirect-rule-add").focus(); } });
|
||||
menu.addEventListener("focusout", event => { if (!menu.contains(event.relatedTarget)) showTemplates(false); });
|
||||
$("redirect-test-url").addEventListener("input", runTester);
|
||||
$("redirect-close").addEventListener("click", closeEditor); $("redirect-reset").addEventListener("click", async () => { if (await allowDiscard()) load(editing ? structuredClone((envelope?.config.redirects || []).find(item => item.id === editing) || defaults()) : defaults()); });
|
||||
dialog.addEventListener("cancel", event => { event.preventDefault(); closeEditor(); });
|
||||
window.rustProxyDrafts.register("redirect", { labelKey: "redirects", isOpen: () => dialog.open, isDirty: () => dirty, suspend: suspendDraft, restore: restoreDraft, close: () => { dirty = false; if (dialog.open) dialog.close(); } });
|
||||
window.rustProxyRedirects = { render, applyPreferences, reset() { dialog.close(); editing = null; revision = null; dirty = false; listPrefs = { sort: "id", descending: false }; list.replaceChildren(); rules.replaceChildren(); $("redirect-search").value = ""; if ($("redirect-sort")) $("redirect-sort").value = listPrefs.sort; syncSortDirection(); } };
|
||||
window.rustProxyRedirects = { render, applyPreferences, test: { routingPath, normalizeRule, ruleLocation, prefixMatches }, reset() { dialog.close(); editing = null; revision = null; dirty = false; listPrefs = { sort: "id", descending: false }; list.replaceChildren(); rules.replaceChildren(); $("redirect-search").value = ""; if ($("redirect-sort")) $("redirect-sort").value = listPrefs.sort; syncSortDirection(); } };
|
||||
if (envelope) render();
|
||||
})();
|
||||
@@ -32,6 +32,11 @@
|
||||
const haystack = `${button.textContent || ""} ${page?.textContent || ""}`.toLocaleLowerCase();
|
||||
const match = !query || haystack.includes(query); button.hidden = !match; if (match) matches.push(button);
|
||||
}
|
||||
for (const caption of document.querySelectorAll("#settings-tabs .settings-nav-group")) {
|
||||
let node = caption.nextElementSibling, visible = false;
|
||||
while (node && !node.classList.contains("settings-nav-group")) { if (!node.hidden) visible = true; node = node.nextElementSibling; }
|
||||
caption.hidden = !visible;
|
||||
}
|
||||
if (searchStatus) searchStatus.textContent = query ? `${t("settingsSearchResults")}: ${matches.length}` : "";
|
||||
if (query && !matches.some(button => button.dataset.settingsTab === active) && matches[0]) select(matches[0].dataset.settingsTab, false, false);
|
||||
}
|
||||
@@ -103,6 +108,196 @@
|
||||
button.addEventListener("keydown", event => { const index = cacheTabs.indexOf(button); let next; if (event.key === "ArrowRight" || event.key === "ArrowDown") next = (index + 1) % cacheTabs.length; else if (event.key === "ArrowLeft" || event.key === "ArrowUp") next = (index + cacheTabs.length - 1) % cacheTabs.length; else if (event.key === "Home") next = 0; else if (event.key === "End") next = cacheTabs.length - 1; else return; event.preventDefault(); selectCacheTab(cacheTabs[next].dataset.cacheSettingsTab, true); });
|
||||
}
|
||||
selectCacheTab("general");
|
||||
// ---- Visual flows (cache request, transformation) ----------------------
|
||||
const FLOW_ICONS = {
|
||||
client: '<rect x="3" y="4" width="18" height="13" rx="1"/><path d="M3 8h18M8 21h8"/>',
|
||||
rules: '<path d="M4 6h16M7 12h10M10 18h4"/>',
|
||||
hot: '<rect x="6" y="6" width="12" height="12"/><path d="M9 2v4M15 2v4M9 18v4M15 18v4M2 9h4M2 15h4M18 9h4M18 15h4"/>',
|
||||
cold: '<ellipse cx="12" cy="6" rx="8" ry="3"/><path d="M4 6v12c0 1.7 3.6 3 8 3s8-1.3 8-3V6"/>',
|
||||
backend: '<rect x="4" y="3" width="16" height="7"/><rect x="4" y="14" width="16" height="7"/><path d="M8 6.5h1M8 17.5h1"/>',
|
||||
unpack: '<path d="M12 3v13M6 10l6 6 6-6M5 21h14"/>',
|
||||
transform: '<path d="M4 7h16M4 12h10M4 17h6M16 14l4 3-4 3"/>',
|
||||
cache: '<rect x="5" y="5" width="14" height="14"/><path d="M9 9h6v6H9z"/>',
|
||||
pack: '<path d="M12 21V8M6 14l6-6 6 6M5 3h14"/>'
|
||||
};
|
||||
const flowIcon = name => { const node = document.createElementNS("http://www.w3.org/2000/svg", "svg"); node.setAttribute("viewBox", "0 0 24 24"); node.setAttribute("aria-hidden", "true"); node.classList.add("settings-flow-icon"); node.innerHTML = FLOW_ICONS[name] || ""; return node; };
|
||||
const flowText = (tag, key, cls) => { const node = el(tag, t(key), cls); node.dataset.i18n = key; return node; };
|
||||
function renderFlow(container, nodes, onSelect) {
|
||||
if (!container) return;
|
||||
const row = el("div", undefined, "settings-flow-row"); row.style.setProperty("--flow-steps", String(nodes.length));
|
||||
nodes.forEach((node, index) => {
|
||||
if (index) row.append(el("span", "→", "settings-flow-arrow"));
|
||||
const step = el(node.tab ? "button" : "div", undefined, `settings-flow-step${node.state ? ` is-${node.state}` : ""}`);
|
||||
if (node.tab) { step.type = "button"; step.addEventListener("click", () => onSelect(node.tab)); step.title = t("settingsFlowOpenTab"); }
|
||||
step.append(flowIcon(node.icon), el("b", t(node.titleKey)));
|
||||
for (const line of node.lines || []) step.append(el("small", line));
|
||||
if (node.badge) step.append(el("span", node.badge, `pill${node.badgeClass ? ` ${node.badgeClass}` : ""}`));
|
||||
row.append(step);
|
||||
});
|
||||
container.replaceChildren(row, ...(container._extra || []));
|
||||
}
|
||||
const num = id => Number($(id)?.value) || 0, on = id => $(id)?.checked === true;
|
||||
const mib = value => value >= 1024 ? `${(value / 1024).toFixed(value % 1024 ? 1 : 0)} GiB` : `${Math.round(value)} MiB`;
|
||||
function cacheRuleCount() { try { return (cacheRulesEditor ? cacheRulesEditor.read() : envelope?.config.cache?.rules || []).length; } catch { return (envelope?.config.cache?.rules || []).length; } }
|
||||
function renderCacheFlow() {
|
||||
const container = $("cache-flow"); if (!container) return;
|
||||
if (!container._extra) {
|
||||
const legend = el("div", undefined, "settings-flow-legend");
|
||||
for (const [badge, cls, key] of [["HIT", "live", "cacheFlowHit"], ["MISS", "warn", "cacheFlowMiss"], ["BYPASS", "", "cacheFlowBypass"]]) { const item = el("p", undefined, "settings-flow-legend-item"); item.append(el("span", badge, `pill ${cls}`.trim()), flowText("span", key)); legend.append(item); }
|
||||
const disabled = flowText("p", "cacheFlowDisabled", "fine settings-flow-disabled"); container._disabled = disabled;
|
||||
container._extra = [legend, disabled];
|
||||
}
|
||||
const enabled = on("cache-enabled"), prefixes = ($("cache-prefixes")?.value || "").split(/\r?\n/).map(v => v.trim()).filter(Boolean).length;
|
||||
const sie = [["cache-sie-timeout", "cacheFlowSieTimeout"], ["cache-sie-connection", "cacheFlowSieConnection"], ["cache-sie-dns", "DNS"], ["cache-sie-tls", "TLS"]].filter(([id]) => on(id)).map(([, key]) => key.startsWith("cache") ? t(key) : key);
|
||||
const statuses = ($("cache-sie-statuses")?.value || "").split(/[\s,]+/).filter(Boolean);
|
||||
renderFlow(container, [
|
||||
{ icon: "client", titleKey: "cacheFlowClient", lines: [t("cacheFlowClientLine")] },
|
||||
{ icon: "rules", titleKey: "cacheFlowRules", tab: "rules", state: enabled ? "on" : "", lines: [`${cacheRuleCount()} ${t("cacheFlowRulesCount")}`, on("cache-query") ? t("cacheFlowSkipQuery") : t("cacheFlowKeepQuery"), `${prefixes} ${t("cacheFlowPrefixes")}`] },
|
||||
{ icon: "hot", titleKey: "cacheFlowHot", tab: "general", state: enabled ? "on" : "", lines: [`${mib(num("cache-memory"))} · ${num("cache-entries")} ${t("cacheFlowEntries")}`, `${t("cacheFlowMaxObject")} ${mib(num("cache-object") / 1024)}`, `${t("cacheFlowMaxTtl")} ${num("cache-ttl")} s`], badge: "HIT", badgeClass: "live" },
|
||||
{ icon: "cold", titleKey: "cacheFlowCold", tab: "cold", state: enabled && on("cache-cold-enabled") ? "on" : "", lines: on("cache-cold-enabled") ? [`${mib(num("cache-cold-bytes"))} · ${num("cache-cold-entries")} ${t("cacheFlowEntries")}`, t("cacheFlowColdLine")] : [t("cacheFlowColdOff")] },
|
||||
{ icon: "backend", titleKey: "cacheFlowBackend", tab: "resilience", lines: [t("cacheFlowMissLine"), num("cache-varnish-grace") > 0 ? `grace ${num("cache-varnish-grace")} s` : t("cacheFlowNoGrace"), sie.length || statuses.length ? `stale-if-error: ${[...sie, ...statuses].join(", ")}` : t("cacheFlowNoStale")], badge: "MISS", badgeClass: "warn" }
|
||||
], selectCacheTab);
|
||||
container.classList.toggle("is-disabled", !enabled); container._disabled.hidden = enabled;
|
||||
renderCacheTimeline();
|
||||
}
|
||||
function renderCacheTimeline() {
|
||||
const box = $("cache-resilience-timeline"); if (!box) return;
|
||||
const steps = [["cacheTimelineStored", "cacheTimelineStoredLine", "ok"]];
|
||||
if (on("cache-proactive-enabled")) steps.push([`TTL − ${num("cache-proactive-before")} s`, `${num("cache-proactive-percent")}% ${t("cacheTimelineProactiveLine")}`, "ok"]);
|
||||
steps.push([num("cache-varnish-grace") > 0 ? `${t("cacheTimelineAfterTtl")} · grace ${num("cache-varnish-grace")} s` : t("cacheTimelineAfterTtl"), num("cache-varnish-grace") > 0 ? t("cacheTimelineGraceLine") : t("cacheTimelineNoGraceLine"), "warn"]);
|
||||
const sie = [["cache-sie-timeout", "cacheFlowSieTimeout"], ["cache-sie-connection", "cacheFlowSieConnection"], ["cache-sie-dns", "DNS"], ["cache-sie-tls", "TLS"]].filter(([id]) => on(id)).map(([, key]) => key.startsWith("cache") ? t(key) : key);
|
||||
const statuses = ($("cache-sie-statuses")?.value || "").split(/[\s,]+/).filter(Boolean);
|
||||
steps.push(["cacheTimelineBackendDown", sie.length || statuses.length ? `stale-if-error: ${[...sie, ...statuses].join(", ")}` : t("cacheFlowNoStale"), "bad"]);
|
||||
box.replaceChildren(...steps.map(([title, line, tone]) => { const step = el("div", undefined, `settings-timeline-step is-${tone}`); step.append(el("b", title.startsWith("cache") ? t(title) : title), el("small", line.startsWith("cache") ? t(line) : line)); return step; }));
|
||||
}
|
||||
$("cache-form")?.addEventListener("input", renderCacheFlow); $("cache-form")?.addEventListener("change", renderCacheFlow);
|
||||
// Outputs below are what the built-in minifiers really produce for these inputs.
|
||||
const TRANSFORM_EXAMPLES = {
|
||||
javascript: ["app.js", "function greet ( name ) {\n // greeting\n return \"Hello, \" + name ;\n}", "function greet ( name ) {\n // greeting\n return \"Hello, \" + name ;\n}"],
|
||||
css: ["site.css", ".button {\n color : #ffffff ;\n /* spacing */\n margin : 0 auto ;\n}", ".button{color :#ffffff;margin :0 auto;}"],
|
||||
html: ["index.html", "<!-- header -->\n<h1>Hello</h1>", "\n<h1>Hello</h1>"],
|
||||
svg: ["logo.svg", "<svg xmlns=\"http://www.w3.org/2000/svg\">\n<!-- exported by editor -->\n<path d=\"M10 10 20 20\"/>\n</svg>", "<svg xmlns=\"http://www.w3.org/2000/svg\">\n\n<path d=\"M10 10 20 20\"/>\n</svg>"],
|
||||
json: ["data.json", "{\n \"name\": \"RustProxy\",\n \"tags\": [ \"proxy\" ]\n}", "{\"name\":\"RustProxy\",\"tags\":[\"proxy\"]}"]
|
||||
};
|
||||
function renderTransformFlow() {
|
||||
const container = $("transform-flow"); if (!container) return;
|
||||
const enabled = on("transform-enabled"), ops = [["javascript", "JS"], ["css", "CSS"], ["html", "HTML"], ["svg", "SVG"], ["json", "JSON"]].filter(([id]) => on(`transform-${id}`));
|
||||
if (!container._example) {
|
||||
const tabs = el("div", undefined, "settings-flow-example-tabs"); tabs.setAttribute("role", "tablist"); tabs.setAttribute("aria-label", t("transformExampleBefore"));
|
||||
for (const [id, text] of [["css", "CSS"], ["json", "JSON"], ["html", "HTML"], ["svg", "SVG"], ["javascript", "JS"]]) {
|
||||
const tab = el("button", text); tab.type = "button"; tab.dataset.example = id; tab.setAttribute("role", "tab");
|
||||
tab.addEventListener("click", () => { container._chosen = id; renderTransformFlow(); }); tabs.append(tab);
|
||||
}
|
||||
const box = el("div", undefined, "settings-flow-example"), left = el("div"), right = el("div");
|
||||
left.append(flowText("span", "transformExampleBefore", "small-label"), el("pre", "")); right.append(flowText("span", "transformExampleAfter", "small-label"), el("pre", ""));
|
||||
box.append(left, right); container._example = box; container._tabs = tabs;
|
||||
const disabled = flowText("p", "transformFlowDisabled", "fine settings-flow-disabled"); container._disabled = disabled;
|
||||
container._extra = [tabs, box, disabled];
|
||||
}
|
||||
const example = container._chosen || ["css", "json", "html", "svg", "javascript"].find(id => on(`transform-${id}`)) || "css", [file, before, after] = TRANSFORM_EXAMPLES[example];
|
||||
for (const tab of container._tabs.children) { const active = tab.dataset.example === example; tab.classList.toggle("active", active); tab.setAttribute("aria-selected", String(active)); }
|
||||
const [beforePre, afterPre] = container._example.querySelectorAll("pre"); beforePre.textContent = before; afterPre.textContent = after;
|
||||
renderFlow(container, [
|
||||
{ icon: "backend", titleKey: "transformFlowBackend", lines: [file, t("transformFlowBackendLine")] },
|
||||
{ icon: "unpack", titleKey: "transformFlowDecode", lines: [t("transformFlowDecodeLine")] },
|
||||
{ icon: "transform", titleKey: "transformFlowTransform", state: enabled && ops.length ? "on" : "", lines: [ops.length ? ops.map(([, label]) => label).join(" · ") : t("transformFlowNoOps"), `${t("transformFlowMaxBody")} ${num("transform-max-body")} KiB`, t("transformFlowNoTransform")] },
|
||||
{ icon: "cache", titleKey: "transformFlowCache", lines: [t("transformFlowCacheLine")] },
|
||||
{ icon: "pack", titleKey: "transformFlowEncode", lines: [t("transformFlowEncodeLine")] },
|
||||
{ icon: "client", titleKey: "cacheFlowClient", lines: [t("transformFlowClientLine")] }
|
||||
], () => {});
|
||||
container.classList.toggle("is-disabled", !enabled); container._disabled.hidden = enabled;
|
||||
}
|
||||
$("transform-form")?.addEventListener("input", renderTransformFlow); $("transform-form")?.addEventListener("change", renderTransformFlow);
|
||||
window.rustProxySettingsFlow = { renderFlow, flowText, renderCache: renderCacheFlow, renderTransform: renderTransformFlow, num, on, mib };
|
||||
renderTransformFlow();
|
||||
// Security page: summary tiles, default-decision cards and a client-side
|
||||
// simulator that mirrors src/acl.rs (any matching deny wins, then any
|
||||
// matching allow, otherwise the default; IPv4-mapped IPv6 is treated as IPv4).
|
||||
function renderSecuritySummary() {
|
||||
const box = $("security-summary"); if (!box) return;
|
||||
const tokens = $("api-token-list")?.querySelectorAll(".certificate-api-credential-item") || [];
|
||||
const rw = [...tokens].filter(item => item.querySelector(".pill.warn")).length, policies = envelope?.config.host_policies?.length || 0;
|
||||
const tile = (target, value, titleKey, line, tone) => {
|
||||
const node = el("button", undefined, `security-summary-tile${tone ? ` is-${tone}` : ""}`); node.type = "button";
|
||||
node.append(el("b", value), flowText("span", titleKey), el("small", line));
|
||||
node.addEventListener("click", () => { const card = $(target); card?.scrollIntoView({ block: "start", behavior: "smooth" }); card?.focus?.({ preventScroll: true }); });
|
||||
return node;
|
||||
};
|
||||
box.replaceChildren(
|
||||
tile("security-account-card", $("session-user")?.textContent || "-", "securitySummaryAccount", $("session-expiry")?.textContent || "", "ok"),
|
||||
tile("api-tokens-card", String(tokens.length), "securitySummaryTokens", tokens.length ? `${tokens.length - rw} RO · ${rw} RW · ${t("securitySummaryTokensLine")}` : t("apiTokenEmpty"), rw ? "warn" : ""),
|
||||
tile("security-policy-card", String(policies), "securitySummaryPolicies", policies ? t("securitySummaryPoliciesLine") : t("securitySummaryNoPolicies"), "")
|
||||
);
|
||||
}
|
||||
for (const id of ["api-token-list", "host-policy-list", "session-user", "session-expiry"]) { const node = $(id); if (node && typeof MutationObserver !== "undefined") new MutationObserver(renderSecuritySummary).observe(node, { childList: true, characterData: true, subtree: true }); }
|
||||
renderSecuritySummary();
|
||||
function parseIp(text, collapseMapped = true) {
|
||||
let value = String(text || "").trim().replace(/^\[|\]$/g, "");
|
||||
const v4 = part => { const items = part.split("."); if (items.length !== 4 || items.some(item => !/^\d{1,3}$/.test(item) || Number(item) > 255)) return null; return items.reduce((acc, item) => (acc << 8n) | BigInt(item), 0n); };
|
||||
if (!value.includes(":")) { const n = v4(value); return n === null ? null : { v: 4, n }; }
|
||||
const zone = value.indexOf("%"); if (zone >= 0) value = value.slice(0, zone);
|
||||
let tail = [];
|
||||
const lastColon = value.lastIndexOf(":");
|
||||
if (value.slice(lastColon + 1).includes(".")) { const n = v4(value.slice(lastColon + 1)); if (n === null) return null; tail = [Number(n >> 16n), Number(n & 0xffffn)].map(x => x.toString(16)); value = value.slice(0, lastColon + 1) + tail.join(":"); }
|
||||
const halves = value.split("::"); if (halves.length > 2) return null;
|
||||
const parts = halves.map(half => half ? half.split(":") : []);
|
||||
if (parts.flat().some(item => !/^[0-9a-f]{1,4}$/i.test(item))) return null;
|
||||
const missing = 8 - parts.flat().length; if (halves.length === 1 ? missing !== 0 : missing < 1) return null;
|
||||
const groups = halves.length === 1 ? parts[0] : [...parts[0], ...Array(missing).fill("0"), ...parts[1]];
|
||||
const n = groups.reduce((acc, item) => (acc << 16n) | BigInt(parseInt(item, 16)), 0n);
|
||||
if (collapseMapped && n >> 32n === 0xffffn) return { v: 4, n: n & 0xffffffffn };
|
||||
return { v: 6, n };
|
||||
}
|
||||
function parseNetwork(text) {
|
||||
const [address, prefixText, extra] = String(text).split("/"); const ip = extra === undefined ? parseIp(address, false) : null; if (!ip) return null;
|
||||
const bits = ip.v === 4 ? 32 : 128, prefix = prefixText === undefined ? bits : Number(prefixText);
|
||||
if (!Number.isInteger(prefix) || prefix < 0 || prefix > bits || (prefixText !== undefined && !/^\d+$/.test(prefixText))) return null;
|
||||
return { ...ip, prefix, bits };
|
||||
}
|
||||
function networkContains(net, ip) {
|
||||
if (net.v !== ip.v) return false;
|
||||
const shift = BigInt(net.bits - net.prefix);
|
||||
return (net.n >> shift) === (ip.n >> shift);
|
||||
}
|
||||
function renderPolicySimulator() {
|
||||
const results = $("policy-simulator-results"), input = $("policy-simulator-ips"); if (!results || !input) return;
|
||||
const ips = (input.value || input.placeholder).split(/[\s,;]+/).map(v => v.trim()).filter(Boolean).slice(0, 8);
|
||||
let rules = [];
|
||||
try { rules = parseRules($("policy-rules").value); }
|
||||
catch (error) { results.replaceChildren(el("p", error.message, "fine acl-simulator-error")); return; }
|
||||
const fallback = $("policy-default").value === "allow" ? "allow" : "deny";
|
||||
let anyDns = false;
|
||||
const rows = ips.map(text => {
|
||||
const row = el("div", undefined, "acl-simulator-row"), ip = parseIp(text);
|
||||
row.append(el("code", text));
|
||||
if (!ip) { row.append(flowText("span", "policySimulatorInvalidIp", "fine"), el("span", "?", "pill")); return row; }
|
||||
let deny = null, allow = null, dns = false;
|
||||
for (const rule of rules) {
|
||||
const net = parseNetwork(rule.network);
|
||||
if (!net) { dns = true; continue; }
|
||||
if (networkContains(net, ip)) { if (rule.action === "deny") { deny = rule; break; } allow ||= rule; }
|
||||
}
|
||||
const matched = deny || allow, decision = matched ? matched.action : fallback;
|
||||
const reason = matched ? `${t("policySimulatorMatches")} ${matched.action} ${matched.network}` : `${t("policySimulatorNoMatch")} (${t(fallback)})`;
|
||||
anyDns ||= dns && !deny;
|
||||
row.append(el("span", reason, "fine"), el("span", decision === "allow" ? t("policySimulatorAllowed") : "403", `pill ${decision === "allow" ? "live" : "danger"}`));
|
||||
return row;
|
||||
});
|
||||
results.replaceChildren(...rows);
|
||||
if (anyDns) results.append(flowText("p", "policySimulatorDns", "fine acl-simulator-note"));
|
||||
}
|
||||
function syncPolicyDefaultCards() {
|
||||
const value = $("policy-default")?.value || "deny";
|
||||
for (const radio of document.querySelectorAll('#policy-default-cards input')) { radio.checked = radio.value === value; radio.closest(".vh-www-choice").classList.toggle("is-selected", radio.checked); }
|
||||
renderPolicySimulator();
|
||||
}
|
||||
for (const radio of document.querySelectorAll('#policy-default-cards input')) radio.addEventListener("change", () => { if (!radio.checked) return; $("policy-default").value = radio.value; $("policy-default").dispatchEvent(new Event("change", { bubbles: true })); });
|
||||
for (const id of ["policy-default", "policy-rules", "policy-simulator-ips"]) for (const type of ["input", "change"]) $(id)?.addEventListener(type, syncPolicyDefaultCards);
|
||||
$("host-policy-form")?.addEventListener("reset", () => setTimeout(syncPolicyDefaultCards));
|
||||
$("security-policy-editor")?.addEventListener("toggle", syncPolicyDefaultCards);
|
||||
window.rustProxySecurityPage = { renderSummary: renderSecuritySummary, syncPolicy: syncPolicyDefaultCards, parseIp, parseNetwork, networkContains };
|
||||
syncPolicyDefaultCards();
|
||||
renderCacheFlow();
|
||||
const cacheGuideDialog = $("cache-vcl-guide-dialog");
|
||||
let guideEditor = null;
|
||||
let guideIsLocal = false;
|
||||
|
||||
+136
-52
@@ -21,6 +21,8 @@
|
||||
if (type === "checkbox") label.append(input, text("span", key)); else label.append(text("span", key), input);
|
||||
parent.append(label); return input;
|
||||
};
|
||||
// Live metrics of the edited stream are shown in its Backends tab, not between the title and the tabs.
|
||||
const setStreamLive = value => { $("stream-live-summary").textContent = value; const tab = $("stream-live-summary-tab"); if (tab) { tab.textContent = value; tab.hidden = !value; } };
|
||||
const group = (key, tab) => { const box = el("fieldset", undefined, "vh-group"); box.dataset.tab = tab; box.append(text("legend", key)); const body = el("div", undefined, "vh-grid"); box.append(body); container.append(box); return body; };
|
||||
const note = (parent, key) => parent.append(text("p", key, "fine vh-wide"));
|
||||
const read = name => form.querySelector(`[name="${name}"]`);
|
||||
@@ -29,17 +31,31 @@
|
||||
const yes = name => read(name).checked;
|
||||
const changed = () => { dirty = true; };
|
||||
const defaults = () => ({ id: "", name: "", enabled: true, protocol: "tcp", listen: "0.0.0.0:10000", upstream: "127.0.0.1:10001", connect_timeout_seconds: 5, idle_timeout_seconds: 300, max_connections: 1024 });
|
||||
const pluralKey = (base, count) => { let kind = "other"; try { kind = new Intl.PluralRules(locale()).select(count); } catch { } return `${base}${kind === "one" ? "One" : kind === "few" ? "Few" : "Many"}`; };
|
||||
async function toggleEnabled(stream) {
|
||||
if (busy) return;
|
||||
if (stream.enabled !== false && !(await appConfirm(t("streamDisableConfirm"), { danger: true, confirmLabel: t("redirectDisable") }))) return;
|
||||
const next = structuredClone(envelope.config.streams || []), index = next.findIndex(item => item.id === stream.id); if (index < 0) return;
|
||||
next[index].enabled = stream.enabled === false;
|
||||
if (await saveSection("streams", next)) render();
|
||||
}
|
||||
const allowDiscard = async () => { if (!dirty) return true; if (!(await appConfirm(t("vhUnsaved"), { danger: true, confirmLabel: t("discardAction") }))) return false; dirty = false; return true; };
|
||||
|
||||
function activateTab(name) {
|
||||
document.querySelectorAll("#stream-tabs button").forEach(node => { node.classList.toggle("active", node.dataset.tab === name); node.setAttribute("aria-pressed", String(node.dataset.tab === name)); });
|
||||
container.querySelectorAll(".vh-group").forEach(groupNode => groupNode.hidden = groupNode.dataset.tab !== name);
|
||||
container.querySelectorAll(":scope > .vh-group").forEach(groupNode => groupNode.hidden = groupNode.dataset.tab !== name);
|
||||
container.scrollTop = 0;
|
||||
}
|
||||
function initTabs() {
|
||||
const tabs = $("stream-tabs"); tabs.replaceChildren();
|
||||
for (const [name, key] of [["details", "streamDetailsTab"], ["network", "streamNetworkTab"], ["limits", "streamLimitsTab"]]) { const node = button(key, () => activateTab(name)); node.dataset.tab = name; tabs.append(node); }
|
||||
for (const [name, key] of [["details", "streamDetailsTab"], ["network", "streamNetworkTab"], ["backends", "streamBackendsTab"], ["health", "streamHealthTab"], ["limits", "streamLimitsTab"]]) {
|
||||
const node = button(key, () => activateTab(name)); node.dataset.tab = name;
|
||||
if (name === "backends") { const count = el("span", "", "vh-tab-count stream-backend-count"); node.append(" ", count); }
|
||||
tabs.append(node);
|
||||
}
|
||||
activateTab("details");
|
||||
}
|
||||
function updateBackendCount() { const count = document.querySelector("#stream-tabs .stream-backend-count"); if (count && backendList) count.textContent = `· ${backendList.children.length}`; }
|
||||
function socketChipField(parent, value) {
|
||||
const wrapper = el("div", undefined, "vh-field vh-wide host-chip-field"); wrapper.append(text("span", "streamListen"));
|
||||
const box = el("div", undefined, "host-chip-editor stream-socket-editor"), input = document.createElement("input"); input.type = "text"; input.maxLength = 128; input.placeholder = "0.0.0.0:10000 / [::]:10000"; input.setAttribute("aria-label", t("streamListenAdd"));
|
||||
@@ -57,19 +73,24 @@
|
||||
address, enabled: true, drain: false, weight: 1, max_sessions: null, metrics_enabled: null,
|
||||
health: { mode: "off", interval_seconds: 10, timeout_ms: 1000, rise: 2, fall: 2, payload_hex: "", expect_hex: null }
|
||||
});
|
||||
let backendList = null;
|
||||
function renderBackendEditor(parent, backend, protocol) {
|
||||
let backendList = null, healthList = null;
|
||||
// One backend = one routing-table row (summary) with its connection fields;
|
||||
// its health check lives in the Health tab and is linked through row._health.
|
||||
function renderBackendEditor(parent, backend, protocol, open = false) {
|
||||
if (backendList?.children.length >= 32) { toast(t("streamBackendLimit"), true); return; }
|
||||
const row = el("fieldset", undefined, "stream-backend-row vh-wide"); row.append(el("legend", backend.id || t("streamBackend")));
|
||||
const controls = el("div", undefined, "vh-grid"); row.append(controls);
|
||||
const backendSection = key => {
|
||||
const row = el("details", undefined, "vh-location stream-backend-row"); row.open = open;
|
||||
const summary = el("summary", undefined, "location-summary stream-backend-summary");
|
||||
const sumOrder = el("span", "", "loc-order"), sumState = el("span", undefined, "loc-state"), sumId = el("span", "", "loc-id"), sumWeight = el("span", "", "loc-match"), sumAddress = el("span", "", "loc-path"), sumLive = el("span", "", "loc-action stream-backend-live"), sumChips = el("span", undefined, "loc-chips");
|
||||
sumState.setAttribute("role", "img"); summary.append(sumOrder, sumState, sumId, sumWeight, sumAddress, sumLive, sumChips); row.append(summary);
|
||||
const body = el("div", undefined, "location-body"), controls = el("div", undefined, "vh-grid"); body.append(controls); row.append(body);
|
||||
const backendSection = (key, holder) => {
|
||||
const section = el("section", undefined, "vh-wide vh-setting-section stream-backend-section");
|
||||
section.append(text("h3", key));
|
||||
const grid = el("div", undefined, "vh-grid"); section.append(grid); controls.append(section);
|
||||
return grid;
|
||||
const heading = el("h3"); heading.append(text("span", key)); section.append(heading);
|
||||
const grid = el("div", undefined, "vh-grid"); section.append(grid); holder.append(section);
|
||||
return [grid, section, heading];
|
||||
};
|
||||
const connectionFields = backendSection("streamBackendConnectionSection");
|
||||
field(connectionFields, "backend-id", "streamBackendId", backend.id, "text", { required: true, maxLength: 64, pattern: "[A-Za-z0-9_\\-]{1,64}" });
|
||||
const [connectionFields] = backendSection("streamBackendConnectionSection", controls);
|
||||
const idInput = field(connectionFields, "backend-id", "streamBackendId", backend.id, "text", { required: true, maxLength: 64, pattern: "[A-Za-z0-9_\\-]{1,64}" });
|
||||
field(connectionFields, "backend-name", "streamBackendName", backend.name || "", "text", { maxLength: 96 });
|
||||
field(connectionFields, "backend-address", "streamBackendAddress", backend.address, "text", { required: true, maxLength: 128 });
|
||||
field(connectionFields, "backend-weight", "streamBackendWeight", backend.weight ?? 1, "number", { min: 1, max: 16, required: true });
|
||||
@@ -79,7 +100,8 @@
|
||||
const detail = backend.metrics_enabled == null ? "inherit" : String(backend.metrics_enabled);
|
||||
field(connectionFields, "backend-metrics", "streamBackendDetailMetrics", detail, "select", { values: [["inherit", "streamMetricsFromStream"], ["true", "streamMetricsOn"], ["false", "streamMetricsOff"]] });
|
||||
const hc = backend.health || backendDefaults().health;
|
||||
const healthFields = backendSection("streamBackendHealthSection");
|
||||
const [healthFields, healthSection, healthHeading] = backendSection("streamBackendHealthSection", healthList || controls);
|
||||
healthSection.classList.add("stream-backend-health"); const healthTitle = el("code", "", "stream-health-backend"); healthHeading.append(" ", healthTitle);
|
||||
const healthMode = field(healthFields, "backend-health-mode", "streamHealthMode", hc.mode || "off", "select", { values: [["off", "streamHealthOff"], [protocol === "tcp" ? "tcp_connect" : "udp_probe", protocol === "tcp" ? "streamHealthTcp" : "streamHealthUdp"]] });
|
||||
const probeFields = el("div", undefined, "vh-wide vh-grid stream-health-probe-fields");
|
||||
healthFields.append(probeFields);
|
||||
@@ -98,15 +120,41 @@
|
||||
field(probeFields, "backend-health-expected", "streamHealthExpected", hc.expect_hex || "", "text", { maxLength: 256 });
|
||||
}
|
||||
syncProbeFields();
|
||||
const remove = button("remove", () => { if (backendList.children.length > 1) { row.remove(); changed(); } });
|
||||
row.append(remove); backendList.append(row);
|
||||
row._health = healthSection;
|
||||
const actions = el("div", undefined, "redirect-rule-actions");
|
||||
actions.append(button("copyEntry", () => {
|
||||
const copy = readBackend(row), used = new Set([...backendList.children].map(item => get(item, "backend-id").value.trim()));
|
||||
let id = `${copy.id}-copy`, index = 2; while (used.has(id)) id = `${copy.id}-copy-${index++}`;
|
||||
copy.id = id; copy.name = copy.name ? `${copy.name} (${t("copySuffix")})` : "";
|
||||
const added = renderBackendEditor(backendList, copy, read("protocol").value, true); if (added) { row.after(added); healthSectionsInOrder(); syncBackendRows(); changed(); }
|
||||
}), button("remove", () => { if (backendList.children.length > 1) { row._health.remove(); row.remove(); syncBackendRows(); changed(); } }));
|
||||
body.append(actions);
|
||||
row.addEventListener("invalid", () => { row.open = true; activateTab("backends"); }, true);
|
||||
healthSection.addEventListener("invalid", () => activateTab("health"), true);
|
||||
const sync = () => syncBackendRow(row);
|
||||
row.addEventListener("input", sync); row.addEventListener("change", sync); healthSection.addEventListener("change", sync);
|
||||
row._summary = { sumOrder, sumState, sumId, sumWeight, sumAddress, sumLive, sumChips, healthTitle, idInput };
|
||||
backendList.append(row); syncBackendRow(row); return row;
|
||||
}
|
||||
const optBool = value => value === "inherit" ? null : value === "true";
|
||||
function collectBackends() {
|
||||
const rows = [...backendList.querySelectorAll(".stream-backend-row")];
|
||||
if (!rows.length) throw new Error(t("streamBackendRequired"));
|
||||
const get = (row, name) => row.querySelector(`[name="${name}"]`);
|
||||
const selected = rows.map(row => ({
|
||||
const get = (row, name) => row.querySelector(`[name="${name}"]`) || row._health?.querySelector(`[name="${name}"]`);
|
||||
function healthSectionsInOrder() { if (!healthList) return; for (const row of backendList.children) healthList.append(row._health); }
|
||||
function syncBackendRow(row) {
|
||||
const s = row._summary; if (!s) return;
|
||||
const id = get(row, "backend-id").value.trim(), name = get(row, "backend-name").value.trim(), enabled = get(row, "backend-enabled").checked, drain = get(row, "backend-drain").checked;
|
||||
s.sumId.textContent = name && name !== id ? `${name} (${id || "—"})` : (id || "—"); s.healthTitle.textContent = id || "—";
|
||||
s.sumWeight.textContent = `${t("streamWeightShort")} ${get(row, "backend-weight").value || 1}`;
|
||||
s.sumAddress.textContent = get(row, "backend-address").value.trim() || "—";
|
||||
row.classList.toggle("is-disabled", !enabled); s.sumState.setAttribute("aria-label", t(enabled ? "enabled" : "vhDisabled"));
|
||||
const chips = [];
|
||||
if (drain) chips.push(t("streamChipDrain"));
|
||||
if (get(row, "backend-max").value) chips.push(`${t("streamChipMax")} ${get(row, "backend-max").value}`);
|
||||
const health = get(row, "backend-health-mode").value; chips.push(health === "off" ? t("streamChipNoHealth") : t(health === "tcp_connect" ? "streamHealthTcp" : "streamChipUdpProbe"));
|
||||
const metrics = get(row, "backend-metrics").value; if (metrics !== "inherit") chips.push(t(metrics === "true" ? "streamChipMetricsOn" : "streamChipMetricsOff"));
|
||||
s.sumChips.replaceChildren(...chips.map(label => el("span", label, "loc-chip")));
|
||||
}
|
||||
function syncBackendRows() { [...(backendList?.children || [])].forEach((row, index) => { if (row._summary) row._summary.sumOrder.textContent = String(index + 1); syncBackendRow(row); }); updateBackendCount(); }
|
||||
function readBackend(row) {
|
||||
return {
|
||||
id: get(row, "backend-id").value.trim(), name: get(row, "backend-name").value.trim(),
|
||||
address: get(row, "backend-address").value.trim(), weight: Number(get(row, "backend-weight").value),
|
||||
max_sessions: get(row, "backend-max").value === "" ? null : Number(get(row, "backend-max").value),
|
||||
@@ -119,7 +167,13 @@
|
||||
payload_hex: get(row, "backend-health-payload")?.value.trim() || "",
|
||||
expect_hex: get(row, "backend-health-expected")?.value.trim() || null
|
||||
}
|
||||
}));
|
||||
};
|
||||
}
|
||||
const optBool = value => value === "inherit" ? null : value === "true";
|
||||
function collectBackends() {
|
||||
const rows = [...backendList.querySelectorAll(":scope > .stream-backend-row")];
|
||||
if (!rows.length) throw new Error(t("streamBackendRequired"));
|
||||
const selected = rows.map(readBackend);
|
||||
if (new Set(selected.map(b => b.id)).size !== selected.length) throw new Error(t("streamBackendDuplicate"));
|
||||
return selected;
|
||||
}
|
||||
@@ -141,16 +195,24 @@
|
||||
|
||||
g = group("streamNetwork", "network");
|
||||
readListen = socketChipField(g, value.listen || "0.0.0.0:10000");
|
||||
field(g, "balance", "streamBalance", value.balance || "round_robin", "select", { values: [["round_robin", "streamRoundRobin"], [protocol.value === "tcp" ? "least_connections" : "least_sessions", "streamLeastSessions"]] });
|
||||
field(g, "stream-metrics", "streamDetailMetrics", value.metrics_enabled == null ? "inherit" : String(value.metrics_enabled), "select", { values: [["inherit", "streamMetricsDefaultOff"], ["true", "streamMetricsOn"], ["false", "streamMetricsOff"]] });
|
||||
note(g, "streamMetricsHelp");
|
||||
const pool = el("div", undefined, "vh-wide stream-backend-pool"); pool.append(text("h3", "streamBackendPool"));
|
||||
backendList = el("div", undefined, "stream-backend-list"); pool.append(backendList);
|
||||
note(g, "streamDedicatedListenerHelp");
|
||||
|
||||
g = group("streamBackendPool", "backends");
|
||||
{ const live = el("p", "", "vh-live-summary vh-live-summary-tab vh-wide"); live.id = "stream-live-summary-tab"; g.append(live); }
|
||||
const toolbar = el("div", undefined, "vh-wide location-toolbar stream-backend-toolbar"); g.append(toolbar);
|
||||
field(toolbar, "balance", "streamBalance", value.balance || "round_robin", "select", { values: [["round_robin", "streamRoundRobin"], [protocol.value === "tcp" ? "least_connections" : "least_sessions", "streamLeastSessions"]] });
|
||||
healthList = el("div", undefined, "vh-wide stream-health-list");
|
||||
backendList = el("div", undefined, "vh-wide vh-locations stream-backend-list");
|
||||
toolbar.append(button("streamBackendAdd", () => { const added = renderBackendEditor(backendList, backendDefaults(backendList.children.length), protocol.value, true); if (added) { syncBackendRows(); changed(); added.querySelector('[name="backend-address"]')?.focus(); } }, "outline"));
|
||||
g.append(backendList);
|
||||
const initial = value.backends?.length ? value.backends : [backendDefaults(0, value.upstream || "127.0.0.1:10001")];
|
||||
for (const backend of initial) renderBackendEditor(backendList, backend, protocol.value);
|
||||
pool.append(button("streamBackendAdd", () => { renderBackendEditor(backendList, backendDefaults(backendList.children.length), protocol.value); changed(); }));
|
||||
note(pool, "streamHealthUdpHelp"); g.append(pool);
|
||||
note(g, "streamDedicatedListenerHelp");
|
||||
if (!editing && backendList.children.length === 1) backendList.firstElementChild.open = true;
|
||||
|
||||
g = group("streamHealthTab", "health");
|
||||
note(g, "streamHealthUdpHelp"); g.append(healthList); healthSectionsInOrder(); syncBackendRows();
|
||||
|
||||
g = group("streamLimits", "limits");
|
||||
const connectTimeout = field(g, "connect-timeout", "streamConnectTimeout", value.connect_timeout_seconds ?? 5, "number", { min: 1, max: 300, required: true });
|
||||
@@ -159,18 +221,19 @@
|
||||
const sync = () => { connectTimeout.disabled = protocol.value !== "tcp"; }; protocol.addEventListener("change", () => {
|
||||
sync();
|
||||
for (const row of backendList.children) {
|
||||
const mode = row.querySelector('[name="backend-health-mode"]');
|
||||
const mode = get(row, "backend-health-mode");
|
||||
if (mode?.value !== "off") mode.value = "off";
|
||||
}
|
||||
const currentBackends = collectBackends(); backendList.replaceChildren();
|
||||
const currentBackends = collectBackends(); backendList.replaceChildren(); healthList.replaceChildren();
|
||||
currentBackends.forEach(backend => renderBackendEditor(backendList, backend, protocol.value));
|
||||
healthSectionsInOrder(); syncBackendRows();
|
||||
const balance = read("balance"); balance.replaceChildren();
|
||||
for (const [val, key] of [["round_robin", "streamRoundRobin"], [protocol.value === "tcp" ? "least_connections" : "least_sessions", "streamLeastSessions"]]) { const option = text("option", key); option.value = val; balance.append(option); }
|
||||
changed();
|
||||
}); sync();
|
||||
note(g, "streamLimitsHelp");
|
||||
if (show) { activateTab("details"); if (!dialog.open) dialog.showModal(); }
|
||||
$("stream-live-summary").textContent = editing ? t("streamNoLiveMetrics") : "";
|
||||
setStreamLive(editing ? t("streamNoLiveMetrics") : "");
|
||||
if (latestStatus) renderStatus(latestStatus);
|
||||
dirty = false;
|
||||
}
|
||||
@@ -185,15 +248,24 @@
|
||||
};
|
||||
}
|
||||
function suspendDraft() {
|
||||
const state = { editing, revision, label: $("stream-editing").textContent, fields: window.rustProxyDrafts.takeChildren(container), tabs: window.rustProxyDrafts.takeChildren($("stream-tabs")), readListen, backendList };
|
||||
const state = { editing, revision, label: $("stream-editing").textContent, fields: window.rustProxyDrafts.takeChildren(container), tabs: window.rustProxyDrafts.takeChildren($("stream-tabs")), readListen, backendList, healthList };
|
||||
const title = read("id")?.value.trim() || editing || t("draftUntitled"); editing = null; revision = null; dirty = false; dialog.close(); return { title, state };
|
||||
}
|
||||
function restoreDraft(state) {
|
||||
window.rustProxyDrafts.restoreChildren(container, state.fields); window.rustProxyDrafts.restoreChildren($("stream-tabs"), state.tabs); readListen = state.readListen; backendList = state.backendList;
|
||||
window.rustProxyDrafts.restoreChildren(container, state.fields); window.rustProxyDrafts.restoreChildren($("stream-tabs"), state.tabs); readListen = state.readListen; backendList = state.backendList; healthList = state.healthList;
|
||||
editing = state.editing; revision = state.revision; initialized = true; dirty = true; $("stream-editing").textContent = state.label; if (!dialog.open) dialog.showModal(); if (latestStatus) renderStatus(latestStatus);
|
||||
}
|
||||
function closeEditor() { if (dirty) return window.rustProxyDrafts.dock("stream"); if (dialog.open) dialog.close(); return true; }
|
||||
|
||||
// Status JSON from the server is key-sorted; compare structures, not key order.
|
||||
const canonical = value => Array.isArray(value) ? `[${value.map(canonical).join(",")}]` : value && typeof value === "object" ? `{${Object.keys(value).sort().map(key => `${JSON.stringify(key)}:${canonical(value[key])}`).join(",")}}` : JSON.stringify(value ?? null);
|
||||
function liveState(stream, status = latestStatus) {
|
||||
const streamStatus = status?.streams || {}, live = (streamStatus.active || []).find(item => item.id === stream.id);
|
||||
const desired = (streamStatus.desired || []).find(item => item.id === stream.id) || stream;
|
||||
if (stream.enabled === false) return "disabled";
|
||||
if (!live || canonical(live) !== canonical(desired) || canonical(desired) !== canonical({ ...desired, ...stream })) return "pending";
|
||||
return "running";
|
||||
}
|
||||
function render() {
|
||||
if (!envelope) return;
|
||||
if (!initialized) load(defaults(), false);
|
||||
@@ -204,32 +276,40 @@
|
||||
const streams = configured.filter(stream => !query || [stream.id, stream.name, stream.protocol, stream.listen, stream.upstream, ...(stream.backends || []).flatMap(b => [b.id, b.name, b.address])].filter(Boolean).join(" ").toLowerCase().includes(query));
|
||||
const active = new Map((latestStatus?.streams?.active || []).map(item => [item.id, item]));
|
||||
const sortValue = stream => {
|
||||
const live = active.get(stream.id), same = live && JSON.stringify(live) === JSON.stringify(stream);
|
||||
return ({ name: String(stream.name || stream.id || "").toLowerCase(), id: String(stream.id || "").toLowerCase(), protocol: String(stream.protocol || "tcp"), listen: String(stream.listen || "").toLowerCase(), upstream: String(stream.upstream || "").toLowerCase(), status: stream.enabled === false ? 2 : same ? 0 : 1, maxConnections: Number(stream.max_connections || 0), idleTimeout: Number(stream.idle_timeout_seconds || 0) })[listPrefs.sort];
|
||||
const state = liveState(stream);
|
||||
return ({ name: String(stream.name || stream.id || "").toLowerCase(), id: String(stream.id || "").toLowerCase(), protocol: String(stream.protocol || "tcp"), listen: String(stream.listen || "").toLowerCase(), upstream: String(stream.upstream || "").toLowerCase(), status: state === "disabled" ? 2 : state === "running" ? 0 : 1, maxConnections: Number(stream.max_connections || 0), idleTimeout: Number(stream.idle_timeout_seconds || 0) })[listPrefs.sort];
|
||||
};
|
||||
streams.sort((left, right) => { const a = sortValue(left), b = sortValue(right); const result = typeof a === "number" && typeof b === "number" ? a - b : compareText(a, b); return listPrefs.descending ? -result : result; });
|
||||
const cards = streams.map(stream => {
|
||||
const box = el("article", undefined, "vhost-card stream-card"); box.dataset.streamCard = stream.id;
|
||||
const head = el("div", undefined, "vhost-card-head"), identity = el("div", undefined, "vhost-card-identity"), title = el("div", undefined, "vhost-title-line");
|
||||
title.append(el("strong", stream.name || stream.id, "entity-title"), el("span", String(stream.protocol || "tcp").toUpperCase(), "pill live"));
|
||||
if (stream.enabled === false) title.append(el("span", t("vhDisabled"), "pill"));
|
||||
identity.append(title, el("div", stream.id, "vhost-hosts")); head.append(identity);
|
||||
const state = liveState(stream), backends = stream.backends?.length ? stream.backends : [backendDefaults(0, stream.upstream)];
|
||||
const statePill = el("span", t({ disabled: "vhDisabled", pending: "streamPendingRestart", running: "streamRunning" }[state]), `pill${state === "running" ? " live" : state === "pending" ? " warn" : ""}`); statePill.dataset.streamStatePill = stream.id;
|
||||
title.append(el("strong", stream.name || stream.id, "entity-title"), statePill, el("span", String(stream.protocol || "tcp").toUpperCase(), "pill"));
|
||||
const balance = t(stream.balance === "least_connections" || stream.balance === "least_sessions" ? "streamLeastSessions" : "streamRoundRobin");
|
||||
identity.append(title, el("div", `${stream.id} · ${stream.listen || "-"} → ${backends.length} ${t(pluralKey("streamBackendCount", backends.length))} · ${balance}`, "vhost-hosts")); head.append(identity);
|
||||
const actions = el("div", undefined, "entity-actions");
|
||||
actions.append(button("edit", () => { window.rustProxyDrafts.prepare(); load(structuredClone(stream)); }), button("copyEntry", () => { window.rustProxyDrafts.prepare(); const copy = structuredClone(stream); copy.id = ""; copy.name = ""; copy.listen = ""; load(copy); }), button("remove", async () => {
|
||||
if (busy || !(await appConfirm(t("streamDelete"), { danger: true }))) return; const next = structuredClone(envelope.config); next.streams = (next.streams || []).filter(item => item.id !== stream.id); if (await saveSection("streams", next.streams || [])) { if (editing === stream.id) load(); render(); }
|
||||
}));
|
||||
const toggle = button(stream.enabled === false ? "redirectEnable" : "redirectDisable", () => toggleEnabled(stream)); if (stream.enabled !== false) toggle.classList.add("danger-quiet"); actions.prepend(toggle);
|
||||
head.append(actions); box.append(head);
|
||||
|
||||
const details = el("div", undefined, "vhost-detail-strip");
|
||||
for (const [key, value] of [["streamProtocol", String(stream.protocol || "tcp").toUpperCase()], ["streamListen", stream.listen], ["streamUpstream", `${stream.backends?.length ? stream.backends.length + " · " : ""}${stream.upstream}`], ["streamIdleShort", `${stream.idle_timeout_seconds}s`], ["streamMaxConnections", String(stream.max_connections)]]) { const item = el("div", undefined, "vhost-detail"); item.append(text("span", key, "small-label"), el("b", value)); details.append(item); }
|
||||
const checked = backends.filter(backend => backend.health?.mode && backend.health.mode !== "off").length;
|
||||
const healthValue = el("b", checked ? `${t(stream.protocol === "udp" ? "streamChipUdpProbe" : "streamHealthTcp")} · ${checked}/${backends.length}` : t("streamChipNoHealth")); healthValue.dataset.streamHealthSummary = stream.id;
|
||||
const metricsValue = stream.metrics_enabled == null ? t("streamMetricsDefaultOff") : t(stream.metrics_enabled ? "streamMetricsOn" : "streamMetricsOff");
|
||||
const limits = `${stream.max_connections} ${t("streamLimitConnections")} · ${t("streamIdleShort").toLowerCase()} ${stream.idle_timeout_seconds} s${stream.protocol === "tcp" ? ` · ${t("streamConnectShort")} ${stream.connect_timeout_seconds ?? 5} s` : ""}`;
|
||||
for (const [key, value] of [["streamHealthTab", healthValue], ["streamLimitsTab", el("b", limits)], ["streamDetailMetrics", el("b", metricsValue)], ["streamUpstream", el("b", stream.upstream || "-")]]) { const item = el("div", undefined, "vhost-detail"); item.append(text("span", key, "small-label"), value); details.append(item); }
|
||||
box.append(details);
|
||||
const backendBox = el("div", undefined, "stream-backend-status");
|
||||
backendBox.append(text("span", "streamBackendPool", "small-label"));
|
||||
for (const backend of stream.backends?.length ? stream.backends : [backendDefaults(0, stream.upstream)]) {
|
||||
const row = el("div", undefined, "stream-backend-status-row");
|
||||
row.append(el("span", `${backend.name || backend.id} · ${backend.address}`));
|
||||
const health = el("span", t("streamWidgetUnverified"), "pill"); health.dataset.streamBackendStatus = `${stream.id}|${backend.id}`;
|
||||
row.append(health); backendBox.append(row);
|
||||
const backendBox = el("div", undefined, "redirect-rule-table stream-backend-status");
|
||||
for (const [index, backend] of backends.entries()) {
|
||||
const row = el("div", undefined, `redirect-rule-line stream-backend-status-row${backend.enabled === false ? " is-disabled" : ""}`);
|
||||
const dot = el("span", undefined, `loc-state${backend.enabled === false ? " is-off" : " is-unknown"}`); dot.dataset.streamBackendDot = `${stream.id}|${backend.id}`;
|
||||
const health = el("span", t("streamWidgetUnverified"), "fine stream-backend-health-text"); health.dataset.streamBackendStatus = `${stream.id}|${backend.id}`;
|
||||
const extra = [backend.drain ? t("streamChipDrain") : "", backend.max_sessions ? `${t("streamChipMax")} ${backend.max_sessions}` : ""].filter(Boolean).join(" · ");
|
||||
row.append(el("span", String(index + 1), "loc-order"), dot, el("span", backend.name || backend.id, "loc-id"), el("span", backend.address, "redirect-rule-target"), el("span", `${t("streamWeightShort")} ${backend.weight ?? 1}`, "fine"), health, el("span", extra, "fine"));
|
||||
backendBox.append(row);
|
||||
}
|
||||
box.append(backendBox);
|
||||
|
||||
@@ -260,12 +340,16 @@
|
||||
const now = performance.now();
|
||||
for (const desired of envelope?.config.streams || []) {
|
||||
const id = desired.id, live = active.get(id), data = metrics[id];
|
||||
if (currentPanel === "streams") for (const backend of data?.backends || []) {
|
||||
const node = document.querySelector(`[data-stream-backend-status="${CSS.escape(`${id}|${backend.id}`)}"]`);
|
||||
if (node) node.textContent = `${t("streamHealthMode")}: ${t(`streamHealthState_${backend.status}`)} · ${backend.active} ${t("streamActiveSessions")}`;
|
||||
for (const backend of data?.backends || []) {
|
||||
const key = `${id}|${backend.id}`, label = `${t(`streamHealthState_${backend.status}`)}${backend.health?.latency_ms != null ? ` · ${backend.health.latency_ms} ms` : ""} · ${fmt(backend.active)} ${t("streamActiveSessions").toLowerCase()}`;
|
||||
if (currentPanel === "streams") {
|
||||
const node = document.querySelector(`[data-stream-backend-status="${CSS.escape(key)}"]`); if (node) { node.textContent = label; node.title = backend.health?.last_error || ""; }
|
||||
const dot = document.querySelector(`[data-stream-backend-dot="${CSS.escape(key)}"]`); if (dot) { dot.classList.toggle("is-bad", backend.status === "unhealthy"); dot.classList.toggle("is-ok", backend.status === "healthy"); dot.classList.toggle("is-unknown", !["healthy", "unhealthy"].includes(backend.status)); }
|
||||
}
|
||||
if (editing === id && backendList) for (const row of backendList.children) if (row._summary && get(row, "backend-id").value.trim() === backend.id) { row._summary.sumLive.textContent = label; row._summary.sumState.classList.toggle("is-bad", backend.status === "unhealthy"); }
|
||||
}
|
||||
const same = live && JSON.stringify(live) === JSON.stringify(desired);
|
||||
const state = desired.enabled === false ? t("vhDisabled") : !live || !same ? t("streamPendingRestart") : t("streamRunning");
|
||||
const stateKey = liveState(desired, status), state = t({ disabled: "vhDisabled", pending: "streamPendingRestart", running: "streamRunning" }[stateKey]);
|
||||
document.querySelectorAll(`[data-stream-state-pill="${CSS.escape(id)}"]`).forEach(node => { node.textContent = state; node.className = `pill${stateKey === "running" ? " live" : stateKey === "pending" ? " warn" : ""}`; });
|
||||
const set = (suffix, value) => document.querySelectorAll(`[data-${suffix.replace(/[A-Z]/g, c => `-${c.toLowerCase()}`)}="${CSS.escape(id)}"]`).forEach(node => node.textContent = value);
|
||||
set("streamState", state); set("streamActive", data ? fmt(data.active) : "-"); set("streamSessions", data ? fmt(data.sessions_total) : "-"); set("streamErrors", data ? fmt(data.errors) : "-"); set("streamRejected", data ? fmt(data.rejected) : "-"); set("streamTransferred", data ? bytes((Number(data.bytes_in) || 0) + (Number(data.bytes_out) || 0)) : "-");
|
||||
if (!data || currentPanel !== "streams") continue;
|
||||
@@ -283,7 +367,7 @@
|
||||
{ top: 6 / 54, bottom: 50 / 54 });
|
||||
const label = document.querySelector(`[data-stream-chart-value="${CSS.escape(id)}"]`); if (label) label.textContent = pausedRate ? "RX - · TX -" : `RX ${bytes(Math.round(rx))}/s · TX ${bytes(Math.round(tx))}/s`;
|
||||
}
|
||||
if (editing) { const data = metrics[editing]; $("stream-live-summary").textContent = data ? `${t("streamActiveSessions")}: ${fmt(data.active)} · RX ${bytes(data.bytes_in)} · TX ${bytes(data.bytes_out)} · ${t("streamErrors")}: ${fmt(data.errors)}` : t("streamNoLiveMetrics"); }
|
||||
if (editing) { const data = metrics[editing]; setStreamLive(data ? `${t("streamActiveSessions")}: ${fmt(data.active)} · RX ${bytes(data.bytes_in)} · TX ${bytes(data.bytes_out)} · ${t("streamErrors")}: ${fmt(data.errors)}` : t("streamNoLiveMetrics")); }
|
||||
}
|
||||
|
||||
form.addEventListener("input", changed); form.addEventListener("change", changed);
|
||||
|
||||
@@ -40,13 +40,14 @@ window.rustProxyTlsConfigurator = (() => {
|
||||
const root = el("div", undefined, "tls-configurator");
|
||||
(holder || textarea).after(root);
|
||||
const presets = el("div", undefined, "tls-config-presets");
|
||||
const presetButtons = Object.keys(PRESETS).map(id => { const button = el("button", t(`tlsPreset${id[0].toUpperCase()}${id.slice(1)}`), "outline"); button.type = "button"; button.dataset.preset = id; button.title = t(`tlsPreset${id[0].toUpperCase()}${id.slice(1)}Help`); return button; });
|
||||
const custom = el("span", t("tlsPresetCustom"), "pill tls-config-custom");
|
||||
presets.append(el("span", t("tlsPresets"), "small-label"), ...presetButtons, custom);
|
||||
const i18n = (node, key) => { node.dataset.i18n = key; return node; };
|
||||
const presetButtons = Object.keys(PRESETS).map(id => { const key = `tlsPreset${id[0].toUpperCase()}${id.slice(1)}`, button = i18n(el("button", t(key), "outline"), key); button.type = "button"; button.dataset.preset = id; button.title = t(`${key}Help`); button.dataset.i18nTitle = `${key}Help`; return button; });
|
||||
const custom = i18n(el("span", t("tlsPresetCustom"), "pill tls-config-custom"), "tlsPresetCustom");
|
||||
presets.append(i18n(el("span", t("tlsPresets"), "small-label"), "tlsPresets"), ...presetButtons, custom);
|
||||
const layout = el("div", undefined, "tls-config-layout");
|
||||
const tableWrap = el("div", undefined, "tls-config-suites"), side = el("div", undefined, "tls-config-side");
|
||||
layout.append(tableWrap, side);
|
||||
root.append(presets, layout, el("p", t("tlsConfiguratorHelp"), "fine"));
|
||||
root.append(presets, layout, i18n(el("p", t("tlsConfiguratorHelp"), "fine"), "tlsConfiguratorHelp"));
|
||||
const available = () => { const list = latestStatus?.tls?.cipher_suites; return Array.isArray(list) && list.length ? list : FALLBACK; };
|
||||
const selected = () => String(textarea.value || "").split(/[\n,]+/).map(value => value.trim()).filter(Boolean);
|
||||
const effective = () => { const names = available(), chosen = selected(); return (chosen.length ? chosen : names).filter(name => names.includes(name)); };
|
||||
|
||||
@@ -390,8 +390,8 @@ function debugOriginIssues(members) {
|
||||
}
|
||||
function aclEditor(parent, initial, onChange = () => { }) {
|
||||
const enabled = field(parent, "acl-use", "aclUse", !!initial, "checkbox", { switch: true }), body = el("div", undefined, "vh-wide vh-grid"); parent.append(body);
|
||||
const policy = field(body, "acl-default", "aclDefault", initial?.default || "deny", "select", { values: [["deny", "vhDeny"], ["allow", "aclAllow"]] }), rows = el("div", undefined, "vh-wide"); body.append(rows);
|
||||
function add(value = { network: "", action: "allow" }) { const row = el("div", undefined, "acl-rule"); field(row, "network", "aclNetwork", value.network, "text", { maxLength: 254 }); field(row, "action", "aclAction", value.action, "select", { values: [["allow", "aclAllow"], ["deny", "vhDeny"]] }); row.append(button("remove", () => { row.remove(); onChange(); })); rows.append(row); }
|
||||
const policy = field(body, "acl-default", "aclDefault", initial?.default || "deny", "select", { values: [["deny", "aclDeny"], ["allow", "aclAllow"]] }), rows = el("div", undefined, "vh-wide"); body.append(rows);
|
||||
function add(value = { network: "", action: "allow" }) { const row = el("div", undefined, "acl-rule"); field(row, "network", "aclNetwork", value.network, "text", { maxLength: 254 }); field(row, "action", "aclAction", value.action, "select", { values: [["allow", "aclAllow"], ["deny", "aclDeny"]] }); row.append(button("remove", () => { row.remove(); onChange(); })); rows.append(row); }
|
||||
body.append(button("aclAdd", () => { add(); onChange(); })); for (const rule of initial?.rules || []) add(rule);
|
||||
const sync = () => { body.hidden = !enabled.checked; onChange(); }; enabled.addEventListener("change", sync); body.addEventListener("input", onChange); body.addEventListener("change", onChange); body.hidden = !enabled.checked;
|
||||
note(parent, "aclHelp"); return {
|
||||
|
||||
@@ -258,7 +258,8 @@ function load(value = defaults(), migrationIds = [], show = true) {
|
||||
field(keepaliveFields, "pool-recycle-seconds", "vhPoolRecycleSeconds", keepalive.pool_recycle_seconds ?? 3600, "number", { required: true, min: 0, max: 604800 });
|
||||
field(keepaliveFields, "http1-max-buffer", "vhHttp1MaxBuffer", keepalive.http1_max_buffer_bytes ?? 131072, "number", { required: true, min: 8192, max: 1048576 });
|
||||
note(keepaliveFields, "vhPoolRecycleHelp");
|
||||
g = group("vhHealth"); const healthMode = field(g, "health-mode", "vhHealthMode", health.mode || "tcp", "select", { values: [["off", "vhOff"], ["tcp", "vhTcp"], ["http", "vhHttp"]] });
|
||||
g = group("vhHealth"); { const live = el("p", $("vhost-health-live")?.textContent || "", "vh-live-summary vh-live-summary-tab vh-wide"); live.id = "vhost-health-live-tab"; live.hidden = $("vhost-health-live")?.hidden === true; g.append(live); }
|
||||
const healthMode = field(g, "health-mode", "vhHealthMode", health.mode || "tcp", "select", { values: [["off", "vhOff"], ["tcp", "vhTcp"], ["http", "vhHttp"]] });
|
||||
const healthOffWarning = note(g, "vhHealthOffWarning"); const syncHealthWarning = () => { healthOffWarning.hidden = healthMode.value !== "off"; }; healthMode.addEventListener("change", syncHealthWarning); syncHealthWarning();
|
||||
field(g, "health-path", "vhHealthPath", health.path || "/", "text", { required: true, maxLength: 1024 });
|
||||
field(g, "health-host", "vhHealthHost", health.host || "", "text", { maxLength: 260 });
|
||||
@@ -586,7 +587,7 @@ function load(value = defaults(), migrationIds = [], show = true) {
|
||||
vhostHeadersControl = headerEditors(g, value.headers || {}, headersJson.target, () => { changed(); headersJson.refresh(); });
|
||||
g.append(headersJson.node);
|
||||
g = group("policyTitle"); vhostPolicyEditor = window.rustProxyPolicy.create({ value: value.policy || {}, scope: "vhost", onChange: changed }); g.append(vhostPolicyEditor.node);
|
||||
g = group("vhPages"); g.classList.add("vh-pages-grid"); pagesEditor = window.rustProxyPages.vhostEditor(g, value.pages || {});
|
||||
g = group("vhPages"); g.classList.add("vh-pages-grid"); pagesEditor = window.rustProxyPages.vhostEditor(g, value.pages || {}, { vhostId: value.id || "" });
|
||||
initTabs(); dirty = false; if (latestStatus) renderStatus(latestStatus); if (show && !dialog.open) dialog.showModal();
|
||||
headersPreviewControl?.refresh(); presetsRefresh();
|
||||
|
||||
|
||||
@@ -581,7 +581,7 @@ function applyBackendOverviewView() {
|
||||
const cell = el("td"); cell.dataset.boColumn = id;
|
||||
if (id === "toggle") {
|
||||
const button = el("button", undefined, "bo-expand"); button.type = "button"; button.dataset.uiIconName = "none"; button.dataset.boKey = item.key;
|
||||
button.setAttribute("aria-expanded", String(open)); button.setAttribute("aria-label", t("backendDetailsToggle")); button.title = t("backendDetailsToggle");
|
||||
button.setAttribute("aria-expanded", String(open)); button.setAttribute("aria-label", t("backendDetailsToggle")); button.title = t("backendDetailsToggle"); button.dataset.i18nAria = "backendDetailsToggle"; button.dataset.i18nTitle = "backendDetailsToggle";
|
||||
button.addEventListener("click", () => { if (boOpen.has(item.key)) boOpen.delete(item.key); else boOpen.add(item.key); applyBackendOverviewView(); });
|
||||
cell.append(button);
|
||||
} else if (id === "identity") {
|
||||
@@ -996,6 +996,8 @@ function renderStatus(status) {
|
||||
const editingHasProxy = editingVhost && vhostRequiresProxy(editingVhost);
|
||||
$("vhost-health-live").hidden = !!editingVhost && !editingHasProxy;
|
||||
$("vhost-health-live").textContent = editing ? (editingHasProxy ? (summaries.get(editing) || t("vhHealthEmpty")) : "") : t("vhNewHealthHint");
|
||||
// The live line is shown inside the Backend health tab, not between the title and the tabs.
|
||||
const liveTab = $("vhost-health-live-tab"); if (liveTab) { liveTab.hidden = $("vhost-health-live").hidden; liveTab.textContent = $("vhost-health-live").textContent; }
|
||||
}
|
||||
form.addEventListener("input", changed); form.addEventListener("change", changed);
|
||||
form.addEventListener("submit", async event => {
|
||||
|
||||
@@ -45,8 +45,13 @@ window.rustProxyPhpProfiles = ({ defaults, mapLines, lines, parseFastCgiParams,
|
||||
if (creating) details.open = true;
|
||||
const summary = el("summary", undefined, "fastcgi-profile-summary");
|
||||
const title = el("span", profile.name || profile.id || t("phpProfileNew"), "fastcgi-profile-title");
|
||||
const kindBadge = el("span", "", "fastcgi-profile-handler");
|
||||
summary.append(title, kindBadge);
|
||||
const kindBadge = el("span", "", "fastcgi-profile-handler pill warn");
|
||||
const usedBy = creating ? [] : (envelope?.config.web_services || []).filter(service => service.php_profile_id === profile.id).map(service => service.id);
|
||||
const usage = el("span", usedBy.length ? t("phpProfileUsedCount").replace("{count}", String(usedBy.length)) : t("webServiceUnused"), usedBy.length ? "pill live" : "pill");
|
||||
usage.title = usedBy.join(", ");
|
||||
const endpointText = el("span", profile.php?.endpoint || "", "fastcgi-profile-endpoint");
|
||||
details.dataset.profileId = profile.id || "";
|
||||
summary.append(title, kindBadge, ...(creating ? [] : [usage]), endpointText);
|
||||
const editor = document.createElement("form"); editor.className = "vh-grid fastcgi-profile-editor"; editor.noValidate = true;
|
||||
const namedInput = (key, value, readonly = false) => {
|
||||
const wrapper = el("label", undefined, "fastcgi-profile-identity");
|
||||
@@ -60,17 +65,19 @@ window.rustProxyPhpProfiles = ({ defaults, mapLines, lines, parseFastCgiParams,
|
||||
elements: [nameInput],
|
||||
taken: () => (envelope?.config.php_fpm_profiles || []).map(item => item.id)
|
||||
});
|
||||
if (creating && nameInput.value) nameInput.dispatchEvent(new Event("input"));
|
||||
idInput.closest("label").append(el("small", t("phpProfileIdHelp"), "fine fastcgi-profile-identity-help"));
|
||||
nameInput.closest("label").append(el("small", t("phpProfileNameHelp"), "fine fastcgi-profile-identity-help"));
|
||||
const controls = {};
|
||||
const phpOnlyWrappers = [];
|
||||
let phpOnlySection;
|
||||
// Same section blocks as the Web Service editor.
|
||||
const section = key => { const box = el("section", undefined, "vh-wide vh-setting-section fastcgi-profile-section"), heading = el("h3", t(key)), grid = el("div", undefined, "vh-grid"); heading.dataset.i18n = key; box.append(heading, grid); editor.append(box); return { box, grid }; };
|
||||
const identitySection = section("phpProfileSectionConnection");
|
||||
for (const input of [nameInput, idInput]) identitySection.grid.append(input.closest("label"));
|
||||
const sections = { connection: identitySection, limits: section("webServicePhpLimitsSection"), params: section("webServicePhpCustomParams"), php: section("phpProfilePhpOnlySection") };
|
||||
const sectionOf = key => ["connect_timeout_ms", "request_timeout_ms", "max_concurrent_requests", "max_request_body_bytes", "max_response_header_bytes", "stderr_log_bytes"].includes(key) ? "limits" : key === "custom_params" ? "params" : ["php_values", "php_admin_values"].includes(key) ? "php" : "connection";
|
||||
const phpOnlySection = sections.php.box;
|
||||
for (const [key, label, kind, min, max] of profileFields) {
|
||||
if (key === "php_values") {
|
||||
phpOnlySection = el("div", undefined, "vh-wide fastcgi-profile-php-heading");
|
||||
phpOnlySection.append(el("strong", t("phpProfilePhpOnlySection")));
|
||||
editor.append(phpOnlySection);
|
||||
}
|
||||
const toggle = kind === "checkbox";
|
||||
const wrapper = toggle ? el("div", undefined, "php-switch-row vh-wide") : el("label");
|
||||
if (!toggle && kind === "textarea") wrapper.className = "vh-wide";
|
||||
@@ -111,7 +118,7 @@ window.rustProxyPhpProfiles = ({ defaults, mapLines, lines, parseFastCgiParams,
|
||||
const hint = el("small", t(helpKeys[key]), "fine");
|
||||
labelEl.append(hint);
|
||||
}
|
||||
editor.append(wrapper); controls[key] = input;
|
||||
sections[sectionOf(key)].grid.append(wrapper); controls[key] = input;
|
||||
}
|
||||
const handlerSelector = controls.handler;
|
||||
const syncHandler = () => {
|
||||
@@ -123,6 +130,7 @@ window.rustProxyPhpProfiles = ({ defaults, mapLines, lines, parseFastCgiParams,
|
||||
phpOnlySection.hidden = !phpFpm;
|
||||
controls.php_values.disabled = !phpFpm;
|
||||
controls.php_admin_values.disabled = !phpFpm;
|
||||
endpointText.textContent = controls.endpoint.value;
|
||||
controls.endpoint.placeholder = kind === "fcgiwrap" ? "unix:/run/fcgiwrap.socket" : kind === "fastcgi" ? "tcp:127.0.0.1:9001" : "unix:/run/php/php-fpm.sock";
|
||||
controls.extensions.placeholder = kind === "fcgiwrap" ? "cgi, pl" : kind === "fastcgi" ? "fcgi" : "php, phtml";
|
||||
};
|
||||
@@ -146,6 +154,12 @@ window.rustProxyPhpProfiles = ({ defaults, mapLines, lines, parseFastCgiParams,
|
||||
const save = el("button", t("apply"), "primary"); save.type = "submit";
|
||||
actions.append(save);
|
||||
if (!creating) {
|
||||
const copy = el("button", t("copyEntry"), "quiet"); copy.type = "button";
|
||||
copy.addEventListener("click", () => {
|
||||
const clone = structuredClone(profile); clone.id = ""; clone.name = `${profile.name || profile.id} (${t("copySuffix")})`;
|
||||
const node = profileEditor(clone, true); $("php-fpm-profiles-list").prepend(node); node.scrollIntoView({ block: "nearest" }); node.querySelector("input")?.focus();
|
||||
});
|
||||
actions.append(copy);
|
||||
const remove = el("button", t("remove"), "quiet"); remove.type = "button";
|
||||
remove.addEventListener("click", async () => {
|
||||
const used = (envelope?.config.web_services || []).filter(service => service.php_profile_id === profile.id).map(service => service.id);
|
||||
@@ -192,9 +206,11 @@ window.rustProxyPhpProfiles = ({ defaults, mapLines, lines, parseFastCgiParams,
|
||||
if (addNew) list.unshift(profileEditor({ id: "", name: "", php: defaults().php }, true));
|
||||
$("php-fpm-profiles-list").replaceChildren(...list);
|
||||
}
|
||||
function openProfiles() {
|
||||
function openProfiles(focusId = "") {
|
||||
renderProfiles();
|
||||
$("php-fpm-profiles-dialog").showModal();
|
||||
const target = focusId ? [...$("php-fpm-profiles-list").children].find(node => node.dataset.profileId === focusId) : null;
|
||||
if (target) { target.open = true; target.scrollIntoView({ block: "nearest" }); }
|
||||
}
|
||||
|
||||
return { renderProfiles, openProfiles, refreshProfileSelect };
|
||||
|
||||
+90
-22
@@ -121,11 +121,11 @@
|
||||
const tabDefinitions = [
|
||||
["general", "webServiceTabGeneral"],
|
||||
["routing", "webServiceTabRouting"],
|
||||
["php", "webServiceTabPhp"],
|
||||
["htaccess", "webServiceTabHtaccess"],
|
||||
["mime", "webServiceTabMime"],
|
||||
["cache", "webServiceTabCacheHeaders"],
|
||||
["delivery", "webServiceTabDelivery"],
|
||||
["php", "webServiceTabPhp"],
|
||||
["mime", "webServiceTabMime"],
|
||||
["security", "webServiceTabSecurity"],
|
||||
];
|
||||
|
||||
@@ -167,6 +167,67 @@
|
||||
defaults, mapLines, lines, parseFastCgiParams, parsePhpValues, validatePhpCustomData
|
||||
});
|
||||
|
||||
// Radio cards (same look as the Vhost www choice) that drive the existing
|
||||
// selects, so saving and drafts keep using the original controls.
|
||||
function choiceCard(group, value, titleKey, helpKey) {
|
||||
const label = el("label", undefined, "vh-www-choice"), input = document.createElement("input"), copy = el("span", undefined, "vh-www-choice-copy");
|
||||
input.type = "radio"; input.name = group; input.value = value;
|
||||
const title = el("strong", t(titleKey)); title.dataset.i18n = titleKey; const help = el("span", t(helpKey), "fine"); help.dataset.i18n = helpKey;
|
||||
copy.append(title, help); label.append(input, copy); return label;
|
||||
}
|
||||
const PHP_APPS = ["php_generic", "wordpress", "drupal", "laravel", "symfony", "joomla", "prestashop"];
|
||||
const kindOf = preset => PHP_APPS.includes(preset) ? "php" : ["static", "spa", "downloads"].includes(preset) ? preset : "custom";
|
||||
const kindChoices = [["static", "webServiceKindStatic", "webServiceKindStaticHelp"], ["spa", "webServicePresetSpa", "webServiceKindSpaHelp"], ["php", "webServiceKindPhp", "webServiceKindPhpHelp"], ["downloads", "webServicePresetDownloads", "webServiceKindDownloadsHelp"], ["custom", "webServicePresetCustom", "webServiceKindCustomHelp"]];
|
||||
$("web-service-kinds").replaceChildren(...kindChoices.map(([value, titleKey, helpKey]) => choiceCard("web-service-kind", value, titleKey, helpKey)));
|
||||
const phpApp = el("select", undefined, "web-service-php-app"); phpApp.setAttribute("aria-label", "PHP");
|
||||
for (const value of PHP_APPS) { const source = $("web-service-preset").querySelector(`option[value="${value}"]`); const option = el("option", source?.textContent.trim() || value); option.value = value; if (source?.dataset.i18n) option.dataset.i18n = source.dataset.i18n; phpApp.append(option); }
|
||||
$("web-service-kinds").querySelector('input[value="php"]').closest("label").querySelector(".vh-www-choice-copy").append(phpApp);
|
||||
function syncKinds() {
|
||||
const preset = $("web-service-preset").value, kind = kindOf(preset);
|
||||
for (const input of document.querySelectorAll('#web-service-kinds input[name="web-service-kind"]')) { input.checked = input.value === kind; input.closest("label").classList.toggle("is-selected", input.checked); }
|
||||
if (PHP_APPS.includes(preset)) phpApp.value = preset;
|
||||
}
|
||||
function kindChanged(value) {
|
||||
$("web-service-preset").value = value === "php" ? phpApp.value : value;
|
||||
syncKinds(); presetChanged();
|
||||
}
|
||||
$("web-service-kinds").addEventListener("change", event => {
|
||||
if (event.target === phpApp) { if (document.querySelector('#web-service-kinds input[value="php"]').checked) kindChanged("php"); return; }
|
||||
if (event.target.name === "web-service-kind") kindChanged(event.target.value);
|
||||
});
|
||||
$("web-service-preset-field").hidden = true;
|
||||
|
||||
const phpSources = $("web-service-php-sources");
|
||||
phpSources.replaceChildren(choiceCard("web-service-php-source", "profile", "phpSourceProfile", "phpSourceProfileHelp"), choiceCard("web-service-php-source", "local", "phpSourceLocal", "phpSourceLocalHelp"));
|
||||
const phpLocalOnly = () => [
|
||||
$("web-service-php-enabled").closest(".php-switch-row"), $("web-service-php-handler").closest("label"), $("web-service-php-script-prefix").closest("label"),
|
||||
$("web-service-php-endpoint").closest("label"), $("web-service-php-extensions").closest("label"),
|
||||
...[...document.querySelectorAll('[data-web-service-page="php"] > section')].slice(1)
|
||||
];
|
||||
function syncPhpSource() {
|
||||
const select = $("web-service-php-profile"), attached = !!select.value, profiles = envelope?.config.php_fpm_profiles || [];
|
||||
const profileChoice = phpSources.querySelector('input[value="profile"]');
|
||||
profileChoice.disabled = !profiles.length && !attached; profileChoice.closest("label").classList.toggle("is-disabled", profileChoice.disabled);
|
||||
for (const input of phpSources.querySelectorAll("input")) { input.checked = input.value === (attached ? "profile" : "local"); input.closest("label").classList.toggle("is-selected", input.checked); }
|
||||
$("web-service-php-profile-field").hidden = !attached;
|
||||
for (const node of phpLocalOnly()) if (node) node.hidden = attached;
|
||||
const profile = attached ? profiles.find(item => item.id === select.value) : null, summary = $("web-service-php-profile-summary");
|
||||
summary.hidden = !profile; $("web-service-php-profile-edit").hidden = !profile;
|
||||
if (profile) {
|
||||
const php = profile.php || {}, handler = { php_fpm: "PHP-FPM", fcgiwrap: "fcgiwrap", fastcgi: "FastCGI" }[php.handler || "php_fpm"] || "FastCGI";
|
||||
const items = [["webServiceFastCgiHandler", php.enabled ? handler : `${handler} · ${t("notEnabled")}`], ["webServicePhpEndpoint", php.endpoint || "-"], ["webServicePhpExtensions", (php.extensions || []).join(", ") || "-"],
|
||||
["webServicePhpLimitsSection", `${php.connect_timeout_ms ?? 1000} / ${php.request_timeout_ms ?? 30000} ms · ${php.max_concurrent_requests ?? 64}`], ["webServiceUsedBy", (envelope?.config.web_services || []).filter(item => item.php_profile_id === profile.id).map(item => item.id).join(", ") || "-"]];
|
||||
summary.replaceChildren(...items.map(([key, value]) => { const item = el("div", undefined, "vhost-detail"); item.append(el("span", t(key), "small-label"), el("b", value)); return item; }));
|
||||
}
|
||||
}
|
||||
phpSources.addEventListener("change", event => {
|
||||
if (event.target.name !== "web-service-php-source") return;
|
||||
const select = $("web-service-php-profile");
|
||||
if (event.target.value === "local") select.value = "";
|
||||
else if (!select.value) select.value = (envelope?.config.php_fpm_profiles || [])[0]?.id || "";
|
||||
dirty = true; syncPhp();
|
||||
});
|
||||
|
||||
function syncPhp() {
|
||||
const attached = !!$("web-service-php-profile").value;
|
||||
const enabled = $("web-service-php-enabled").checked;
|
||||
@@ -187,6 +248,7 @@
|
||||
"web-service-php-body-limit", "web-service-php-header-limit", "web-service-php-stderr-limit",
|
||||
"web-service-php-custom-params"
|
||||
]) $(id).disabled = !enabled || attached;
|
||||
syncPhpSource();
|
||||
}
|
||||
|
||||
function syncCompression() {
|
||||
@@ -334,7 +396,7 @@
|
||||
}
|
||||
|
||||
function presetChanged() {
|
||||
updatePresetSummary();
|
||||
updatePresetSummary(); syncKinds();
|
||||
if ($("web-service-preset").value !== "custom") applyPreset();
|
||||
}
|
||||
|
||||
@@ -353,7 +415,7 @@
|
||||
$("web-service-root").value = item.document_root || "";
|
||||
populateSettings(item);
|
||||
$("web-service-preset").value = "custom";
|
||||
updatePresetSummary();
|
||||
updatePresetSummary(); syncKinds();
|
||||
$("web-service-editing").textContent = t(editing ? "vhEditLabel" : "vhNewLabel");
|
||||
activateTab("general"); dirty = false;
|
||||
dialog.showModal();
|
||||
@@ -370,7 +432,7 @@
|
||||
const saved = state.editing ? (envelope?.config.web_services || []).find(item => item.id === state.editing) : null;
|
||||
open(saved ? structuredClone(saved) : (state.editing ? { id: state.editing } : null));
|
||||
window.rustProxyDrafts.restoreControls(form, state.controls); editing = state.editing; $("web-service-editing").textContent = state.label;
|
||||
syncPhp(); syncPrecompressed(); syncHtaccess(); syncRootPermissions(); updatePresetSummary(); activateTab(state.activeTab || "general"); dirty = true;
|
||||
syncPhp(); syncPrecompressed(); syncHtaccess(); syncRootPermissions(); updatePresetSummary(); syncKinds(); activateTab(state.activeTab || "general"); dirty = true;
|
||||
}
|
||||
function closeEditor() { if (dirty) return window.rustProxyDrafts.dock("web-server"); clearEditor(); return true; }
|
||||
|
||||
@@ -396,11 +458,15 @@
|
||||
const cards = services.map(service => {
|
||||
const box = el("article", undefined, "vhost-card");
|
||||
const head = el("div", undefined, "vhost-card-head"), identity = el("div", undefined, "vhost-card-identity");
|
||||
const title = el("div", undefined, "vhost-title-line");
|
||||
title.append(el("strong", service.name || service.id, "entity-title"), el("span", t("webServer"), "pill live"));
|
||||
identity.append(title, el("div", service.document_root, "vhost-hosts"));
|
||||
const title = el("div", undefined, "vhost-title-line"), used = usage(service.id);
|
||||
const profile = service.php_profile_id ? (envelope.config.php_fpm_profiles || []).find(item => item.id === service.php_profile_id) : null;
|
||||
const php = profile ? profile.php : service.php, handler = { php_fpm: "PHP-FPM", fcgiwrap: "fcgiwrap", fastcgi: "FastCGI" }[php?.handler || "php_fpm"] || "FastCGI";
|
||||
const kind = php?.enabled ? (profile ? `${handler}: ${profile.name || profile.id}` : handler) : t("webServiceKindStatic");
|
||||
title.append(el("strong", service.name || service.id, "entity-title"), el("span", t(used.length ? "webServiceUsed" : "webServiceUnused"), used.length ? "pill live" : "pill"), el("span", kind, php?.enabled ? "pill warn" : "pill"));
|
||||
identity.append(title, el("div", `${service.id} · ${service.document_root}`, "vhost-hosts"));
|
||||
const actions = el("div", undefined, "entity-actions");
|
||||
const edit = el("button", t("edit"), "quiet"); edit.type = "button"; edit.addEventListener("click", () => { window.rustProxyDrafts.prepare(); open(structuredClone(service)); });
|
||||
const copy = el("button", t("copyEntry"), "quiet"); copy.type = "button"; copy.addEventListener("click", () => { window.rustProxyDrafts.prepare(); const clone = structuredClone(service); clone.id = ""; clone.name = `${service.name || service.id} (${t("copySuffix")})`; open(clone); $("web-service-name").dispatchEvent(new Event("input", { bubbles: true })); });
|
||||
const remove = el("button", t("remove"), "quiet"); remove.type = "button"; remove.addEventListener("click", async () => {
|
||||
const used = usage(service.id);
|
||||
if (used.length) { toast(`${t("webServiceInUse")}: ${used.join(", ")}`, true); return; }
|
||||
@@ -408,20 +474,20 @@
|
||||
const next = (envelope.config.web_services || []).filter(item => item.id !== service.id);
|
||||
if (await saveSection("web-services", next)) render();
|
||||
});
|
||||
actions.append(edit, remove); head.append(identity, actions); box.append(head);
|
||||
actions.append(edit, copy, remove); head.append(identity, actions); box.append(head);
|
||||
const details = el("div", undefined, "vhost-detail-strip");
|
||||
// One cell per area; "-" means the default for that area.
|
||||
const join = parts => parts.filter(Boolean).join(" · ") || "-";
|
||||
const tryFiles = service.try_files || [];
|
||||
const warningsCount = htaccessWarningsRevision === envelope.revision ? (htaccessWarnings[service.id]?.warnings || []).length : 0;
|
||||
const detailItems = [
|
||||
["webServiceId", service.id],
|
||||
["webServiceIndex", (service.index || []).join(", ") || t("webServiceNoIndex")],
|
||||
["webServiceDirectoryListing", t(service.directory_listing ? "enabled" : "notEnabled")],
|
||||
["webServiceTryFiles", (service.try_files || []).length ? String(service.try_files.length) : "-"],
|
||||
["webServiceHtaccessEnabled", t(service.htaccess?.enabled ? "enabled" : "notEnabled")],
|
||||
["webServicePhpEnabled", service.php_profile_id ? `${service.php_profile_id} (${t("phpProfileShared")})` : t(service.php?.enabled ? "enabled" : "notEnabled")],
|
||||
["webServiceCompression", service.compression?.enabled === true ? t("enabled") : service.compression?.enabled === false ? t("notEnabled") : t("inherit")],
|
||||
["webServicePrecompressed", t(service.precompressed?.enabled ? "enabled" : "notEnabled")],
|
||||
["webServiceHardeningTitle", t((service.hardening?.block_common_attacks || service.hardening?.strip_unnecessary_headers) ? "enabled" : "notEnabled")],
|
||||
["webServiceCacheControl", service.cache_control || t("inherit")],
|
||||
["webServiceUsedBy", usage(service.id).length ? usage(service.id).join(", ") : t("webServiceUnused")],
|
||||
["webServiceCardFastCgi", php?.enabled ? join([php.endpoint, (php.extensions || []).join(", ")]) : "-"],
|
||||
["webServiceCardIndex", join([(service.index || []).join(", ") || t("webServiceNoIndex"), tryFiles.length ? `try_files → ${tryFiles[tryFiles.length - 1]}` : "", service.directory_listing ? t("webServiceDirectoryListing") : ""])],
|
||||
["webServiceTabHtaccess", service.htaccess?.enabled ? join([t("enabled"), warningsCount ? `${warningsCount} ${t("webServiceCardWarnings")}` : ""]) : "-"],
|
||||
["webServiceCardDelivery", join([service.compression?.enabled === true ? `${t("webServiceCompression")}: ${t("enabled")}` : service.compression?.enabled === false ? `${t("webServiceCompression")}: ${t("notEnabled")}` : "", service.precompressed?.enabled ? t("webServiceCardPrecompressed") : "", service.sendfile === "auto" ? "sendfile" : ""])],
|
||||
["webServiceCacheControl", join([service.cache_control || "", (service.cache_rules || []).length ? `${service.cache_rules.length} ${t("webServiceCardRules")}` : ""])],
|
||||
["webServiceHardeningTitle", join([service.hardening?.block_common_attacks ? t("webServiceCardAttacks") : "", service.hardening?.strip_unnecessary_headers ? t("webServiceCardHeaders") : "", service.symlink_policy && service.symlink_policy !== "deny" ? "symlinks" : ""])],
|
||||
["webServiceUsedBy", used.length ? used.join(", ") : t("webServiceUnused")],
|
||||
];
|
||||
for (const [key, value] of detailItems) {
|
||||
const item = el("div", undefined, "vhost-detail");
|
||||
@@ -605,9 +671,11 @@
|
||||
syncPhp();
|
||||
});
|
||||
$("web-service-php-profile").addEventListener("change", syncPhp);
|
||||
$("web-service-php-profiles").addEventListener("click", openProfiles);
|
||||
$("web-service-php-profiles-open").addEventListener("click", openProfiles);
|
||||
$("web-service-php-profiles").addEventListener("click", () => openProfiles());
|
||||
$("web-service-php-profile-edit").addEventListener("click", () => openProfiles($("web-service-php-profile").value));
|
||||
$("web-service-php-profiles-open").addEventListener("click", () => openProfiles());
|
||||
$("php-fpm-profiles-close").addEventListener("click", () => $("php-fpm-profiles-dialog").close());
|
||||
$("php-fpm-profiles-dialog").addEventListener("close", () => { if (dialog.open) syncPhp(); });
|
||||
$("php-fpm-profile-add").addEventListener("click", () => renderProfiles(true));
|
||||
$("php-fpm-profiles-help").addEventListener("click", () => $("php-help-dialog").showModal());
|
||||
$("web-service-compression").addEventListener("change", syncCompression);
|
||||
|
||||
Reference in new issue
Block a user