3x-ui/frontend/src/schemas/protocols/stream/httpupgrade.ts
MHSanaei 9721dae2b6
feat(frontend): stream and security Zod families with discriminated unions
Stand up the remaining Step 2 families. NetworkSettingsSchema is a
6-branch DU on `network` covering tcp/kcp/ws/grpc/httpupgrade/xhttp, with
asymmetric per-network wire keys (tcpSettings, wsSettings, ...) preserved
exactly so fixtures round-trip byte-identical. SecuritySettingsSchema is a
3-branch DU on `security` covering none/tls/reality. TLS certs use a
file-vs-inline union; uTLS fingerprints are shared between TLS and Reality
via a single primitive enum.

Hysteria-as-network, finalmask, and sockopt are not in the plan's Step 2
inventory and are deferred to Step 6 (Tighten) - they're orthogonal extras
on the stream root, not network-discriminated branches.

Resolves a Security identifier collision in protocols/index.ts by
re-exporting the type alias as SecurityKind (the `Security` name is taken
by the namespace re-export).
2026-05-25 23:13:29 +02:00

14 lines
581 B
TypeScript

import { z } from 'zod';
import { WsHeaderMapSchema } from '@/schemas/protocols/stream/ws';
// HTTP Upgrade transport reuses the flat WS-style header map (string values,
// not arrays — toV2Headers with arr=false). No heartbeat field — that's
// websocket-specific.
export const HttpUpgradeStreamSettingsSchema = z.object({
acceptProxyProtocol: z.boolean().default(false),
path: z.string().default('/'),
host: z.string().default(''),
headers: WsHeaderMapSchema.default({}),
});
export type HttpUpgradeStreamSettings = z.infer<typeof HttpUpgradeStreamSettingsSchema>;