fix(schemas): accept boolean acceptProxyProtocol on TCP stream

TcpStreamSettingsSchema declared `acceptProxyProtocol: z.literal(true).optional()`,
so saving an inbound where the AntD Switch sat in the off state failed
validation with `Invalid input` because the Switch always emits a plain
boolean.

Switch to `z.boolean().default(false)` — same shape ws/sockopt/httpupgrade
already use, and matches the actual wire payload (golden fixtures and
other settings blocks all store `acceptProxyProtocol: false`).

Snapshots for stream.test and inbound-full.test pick up the new defaulted
field on TCP fixtures.
This commit is contained in:
MHSanaei 2026-05-27 22:47:31 +02:00
parent cfec48afec
commit 01d9753564
No known key found for this signature in database
GPG key ID: 7E4060F2FBE5AB7A
3 changed files with 10 additions and 5 deletions

View file

@ -38,10 +38,8 @@ export const TcpHeaderSchema = z.discriminatedUnion('type', [
]);
export type TcpHeader = z.infer<typeof TcpHeaderSchema>;
// Top-level TCP stream payload. `acceptProxyProtocol` only appears on the
// wire when true (panel omits it when false), so we treat it as optional.
export const TcpStreamSettingsSchema = z.object({
acceptProxyProtocol: z.literal(true).optional(),
acceptProxyProtocol: z.boolean().default(false),
header: TcpHeaderSchema.optional(),
});
export type TcpStreamSettings = z.infer<typeof TcpStreamSettingsSchema>;

View file

@ -43,7 +43,9 @@ exports[`InboundSchema (full) fixtures > parses hysteria-v1-tls byte-stably 1`]
"streamSettings": {
"network": "tcp",
"security": "tls",
"tcpSettings": {},
"tcpSettings": {
"acceptProxyProtocol": false,
},
"tlsSettings": {
"alpn": [
"h3",
@ -125,6 +127,7 @@ exports[`InboundSchema (full) fixtures > parses shadowsocks-tcp-2022 byte-stably
"network": "tcp",
"security": "none",
"tcpSettings": {
"acceptProxyProtocol": false,
"header": {
"type": "none",
},
@ -292,6 +295,7 @@ exports[`InboundSchema (full) fixtures > parses vless-tcp-reality byte-stably 1`
},
"security": "reality",
"tcpSettings": {
"acceptProxyProtocol": false,
"header": {
"type": "none",
},
@ -434,6 +438,7 @@ exports[`InboundSchema (full) fixtures > parses vmess-tcp-tls byte-stably 1`] =
"network": "tcp",
"security": "tls",
"tcpSettings": {
"acceptProxyProtocol": false,
"header": {
"type": "none",
},

View file

@ -14,7 +14,9 @@ exports[`NetworkSettingsSchema fixtures > parses grpc-basic byte-stably 1`] = `
exports[`NetworkSettingsSchema fixtures > parses tcp-none byte-stably 1`] = `
{
"network": "tcp",
"tcpSettings": {},
"tcpSettings": {
"acceptProxyProtocol": false,
},
}
`;