Files
mirror-3x-ui/frontend/src/test/host-link.test.ts
T
MHSanaei 7c8889466b feat(tls,reality): port xray TLS/REALITY fields, cert-hash helpers, fallback UX
TLS: add verifyPeerCertByName (vcn) to inbound settings + emit in both share-link generators (frontend + Go sub) and outbound parser; the allowInsecure replacement xray removed after 2026-06-01. Add server-side curvePreferences, masterKeyLog, echSockopt (passthrough + form) at tlsSettings top-level so they survive the panel-only settings strip.

REALITY: add limitFallbackUpload/Download (afterBytes/bytesPerSec/burstBytesPerSec) with per-field tooltips, plus masterKeyLog. Verified field names/semantics against pinned xray v1.260327.1 (bytesPerSec=0 disables).

Hosts: fix verify_peer_cert_by_name column bool->string (xray expects comma-separated names) with an idempotent, history-gate-free migration (SQLite typeof blank; Postgres ALTER once); emit vcn for hosts/external proxies.

Server: add getCertHash (local cert DER SHA-256) and getRemoteCertHash (xray tls ping) endpoints + api-docs; wire pinned-cert field buttons. Drop the meaningless random-hash button.

Xray UI: metrics endpoint (listen/tag) config in Basics; import/export for routing rules and outbounds.

Fallbacks card: compact empty state, header-aligned actions, responsive labeled grid rows.

i18n: add all new keys to every locale; drop unused generateRandomPin.
2026-06-21 15:58:42 +02:00

57 lines
2.0 KiB
TypeScript

/// <reference types="vite/client" />
import { describe, expect, it } from 'vitest';
import { hostToExternalProxyEntry } from '@/lib/hosts/host-link';
describe('hostToExternalProxyEntry', () => {
const base = {
security: 'tls' as const,
address: 'cdn.example.com',
port: 8443,
remark: 'R',
sni: 'sni.example.com',
alpn: ['h2'] as ('h2' | 'h3' | 'http/1.1')[],
fingerprint: 'chrome' as const,
pinnedPeerCertSha256: ['AAAA'],
verifyPeerCertByName: 'verify.example.com',
echConfigList: 'ECH',
overrideSniFromAddress: false,
keepSniBlank: false,
};
it('maps the overlapping fields onto an external-proxy entry', () => {
const ep = hostToExternalProxyEntry(base);
expect(ep.forceTls).toBe('tls');
expect(ep.dest).toBe('cdn.example.com');
expect(ep.port).toBe(8443);
expect(ep.remark).toBe('R');
expect(ep.sni).toBe('sni.example.com');
expect(ep.alpn).toEqual(['h2']);
expect(ep.fingerprint).toBe('chrome');
expect(ep.pinnedPeerCertSha256).toEqual(['AAAA']);
expect(ep.verifyPeerCertByName).toBe('verify.example.com');
expect(ep.echConfigList).toBe('ECH');
});
it('maps reality/same security to forceTls "same"', () => {
expect(hostToExternalProxyEntry({ ...base, security: 'reality' }).forceTls).toBe('same');
expect(hostToExternalProxyEntry({ ...base, security: 'same' }).forceTls).toBe('same');
expect(hostToExternalProxyEntry({ ...base, security: 'none' }).forceTls).toBe('none');
});
it('uses the address as sni when overrideSniFromAddress is set', () => {
const ep = hostToExternalProxyEntry({ ...base, overrideSniFromAddress: true });
expect(ep.sni).toBe('cdn.example.com');
});
it('omits sni when keepSniBlank is set', () => {
const ep = hostToExternalProxyEntry({ ...base, keepSniBlank: true });
expect(ep.sni).toBeUndefined();
});
it('falls back to port 443 when the host port is 0 (inherit)', () => {
const ep = hostToExternalProxyEntry({ ...base, port: 0 });
expect(ep.port).toBe(443);
});
});