Skip to content

Commit 525e54e

Browse files
committed
feat: Surge 支持 Hysteria 2 Salamander 混淆. 根据请求的 User-Agent 中的版本号自动开启, 或使用 includeUnsupportedProxy 参数或开启 包含官方/商店版不支持的协议 开关
1 parent 5d3790d commit 525e54e

4 files changed

Lines changed: 21 additions & 8 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.20.60",
3+
"version": "2.20.61",
44
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
55
"main": "src/main.js",
66
"scripts": {

backend/src/core/proxy-utils/parsers/peggy/surge.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ wireguard = tag equals "wireguard" (section_name/no_error_alert/ip_version/under
105105
proxy.type = "wireguard-surge";
106106
handleShadowTLS();
107107
}
108-
hysteria2 = tag equals "hysteria2" address (no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/sni/tls_verification/passwordk/tls_fingerprint/download_bandwidth/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* {
108+
hysteria2 = tag equals "hysteria2" address (no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/sni/tls_verification/passwordk/tls_fingerprint/download_bandwidth/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/salamander_password/others)* {
109109
proxy.type = "hysteria2";
110110
handleShadowTLS();
111111
}
@@ -254,6 +254,7 @@ shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { proxy["sh
254254
token = comma "token" equals match:[^,]+ { proxy.token = match.join(""); }
255255
alpn = comma "alpn" equals match:[^,]+ { proxy.alpn = match.join(""); }
256256
uuidk = comma "uuid" equals match:[^,]+ { proxy.uuid = match.join(""); }
257+
salamander_password = comma "salamander-password" equals match:[^,]+ { proxy['obfs-password'] = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); proxy.obfs = 'salamander'; }
257258
258259
tag = match:[^=,]* { proxy.name = match.join("").trim(); }
259260
comma = _ "," _

backend/src/core/proxy-utils/parsers/peggy/surge.peg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ wireguard = tag equals "wireguard" (section_name/no_error_alert/ip_version/under
103103
proxy.type = "wireguard-surge";
104104
handleShadowTLS();
105105
}
106-
hysteria2 = tag equals "hysteria2" address (no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/sni/tls_verification/passwordk/tls_fingerprint/download_bandwidth/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* {
106+
hysteria2 = tag equals "hysteria2" address (no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/sni/tls_verification/passwordk/tls_fingerprint/download_bandwidth/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/salamander_password/others)* {
107107
proxy.type = "hysteria2";
108108
handleShadowTLS();
109109
}
@@ -252,6 +252,7 @@ shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { proxy["sh
252252
token = comma "token" equals match:[^,]+ { proxy.token = match.join(""); }
253253
alpn = comma "alpn" equals match:[^,]+ { proxy.alpn = match.join(""); }
254254
uuidk = comma "uuid" equals match:[^,]+ { proxy.uuid = match.join(""); }
255+
salamander_password = comma "salamander-password" equals match:[^,]+ { proxy['obfs-password'] = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); proxy.obfs = 'salamander'; }
255256

256257
tag = match:[^=,]* { proxy.name = match.join("").trim(); }
257258
comma = _ "," _

backend/src/core/proxy-utils/producers/surge.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default function Surge_Producer() {
2020
}
2121
switch (proxy.type) {
2222
case 'ss':
23-
return shadowsocks(proxy, opts['include-unsupported-proxy']);
23+
return shadowsocks(proxy);
2424
case 'trojan':
2525
return trojan(proxy);
2626
case 'vmess':
@@ -38,7 +38,7 @@ export default function Surge_Producer() {
3838
case 'wireguard-surge':
3939
return wireguard_surge(proxy);
4040
case 'hysteria2':
41-
return hysteria2(proxy);
41+
return hysteria2(proxy, opts['include-unsupported-proxy']);
4242
case 'ssh':
4343
return ssh(proxy);
4444
}
@@ -1088,10 +1088,17 @@ function wireguard_surge(proxy) {
10881088
return result.toString();
10891089
}
10901090

1091-
function hysteria2(proxy) {
1092-
if (proxy.obfs || proxy['obfs-password']) {
1093-
throw new Error(`obfs is unsupported`);
1091+
function hysteria2(proxy, includeUnsupportedProxy) {
1092+
if (includeUnsupportedProxy) {
1093+
if (proxy['obfs-password'] && proxy.obfs != 'salamander') {
1094+
throw new Error(`only salamander obfs is supported`);
1095+
}
1096+
} else {
1097+
if (proxy.obfs || proxy['obfs-password']) {
1098+
throw new Error(`obfs is unsupported`);
1099+
}
10941100
}
1101+
10951102
const result = new Result(proxy);
10961103
result.append(`${proxy.name}=hysteria2,${proxy.server},${proxy.port}`);
10971104

@@ -1106,6 +1113,10 @@ function hysteria2(proxy) {
11061113
'hop-interval',
11071114
);
11081115

1116+
if (proxy['obfs-password'] && proxy.obfs == 'salamander') {
1117+
result.append(`,salamander-password="${proxy['obfs-password']}"`);
1118+
}
1119+
11091120
const ip_version = ipVersions[proxy['ip-version']] || proxy['ip-version'];
11101121
result.appendIfPresent(`,ip-version=${ip_version}`, 'ip-version');
11111122

0 commit comments

Comments
 (0)