Skip to content

Commit c8632ef

Browse files
committed
feat: 修改 sni off 的逻辑.
1 parent 569f010 commit c8632ef

2 files changed

Lines changed: 18 additions & 17 deletions

File tree

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sub-store",
3-
"version": "2.36.10",
3+
"version": "2.36.11",
44
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
55
"main": "src/main.js",
66
"packageManager": "pnpm@11.0.9",

backend/src/core/proxy-utils/index.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import { produceArtifact } from '@/restful/sync';
3333
import { getFlag, removeFlag, getISO, MMDB } from '@/utils/geo';
3434
import Gist from '@/utils/gist';
3535
import {
36-
isPresent,
3736
isShadowsocksOverTls,
3837
normalizeWireGuardInterface,
3938
} from './producers/utils';
@@ -395,15 +394,6 @@ function produce(proxies, targetPlatform, type, opts = {}) {
395394
}
396395

397396
const normalizedTarget = String(targetPlatform).toLowerCase();
398-
const supportedShadowsocksOverTlsTargets = new Set([
399-
'qx',
400-
'quantumultx',
401-
'shadowrocket',
402-
]);
403-
404-
const sni_off_supported = /Surge|SurgeMac|Shadowrocket/i.test(
405-
targetPlatform,
406-
);
407397

408398
// filter unsupported proxies
409399
proxies = proxies.filter((proxy) => {
@@ -437,7 +427,7 @@ function produce(proxies, targetPlatform, type, opts = {}) {
437427
if (
438428
!includeUnsupportedProxy &&
439429
isShadowsocksOverTls(proxy) &&
440-
!supportedShadowsocksOverTlsTargets.has(normalizedTarget)
430+
!['qx', 'quantumultx', 'shadowrocket'].includes(normalizedTarget)
441431
) {
442432
return false;
443433
}
@@ -518,13 +508,20 @@ function produce(proxies, targetPlatform, type, opts = {}) {
518508
proxy.name = `${proxy.type} ${proxy.server}:${proxy.port}`;
519509
}
520510
if (proxy['disable-sni']) {
521-
if (sni_off_supported) {
511+
if (
512+
['surge', 'surgemac', 'shadowrocket'].includes(normalizedTarget)
513+
) {
522514
proxy.sni = 'off';
523-
} else if (!['tuic'].includes(proxy.type)) {
515+
} else if (
516+
!['tuic'].includes(proxy.type) &&
517+
!['sing-box', 'singbox'].includes(normalizedTarget)
518+
) {
519+
// 目前 Sub-Store 里 sing-box 是靠 mihomo 转一次的. 会用到 disable-sni 转成 disable_sni. 是支持的
520+
// 其他客户端行为可能不一致. mihomo 可设置为 ip, 此时会不发 sni
524521
$.error(
525-
`Target platform ${targetPlatform} does not support sni off, proxy ${proxy.name} sni will be set to empty string instead.`,
522+
`Target platform ${targetPlatform} does not support sni off. As a workaround for mihomo, proxy ${proxy.name} sni will be set to IP instead`,
526523
);
527-
proxy.sni = '';
524+
proxy.sni = isIP(proxy.server) ? proxy.server : '127.0.0.1';
528525
// proxy['skip-cert-verify'] = true;
529526
// delete proxy['tls-fingerprint'];
530527
}
@@ -533,7 +530,11 @@ function produce(proxies, targetPlatform, type, opts = {}) {
533530
// 处理 端口跳跃
534531
if (proxy.ports) {
535532
proxy.ports = String(proxy.ports);
536-
if (!['ClashMeta'].includes(targetPlatform)) {
533+
if (
534+
!['meta', 'clashmeta', 'clash.meta', 'mihomo'].includes(
535+
normalizedTarget,
536+
)
537+
) {
537538
proxy.ports = proxy.ports.replace(/\//g, ',');
538539
}
539540
if (!proxy.port) {

0 commit comments

Comments
 (0)