v0.38.1
This commit is contained in:
1 parent
faedd249b8
commit
758cfd6274
25 files changed
+973
-39
No files matched your search
@@ -2,7 +2,7 @@
|
||||
"openapi": "3.0.3",
|
||||
"info": {
|
||||
"title": "RustProxy Administration API",
|
||||
"version": "0.38.0",
|
||||
"version": "0.38.1",
|
||||
"description": "Administration API for the active panel origin. Sign in through the panel; the same-origin HttpOnly cookie authenticates all private operations. Mutations also require the exact Origin, X-RustProxy-Request: 1 and a session-bound X-CSRF-Token. Loopback HTTP is the default; Settings can enable HTTPS before using a non-loopback administration bind. This document contains no live configuration or credentials. Object schemas marked extensible are summaries: full configuration validation is authoritative in Rust. The API also permits explicitly scoped GeneralApiBearer tokens on a narrow route allowlist, with RO/RW and source CIDR checks; API-token management and Prometheus-token management are browser-session-only."
|
||||
},
|
||||
"servers": [
|
||||
|
||||
@@ -430,3 +430,66 @@ fn docker_widget_agents_accept_only_docker_cards_and_valid_ids() {
|
||||
.insert("docker_apps".into(), "bad id!".into());
|
||||
assert!(validate_admin_preferences(&prefs).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn builtin_dashboard_presets_are_valid_layouts_with_translations() {
|
||||
#[derive(serde::Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct BuiltinPreset {
|
||||
id: String,
|
||||
form: String,
|
||||
name_key: String,
|
||||
description_key: String,
|
||||
dashboard_density: String,
|
||||
overview_samples: u16,
|
||||
widgets: Vec<(String, u8)>,
|
||||
}
|
||||
let presets: Vec<BuiltinPreset> =
|
||||
serde_json::from_str(include_str!("web/dashboard-builtin-presets.json")).unwrap();
|
||||
assert!(presets.len() >= 10);
|
||||
assert!(presets.iter().any(|preset| preset.form == "mobile"));
|
||||
let mut ids = std::collections::HashSet::new();
|
||||
let languages: Vec<serde_json::Value> = [
|
||||
include_str!("../../langs/en_US.json"),
|
||||
include_str!("../../langs/pl_pl.json"),
|
||||
]
|
||||
.into_iter()
|
||||
.map(|pack| serde_json::from_str(pack).unwrap())
|
||||
.collect();
|
||||
for preset in &presets {
|
||||
assert!(ids.insert(preset.id.as_str()), "{}", preset.id);
|
||||
assert!(matches!(preset.form.as_str(), "desktop" | "mobile"));
|
||||
for language in &languages {
|
||||
for key in [&preset.name_key, &preset.description_key] {
|
||||
assert!(
|
||||
language["translations"][key.as_str()].is_string(),
|
||||
"{} missing translation {key}",
|
||||
preset.id
|
||||
);
|
||||
}
|
||||
}
|
||||
let visible: Vec<String> = preset.widgets.iter().map(|(id, _)| id.clone()).collect();
|
||||
let unique: std::collections::HashSet<&String> = visible.iter().collect();
|
||||
assert_eq!(unique.len(), visible.len(), "{}", preset.id);
|
||||
let hidden: Vec<String> = DASHBOARD_WIDGETS
|
||||
.iter()
|
||||
.map(|widget| widget.id.clone())
|
||||
.filter(|id| !visible.contains(id))
|
||||
.collect();
|
||||
let mut order = visible.clone();
|
||||
order.extend(hidden.iter().cloned());
|
||||
let layout = DashboardPresetLayout {
|
||||
dashboard_widgets: order,
|
||||
dashboard_hidden_widgets: hidden,
|
||||
dashboard_widget_sizes: Some(preset.widgets.iter().cloned().collect()),
|
||||
dashboard_widget_heights: None,
|
||||
dashboard_density: preset.dashboard_density.clone(),
|
||||
overview_samples: preset.overview_samples,
|
||||
};
|
||||
assert!(
|
||||
validate_dashboard_preset_layout(&layout).is_ok(),
|
||||
"invalid built-in preset {}",
|
||||
preset.id
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -70,6 +70,9 @@ fn admin_app_javascript() -> &'static str {
|
||||
include_str!("web/dashboard-widgets.json"),
|
||||
");",
|
||||
include_str!("web/app/preferences.js"),
|
||||
"const ADMIN_DASHBOARD_BUILTIN_PRESETS = Object.freeze(",
|
||||
include_str!("web/dashboard-builtin-presets.json"),
|
||||
");",
|
||||
include_str!("web/app/dashboard-presets.js"),
|
||||
include_str!("web/app/dashboard-inline-layout.js"),
|
||||
include_str!("web/app/stream-dashboard.js"),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
window.rustProxyDashboardLayout = (() => {
|
||||
const dialog = $("overview-presets-dialog");
|
||||
const list = $("overview-presets-list");
|
||||
const builtinList = $("overview-presets-builtin");
|
||||
const input = $("overview-presets-name");
|
||||
const message = $("overview-presets-message");
|
||||
const save = $("overview-presets-save");
|
||||
@@ -30,7 +31,7 @@ window.rustProxyDashboardLayout = (() => {
|
||||
}
|
||||
function lock(value) {
|
||||
busy = value;
|
||||
for (const control of [save, factory, close, input, ...list.querySelectorAll("button")])
|
||||
for (const control of [save, factory, close, input, ...list.querySelectorAll("button"), ...(builtinList?.querySelectorAll("button") || [])])
|
||||
if (control) control.disabled = value;
|
||||
}
|
||||
async function run(fn) {
|
||||
@@ -58,7 +59,49 @@ window.rustProxyDashboardLayout = (() => {
|
||||
button.addEventListener("click", () => void run(fn));
|
||||
return button;
|
||||
}
|
||||
function builtinLayout(preset) {
|
||||
const visible = preset.widgets.map(([id]) => id).filter(id => ADMIN_DASHBOARD_BY_ID.has(id));
|
||||
const sizes = {};
|
||||
for (const [id, span] of preset.widgets) if (ADMIN_DASHBOARD_BY_ID.has(id)) sizes[id] = span;
|
||||
return {
|
||||
dashboard_widgets: normalizeDashboardWidgets(visible),
|
||||
dashboard_hidden_widgets: ADMIN_DASHBOARD_WIDGETS.filter(id => !visible.includes(id)),
|
||||
dashboard_widget_sizes: sizes,
|
||||
dashboard_widget_heights: null,
|
||||
dashboard_widget_positions: null,
|
||||
dashboard_auto_fit: true,
|
||||
dashboard_density: preset.dashboard_density,
|
||||
overview_samples: preset.overview_samples,
|
||||
};
|
||||
}
|
||||
function renderBuiltin() {
|
||||
if (!builtinList) return;
|
||||
const groups = [["desktop", "dashboardBuiltinDesktop"], ["mobile", "dashboardBuiltinMobile"]].map(([form, key]) => {
|
||||
const items = ADMIN_DASHBOARD_BUILTIN_PRESETS.filter(preset => preset.form === form);
|
||||
if (!items.length) return null;
|
||||
const group = el("div", undefined, "overview-presets-builtin-group");
|
||||
group.append(el("h3", t(key)));
|
||||
for (const preset of items) {
|
||||
const row = el("div", undefined, "overview-presets-row overview-presets-builtin-row");
|
||||
row.setAttribute("role", "listitem");
|
||||
row.dataset.builtinPreset = preset.id;
|
||||
const text = el("div", undefined, "overview-presets-builtin-text");
|
||||
text.append(el("strong", t(preset.name_key)), el("span", t(preset.description_key), "fine"));
|
||||
const actions = el("div", undefined, "overview-presets-actions");
|
||||
actions.append(entryButton("dashboardPresetsLoad", "primary", async () => {
|
||||
await apply(builtinLayout(preset));
|
||||
dialog.close();
|
||||
toast(translateName("dashboardBuiltinLoaded", t(preset.name_key)));
|
||||
}, t(preset.name_key)));
|
||||
row.append(text, actions);
|
||||
group.append(row);
|
||||
}
|
||||
return group;
|
||||
}).filter(Boolean);
|
||||
builtinList.replaceChildren(...groups);
|
||||
}
|
||||
function render() {
|
||||
renderBuiltin();
|
||||
const elements = presets.map(preset => {
|
||||
const row = el("div", undefined, "overview-presets-row");
|
||||
row.setAttribute("role", "listitem");
|
||||
@@ -100,6 +143,8 @@ window.rustProxyDashboardLayout = (() => {
|
||||
dashboard_widget_sizes: layout.dashboard_widget_sizes === null ? null : { ...layout.dashboard_widget_sizes },
|
||||
dashboard_widget_heights: normalizeDashboardWidgetHeights(layout.dashboard_widget_heights),
|
||||
dashboard_density: layout.dashboard_density,
|
||||
...("dashboard_widget_positions" in layout ? { dashboard_widget_positions: layout.dashboard_widget_positions } : {}),
|
||||
...("dashboard_auto_fit" in layout ? { dashboard_auto_fit: layout.dashboard_auto_fit } : {}),
|
||||
});
|
||||
window.rustProxyOverviewSamples.setLimit(layout.overview_samples, true);
|
||||
}
|
||||
|
||||
@@ -2386,6 +2386,38 @@ html:is([data-corner-style=square], [data-corner-style=subtle], [data-corner-sty
|
||||
background: var(--panel);
|
||||
}
|
||||
|
||||
.overview-presets-builtin {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.overview-presets-builtin h3,
|
||||
.overview-presets-own-title,
|
||||
.overview-presets-builtin-group h3 {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
font-weight: 650;
|
||||
}
|
||||
|
||||
.overview-presets-builtin-group {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.overview-presets-builtin-group h3 {
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
|
||||
.overview-presets-builtin-text {
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
min-width: 0;
|
||||
flex: 1 1 260px;
|
||||
}
|
||||
|
||||
.overview-presets-row strong {
|
||||
font-size: 13px;
|
||||
overflow-wrap: anywhere;
|
||||
|
||||
@@ -0,0 +1,646 @@
|
||||
[
|
||||
{
|
||||
"id": "operations",
|
||||
"form": "desktop",
|
||||
"name_key": "dashboardBuiltinOperations",
|
||||
"description_key": "dashboardBuiltinOperationsHelp",
|
||||
"dashboard_density": "compact",
|
||||
"overview_samples": 300,
|
||||
"widgets": [
|
||||
[
|
||||
"requests",
|
||||
2
|
||||
],
|
||||
[
|
||||
"active",
|
||||
2
|
||||
],
|
||||
[
|
||||
"bandwidth",
|
||||
2
|
||||
],
|
||||
[
|
||||
"errors",
|
||||
2
|
||||
],
|
||||
[
|
||||
"memory",
|
||||
2
|
||||
],
|
||||
[
|
||||
"extra_response_latency",
|
||||
2
|
||||
],
|
||||
[
|
||||
"traffic_chart",
|
||||
6
|
||||
],
|
||||
[
|
||||
"connection_chart",
|
||||
6
|
||||
],
|
||||
[
|
||||
"backend_health",
|
||||
3
|
||||
],
|
||||
[
|
||||
"backend_errors",
|
||||
3
|
||||
],
|
||||
[
|
||||
"backend_latency",
|
||||
3
|
||||
],
|
||||
[
|
||||
"extra_backend_unhealthy",
|
||||
3
|
||||
],
|
||||
[
|
||||
"backend_table",
|
||||
12
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "traffic",
|
||||
"form": "desktop",
|
||||
"name_key": "dashboardBuiltinTraffic",
|
||||
"description_key": "dashboardBuiltinTrafficHelp",
|
||||
"dashboard_density": "compact",
|
||||
"overview_samples": 300,
|
||||
"widgets": [
|
||||
[
|
||||
"requests",
|
||||
2
|
||||
],
|
||||
[
|
||||
"extra_total_rps",
|
||||
2
|
||||
],
|
||||
[
|
||||
"bandwidth",
|
||||
2
|
||||
],
|
||||
[
|
||||
"http_protocol",
|
||||
2
|
||||
],
|
||||
[
|
||||
"extra_h2_share",
|
||||
2
|
||||
],
|
||||
[
|
||||
"extra_h3_share",
|
||||
2
|
||||
],
|
||||
[
|
||||
"wide_protocol_rates",
|
||||
6
|
||||
],
|
||||
[
|
||||
"traffic_chart",
|
||||
6
|
||||
],
|
||||
[
|
||||
"http2",
|
||||
3
|
||||
],
|
||||
[
|
||||
"http3",
|
||||
3
|
||||
],
|
||||
[
|
||||
"tls",
|
||||
3
|
||||
],
|
||||
[
|
||||
"websocket_protocol",
|
||||
3
|
||||
],
|
||||
[
|
||||
"wide_connections",
|
||||
6
|
||||
],
|
||||
[
|
||||
"connection_chart",
|
||||
6
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "cache",
|
||||
"form": "desktop",
|
||||
"name_key": "dashboardBuiltinCache",
|
||||
"description_key": "dashboardBuiltinCacheHelp",
|
||||
"dashboard_density": "compact",
|
||||
"overview_samples": 300,
|
||||
"widgets": [
|
||||
[
|
||||
"cache",
|
||||
2
|
||||
],
|
||||
[
|
||||
"cache_outcomes",
|
||||
2
|
||||
],
|
||||
[
|
||||
"extra_cache_hit_rate",
|
||||
2
|
||||
],
|
||||
[
|
||||
"extra_cache_miss_rate",
|
||||
2
|
||||
],
|
||||
[
|
||||
"extra_cache_memory",
|
||||
2
|
||||
],
|
||||
[
|
||||
"extra_cold_storage",
|
||||
2
|
||||
],
|
||||
[
|
||||
"wide_cache_activity",
|
||||
6
|
||||
],
|
||||
[
|
||||
"cache_diagnostics",
|
||||
6
|
||||
],
|
||||
[
|
||||
"wide_compression_activity",
|
||||
6
|
||||
],
|
||||
[
|
||||
"wide_transform_activity",
|
||||
6
|
||||
],
|
||||
[
|
||||
"extra_cold_queue_memory",
|
||||
4
|
||||
],
|
||||
[
|
||||
"bandwidth",
|
||||
4
|
||||
],
|
||||
[
|
||||
"extra_response_latency",
|
||||
4
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "backends",
|
||||
"form": "desktop",
|
||||
"name_key": "dashboardBuiltinBackends",
|
||||
"description_key": "dashboardBuiltinBackendsHelp",
|
||||
"dashboard_density": "compact",
|
||||
"overview_samples": 300,
|
||||
"widgets": [
|
||||
[
|
||||
"backend_health",
|
||||
2
|
||||
],
|
||||
[
|
||||
"extra_backends_healthy",
|
||||
2
|
||||
],
|
||||
[
|
||||
"backend_capacity",
|
||||
2
|
||||
],
|
||||
[
|
||||
"backend_queue",
|
||||
2
|
||||
],
|
||||
[
|
||||
"backend_retries",
|
||||
2
|
||||
],
|
||||
[
|
||||
"backend_rotations",
|
||||
2
|
||||
],
|
||||
[
|
||||
"backend_requests",
|
||||
4
|
||||
],
|
||||
[
|
||||
"backend_latency",
|
||||
4
|
||||
],
|
||||
[
|
||||
"backend_errors",
|
||||
4
|
||||
],
|
||||
[
|
||||
"backend_traffic",
|
||||
4
|
||||
],
|
||||
[
|
||||
"backend_http5xx",
|
||||
4
|
||||
],
|
||||
[
|
||||
"backend_timeouts",
|
||||
4
|
||||
],
|
||||
[
|
||||
"wide_backend_health",
|
||||
6
|
||||
],
|
||||
[
|
||||
"wide_latency",
|
||||
6
|
||||
],
|
||||
[
|
||||
"backend_table",
|
||||
12
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "resources",
|
||||
"form": "desktop",
|
||||
"name_key": "dashboardBuiltinResources",
|
||||
"description_key": "dashboardBuiltinResourcesHelp",
|
||||
"dashboard_density": "compact",
|
||||
"overview_samples": 600,
|
||||
"widgets": [
|
||||
[
|
||||
"extra_process_cpu",
|
||||
2
|
||||
],
|
||||
[
|
||||
"extra_process_rss",
|
||||
2
|
||||
],
|
||||
[
|
||||
"extra_process_fds",
|
||||
2
|
||||
],
|
||||
[
|
||||
"extra_open_connections",
|
||||
2
|
||||
],
|
||||
[
|
||||
"memory",
|
||||
2
|
||||
],
|
||||
[
|
||||
"extra_active_exchanges",
|
||||
2
|
||||
],
|
||||
[
|
||||
"wide_cpu",
|
||||
6
|
||||
],
|
||||
[
|
||||
"wide_memory",
|
||||
6
|
||||
],
|
||||
[
|
||||
"system_chart",
|
||||
6
|
||||
],
|
||||
[
|
||||
"memory_breakdown",
|
||||
6
|
||||
],
|
||||
[
|
||||
"process_diagnostics",
|
||||
6
|
||||
],
|
||||
[
|
||||
"network_diagnostics",
|
||||
6
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "security",
|
||||
"form": "desktop",
|
||||
"name_key": "dashboardBuiltinSecurity",
|
||||
"description_key": "dashboardBuiltinSecurityHelp",
|
||||
"dashboard_density": "compact",
|
||||
"overview_samples": 300,
|
||||
"widgets": [
|
||||
[
|
||||
"errors",
|
||||
2
|
||||
],
|
||||
[
|
||||
"extra_request_error_rate",
|
||||
2
|
||||
],
|
||||
[
|
||||
"extra_error_share",
|
||||
2
|
||||
],
|
||||
[
|
||||
"extra_rejected_rate",
|
||||
2
|
||||
],
|
||||
[
|
||||
"extra_tls_error_rate",
|
||||
2
|
||||
],
|
||||
[
|
||||
"extra_cert_expiry",
|
||||
2
|
||||
],
|
||||
[
|
||||
"backend_http5xx",
|
||||
4
|
||||
],
|
||||
[
|
||||
"backend_errors",
|
||||
4
|
||||
],
|
||||
[
|
||||
"backend_timeouts",
|
||||
4
|
||||
],
|
||||
[
|
||||
"traffic_chart",
|
||||
6
|
||||
],
|
||||
[
|
||||
"wide_latency",
|
||||
6
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "docker",
|
||||
"form": "desktop",
|
||||
"name_key": "dashboardBuiltinDocker",
|
||||
"description_key": "dashboardBuiltinDockerHelp",
|
||||
"dashboard_density": "compact",
|
||||
"overview_samples": 300,
|
||||
"widgets": [
|
||||
[
|
||||
"docker_agents",
|
||||
3
|
||||
],
|
||||
[
|
||||
"docker_apps",
|
||||
3
|
||||
],
|
||||
[
|
||||
"docker_host_load",
|
||||
3
|
||||
],
|
||||
[
|
||||
"docker_containers",
|
||||
3
|
||||
],
|
||||
[
|
||||
"docker_requests",
|
||||
6
|
||||
],
|
||||
[
|
||||
"docker_host_network",
|
||||
6
|
||||
],
|
||||
[
|
||||
"requests",
|
||||
3
|
||||
],
|
||||
[
|
||||
"errors",
|
||||
3
|
||||
],
|
||||
[
|
||||
"backend_health",
|
||||
3
|
||||
],
|
||||
[
|
||||
"extra_response_latency",
|
||||
3
|
||||
],
|
||||
[
|
||||
"backend_table",
|
||||
12
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "webserver",
|
||||
"form": "desktop",
|
||||
"name_key": "dashboardBuiltinWebServer",
|
||||
"description_key": "dashboardBuiltinWebServerHelp",
|
||||
"dashboard_density": "compact",
|
||||
"overview_samples": 300,
|
||||
"widgets": [
|
||||
[
|
||||
"www_status",
|
||||
2
|
||||
],
|
||||
[
|
||||
"www_kind",
|
||||
2
|
||||
],
|
||||
[
|
||||
"www_capacity",
|
||||
2
|
||||
],
|
||||
[
|
||||
"www_methods",
|
||||
2
|
||||
],
|
||||
[
|
||||
"www_error_rate",
|
||||
2
|
||||
],
|
||||
[
|
||||
"www_php_requests",
|
||||
2
|
||||
],
|
||||
[
|
||||
"www_requests",
|
||||
6
|
||||
],
|
||||
[
|
||||
"www_latency",
|
||||
6
|
||||
],
|
||||
[
|
||||
"www_traffic",
|
||||
6
|
||||
],
|
||||
[
|
||||
"www_failures",
|
||||
6
|
||||
],
|
||||
[
|
||||
"www_top_services",
|
||||
6
|
||||
],
|
||||
[
|
||||
"www_status_trend",
|
||||
6
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "streams",
|
||||
"form": "desktop",
|
||||
"name_key": "dashboardBuiltinStreams",
|
||||
"description_key": "dashboardBuiltinStreamsHelp",
|
||||
"dashboard_density": "compact",
|
||||
"overview_samples": 300,
|
||||
"widgets": [
|
||||
[
|
||||
"stream_overview",
|
||||
4
|
||||
],
|
||||
[
|
||||
"stream_sessions",
|
||||
4
|
||||
],
|
||||
[
|
||||
"stream_backend_health",
|
||||
4
|
||||
],
|
||||
[
|
||||
"stream_traffic",
|
||||
6
|
||||
],
|
||||
[
|
||||
"active",
|
||||
3
|
||||
],
|
||||
[
|
||||
"bandwidth",
|
||||
3
|
||||
],
|
||||
[
|
||||
"connection_chart",
|
||||
6
|
||||
],
|
||||
[
|
||||
"wide_connections",
|
||||
6
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "wall",
|
||||
"form": "desktop",
|
||||
"name_key": "dashboardBuiltinWall",
|
||||
"description_key": "dashboardBuiltinWallHelp",
|
||||
"dashboard_density": "normal",
|
||||
"overview_samples": 600,
|
||||
"widgets": [
|
||||
[
|
||||
"requests",
|
||||
3
|
||||
],
|
||||
[
|
||||
"active",
|
||||
3
|
||||
],
|
||||
[
|
||||
"bandwidth",
|
||||
3
|
||||
],
|
||||
[
|
||||
"errors",
|
||||
3
|
||||
],
|
||||
[
|
||||
"traffic_chart",
|
||||
12
|
||||
],
|
||||
[
|
||||
"backend_health",
|
||||
4
|
||||
],
|
||||
[
|
||||
"extra_response_latency",
|
||||
4
|
||||
],
|
||||
[
|
||||
"extra_cache_hit_rate",
|
||||
4
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "mobile_status",
|
||||
"form": "mobile",
|
||||
"name_key": "dashboardBuiltinMobileStatus",
|
||||
"description_key": "dashboardBuiltinMobileStatusHelp",
|
||||
"dashboard_density": "compact",
|
||||
"overview_samples": 60,
|
||||
"widgets": [
|
||||
[
|
||||
"requests",
|
||||
2
|
||||
],
|
||||
[
|
||||
"errors",
|
||||
2
|
||||
],
|
||||
[
|
||||
"active",
|
||||
2
|
||||
],
|
||||
[
|
||||
"bandwidth",
|
||||
2
|
||||
],
|
||||
[
|
||||
"extra_response_latency",
|
||||
2
|
||||
],
|
||||
[
|
||||
"extra_cache_hit_rate",
|
||||
2
|
||||
],
|
||||
[
|
||||
"backend_health",
|
||||
12
|
||||
],
|
||||
[
|
||||
"traffic_chart",
|
||||
12
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "mobile_oncall",
|
||||
"form": "mobile",
|
||||
"name_key": "dashboardBuiltinMobileOnCall",
|
||||
"description_key": "dashboardBuiltinMobileOnCallHelp",
|
||||
"dashboard_density": "compact",
|
||||
"overview_samples": 60,
|
||||
"widgets": [
|
||||
[
|
||||
"errors",
|
||||
2
|
||||
],
|
||||
[
|
||||
"extra_request_error_rate",
|
||||
2
|
||||
],
|
||||
[
|
||||
"extra_backend_unhealthy",
|
||||
2
|
||||
],
|
||||
[
|
||||
"extra_cert_expiry",
|
||||
2
|
||||
],
|
||||
[
|
||||
"backend_errors",
|
||||
12
|
||||
],
|
||||
[
|
||||
"backend_tiny",
|
||||
12
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -4212,6 +4212,12 @@
|
||||
<div class="overview-presets-content">
|
||||
<p class="fine" data-i18n="dashboardPresetsHelp">Save named arrangements and restore them from any browser.
|
||||
Use Unlock layout on Overview to move, resize or hide cards before saving a preset.</p>
|
||||
<section class="overview-presets-builtin" aria-labelledby="overview-presets-builtin-title">
|
||||
<h3 id="overview-presets-builtin-title" data-i18n="dashboardBuiltinTitle">Built-in presets</h3>
|
||||
<p class="fine" data-i18n="dashboardBuiltinHelp">Ready-made layouts for common tasks. Loading one replaces the current arrangement; save it under your own name to keep changes.</p>
|
||||
<div class="overview-presets-list" id="overview-presets-builtin" role="list"></div>
|
||||
</section>
|
||||
<h3 class="overview-presets-own-title" data-i18n="dashboardPresetsOwnTitle">My presets</h3>
|
||||
<div class="overview-presets-create">
|
||||
<label for="overview-presets-name" data-i18n="dashboardPresetsName">Preset name</label>
|
||||
<div class="overview-presets-create-controls">
|
||||
|
||||
Vendored
+6
-1
@@ -416,10 +416,15 @@ fn compile_condition(condition: &RuleCondition, stage: RuleStage) -> Result<Comp
|
||||
.values
|
||||
.iter()
|
||||
.map(|value| {
|
||||
let value = if condition.field == ConditionField::Extension {
|
||||
value.trim().trim_start_matches('.')
|
||||
} else {
|
||||
value.as_str()
|
||||
};
|
||||
if fold {
|
||||
value.to_ascii_lowercase()
|
||||
} else {
|
||||
value.clone()
|
||||
value.to_owned()
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
Vendored
+20
@@ -23,6 +23,26 @@ mod cache_rules_tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn extension_values_with_a_leading_dot_or_capitals_match() {
|
||||
let global = vec![rule(
|
||||
serde_json::json!({"id": "assets", "conditions": [{"field": "extension", "operator": "equals", "values": [".CSS", " .js"]}], "actions": [{"type": "pass"}]}),
|
||||
)];
|
||||
validate_rules(&global, true).unwrap();
|
||||
let rules = CompiledRules::compile("shop", &[], &global, false).unwrap();
|
||||
for path in ["/app.css", "/theme/app.CSS", "/bundle.js"] {
|
||||
assert_eq!(
|
||||
rules.evaluate_request(&request(path, None, &[]), false).pass.as_deref(),
|
||||
Some("assets"),
|
||||
"{path}"
|
||||
);
|
||||
}
|
||||
assert!(rules
|
||||
.evaluate_request(&request("/app.json", None, &[]), false)
|
||||
.pass
|
||||
.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn request_rules_pass_strip_cookies_query_and_hash() {
|
||||
let global = vec![
|
||||
|
||||
+13
@@ -189,6 +189,19 @@ mod varnish_compatible_tests {
|
||||
),
|
||||
RequestPolicy::Bypass("path_excluded")
|
||||
);
|
||||
settings.bypass_prefixes = vec!["/api/".into()];
|
||||
for path in ["/api/", "/api/health"] {
|
||||
assert_eq!(
|
||||
request_policy(&Method::GET, &HeaderMap::new(), true, path, false, &settings),
|
||||
RequestPolicy::Bypass("path_excluded"),
|
||||
"{path}"
|
||||
);
|
||||
}
|
||||
assert_ne!(
|
||||
request_policy(&Method::GET, &HeaderMap::new(), true, "/apix", false, &settings),
|
||||
RequestPolicy::Bypass("path_excluded")
|
||||
);
|
||||
settings.bypass_prefixes = vec!["/private".into()];
|
||||
assert_eq!(
|
||||
request_policy(
|
||||
&Method::POST,
|
||||
|
||||
@@ -401,7 +401,7 @@ pub fn prefix_matches(prefix: &str, path: &str) -> bool {
|
||||
|| path == prefix
|
||||
|| path
|
||||
.strip_prefix(prefix)
|
||||
.is_some_and(|tail| tail.starts_with('/'))
|
||||
.is_some_and(|tail| tail.starts_with('/') || prefix.ends_with('/'))
|
||||
}
|
||||
pub(crate) fn valid_id(id: &str) -> bool {
|
||||
!id.is_empty()
|
||||
|
||||
@@ -689,6 +689,10 @@ mod tests {
|
||||
assert!(prefix_matches("/api", "/api"));
|
||||
assert!(prefix_matches("/api", "/api/users"));
|
||||
assert!(!prefix_matches("/api", "/apix"));
|
||||
assert!(prefix_matches("/api/", "/api/"));
|
||||
assert!(prefix_matches("/api/", "/api/users"));
|
||||
assert!(!prefix_matches("/api/", "/api"));
|
||||
assert!(!prefix_matches("/api/", "/apix"));
|
||||
assert!(prefix_matches("/", "/anything"));
|
||||
}
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user