|
@@ -1,17 +1,32 @@
|
|
|
import { describe, expect, it } from 'vitest';
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
|
|
|
|
import {
|
|
import {
|
|
|
|
|
+ createDefaultHttpInboundSettings,
|
|
|
|
|
+ createDefaultHysteria2InboundSettings,
|
|
|
createDefaultHysteriaClient,
|
|
createDefaultHysteriaClient,
|
|
|
|
|
+ createDefaultHysteriaInboundSettings,
|
|
|
|
|
+ createDefaultMixedInboundSettings,
|
|
|
createDefaultShadowsocksClient,
|
|
createDefaultShadowsocksClient,
|
|
|
|
|
+ createDefaultShadowsocksInboundSettings,
|
|
|
createDefaultTrojanClient,
|
|
createDefaultTrojanClient,
|
|
|
|
|
+ createDefaultTrojanInboundSettings,
|
|
|
|
|
+ createDefaultTunnelInboundSettings,
|
|
|
createDefaultVlessClient,
|
|
createDefaultVlessClient,
|
|
|
|
|
+ createDefaultVlessInboundSettings,
|
|
|
createDefaultVmessClient,
|
|
createDefaultVmessClient,
|
|
|
|
|
+ createDefaultVmessInboundSettings,
|
|
|
|
|
+ createDefaultWireguardInboundSettings,
|
|
|
} from '@/lib/xray/inbound-defaults';
|
|
} from '@/lib/xray/inbound-defaults';
|
|
|
-import { HysteriaClientSchema } from '@/schemas/protocols/inbound/hysteria';
|
|
|
|
|
-import { ShadowsocksClientSchema } from '@/schemas/protocols/inbound/shadowsocks';
|
|
|
|
|
-import { TrojanClientSchema } from '@/schemas/protocols/inbound/trojan';
|
|
|
|
|
-import { VlessClientSchema } from '@/schemas/protocols/inbound/vless';
|
|
|
|
|
-import { VmessClientSchema } from '@/schemas/protocols/inbound/vmess';
|
|
|
|
|
|
|
+import { HttpInboundSettingsSchema } from '@/schemas/protocols/inbound/http';
|
|
|
|
|
+import { Hysteria2InboundSettingsSchema } from '@/schemas/protocols/inbound/hysteria2';
|
|
|
|
|
+import { HysteriaClientSchema, HysteriaInboundSettingsSchema } from '@/schemas/protocols/inbound/hysteria';
|
|
|
|
|
+import { MixedInboundSettingsSchema } from '@/schemas/protocols/inbound/mixed';
|
|
|
|
|
+import { ShadowsocksClientSchema, ShadowsocksInboundSettingsSchema } from '@/schemas/protocols/inbound/shadowsocks';
|
|
|
|
|
+import { TrojanClientSchema, TrojanInboundSettingsSchema } from '@/schemas/protocols/inbound/trojan';
|
|
|
|
|
+import { TunnelInboundSettingsSchema } from '@/schemas/protocols/inbound/tunnel';
|
|
|
|
|
+import { VlessClientSchema, VlessInboundSettingsSchema } from '@/schemas/protocols/inbound/vless';
|
|
|
|
|
+import { VmessClientSchema, VmessInboundSettingsSchema } from '@/schemas/protocols/inbound/vmess';
|
|
|
|
|
+import { WireguardInboundSettingsSchema } from '@/schemas/protocols/inbound/wireguard';
|
|
|
|
|
|
|
|
// Tests pass explicit seeds for every random field so the assertions don't
|
|
// Tests pass explicit seeds for every random field so the assertions don't
|
|
|
// depend on window.crypto (the node test env has no crypto.randomUUID).
|
|
// depend on window.crypto (the node test env has no crypto.randomUUID).
|
|
@@ -65,3 +80,67 @@ describe('createDefaultHysteriaClient', () => {
|
|
|
expect(HysteriaClientSchema.parse(c)).toEqual(c);
|
|
expect(HysteriaClientSchema.parse(c)).toEqual(c);
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+describe('createDefault*InboundSettings factories', () => {
|
|
|
|
|
+ it('vless', () => {
|
|
|
|
|
+ const s = createDefaultVlessInboundSettings();
|
|
|
|
|
+ expect(s).toMatchSnapshot();
|
|
|
|
|
+ expect(VlessInboundSettingsSchema.parse(s)).toEqual(s);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('vmess', () => {
|
|
|
|
|
+ const s = createDefaultVmessInboundSettings();
|
|
|
|
|
+ expect(s).toMatchSnapshot();
|
|
|
|
|
+ expect(VmessInboundSettingsSchema.parse(s)).toEqual(s);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('trojan', () => {
|
|
|
|
|
+ const s = createDefaultTrojanInboundSettings();
|
|
|
|
|
+ expect(s).toMatchSnapshot();
|
|
|
|
|
+ expect(TrojanInboundSettingsSchema.parse(s)).toEqual(s);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('shadowsocks', () => {
|
|
|
|
|
+ const s = createDefaultShadowsocksInboundSettings({ password: 'ZmFrZS1zcy1zZWVk' });
|
|
|
|
|
+ expect(s).toMatchSnapshot();
|
|
|
|
|
+ expect(ShadowsocksInboundSettingsSchema.parse(s)).toEqual(s);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('hysteria (v1, defaults to v2 wire version)', () => {
|
|
|
|
|
+ const s = createDefaultHysteriaInboundSettings();
|
|
|
|
|
+ expect(s).toMatchSnapshot();
|
|
|
|
|
+ expect(HysteriaInboundSettingsSchema.parse(s)).toEqual(s);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('hysteria2', () => {
|
|
|
|
|
+ const s = createDefaultHysteria2InboundSettings();
|
|
|
|
|
+ expect(s).toMatchSnapshot();
|
|
|
|
|
+ expect(Hysteria2InboundSettingsSchema.parse(s)).toEqual(s);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('http', () => {
|
|
|
|
|
+ const s = createDefaultHttpInboundSettings();
|
|
|
|
|
+ expect(s).toMatchSnapshot();
|
|
|
|
|
+ expect(HttpInboundSettingsSchema.parse(s)).toEqual(s);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('mixed', () => {
|
|
|
|
|
+ const s = createDefaultMixedInboundSettings();
|
|
|
|
|
+ expect(s).toMatchSnapshot();
|
|
|
|
|
+ expect(MixedInboundSettingsSchema.parse(s)).toEqual(s);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('tunnel', () => {
|
|
|
|
|
+ const s = createDefaultTunnelInboundSettings();
|
|
|
|
|
+ expect(s).toMatchSnapshot();
|
|
|
|
|
+ expect(TunnelInboundSettingsSchema.parse(s)).toEqual(s);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('wireguard', () => {
|
|
|
|
|
+ const s = createDefaultWireguardInboundSettings({
|
|
|
|
|
+ secretKey: 'QGVlb2dXc1ZTWGw0ZXBzZndsWmtMaUM5MUlNYjBHWFdYbz0=',
|
|
|
|
|
+ });
|
|
|
|
|
+ expect(s).toMatchSnapshot();
|
|
|
|
|
+ expect(WireguardInboundSettingsSchema.parse(s)).toEqual(s);
|
|
|
|
|
+ });
|
|
|
|
|
+});
|