mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-03 03:35:04 +03:00
feat(sub): export TLS cipher suites as the cs query param in share links (#6825)
Hosts and TLS inbounds can set cipher suites, but they reached only the JSON and Clash subscriptions; raw share links never carried them, so clients that read cs from links (v2rayNG forks used with fp=unsafe) had to enter them by hand. Share links now emit cs from the host or inbound TLS settings, the panel's own link generator and previews do the same, and both link parsers (the Go one and the panel's outbound import) read cs back into tlsSettings.cipherSuites.
This commit is contained in:
@@ -16,6 +16,7 @@ describe('hostToExternalProxyEntry', () => {
|
||||
pinnedPeerCertSha256: ['AAAA'],
|
||||
verifyPeerCertByName: 'verify.example.com',
|
||||
echConfigList: 'ECH',
|
||||
cipherSuites: 'TLS_AES_128_GCM_SHA256',
|
||||
overrideSniFromAddress: false,
|
||||
keepSniBlank: false,
|
||||
vlessRoute: '',
|
||||
@@ -34,6 +35,7 @@ describe('hostToExternalProxyEntry', () => {
|
||||
expect(ep.pinnedPeerCertSha256).toEqual(['AAAA']);
|
||||
expect(ep.verifyPeerCertByName).toBe('verify.example.com');
|
||||
expect(ep.echConfigList).toBe('ECH');
|
||||
expect(ep.cipherSuites).toBe('TLS_AES_128_GCM_SHA256');
|
||||
});
|
||||
|
||||
it('maps reality/same security to forceTls "same"', () => {
|
||||
|
||||
@@ -1496,4 +1496,31 @@ describe('isPostQuantumLink', () => {
|
||||
});
|
||||
expect(isPostQuantumLink(link)).toBe(true);
|
||||
});
|
||||
|
||||
it('exports cipherSuites as cs query parameter on VLESS TLS links', () => {
|
||||
const [, rawFixture] = fixturesForProtocol('vless')[0];
|
||||
const stream = rawFixture.streamSettings as Record<string, unknown> | undefined;
|
||||
const tls = stream?.tlsSettings as Record<string, unknown> | undefined;
|
||||
const typed = InboundSchema.parse({
|
||||
...rawFixture,
|
||||
streamSettings: {
|
||||
...stream,
|
||||
security: 'tls',
|
||||
tlsSettings: {
|
||||
...tls,
|
||||
cipherSuites: 'TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const link = genVlessLink({
|
||||
inbound: typed,
|
||||
address: 'example.test',
|
||||
port: 443,
|
||||
clientId: '11111111-2222-3333-4444-555555555555',
|
||||
});
|
||||
expect(new URL(link).searchParams.get('cs')).toBe(
|
||||
'TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -75,6 +75,7 @@ describe('parseVmessLink', () => {
|
||||
ech: 'AEX+DQBB',
|
||||
vcn: 'vcn.example.com',
|
||||
pcs: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=',
|
||||
cs: 'TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256',
|
||||
};
|
||||
const link = `vmess://${Base64.encode(JSON.stringify(json))}`;
|
||||
const out = parseVmessLink(link);
|
||||
@@ -82,6 +83,7 @@ describe('parseVmessLink', () => {
|
||||
const stream = out?.streamSettings as Record<string, unknown>;
|
||||
const tls = stream.tlsSettings as Record<string, unknown>;
|
||||
expect(tls.echConfigList).toBe('AEX+DQBB');
|
||||
expect(tls.cipherSuites).toBe('TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256');
|
||||
expect(tls.verifyPeerCertByName).toBe('vcn.example.com');
|
||||
expect(tls.pinnedPeerCertSha256).toBe('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=');
|
||||
});
|
||||
@@ -428,6 +430,15 @@ describe('parseTrojanLink', () => {
|
||||
expect(stream.network).toBe('ws');
|
||||
expect((stream.wsSettings as Record<string, unknown>).path).toBe('/tj');
|
||||
});
|
||||
|
||||
it('reads the cs cipher suites into tlsSettings, as the Go link parser does', () => {
|
||||
const out = parseTrojanLink(
|
||||
'trojan://pw@srv.example:443?type=tcp&security=tls&sni=srv.example&fp=unsafe&cs=TLS_AES_256_GCM_SHA384#cs',
|
||||
);
|
||||
const stream = out!.streamSettings as Record<string, unknown>;
|
||||
const tls = stream.tlsSettings as Record<string, unknown>;
|
||||
expect(tls.cipherSuites).toBe('TLS_AES_256_GCM_SHA384');
|
||||
});
|
||||
});
|
||||
|
||||
describe('parseShadowsocksLink', () => {
|
||||
|
||||
Reference in New Issue
Block a user