Files
mirror-3x-ui/frontend/src/test/stream.test.ts
T
MHSanaei 61b129d5b3 feat(xray): update xray-core to v26.10.21 and adapt panel
Bump xtls/xray-core to 1b1647cd9ddf (v26.10.21) and move the three
binary pins (DockerInit.sh, both release.yml fetches) in lockstep. The
v26.10.10 release was pulled upstream, so the old pins already 404.

XDRIVE (#7182): the core now runs XDRIVE only for VLESS inside VLESS
encryption, with no flow, and an outbound only over Mux; it refuses the
whole config otherwise. The panel offers XDRIVE only for VLESS, refuses
to save an inbound without decryption, never emits a client flow on an
XDRIVE stream (config, JSON subscription, forms), and turns Mux on when
an outbound picks XDRIVE. An inbound or template outbound stored before
the upgrade that the core would refuse is left out of the generated
config with a warning, so it no longer stops every other inbound. The
service "Google Drive" is now "google-drive" (old name read as a
deprecated alias); saves, the schema and both form adapters store the
new name. XDRIVE and MASQUE gain a client xmux; both schemas keep it
instead of stripping it on an inbound save.

Lua scripts (#7124, #7136): the core refuses a routing script beside
rules or domainStrategy, and a dns script beside the fallback/parallel
switches or a domain-scoped server. The panel always keeps its api
routing rule, so a template save now refuses any routing script and a
dns script in a refused combination, and a stored one is dropped from
the generated config so the core still starts. Noise masks gain a Lua
script that the loader compiles inside Build: the in-process build
(template save check, hot add) now resolves a relative script the way
the xray child does, beside the xray binary, instead of failing it. The
mask editor gets a Script field that replaces the noise list.

XDNS (#7140): a resolver takes https:// DoH addresses with worker,
tlsConfig and quicConfig. The mask editor registered only addrs, so a
save dropped the rest; it now edits all four.

Finalmask filter (#7206): a new TCP/UDP mask screens an inbound's source
IPs. The inbound mask editor offers it with its allow and block lists;
it is a no-op on a dialer and an older client core refuses the type, so
the share link and JSON subscription drop it like the Go link already
does.
2026-10-22 17:10:11 +02:00

73 lines
2.7 KiB
TypeScript

/// <reference types="vite/client" />
import { describe, expect, it } from 'vitest';
import { NetworkSettingsSchema } from '@/schemas/protocols';
const streamFixtures = import.meta.glob<unknown>('./golden/fixtures/stream/*.json', {
eager: true,
import: 'default',
});
function fixtureName(path: string): string {
const file = path.split('/').pop() ?? path;
return file.replace(/\.json$/, '');
}
describe('NetworkSettingsSchema fixtures', () => {
const entries = Object.entries(streamFixtures).sort(([a], [b]) => a.localeCompare(b));
expect(
entries.length,
'expected at least one fixture under golden/fixtures/stream',
).toBeGreaterThan(0);
for (const [path, raw] of entries) {
it(`parses ${fixtureName(path)} byte-stably`, () => {
const parsed = NetworkSettingsSchema.parse(raw);
expect(parsed).toMatchSnapshot();
});
}
});
describe('NetworkSettingsSchema method alias', () => {
it('folds xray-core v26.7.11 method alias back into network', () => {
const parsed = NetworkSettingsSchema.parse({ method: 'ws', wsSettings: {} });
expect((parsed as { network?: string }).network).toBe('ws');
expect((parsed as Record<string, unknown>).method).toBeUndefined();
});
it('prefers method over network when both are present', () => {
const parsed = NetworkSettingsSchema.parse({
method: 'grpc',
network: 'tcp',
grpcSettings: {},
});
expect((parsed as { network?: string }).network).toBe('grpc');
});
});
// xray-core 26.10.17 (#7182) renamed the XDRIVE service, reading "Google Drive" only as an alias.
// XDRIVE's and MASQUE's xmux are client keys a JSON subscription hands on from the inbound.
describe('NetworkSettingsSchema xray-core 26.10.21 keys', () => {
it('folds the "Google Drive" service into google-drive', () => {
const parsed = NetworkSettingsSchema.parse({
network: 'xdrive',
xdriveSettings: { service: 'Google Drive', remoteFolder: 'f', secrets: ['a', 'b', 'c'] },
}) as { xdriveSettings: { service: string } };
expect(parsed.xdriveSettings.service).toBe('google-drive');
});
it('keeps the XDRIVE and MASQUE xmux', () => {
const xmux = { maxConnections: 2, hMaxReusableSecs: '1800-3000' };
const xdrive = NetworkSettingsSchema.parse({
network: 'xdrive',
xdriveSettings: { service: 'local', remoteFolder: '/srv/drive', xmux },
}) as { xdriveSettings: { xmux?: unknown } };
const masque = NetworkSettingsSchema.parse({
network: 'masque',
masqueSettings: { host: 'masque.example.com', xmux },
}) as { masqueSettings: { xmux?: unknown } };
expect(xdrive.xdriveSettings.xmux).toEqual(xmux);
expect(masque.masqueSettings.xmux).toEqual(xmux);
});
});