v0.42.3
This commit is contained in:
1 parent
a75893d428
commit
bfbeedfad7
43 files changed
+5834
-125
No files matched your search
@@ -11,10 +11,12 @@
|
||||
const syncEnabledControl = window.rustProxyEnableControl($("notfound-enabled"));
|
||||
const ERROR_STATUSES = [400, 401, 403, 404, 408, 413, 429, 500, 502, 503, 504];
|
||||
const BUILTIN_STATUSES = [401, 403, 404, 429, 503, 504];
|
||||
const STATUS_NAMES = { 400: "Bad Request", 401: "Unauthorized", 403: "Forbidden", 404: "Not Found", 408: "Request Timeout", 413: "Payload Too Large", 429: "Too Many Requests", 500: "Internal Server Error", 502: "Bad Gateway", 503: "Service Unavailable", 504: "Gateway Timeout" };
|
||||
const CLOUDFLARE_STATUSES = [400, 401, 403, 404, 408, 410, 413, 429, 500, 502, 503, 504];
|
||||
const STATUS_NAMES = { 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" };
|
||||
function populateStatuses(selected = null) {
|
||||
const select = $("notfound-status"); if (!select) return;
|
||||
const codes = $("notfound-mode")?.value === "builtin" ? BUILTIN_STATUSES : ERROR_STATUSES;
|
||||
const kind = $("notfound-mode")?.value;
|
||||
const codes = kind === "builtin" ? BUILTIN_STATUSES : kind === "cloudflare" ? CLOUDFLARE_STATUSES : ERROR_STATUSES;
|
||||
const wanted = Number(selected ?? select.value ?? 404);
|
||||
select.replaceChildren(...codes.map(code => { const node = el("option", `${code} ${STATUS_NAMES[code]}`); node.value = String(code); return node; }));
|
||||
select.value = codes.includes(wanted) ? String(wanted) : "404";
|
||||
@@ -69,7 +71,7 @@
|
||||
function collect() {
|
||||
const id = value("notfound-id"), name = value("notfound-name") || id, hosts = readHosts(), listener_ids = readBindings(), kind = value("notfound-mode"), status = Number(value("notfound-status")), html = $("notfound-html").value;
|
||||
if (!listener_ids.length) throw new Error(t("notfoundListenersRequired"));
|
||||
const allowed = kind === "builtin" ? BUILTIN_STATUSES : ERROR_STATUSES;
|
||||
const allowed = kind === "builtin" ? BUILTIN_STATUSES : kind === "cloudflare" ? CLOUDFLARE_STATUSES : ERROR_STATUSES;
|
||||
if (!Number.isInteger(status) || !allowed.includes(status)) throw new Error(t("notfoundStatusInvalid"));
|
||||
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 : "" } };
|
||||
|
||||
Reference in new issue
Block a user