Files
3x-ui/frontend/src/schemas/protocols/outbound/http.ts
T
MHSanaei bd60e770f4 fix(outbound): preserve custom headers for HTTP outbounds (#5519)
The Outbounds form routed HTTP through the SOCKS-shared simpleAuth adapter, which only knew address/port/user/pass, so xray's top-level settings.headers was dropped on both load and save. Opening and re-saving an HTTP outbound destroyed its headers.

Add headers to the HTTP wire/form schemas, round-trip it via dedicated httpFromWire/httpToWire helpers, and expose a HeaderMapEditor in the form. Only settings-level headers round-trip; xray-core ignores per-server headers.
2026-06-24 14:22:25 +02:00

27 lines
1018 B
TypeScript

import { z } from 'zod';
import { PortSchema } from '@/schemas/primitives';
// HTTP outbound persists in Xray's `servers[].users[]` shape. The panel only
// supports a single server with at most one user (the constructor reads
// servers[0] / users[0]). We model the wire shape rather than the panel's
// flattened class fields so saves round-trip exactly.
export const HttpOutboundUserSchema = z.object({
user: z.string().min(1),
pass: z.string().min(1),
});
export type HttpOutboundUser = z.infer<typeof HttpOutboundUserSchema>;
export const HttpOutboundServerSchema = z.object({
address: z.string().min(1),
port: PortSchema,
users: z.array(HttpOutboundUserSchema).default([]),
});
export type HttpOutboundServer = z.infer<typeof HttpOutboundServerSchema>;
export const HttpOutboundSettingsSchema = z.object({
servers: z.array(HttpOutboundServerSchema).min(1),
headers: z.record(z.string(), z.string()).optional(),
});
export type HttpOutboundSettings = z.infer<typeof HttpOutboundSettingsSchema>;