fix: 修复 Loon XHTTP 下行的 REALITY 转 mihomo 中的 X25519MLKEM768 判断

This commit is contained in:
xream committed 2026-11-25 02:47:38 +08:00
1 parent f01b6ad78e
commit 19574cee50
3 files changed
+55 -9

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.44.29",
"version": "2.44.30",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
"main": "src/main.js",
"packageManager": "pnpm@11.0.9",
+15 -8
View File
@@ -810,14 +810,21 @@ function lastParse(proxy) {
}
normalizeOpts(proxy[normalizedKey]);
}
if (
proxy['reality-opts']?.['public-key'] &&
!hasOwn(proxy['reality-opts'], 'support-x25519mlkem768') &&
['safari-ios-26', 'chrome147'].includes(
`${proxy._loon_tls_profile || ''}`.trim(),
)
) {
proxy['reality-opts']['support-x25519mlkem768'] = true;
const inferLoonRealityMlkem = (endpoint) => {
const realityOpts = endpoint?.['reality-opts'];
if (
isNotBlank(realityOpts?.['public-key']) &&
!hasOwn(realityOpts, 'support-x25519mlkem768') &&
['safari-ios-26', 'chrome147'].includes(
`${endpoint._loon_tls_profile || ''}`.trim(),
)
) {
realityOpts['support-x25519mlkem768'] = true;
}
};
inferLoonRealityMlkem(proxy);
if (proxy.network === 'xhttp') {
inferLoonRealityMlkem(proxy['xhttp-opts']?.['download-settings']);
}
proxy.udp = ![false, 0, '0', 'false', 'off'].includes(
typeof proxy.udp === 'string' ? proxy.udp.toLowerCase() : proxy.udp,
@@ -1020,6 +1020,45 @@ describe('Proxy text producers', function () {
).to.deep.equal([reality]);
});
it('maps REALITY ML-KEM independently for Loon XHTTP uploads and downloads', function () {
const flag = 'support-x25519mlkem768';
const input = `Split=vless,upload.example.com,443,"${UUID}",transport=xhttp,over-tls=true,xhttp-download-server=down.example.com,xhttp-download-over-tls=true`;
for (const [upload, download, uploadFlag, downloadFlag] of [
[undefined, 'chrome147', undefined, true],
['chrome', 'safari-ios-26', undefined, true],
['chrome147', 'chrome', true, undefined],
]) {
const line = [
input,
upload && `public-key=up-key,tls-profile=${upload}`,
`xhttp-download-tls-profile=${download}`,
]
.filter(Boolean)
.join(',');
const [tlsOnly] = ProxyUtils.parse(line);
expect(
tlsOnly['xhttp-opts']['download-settings'],
).not.to.have.property('reality-opts');
const [proxy] = ProxyUtils.parse(
`${line},xhttp-download-public-key=down-key`,
);
const [mihomo] = produceInternal('Mihomo', proxy);
const downloadReality =
mihomo['xhttp-opts']['download-settings']['reality-opts'];
expect(mihomo['reality-opts']?.[flag]).to.equal(uploadFlag);
expect(downloadReality[flag]).to.equal(downloadFlag);
downloadReality[flag] = false;
const [reparsed] = ProxyUtils.parse(JSON.stringify(mihomo));
expect(
reparsed['xhttp-opts']['download-settings']['reality-opts'][
flag
],
).to.equal(false);
}
});
it('validates Loon XHTTP XMUX quotas per endpoint', function () {
const input = `Split=vless,upload.example.com,443,"${UUID}",transport=xhttp,over-tls=true,alpn=h2,xhttp-mode=stream-up`;
const split = `${input},xhttp-download-server=download.example.com,xhttp-download-port=8443,xhttp-download-over-tls=true,xhttp-download-alpn=h2`;