mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-07-14 00:26:06 +00:00
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.
This commit is contained in:
@@ -175,6 +175,29 @@ describe('outbound-form-adapter: round-trip', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('http preserves top-level settings.headers across wire → form → wire (#5519)', () => {
|
||||
const headers = { 'X-T5-Auth': '683556433', Host: '153.3.236.22:443' };
|
||||
const form = rawOutboundToFormValues({
|
||||
protocol: 'http',
|
||||
tag: 'h',
|
||||
settings: { servers: [{ address: 'a', port: 443, users: [] }], headers },
|
||||
});
|
||||
expect(form.protocol).toBe('http');
|
||||
if (form.protocol === 'http') {
|
||||
expect(form.settings.headers).toEqual(headers);
|
||||
}
|
||||
const back = formValuesToWirePayload(form);
|
||||
expect(back.settings).toMatchObject({ headers });
|
||||
});
|
||||
|
||||
it('http omits headers when empty', () => {
|
||||
const back = formValuesToWirePayload(rawOutboundToFormValues({
|
||||
protocol: 'http',
|
||||
settings: { servers: [{ address: 'a', port: 8080, users: [] }] },
|
||||
}));
|
||||
expect(back.settings).not.toHaveProperty('headers');
|
||||
});
|
||||
|
||||
it('wireguard csv-joins address and reserved on read, splits on write', () => {
|
||||
const wire = {
|
||||
protocol: 'wireguard',
|
||||
|
||||
Reference in New Issue
Block a user