fix: keep Hysteria UDP 443 beside Caddy

This commit is contained in:
Codex
2026-07-15 10:58:41 +02:00
parent 7511a73ce3
commit 4fa0c4fe70
2 changed files with 12 additions and 1 deletions
+3
View File
@@ -357,6 +357,9 @@ publicEdge:
containerName: pikaoa-edge
httpPort: 80
httpsPort: 443
protocols:
- h1
- h2
responseHeaderTimeoutSeconds: 60
sites:
production:
+9 -1
View File
@@ -37,6 +37,7 @@ interface EdgeSpec {
containerName: string;
httpPort: number;
httpsPort: number;
protocols: string[];
responseHeaderTimeoutSeconds: number;
};
sites: EdgeSite[];
@@ -132,6 +133,7 @@ function readSpec(path: string): EdgeSpec {
containerName: string(caddy.containerName, "publicEdge.caddy.containerName"),
httpPort: integer(caddy.httpPort, "publicEdge.caddy.httpPort"),
httpsPort: integer(caddy.httpsPort, "publicEdge.caddy.httpsPort"),
protocols: stringList(caddy.protocols, "publicEdge.caddy.protocols"),
responseHeaderTimeoutSeconds: integer(caddy.responseHeaderTimeoutSeconds, "publicEdge.caddy.responseHeaderTimeoutSeconds"),
},
sites: Object.entries(sites).map(([id, value]) => {
@@ -329,7 +331,8 @@ PY
}
function renderCaddyfile(spec: EdgeSpec): string {
return spec.sites.map((site) => `${site.hostname} {\n reverse_proxy ${site.upstream} {\n transport http {\n response_header_timeout ${spec.caddy.responseHeaderTimeoutSeconds}s\n }\n }\n}`).join("\n\n") + "\n";
const global = `{\n servers {\n protocols ${spec.caddy.protocols.join(" ")}\n }\n}\n`;
return global + spec.sites.map((site) => `${site.hostname} {\n reverse_proxy ${site.upstream} {\n transport http {\n response_header_timeout ${spec.caddy.responseHeaderTimeoutSeconds}s\n }\n }\n}`).join("\n\n") + "\n";
}
function renderCompose(spec: EdgeSpec): string {
@@ -356,6 +359,11 @@ function boolean(value: unknown, path: string): boolean {
return value;
}
function stringList(value: unknown, path: string): string[] {
if (!Array.isArray(value) || value.length === 0) throw inputError(`${path} 必须是非空字符串数组`, "invalid-config", path);
return value.map((item, index) => string(item, `${path}[${index}]`));
}
function hostname(value: unknown, path: string): string {
const result = string(value, path);
if (!/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/u.test(result)) throw inputError(`${path} hostname`, "invalid-config", path);