mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-02 19:25:05 +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:
@@ -18,6 +18,7 @@ export type HostLinkInput = Pick<
|
||||
| 'pinnedPeerCertSha256'
|
||||
| 'verifyPeerCertByName'
|
||||
| 'echConfigList'
|
||||
| 'cipherSuites'
|
||||
| 'overrideSniFromAddress'
|
||||
| 'keepSniBlank'
|
||||
| 'vlessRoute'
|
||||
@@ -55,6 +56,7 @@ export function hostToExternalProxyEntry(host: HostLinkInput): ExternalProxyEntr
|
||||
: undefined,
|
||||
verifyPeerCertByName: host.verifyPeerCertByName || undefined,
|
||||
echConfigList: host.echConfigList || undefined,
|
||||
cipherSuites: host.cipherSuites || undefined,
|
||||
vlessRoute: host.vlessRoute || undefined,
|
||||
allowInsecure: host.allowInsecure || undefined,
|
||||
};
|
||||
|
||||
@@ -235,6 +235,8 @@ function applyExternalProxyTLSObj(
|
||||
}
|
||||
if (externalProxy.echConfigList && externalProxy.echConfigList.length > 0)
|
||||
obj.ech = externalProxy.echConfigList;
|
||||
if (externalProxy.cipherSuites && externalProxy.cipherSuites.length > 0)
|
||||
obj.cs = externalProxy.cipherSuites;
|
||||
}
|
||||
|
||||
export interface GenVmessLinkInput {
|
||||
@@ -337,6 +339,9 @@ export function genVmessLink(input: GenVmessLinkInput): string {
|
||||
if (tlsSettings.settings.pinnedPeerCertSha256.length > 0) {
|
||||
obj.pcs = tlsSettings.settings.pinnedPeerCertSha256.join(',');
|
||||
}
|
||||
if (tlsSettings.cipherSuites && tlsSettings.cipherSuites.length > 0) {
|
||||
obj.cs = tlsSettings.cipherSuites;
|
||||
}
|
||||
}
|
||||
|
||||
applyExternalProxyTLSObj(externalProxy, obj, tls);
|
||||
@@ -394,6 +399,8 @@ function applyExternalProxyTLSParams(
|
||||
}
|
||||
if (externalProxy.echConfigList && externalProxy.echConfigList.length > 0)
|
||||
params.set('ech', externalProxy.echConfigList);
|
||||
if (externalProxy.cipherSuites && externalProxy.cipherSuites.length > 0)
|
||||
params.set('cs', externalProxy.cipherSuites);
|
||||
}
|
||||
|
||||
export interface GenVlessLinkInput {
|
||||
@@ -497,6 +504,9 @@ export function genVlessLink(input: GenVlessLinkInput): string {
|
||||
if (tls.settings.pinnedPeerCertSha256.length > 0) {
|
||||
params.set('pcs', tls.settings.pinnedPeerCertSha256.join(','));
|
||||
}
|
||||
if (tls.cipherSuites && tls.cipherSuites.length > 0) {
|
||||
params.set('cs', tls.cipherSuites);
|
||||
}
|
||||
}
|
||||
applyExternalProxyTLSParams(externalProxy, params, security);
|
||||
} else if (security === 'reality') {
|
||||
@@ -602,6 +612,9 @@ function writeTlsParams(
|
||||
if (tls.settings.pinnedPeerCertSha256.length > 0) {
|
||||
params.set('pcs', tls.settings.pinnedPeerCertSha256.join(','));
|
||||
}
|
||||
if (tls.cipherSuites && tls.cipherSuites.length > 0) {
|
||||
params.set('cs', tls.cipherSuites);
|
||||
}
|
||||
}
|
||||
|
||||
// Reality query-string writer shared by VLESS and Trojan. Preserves the
|
||||
|
||||
@@ -489,6 +489,8 @@ function applySecurityParams(stream: Raw, params: URLSearchParams): void {
|
||||
tls.echConfigList = params.get('ech') ?? '';
|
||||
tls.verifyPeerCertByName = params.get('vcn') ?? '';
|
||||
tls.pinnedPeerCertSha256 = params.get('pcs') ?? '';
|
||||
const cs = params.get('cs');
|
||||
if (cs) tls.cipherSuites = cs;
|
||||
} else if (stream.security === 'reality') {
|
||||
const reality = stream.realitySettings as Raw;
|
||||
reality.serverName = params.get('sni') ?? '';
|
||||
@@ -567,6 +569,7 @@ export function parseVmessLink(link: string): Raw | null {
|
||||
if (typeof json.ech === 'string') tls.echConfigList = json.ech;
|
||||
if (typeof json.vcn === 'string') tls.verifyPeerCertByName = json.vcn;
|
||||
if (typeof json.pcs === 'string') tls.pinnedPeerCertSha256 = json.pcs;
|
||||
if (typeof json.cs === 'string') tls.cipherSuites = json.cs;
|
||||
}
|
||||
|
||||
const port = Number(json.port) || 443;
|
||||
|
||||
Reference in New Issue
Block a user