This commit is contained in:
Mateusz Gruszczyński committed 2026-11-28 17:36:53 +01:00
1 parent 5b6d4a7903
commit 4d1087e357
160 files changed
+2407 -1933

No files matched your search

-14
View File
@@ -1,6 +1,3 @@
// Load-balancing editor (vhost and location) with a consistent-hash distribution
// simulator. The pure helpers at the top mirror src/balance/model.rs (rendezvous
// scoring and hash keys); keep them in step with tests/fixtures/balance_rendezvous_vectors.txt.
const lbSha256 = (() => {
const K = new Uint32Array([
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
@@ -32,7 +29,6 @@ const lbSha256 = (() => {
})();
const lbEncoder = new TextEncoder();
const LB_U64_SPAN = Number(2n ** 64n - 1n) + 2, LB_MIN_POSITIVE = 2.2250738585072014e-308;
// Same as rendezvous_score() in src/balance/model.rs: lowest score wins.
function lbScore(poolId, key, memberId, weight) {
const digest = lbSha256(lbEncoder.encode(`${poolId}|${key}|${memberId}`));
let n = 0n; for (let i = 0; i < 8; i++) n = (n << 8n) | BigInt(digest[i]);
@@ -47,7 +43,6 @@ function lbPathDepth(path, depth) {
for (let i = 1; i < path.length; i++) if (path[i] === "/" && ++seen === depth) return path.slice(0, i);
return path;
}
// Parses one simulator sample: "/path?query", "https://host/path?query" or "host/path".
function lbParseSample(line) {
let rest = line.trim(), host = "";
const scheme = rest.match(/^[a-z][a-z0-9+.-]*:\/\//i);
@@ -59,7 +54,6 @@ function lbParseSample(line) {
host = bracketed ? bracketed[1] : host.includes(":") && host.indexOf(":") === host.lastIndexOf(":") ? host.replace(/:\d*$/, "") : host;
return { host: host.replace(/\.$/, "").toLowerCase(), path: mark < 0 ? rest : rest.slice(0, mark), query: mark < 0 ? null : rest.slice(mark + 1) };
}
// Mirrors HashSettings::key(); header/cookie/IP samples are the raw value itself.
function lbHashKey(settings, line) {
const source = settings.source || "path", value = String(line).trim(); if (!value) return null;
if (source === "ip") return value;
@@ -79,8 +73,6 @@ function lbHashKey(settings, line) {
if (!key) return null;
return settings.ignore_case ? key.toLowerCase() : key;
}
// Which members a request may use (mirrors candidates: enabled, not draining, backups
// only when no primary is left).
function lbEligible(members, explicit, down = new Set()) {
const usable = members.filter(m => m.enabled && !m.drain && (explicit || m.pool_eligible) && !down.has(m.id));
return usable.some(m => !m.backup) ? usable.filter(m => !m.backup) : usable;
@@ -106,7 +98,6 @@ const LB_PRESETS = [
{ key: "lbPresetIp", algorithm: "hash", hash: { source: "ip" }, samples: "203.0.113.10\n203.0.113.11\n198.51.100.7\n2001:db8::42" },
{ key: "lbPresetEven", algorithm: "least_connections", hash: {} }
];
// HAProxy-style one-liner describing the configuration (helps people migrating).
function lbHaproxyLine(algorithm, hash) {
const map = { round_robin: "balance roundrobin", least_connections: "balance leastconn", random: "balance random(2)", ip_hash: "balance source\nhash-type consistent" };
if (map[algorithm]) return map[algorithm];
@@ -117,9 +108,6 @@ function lbHaproxyLine(algorithm, hash) {
return `${source}\nhash-type consistent${Number(hash.balance_factor) ? `\nhash-balance-factor ${hash.balance_factor}` : ""}`;
}
// Balancing editor. options: { names: input name prefix, value: {algorithm, hash, sticky},
// members(): [{id, weight, enabled, drain, backup, pool_eligible}], explicit(): bool,
// poolId(): string, stickyField: include a location affinity select, onChange() }.
function balancingEditor(parent, options) {
const value = options.value || {}, hash = { ...(value.hash || {}) }, prefix = options.names;
const box = el("div", undefined, "vh-wide lb-editor"); parent.append(box);
@@ -232,7 +220,6 @@ function balancingEditor(parent, options) {
sync(); simulator.open = preset.algorithm === "hash"; if (simulator.open) simulate(); options.onChange?.();
}, "quiet lb-preset"));
}
// The simulator is a scratch pad: its inputs never mark the vhost as changed.
for (const type of ["input", "change"]) simulator.addEventListener(type, event => { event.stopPropagation(); if (event.target === samples) simulate(); });
box.addEventListener("input", () => { sync(); options.onChange?.(); });
box.addEventListener("change", () => { sync(); options.onChange?.(); });
@@ -246,7 +233,6 @@ function balancingEditor(parent, options) {
validate() { if (algorithm.value === "hash" && ["header", "cookie", "query"].includes(source.value) && !name.value.trim()) throw new Error(t("lbHashNameRequired")); }
};
}
// Reads the vhost backend rows for the balancing editors and simulators.
function balancingMembers() {
return [...form.querySelectorAll(".vh-member")].map(row => ({
id: str("member-id", row), weight: Number(str("member-weight", row)) || 1,
-7
View File
@@ -426,9 +426,6 @@ function openLocationHelp(topic = "locations") {
}
dialog.showModal();
}
// Error fallback = target internal location + the upstream statuses it handles.
// The status chips write the legacy comma-separated "<prefix>-statuses" field,
// so readers, JSON drawers and saved configuration keep their exact format.
const ERROR_FALLBACK_STATUSES = [403, 404, 500, 502, 503, 504];
let errorFallbackListId = 0;
const internalLocationIds = () => [...form.querySelectorAll('.vh-location [name="location-internal"]')].filter(box => box.checked)
@@ -452,7 +449,6 @@ function errorFallbackFields(parent, prefix, value, keys) {
const write = () => { hidden.value = boxes.filter(input => input.checked).map(input => input.value).join(", "); };
const sync = () => { const off = !target.value.trim(); box.classList.toggle("is-inactive", off); for (const input of boxes) input.disabled = off; };
chips.addEventListener("change", event => {
// At least one status stays selected; an empty list would silently mean 404.
if (!boxes.some(input => input.checked)) event.target.checked = true;
write(); hidden.dispatchEvent(new Event("input", { bubbles: true }));
});
@@ -463,7 +459,6 @@ function errorFallbackFields(parent, prefix, value, keys) {
const LOCATION_GROUP = "__group__";
function locationsEditor(parent, values, onChange = changed) {
const toolbar = el("div", undefined, "vh-wide location-toolbar"), rows = el("div", undefined, "vh-wide vh-locations");
// "Add location" opens starting points; each one only pre-fills ordinary fields.
const addMenu = el("div", undefined, "location-add-menu"), templates = el("div", undefined, "location-templates"); templates.hidden = true;
const showTemplates = open => { templates.hidden = !open; addTop.setAttribute("aria-expanded", String(open)); };
const addTop = button("locationAdd", () => showTemplates(templates.hidden), "primary"); addTop.setAttribute("aria-haspopup", "true"); addTop.setAttribute("aria-expanded", "false");
@@ -522,7 +517,6 @@ function locationsEditor(parent, values, onChange = changed) {
if (rows.children.length >= 64) { toast(t("locationLimit"), true); return; }
const row = el("details", undefined, "vh-location"); row.open = open;
const summary = el("summary", undefined, "location-summary"), body = el("div", undefined, "vh-grid location-body"); row.append(summary, body);
// Collapsed row = one line of the routing table; expanded = When / What / Options.
const sumOrder = el("span", String(rows.children.length + 1), "loc-order"), sumState = el("span", undefined, "loc-state"), sumId = el("span", "", "loc-id");
const 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); row._order = sumOrder;
@@ -722,7 +716,6 @@ function locationsEditor(parent, values, onChange = changed) {
const headerValue = editor.read(), requestRules = headerValue.request?.length || 0, responseRules = headerValue.response?.length || 0;
previewValues.headers.textContent = `${requestRules} ${t("locationPreviewRequestRules")} / ${responseRules} ${t("locationPreviewResponseRules")}`; headerCount = requestRules + responseRules;
} catch { previewValues.headers.textContent = t("headersInvalid"); }
// Row summary, headline and option tab states.
sumAction.textContent = actionText || "";
const fallbackTarget = str("location-error-target", row), fallbackStatuses = str("location-error-statuses", row).replace(/\s+/g, "");
const visualRules = policyBody.querySelector(".policy-visual:not([hidden]) .policy-rules"); if (visualRules) policyCount = visualRules.querySelectorAll(":scope > .policy-rule").length;
-9
View File
@@ -1,10 +1,7 @@
// Headers tab of the vhost editor: live preview of the headers RustProxy sends to the
// backend and to the client, example values for %[variables] and diagnostic cards.
const HEADER_VARIABLE_NAMES = new Set(HEADER_VARIABLES.map(([name]) => name));
const HEADER_RESPONSE_ONLY = new Set(HEADER_VARIABLES.filter(([, only]) => only).map(([name]) => name));
let headerExampleContext = { member: "", location: "main", cache: "MISS" };
// Example values for header variables, based on the draft (first eligible backend…).
function headerExampleVars(context = headerExampleContext) {
const members = (typeof balancingMembers === "function" ? balancingMembers() : []).filter(m => m.id);
const member = members.find(m => m.id === context.member) || members.find(m => m.enabled && m.pool_eligible) || members[0];
@@ -19,7 +16,6 @@ function headerExampleVars(context = headerExampleContext) {
path: "/media/a.mp3", cache_status: context.cache, backend_time: hits ? "-" : "12.40ms"
};
}
// Checks a header value and renders it with example variables.
function headerValueCheck(value, direction, vars = headerExampleVars()) {
const text = String(value ?? "");
if (!text.includes("%[")) return { dynamic: false, rendered: text };
@@ -34,7 +30,6 @@ function headerValueCheck(value, direction, vars = headerExampleVars()) {
}
return { dynamic: true, rendered: rendered + rest };
}
// Applies header rules to an ordered header list [{name, value, source, dynamic}].
function headerApplyRules(list, rules, source, direction, vars, stage) {
for (const rule of rules || []) {
if (!rule?.name) continue;
@@ -86,7 +81,6 @@ function headersPreview(parent) {
cacheSelect.value = headerExampleContext.cache;
const vars = headerExampleVars(), route = routes.find(r => r.id === headerExampleContext.location);
const global = envelope?.config?.headers || {}, vhost = safe(() => vhostHeadersControl?.read()) || {}, location = route?.headers || {};
// Request: static rules (global → vhost → location), then forwarding, then rules with variables.
const request = [], requestVars = headerExampleVars({ ...headerExampleContext, cache: "MISS" });
if (headerExampleContext.cache === "HIT") request.push({ name: t("hdrPreviewHitNoRequest"), value: undefined, source: "system", system: true });
else for (const stage of ["static", "dynamic"]) {
@@ -95,7 +89,6 @@ function headersPreview(parent) {
headerApplyRules(request, vhost.request, "vhost", "request", requestVars, stage);
headerApplyRules(request, location.request, "location", "request", requestVars, stage);
}
// Response: static rules, diagnostics and identity, then rules with variables.
const response = [];
headerApplyRules(response, global.response, "global", "response", vars, "static");
headerApplyRules(response, vhost.response, "vhost", "response", vars, "static");
@@ -121,7 +114,6 @@ function headersPreview(parent) {
return { refresh };
}
// One switch as a card that shows the header it produces.
function diagnosticCard(parent, { name, key, checked, header, example, help, extra }) {
const card = el("div", undefined, "hdr-card"), head = el("div", undefined, "hdr-card-head"); card.append(head);
const input = field(head, name, key, checked, "checkbox", { switch: true });
@@ -132,6 +124,5 @@ function diagnosticCard(parent, { name, key, checked, header, example, help, ext
input.addEventListener("change", sync); sync(); parent.append(card); return input;
}
// The preview follows every edit in the editor and the Headers tab button.
for (const type of ["input", "change", "click"]) container.addEventListener(type, () => { headersPreviewControl?.refresh(); presetsRefresh(); });
$("vhost-tabs").addEventListener("click", () => headersPreviewControl?.refresh());
+1 -13
View File
@@ -178,8 +178,6 @@ function syncVhostSortDirection() {
control.setAttribute("aria-label", t(vhostListPrefs.descending ? "backendSortDescending" : "backendSortAscending"));
}
function applyPreferences(preferences) {
// Updating backend columns should never reconstruct the unrelated Vhost list.
// Keep any newer local column change while an earlier write is in flight.
const nextPool = poolPreferenceSaveQueued ? poolTablePrefs : normalizePoolTablePrefs(preferences);
const nextVhost = normalizeVhostListPrefs(preferences);
const poolChanged = JSON.stringify(nextPool) !== JSON.stringify(poolTablePrefs);
@@ -249,8 +247,6 @@ function applyPoolTableView() {
const result = typeof a === "number" && typeof b === "number" ? a - b : compareText(a, b);
return poolTablePrefs.descending ? -result : result;
});
// Retain rows that are already ordered correctly. A needless detach of a
// focused/anchored table row can jump the page even when sorting is unchanged.
let cursor = body.firstElementChild;
for (const row of rows) {
if (row === cursor) cursor = cursor.nextElementSibling;
@@ -484,8 +480,6 @@ const BO_EXTRA_CELLS = {
if (extra.h1 + extra.h2) cell.append(el("small", `H2 ${boPercent(extra.h2, extra.h1 + extra.h2)}`));
},
};
// Keep filter buttons and keyed table rows mounted between live samples.
// Replacing them every few seconds discards keyboard focus and browser scroll anchors.
const BO_FILTERS = [["all", "backendFilterAll"], ["up", "vhUp"], ["down", "vhDown"], ["other", "backendFilterOther"]];
function syncBackendOverviewFilters(filters, counts) {
if (filters.getAttribute("aria-label") !== t("backendFilterLabel")) filters.setAttribute("aria-label", t("backendFilterLabel"));
@@ -521,7 +515,6 @@ function syncBackendOverviewRows(body, rendered) {
if (cell.colSpan !== updated.colSpan) cell.colSpan = updated.colSpan;
if (updated.dataset.boColumn && cell.dataset.boColumn !== updated.dataset.boColumn) cell.dataset.boColumn = updated.dataset.boColumn;
if (updated.dataset.boColumn === "toggle") {
// The expansion control itself must survive refreshes, not just regain focus.
const button = cell.querySelector("button"), nextButton = updated.querySelector("button");
if (button && nextButton) {
if (button.getAttribute("aria-expanded") !== nextButton.getAttribute("aria-expanded")) button.setAttribute("aria-expanded", nextButton.getAttribute("aria-expanded"));
@@ -532,8 +525,6 @@ function syncBackendOverviewRows(body, rendered) {
}
return current;
});
// Do not detach rows already in the correct position: moving a focused row
// needlessly also breaks the scroll anchor on some browsers.
let cursor = body.firstElementChild;
for (const row of rows) {
if (row === cursor) cursor = cursor.nextElementSibling;
@@ -628,8 +619,6 @@ function applyBackendOverviewView() {
}
const scroller = body.closest(".table-scroll"), scrollTop = scroller?.scrollTop ?? 0, scrollLeft = scroller?.scrollLeft ?? 0;
syncBackendOverviewRows(body, rows);
// Sorting or filtering can change the table height; preserve the user's
// scroll position, but avoid forced layout for an untouched scroll offset.
if (scroller && (scrollTop || scrollLeft)) { if (scroller.scrollTop !== scrollTop) scroller.scrollTop = scrollTop; if (scroller.scrollLeft !== scrollLeft) scroller.scrollLeft = scrollLeft; }
if (hadFocus && document.activeElement?.dataset?.boKey !== focusKey) [...body.querySelectorAll(".bo-expand")].find(button => button.dataset.boKey === focusKey)?.focus({ preventScroll: true });
const empty = $("bo-empty");
@@ -996,7 +985,6 @@ 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);
@@ -1055,5 +1043,5 @@ $("pool-open").addEventListener("click", () => setPanel("vhosts"));
initPoolTableTools();
$("location-help-close")?.addEventListener("click", () => $("location-help-dialog")?.close());
window.rustProxyDrafts.register("vhost", { labelKey: "vhosts", isOpen: () => dialog.open, isDirty: () => dirty, suspend: suspendDraft, restore: restoreDraft, close: () => { dirty = false; if (dialog.open) dialog.close(); } });
window.rustProxyVhosts = { render, renderStatus, applyPreferences, flushOverviewViews, reset() { closeVhostBackendPopup(); dialog.close(); draftEpoch++; stagedCertificates = []; uploading = false; editing = null; revision = null; dirty = false; initialized = false; backendHealthEditorControl = null; poolTablePrefs = defaultPoolTablePrefs(); vhostListPrefs = defaultVhostListPrefs(); poolPreferenceSaveRunning = false; poolPreferenceSaveQueued = false; chartHistory.clear(); backendTrafficHistory.clear(); backendRequestHistory.clear(); vhostTrafficHistory.clear(); container.replaceChildren(); $("vhost-search").value = ""; if ($("pool-search")) $("pool-search").value = ""; $("vhost-list").replaceChildren(); $("pool-rows").replaceChildren(); const sort = $("pool-sort"); if (sort) sort.value = poolTablePrefs.sort; const vhostSort = $("vhost-sort"); if (vhostSort) vhostSort.value = vhostListPrefs.sort; syncVhostSortDirection(); applyPoolTableView(); } };
window.rustProxyVhosts = { render, edit(id) { const item = (envelope?.config.vhosts || []).find(entry => entry.id === id); if (!item) return false; window.rustProxyDrafts.prepare(); load(structuredClone(item)); return true; }, renderStatus, applyPreferences, flushOverviewViews, reset() { closeVhostBackendPopup(); dialog.close(); draftEpoch++; stagedCertificates = []; uploading = false; editing = null; revision = null; dirty = false; initialized = false; backendHealthEditorControl = null; poolTablePrefs = defaultPoolTablePrefs(); vhostListPrefs = defaultVhostListPrefs(); poolPreferenceSaveRunning = false; poolPreferenceSaveQueued = false; chartHistory.clear(); backendTrafficHistory.clear(); backendRequestHistory.clear(); vhostTrafficHistory.clear(); container.replaceChildren(); $("vhost-search").value = ""; if ($("pool-search")) $("pool-search").value = ""; $("vhost-list").replaceChildren(); $("pool-rows").replaceChildren(); const sort = $("pool-sort"); if (sort) sort.value = poolTablePrefs.sort; const vhostSort = $("vhost-sort"); if (vhostSort) vhostSort.value = vhostListPrefs.sort; syncVhostSortDirection(); applyPoolTableView(); } };
if (envelope) render(); if (latestStatus) renderStatus(latestStatus);
+1 -11
View File
@@ -1,6 +1,3 @@
// Location conditions editor and the routing tester. The pure helpers mirror
// src/config/snapshot.rs (select_route) and src/vhost/conditions.rs and are checked
// against the cases in tests/fixtures/routing_conditions_cases.json.
const RT_SOURCES = [["header", "rtSourceHeader"], ["cookie", "rtSourceCookie"], ["query", "rtSourceQuery"], ["method", "rtSourceMethod"], ["ip", "rtSourceIp"], ["host", "rtSourceHost"], ["country", "rtSourceCountry"]];
const RT_OPERATORS = [["equals", "rtOpEquals"], ["exists", "rtOpExists"], ["prefix", "rtOpPrefix"], ["suffix", "rtOpSuffix"], ["contains", "rtOpContains"], ["regex", "rtOpRegex"], ["cidr", "rtOpCidr"]];
function rtOperatorsFor(source) {
@@ -9,7 +6,6 @@ function rtOperatorsFor(source) {
if (source === "host") return ["equals", "prefix", "suffix", "contains", "regex"];
return ["equals", "exists", "prefix", "suffix", "contains", "regex"];
}
// Rust regex → JS RegExp (common subset; a leading (?i) becomes the i flag).
function rtRegex(pattern, insensitive = false) {
let flags = insensitive ? "i" : "", body = pattern;
const inline = body.match(/^\(\?([imsx]+)\)/);
@@ -33,7 +29,7 @@ function rtIpToBits(text) {
const all = [...left, ...Array(tail === undefined ? 0 : fill).fill("0"), ...right];
if (all.length !== 8 || all.some(h => !/^[0-9a-f]{1,4}$/i.test(h))) return null;
const bits = all.reduce((acc, h) => (acc << 16n) | BigInt(parseInt(h, 16)), 0n);
if (bits >> 32n === 0xffffn) return { v6: false, bits: bits & 0xffffffffn }; // IPv4-mapped, like canonical_ip()
if (bits >> 32n === 0xffffn) return { v6: false, bits: bits & 0xffffffffn };
return { v6: true, bits };
}
function rtCidrContains(network, ip) {
@@ -59,7 +55,6 @@ function rtConditionValues(condition, request) {
default: return [];
}
}
// Mirrors CompiledCondition::matches(). Throws for patterns the browser cannot run.
function rtConditionMatches(condition, request) {
const op = condition.operator || "equals", source = condition.source || "header";
const fold = (condition.ignore_case && ["header", "cookie", "query"].includes(source)) || source === "host";
@@ -82,7 +77,6 @@ function rtConditionMatches(condition, request) {
}
function rtNormalizePrefix(prefix) { let value = String(prefix || "/").trim(); if (!value.startsWith("/")) value = `/${value}`; if (value.length > 1) value = value.replace(/\/+$/, ""); return value || "/"; }
function rtPrefixMatches(prefix, path) { return prefix === "/" || path === prefix || path.startsWith(`${prefix}/`); }
// Evaluates every location like select_route() and returns the winner plus a trace.
function rtEvaluate(routes, request) {
const path = String(request.path || "/").replace(/%2f/gi, "/");
const trace = routes.map((route, index) => {
@@ -112,7 +106,6 @@ function rtEvaluate(routes, request) {
}
if (typeof window !== "undefined") window.rustProxyRoutingCore = { evaluate: rtEvaluate, conditionMatches: rtConditionMatches, cidrContains: rtCidrContains };
// Editor for a location's conditions. Returns read() → array of conditions.
function conditionsEditor(parent, values = [], onChange = () => { }) {
const box = el("div", undefined, "vh-wide rt-conditions"), list = el("div", undefined, "rt-condition-list"); box.append(list); parent.append(box);
const empty = text("p", "rtNoConditions", "fine rt-empty"); box.prepend(empty);
@@ -129,7 +122,6 @@ function conditionsEditor(parent, values = [], onChange = () => { }) {
const fillOperators = chosen => { operator.replaceChildren(...rtOperatorsFor(source.value).map(v => { const o = text("option", RT_OPERATORS.find(([x]) => x === v)[1]); o.value = v; return o; })); operator.value = rtOperatorsFor(source.value).includes(chosen) ? chosen : rtOperatorsFor(source.value)[0]; };
const syncRow = () => {
const named = ["header", "cookie", "query"].includes(source.value);
// .check labels set their own display, so the hidden attribute is not enough.
name.hidden = !named; ignoreLabel.hidden = !named; ignoreLabel.style.display = named ? "" : "none"; valuesInput.hidden = operator.value === "exists";
name.placeholder = { header: "X-Beta", cookie: "session", query: "tenant" }[source.value] || "";
valuesInput.placeholder = { ip: "10.0.0.0/8\n2001:db8::/32", method: "POST\nPUT", country: "PL\nDE", host: "beta.example.com" }[source.value] || t("rtValuesPlaceholder");
@@ -153,7 +145,6 @@ function conditionsEditor(parent, values = [], onChange = () => { }) {
return { read: () => [...list.children].map(row => row.read()), count: () => list.children.length };
}
// Routing tester for the Locations tab: works on the unsaved draft.
function routingTester(parent, readRoutes) {
const box = el("details", undefined, "vh-wide rt-tester"); box.append(text("summary", "rtTester")); parent.append(box);
const body = el("div", undefined, "rt-tester-body"); box.append(body);
@@ -196,7 +187,6 @@ function routingTester(parent, readRoutes) {
}
out.append(table, text("p", "rtTesterHelp", "fine"));
};
// Backend for the chosen route: pinned backend, group or vhost pool + algorithm.
const rtTarget = (route, request) => {
if (route && (route.response || route.redirect)) return t(route.response ? "locationReturnShort" : "locationRedirectShort");
if (route?.source?.type === "web_server") return `${t("locationWebServerShort")} ${route.source.web_service_id || ""}`;
-3
View File
@@ -1,7 +1,4 @@
"use strict";
// A local redirect or response terminates in RustProxy and never connects to an
// upstream. Disabled custom locations do not create a live backend dependency.
// Keep these checks aligned with Vhost::validate and config/routing.rs.
function locationRequiresProxy(route) {
return route.enabled !== false
&& !route.response