mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-28 00:24:19 +00:00
bd60e770f4
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.
27 lines
1018 B
TypeScript
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>;
|