sub-store-convert 2.24.19 → 2.33.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +476 -463
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -59,6 +59,7 @@ var grammars = String.raw`
|
|
|
59
59
|
{
|
|
60
60
|
const proxy = {};
|
|
61
61
|
const obfs = {};
|
|
62
|
+
const shadowTLS = {};
|
|
62
63
|
const $ = {};
|
|
63
64
|
|
|
64
65
|
function handleWebsocket() {
|
|
@@ -72,8 +73,23 @@ var grammars = String.raw`
|
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
function handleShadowTLS() {
|
|
75
|
-
if (
|
|
76
|
-
|
|
76
|
+
if (shadowTLS.password && !shadowTLS.version) {
|
|
77
|
+
shadowTLS.version = 2;
|
|
78
|
+
}
|
|
79
|
+
if (shadowTLS.password) {
|
|
80
|
+
if (shadowTLS.version < 2) {
|
|
81
|
+
throw new Error("shadow-tls version " + shadowTLS.version + " is not supported");
|
|
82
|
+
}
|
|
83
|
+
proxy.plugin = "shadow-tls";
|
|
84
|
+
proxy["plugin-opts"] = {
|
|
85
|
+
host: shadowTLS.host,
|
|
86
|
+
password: shadowTLS.password,
|
|
87
|
+
version: shadowTLS.version,
|
|
88
|
+
};
|
|
89
|
+
if (proxy.alpn) {
|
|
90
|
+
$set(proxy, "plugin-opts.alpn", proxy.alpn);
|
|
91
|
+
delete proxy.alpn;
|
|
92
|
+
}
|
|
77
93
|
}
|
|
78
94
|
}
|
|
79
95
|
function stripQuotes(value) {
|
|
@@ -386,13 +402,19 @@ var grammars = String.raw`
|
|
|
386
402
|
if (!supported.includes(normalized)) return "auto";
|
|
387
403
|
return normalized === "chacha20-ietf-poly1305" ? "chacha20-poly1305" : normalized;
|
|
388
404
|
}
|
|
405
|
+
function parseAlpn(value) {
|
|
406
|
+
return stripQuotes(value)
|
|
407
|
+
.split(",")
|
|
408
|
+
.map((item) => item.trim())
|
|
409
|
+
.filter((item) => item !== "");
|
|
410
|
+
}
|
|
389
411
|
}
|
|
390
412
|
|
|
391
413
|
start = (anytls/shadowsocks/vmess/trojan/h2_connect/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2/ssh/trust_tunnel/direct) {
|
|
392
414
|
return proxy;
|
|
393
415
|
}
|
|
394
416
|
|
|
395
|
-
shadowsocks = tag equals "ss" address (method/passwordk/obfs/obfs_host/obfs_uri/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/udp_port/others)* {
|
|
417
|
+
shadowsocks = tag equals "ss" address (method/passwordk/obfs/obfs_host/obfs_uri/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/alpn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/udp_port/others)* {
|
|
396
418
|
proxy.type = "ss";
|
|
397
419
|
// handle obfs
|
|
398
420
|
if (obfs.type == "http" || obfs.type === "tls") {
|
|
@@ -403,7 +425,7 @@ shadowsocks = tag equals "ss" address (method/passwordk/obfs/obfs_host/obfs_uri/
|
|
|
403
425
|
}
|
|
404
426
|
handleShadowTLS();
|
|
405
427
|
}
|
|
406
|
-
vmess = tag equals "vmess" address (vmess_uuid/vmess_aead/ws/ws_path/ws_headers/vmess_method/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls/sni/tls_fingerprint/tls_verification/client_cert/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
428
|
+
vmess = tag equals "vmess" address (vmess_uuid/vmess_aead/ws/ws_path/ws_headers/vmess_method/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls/sni/alpn/tls_fingerprint/tls_verification/client_cert/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
407
429
|
proxy.type = "vmess";
|
|
408
430
|
proxy.cipher = proxy.cipher || "auto";
|
|
409
431
|
// Surfboard 与 Surge 默认不一致, 不管 Surfboard https://getsurfboard.com/docs/profile-format/proxy/external-proxy/vmess
|
|
@@ -415,17 +437,17 @@ vmess = tag equals "vmess" address (vmess_uuid/vmess_aead/ws/ws_path/ws_headers/
|
|
|
415
437
|
handleWebsocket();
|
|
416
438
|
handleShadowTLS();
|
|
417
439
|
}
|
|
418
|
-
trojan = tag equals "trojan" address (passwordk/ws/ws_path/ws_headers/tls/sni/tls_fingerprint/tls_verification/client_cert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
440
|
+
trojan = tag equals "trojan" address (passwordk/ws/ws_path/ws_headers/tls/sni/alpn/tls_fingerprint/tls_verification/client_cert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
419
441
|
proxy.type = "trojan";
|
|
420
442
|
handleWebsocket();
|
|
421
443
|
handleShadowTLS();
|
|
422
444
|
}
|
|
423
|
-
https = tag equals "https" address (username password)? (usernamek passwordk)? (headers/sni/tls_fingerprint/tls_verification/client_cert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
445
|
+
https = tag equals "https" address (username password)? (usernamek passwordk)? (headers/sni/alpn/tls_fingerprint/tls_verification/client_cert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
424
446
|
proxy.type = "http";
|
|
425
447
|
proxy.tls = true;
|
|
426
448
|
handleShadowTLS();
|
|
427
449
|
}
|
|
428
|
-
h2_connect = tag equals "h2-connect" address (username password)? (usernamek passwordk)? (headers/max_streams/sni/tls_fingerprint/tls_verification/client_cert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
450
|
+
h2_connect = tag equals "h2-connect" address (username password)? (usernamek passwordk)? (headers/max_streams/sni/alpn/tls_fingerprint/tls_verification/client_cert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
429
451
|
proxy.type = "h2-connect";
|
|
430
452
|
proxy.tls = true;
|
|
431
453
|
handleShadowTLS();
|
|
@@ -438,7 +460,7 @@ ssh = tag equals "ssh" address (username password)? (usernamek passwordk)? (serv
|
|
|
438
460
|
proxy.type = "ssh";
|
|
439
461
|
handleShadowTLS();
|
|
440
462
|
}
|
|
441
|
-
snell = tag equals "snell" address (snell_version/snell_psk/obfs/obfs_host/obfs_uri/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/reuse/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
463
|
+
snell = tag equals "snell" address (snell_version/snell_mode/snell_psk/obfs/obfs_host/obfs_uri/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/reuse/alpn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
442
464
|
proxy.type = "snell";
|
|
443
465
|
// handle obfs
|
|
444
466
|
if (obfs.type == "http" || obfs.type === "tls") {
|
|
@@ -461,7 +483,7 @@ wireguard = tag equals "wireguard" (section_name/no_error_alert/ip_version/under
|
|
|
461
483
|
proxy.type = "wireguard-surge";
|
|
462
484
|
handleShadowTLS();
|
|
463
485
|
}
|
|
464
|
-
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/client_cert/passwordk/tls_fingerprint/download_bandwidth/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/salamander_password/others)* {
|
|
486
|
+
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/alpn/tls_verification/client_cert/passwordk/tls_fingerprint/download_bandwidth/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/salamander_password/gecko_password/others)* {
|
|
465
487
|
proxy.type = "hysteria2";
|
|
466
488
|
handleShadowTLS();
|
|
467
489
|
}
|
|
@@ -469,16 +491,16 @@ socks5 = tag equals "socks5" address (username password)? (usernamek passwordk)?
|
|
|
469
491
|
proxy.type = "socks5";
|
|
470
492
|
handleShadowTLS();
|
|
471
493
|
}
|
|
472
|
-
socks5_tls = tag equals "socks5-tls" address (username password)? (usernamek passwordk)? (udp_relay/no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/sni/tls_fingerprint/tls_verification/client_cert/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
494
|
+
socks5_tls = tag equals "socks5-tls" address (username password)? (usernamek passwordk)? (udp_relay/no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/sni/alpn/tls_fingerprint/tls_verification/client_cert/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
473
495
|
proxy.type = "socks5";
|
|
474
496
|
proxy.tls = true;
|
|
475
497
|
handleShadowTLS();
|
|
476
498
|
}
|
|
477
|
-
anytls = tag equals "anytls" address (passwordk/reuse/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/client_cert/sni/fast_open/tfo/block_quic/others)* {
|
|
499
|
+
anytls = tag equals "anytls" address (passwordk/reuse/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/client_cert/sni/alpn/fast_open/tfo/block_quic/others)* {
|
|
478
500
|
proxy.type = "anytls";
|
|
479
501
|
proxy.tls = true;
|
|
480
502
|
}
|
|
481
|
-
trust_tunnel = tag equals "trust-tunnel" address (usernamek/passwordk/headers/max_streams/reuse/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/client_cert/sni/fast_open/tfo/block_quic/others)* {
|
|
503
|
+
trust_tunnel = tag equals "trust-tunnel" address (usernamek/passwordk/headers/max_streams/reuse/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/client_cert/sni/alpn/fast_open/tfo/block_quic/others)* {
|
|
482
504
|
proxy.type = "trusttunnel";
|
|
483
505
|
proxy.tls = true;
|
|
484
506
|
}
|
|
@@ -561,6 +583,12 @@ client_cert = comma "client-cert" equals match:[^,]+ { proxy["keystore-client-ce
|
|
|
561
583
|
|
|
562
584
|
snell_psk = comma "psk" equals match:[^,]+ { proxy.psk = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
|
563
585
|
snell_version = comma "version" equals match:$[0-9]+ { proxy.version = parseInt(match.trim()); }
|
|
586
|
+
snell_mode = comma "mode" equals match:[^,]+ {
|
|
587
|
+
const mode = stripQuotes(match.join("")).trim();
|
|
588
|
+
if (["default", "unshaped", "unsafe-raw"].includes(mode)) {
|
|
589
|
+
proxy.mode = mode;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
564
592
|
|
|
565
593
|
usernamek = comma "username" equals match:[^,]+ { proxy.username = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
|
566
594
|
passwordk = comma "password" equals match:[^,]+ { proxy.password = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
|
@@ -623,13 +651,18 @@ private_key = comma "private-key" equals match:[^,]+ { proxy["keystore-private-k
|
|
|
623
651
|
server_fingerprint = comma "server-fingerprint" equals match:[^,]+ { proxy["server-fingerprint"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
|
624
652
|
block_quic = comma "block-quic" equals match:[^,]+ { proxy["block-quic"] = match.join(""); }
|
|
625
653
|
udp_port = comma "udp-port" equals match:$[0-9]+ { proxy["udp-port"] = parseInt(match.trim()); }
|
|
626
|
-
shadow_tls_version = comma "shadow-tls-version" equals match:$[0-9]+ {
|
|
627
|
-
shadow_tls_sni = comma "shadow-tls-sni" equals match:[^,]+ {
|
|
628
|
-
shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ {
|
|
654
|
+
shadow_tls_version = comma "shadow-tls-version" equals match:$[0-9]+ { shadowTLS.version = parseInt(match.trim()); }
|
|
655
|
+
shadow_tls_sni = comma "shadow-tls-sni" equals match:[^,]+ { shadowTLS.host = match.join(""); }
|
|
656
|
+
shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { shadowTLS.password = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
|
629
657
|
token = comma "token" equals match:[^,]+ { proxy.token = match.join(""); }
|
|
630
|
-
alpn = comma "alpn" equals match:
|
|
658
|
+
alpn = comma "alpn" equals match:quoted_value {
|
|
659
|
+
const values = parseAlpn(match);
|
|
660
|
+
if (values.length > 0) proxy.alpn = values;
|
|
661
|
+
}
|
|
662
|
+
quoted_value = '"' match:$[^"]* '"' { return match; } / "'" match:$[^']* "'" { return match; } / match:$[^,]+ { return match; }
|
|
631
663
|
uuidk = comma "uuid" equals match:[^,]+ { proxy.uuid = match.join(""); }
|
|
632
664
|
salamander_password = comma "salamander-password" equals match:[^,]+ { proxy['obfs-password'] = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); proxy.obfs = 'salamander'; }
|
|
665
|
+
gecko_password = comma "gecko-password" equals match:[^,]+ { proxy['obfs-password'] = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); proxy.obfs = 'gecko'; }
|
|
633
666
|
|
|
634
667
|
tag = match:[^=,]* { proxy.name = match.join("").trim(); }
|
|
635
668
|
comma = _ "," _
|
|
@@ -668,6 +701,7 @@ var grammars2 = String.raw`
|
|
|
668
701
|
const proxy = {};
|
|
669
702
|
const obfs = {};
|
|
670
703
|
const transport = {};
|
|
704
|
+
const shadowTLS = {};
|
|
671
705
|
const $ = {};
|
|
672
706
|
|
|
673
707
|
function handleTransport() {
|
|
@@ -683,6 +717,24 @@ var grammars2 = String.raw`
|
|
|
683
717
|
}
|
|
684
718
|
}
|
|
685
719
|
|
|
720
|
+
function handleShadowTLS() {
|
|
721
|
+
if (shadowTLS.password) {
|
|
722
|
+
if (shadowTLS.version < 2) {
|
|
723
|
+
throw new Error("shadow-tls version " + shadowTLS.version + " is not supported");
|
|
724
|
+
}
|
|
725
|
+
proxy.plugin = "shadow-tls";
|
|
726
|
+
proxy["plugin-opts"] = {
|
|
727
|
+
host: shadowTLS.host,
|
|
728
|
+
password: shadowTLS.password,
|
|
729
|
+
version: shadowTLS.version,
|
|
730
|
+
};
|
|
731
|
+
if (proxy.alpn) {
|
|
732
|
+
$set(proxy, "plugin-opts.alpn", proxy.alpn);
|
|
733
|
+
delete proxy.alpn;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
|
|
686
738
|
function normalizeVmessSecurity(security) {
|
|
687
739
|
const normalized = String(security || "").trim().toLowerCase();
|
|
688
740
|
const supported = ["none", "auto", "aes-128-gcm", "chacha20-ietf-poly1305"];
|
|
@@ -705,12 +757,13 @@ start = (shadowsocksr/shadowsocks/vmess/vless/trojan/https/http/socks5/hysteria2
|
|
|
705
757
|
return proxy;
|
|
706
758
|
}
|
|
707
759
|
|
|
708
|
-
shadowsocksr = tag equals "shadowsocksr"i address method password (ssr_protocol/ssr_protocol_param/obfs_ssr/obfs_ssr_param/obfs_host/obfs_uri/fast_open/udp_relay/udp_port/shadow_tls_version/shadow_tls_sni/shadow_tls_password/ip_mode/block_quic/others)*{
|
|
760
|
+
shadowsocksr = tag equals "shadowsocksr"i address method password (ssr_protocol/ssr_protocol_param/obfs_ssr/obfs_ssr_param/obfs_host/obfs_uri/fast_open/udp_relay/udp_port/tls_profile/alpn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/ip_mode/block_quic/others)*{
|
|
709
761
|
proxy.type = "ssr";
|
|
710
762
|
// handle ssr obfs
|
|
711
763
|
proxy.obfs = obfs.type;
|
|
764
|
+
handleShadowTLS();
|
|
712
765
|
}
|
|
713
|
-
shadowsocks = tag equals "shadowsocks"i address method password (obfs_typev obfs_hostv)? (obfs_ss/obfs_host/obfs_uri/fast_open/udp_relay/udp_port/shadow_tls_version/shadow_tls_sni/shadow_tls_password/ip_mode/block_quic/udp_over_tcp/others)* {
|
|
766
|
+
shadowsocks = tag equals "shadowsocks"i address method password (obfs_typev obfs_hostv)? (obfs_ss/obfs_host/obfs_uri/fast_open/udp_relay/udp_port/tls_profile/alpn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/ip_mode/block_quic/udp_over_tcp/others)* {
|
|
714
767
|
proxy.type = "ss";
|
|
715
768
|
// handle ss obfs
|
|
716
769
|
if (obfs.type == "http" || obfs.type === "tls") {
|
|
@@ -719,6 +772,7 @@ shadowsocks = tag equals "shadowsocks"i address method password (obfs_typev obfs
|
|
|
719
772
|
$set(proxy, "plugin-opts.host", obfs.host);
|
|
720
773
|
$set(proxy, "plugin-opts.path", obfs.path);
|
|
721
774
|
}
|
|
775
|
+
handleShadowTLS();
|
|
722
776
|
}
|
|
723
777
|
vmess = tag equals "vmess"i address vmess_method uuid (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/vmess_alterId/fast_open/udp_relay/ip_mode/public_key/short_id/block_quic/others)* {
|
|
724
778
|
proxy.type = "vmess";
|
|
@@ -730,11 +784,11 @@ vless = tag equals "vless"i address uuid (transport/transport_host/transport_pat
|
|
|
730
784
|
proxy.type = "vless";
|
|
731
785
|
handleTransport();
|
|
732
786
|
}
|
|
733
|
-
trojan = tag equals "trojan"i address password (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/fast_open/udp_relay/ip_mode/block_quic/others)* {
|
|
787
|
+
trojan = tag equals "trojan"i address password (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/fast_open/udp_relay/ip_mode/public_key/short_id/block_quic/others)* {
|
|
734
788
|
proxy.type = "trojan";
|
|
735
789
|
handleTransport();
|
|
736
790
|
}
|
|
737
|
-
anytls = tag equals "anytls"i address password (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/fast_open/udp_relay/ip_mode/block_quic/idle_session_check_interval/idle_session_timeout/min_idle_session/max_stream_count/others)* {
|
|
791
|
+
anytls = tag equals "anytls"i address password (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/fast_open/udp_relay/ip_mode/public_key/short_id/block_quic/idle_session_check_interval/idle_session_timeout/min_idle_session/max_stream_count/others)* {
|
|
738
792
|
proxy.type = "anytls";
|
|
739
793
|
handleTransport();
|
|
740
794
|
}
|
|
@@ -843,9 +897,9 @@ ssr_protocol_param = comma "protocol-param" equals param:$[^=,]+ { proxy["protoc
|
|
|
843
897
|
vmess_alterId = comma "alterId" equals alterId:$[0-9]+ { proxy.alterId = parseInt(alterId); }
|
|
844
898
|
|
|
845
899
|
udp_port = comma "udp-port" equals match:$[0-9]+ { proxy["udp-port"] = parseInt(match.trim()); }
|
|
846
|
-
shadow_tls_version = comma "shadow-tls-version" equals match:$[0-9]+ {
|
|
847
|
-
shadow_tls_sni = comma "shadow-tls-sni" equals match:[^,]+ {
|
|
848
|
-
shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ {
|
|
900
|
+
shadow_tls_version = comma "shadow-tls-version" equals match:$[0-9]+ { shadowTLS.version = parseInt(match.trim()); }
|
|
901
|
+
shadow_tls_sni = comma "shadow-tls-sni" equals match:[^,]+ { shadowTLS.host = match.join(""); }
|
|
902
|
+
shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { shadowTLS.password = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
|
849
903
|
|
|
850
904
|
over_tls = comma "over-tls" equals flag:bool { proxy.tls = flag; }
|
|
851
905
|
tls_name = comma sni:("tls-name") equals match:[^,]+ { proxy.sni = match.join("").replace(/^"(.*)"$/, '$1'); }
|
|
@@ -1452,7 +1506,11 @@ var app_default = console;
|
|
|
1452
1506
|
import JSON5 from "json5";
|
|
1453
1507
|
|
|
1454
1508
|
// src/vendors/Sub-Store/backend/src/utils/yaml.js
|
|
1455
|
-
import
|
|
1509
|
+
import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
|
|
1510
|
+
var DEFAULT_PARSE_OPTIONS = {
|
|
1511
|
+
logLevel: "error",
|
|
1512
|
+
merge: true
|
|
1513
|
+
};
|
|
1456
1514
|
function retry(fn, content, ...args) {
|
|
1457
1515
|
try {
|
|
1458
1516
|
return fn(content, ...args);
|
|
@@ -1468,17 +1526,65 @@ function retry(fn, content, ...args) {
|
|
|
1468
1526
|
);
|
|
1469
1527
|
}
|
|
1470
1528
|
}
|
|
1529
|
+
function toSerializable(content) {
|
|
1530
|
+
return JSON.parse(JSON.stringify(content));
|
|
1531
|
+
}
|
|
1532
|
+
function normalizeParseOptions(options) {
|
|
1533
|
+
return {
|
|
1534
|
+
...DEFAULT_PARSE_OPTIONS,
|
|
1535
|
+
...options || {}
|
|
1536
|
+
};
|
|
1537
|
+
}
|
|
1538
|
+
function normalizeStringifyOptions(options = {}) {
|
|
1539
|
+
const {
|
|
1540
|
+
forceQuotes,
|
|
1541
|
+
lineWidth,
|
|
1542
|
+
noArrayIndent,
|
|
1543
|
+
noRefs,
|
|
1544
|
+
quotingType,
|
|
1545
|
+
sortKeys,
|
|
1546
|
+
...rest
|
|
1547
|
+
} = options || {};
|
|
1548
|
+
const normalized = { ...rest };
|
|
1549
|
+
if (typeof lineWidth === "number") {
|
|
1550
|
+
normalized.lineWidth = lineWidth <= 0 ? 0 : lineWidth;
|
|
1551
|
+
}
|
|
1552
|
+
if (typeof noArrayIndent === "boolean") {
|
|
1553
|
+
normalized.indentSeq = !noArrayIndent;
|
|
1554
|
+
}
|
|
1555
|
+
if (typeof noRefs === "boolean") {
|
|
1556
|
+
normalized.aliasDuplicateObjects = !noRefs;
|
|
1557
|
+
}
|
|
1558
|
+
if (typeof sortKeys !== "undefined") {
|
|
1559
|
+
normalized.sortMapEntries = sortKeys;
|
|
1560
|
+
}
|
|
1561
|
+
if (quotingType === "'") {
|
|
1562
|
+
normalized.singleQuote = true;
|
|
1563
|
+
} else if (quotingType === '"') {
|
|
1564
|
+
normalized.singleQuote = false;
|
|
1565
|
+
}
|
|
1566
|
+
if (forceQuotes) {
|
|
1567
|
+
normalized.defaultStringType = quotingType === "'" ? "QUOTE_SINGLE" : "QUOTE_DOUBLE";
|
|
1568
|
+
}
|
|
1569
|
+
return normalized;
|
|
1570
|
+
}
|
|
1571
|
+
function parse(content, options) {
|
|
1572
|
+
return parseYaml(content, normalizeParseOptions(options));
|
|
1573
|
+
}
|
|
1574
|
+
function stringify(content, options) {
|
|
1575
|
+
return stringifyYaml(content, normalizeStringifyOptions(options));
|
|
1576
|
+
}
|
|
1471
1577
|
function safeLoad(content, ...args) {
|
|
1472
|
-
return retry(
|
|
1578
|
+
return retry(parse, toSerializable(content), ...args);
|
|
1473
1579
|
}
|
|
1474
1580
|
function load(content, ...args) {
|
|
1475
|
-
return retry(
|
|
1581
|
+
return retry(parse, toSerializable(content), ...args);
|
|
1476
1582
|
}
|
|
1477
1583
|
function safeDump(content, ...args) {
|
|
1478
|
-
return
|
|
1584
|
+
return stringify(toSerializable(content), ...args);
|
|
1479
1585
|
}
|
|
1480
1586
|
function dump(content, ...args) {
|
|
1481
|
-
return
|
|
1587
|
+
return stringify(toSerializable(content), ...args);
|
|
1482
1588
|
}
|
|
1483
1589
|
var yaml_default = {
|
|
1484
1590
|
safeLoad,
|
|
@@ -2002,7 +2108,7 @@ function URI_PROXY() {
|
|
|
2002
2108
|
const test = (line) => {
|
|
2003
2109
|
return /^(socks5\+tls|socks5|http|https):\/\//.test(line);
|
|
2004
2110
|
};
|
|
2005
|
-
const
|
|
2111
|
+
const parse2 = (line) => {
|
|
2006
2112
|
let [__, type, tls, username, password, server, port, query, name2] = line.match(
|
|
2007
2113
|
/^(socks5|http|http)(\+tls|s)?:\/\/(?:(.*?):(.*?)@)?(.*?)(?::(\d+?))?\/?(\?.*?)?(?:#(.*?))?$/
|
|
2008
2114
|
);
|
|
@@ -2030,14 +2136,14 @@ function URI_PROXY() {
|
|
|
2030
2136
|
};
|
|
2031
2137
|
return proxy;
|
|
2032
2138
|
};
|
|
2033
|
-
return { name, test, parse };
|
|
2139
|
+
return { name, test, parse: parse2 };
|
|
2034
2140
|
}
|
|
2035
2141
|
function URI_SOCKS() {
|
|
2036
2142
|
const name = "URI SOCKS Parser";
|
|
2037
2143
|
const test = (line) => {
|
|
2038
2144
|
return /^socks:\/\//.test(line);
|
|
2039
2145
|
};
|
|
2040
|
-
const
|
|
2146
|
+
const parse2 = (line) => {
|
|
2041
2147
|
let [__, type, auth, server, port, query, name2] = line.match(
|
|
2042
2148
|
/^(socks)?:\/\/(?:(.*)@)?(.*?)(?::(\d+?))?(\?.*?)?(?:#(.*?))?$/
|
|
2043
2149
|
);
|
|
@@ -2063,14 +2169,14 @@ function URI_SOCKS() {
|
|
|
2063
2169
|
};
|
|
2064
2170
|
return proxy;
|
|
2065
2171
|
};
|
|
2066
|
-
return { name, test, parse };
|
|
2172
|
+
return { name, test, parse: parse2 };
|
|
2067
2173
|
}
|
|
2068
2174
|
function URI_SS() {
|
|
2069
2175
|
const name = "URI SS Parser";
|
|
2070
2176
|
const test = (line) => {
|
|
2071
2177
|
return /^ss:\/\//.test(line);
|
|
2072
2178
|
};
|
|
2073
|
-
const
|
|
2179
|
+
const parse2 = (line) => {
|
|
2074
2180
|
let { content, fragment: name2 } = splitURIFragment(
|
|
2075
2181
|
line.split("ss://")[1]
|
|
2076
2182
|
);
|
|
@@ -2333,14 +2439,14 @@ function URI_SS() {
|
|
|
2333
2439
|
proxy.name = name2 ?? `SS ${proxy.server}:${proxy.port}`;
|
|
2334
2440
|
return proxy;
|
|
2335
2441
|
};
|
|
2336
|
-
return { name, test, parse };
|
|
2442
|
+
return { name, test, parse: parse2 };
|
|
2337
2443
|
}
|
|
2338
2444
|
function URI_SSR() {
|
|
2339
2445
|
const name = "URI SSR Parser";
|
|
2340
2446
|
const test = (line) => {
|
|
2341
2447
|
return /^ssr:\/\//.test(line);
|
|
2342
2448
|
};
|
|
2343
|
-
const
|
|
2449
|
+
const parse2 = (line) => {
|
|
2344
2450
|
line = Base64.decode(line.split("ssr://")[1]);
|
|
2345
2451
|
let splitIdx = line.indexOf(":origin");
|
|
2346
2452
|
if (splitIdx === -1) {
|
|
@@ -2387,14 +2493,14 @@ function URI_SSR() {
|
|
|
2387
2493
|
};
|
|
2388
2494
|
return proxy;
|
|
2389
2495
|
};
|
|
2390
|
-
return { name, test, parse };
|
|
2496
|
+
return { name, test, parse: parse2 };
|
|
2391
2497
|
}
|
|
2392
2498
|
function URI_VMess() {
|
|
2393
2499
|
const name = "URI VMess Parser";
|
|
2394
2500
|
const test = (line) => {
|
|
2395
2501
|
return /^vmess:\/\//.test(line);
|
|
2396
2502
|
};
|
|
2397
|
-
const
|
|
2503
|
+
const parse2 = (line) => {
|
|
2398
2504
|
let { content: lineWithoutFragment, fragment: fragmentName } = splitURIFragment(line.split("vmess://")[1]);
|
|
2399
2505
|
let content = Base64.decode(lineWithoutFragment.replace(/\?.*?$/, ""));
|
|
2400
2506
|
if (/=\s*vmess/.test(content)) {
|
|
@@ -2610,14 +2716,14 @@ function URI_VMess() {
|
|
|
2610
2716
|
return proxy;
|
|
2611
2717
|
}
|
|
2612
2718
|
};
|
|
2613
|
-
return { name, test, parse };
|
|
2719
|
+
return { name, test, parse: parse2 };
|
|
2614
2720
|
}
|
|
2615
2721
|
function URI_VLESS() {
|
|
2616
2722
|
const name = "URI VLESS Parser";
|
|
2617
2723
|
const test = (line) => {
|
|
2618
2724
|
return /^vless:\/\//.test(line);
|
|
2619
2725
|
};
|
|
2620
|
-
const
|
|
2726
|
+
const parse2 = (line) => {
|
|
2621
2727
|
const mapXmuxToReuseSettings = (xmux) => {
|
|
2622
2728
|
if (!isPlainObject(xmux)) {
|
|
2623
2729
|
return void 0;
|
|
@@ -3576,14 +3682,14 @@ function URI_VLESS() {
|
|
|
3576
3682
|
}
|
|
3577
3683
|
return proxy;
|
|
3578
3684
|
};
|
|
3579
|
-
return { name, test, parse };
|
|
3685
|
+
return { name, test, parse: parse2 };
|
|
3580
3686
|
}
|
|
3581
3687
|
function URI_AnyTLS() {
|
|
3582
3688
|
const name = "URI AnyTLS Parser";
|
|
3583
3689
|
const test = (line) => {
|
|
3584
3690
|
return /^anytls:\/\//.test(line);
|
|
3585
3691
|
};
|
|
3586
|
-
const
|
|
3692
|
+
const parse2 = (line) => {
|
|
3587
3693
|
const parsed = URI_VLESS().parse(line.replace("anytls", "vless"));
|
|
3588
3694
|
line = line.split(/anytls:\/\//)[1];
|
|
3589
3695
|
let [__, password, server, port, addons = "", name2] = /^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
@@ -3628,14 +3734,14 @@ function URI_AnyTLS() {
|
|
|
3628
3734
|
}
|
|
3629
3735
|
return proxy;
|
|
3630
3736
|
};
|
|
3631
|
-
return { name, test, parse };
|
|
3737
|
+
return { name, test, parse: parse2 };
|
|
3632
3738
|
}
|
|
3633
3739
|
function URI_Hysteria2() {
|
|
3634
3740
|
const name = "URI Hysteria2 Parser";
|
|
3635
3741
|
const test = (line) => {
|
|
3636
3742
|
return /^(hysteria2|hy2):\/\//.test(line);
|
|
3637
3743
|
};
|
|
3638
|
-
const
|
|
3744
|
+
const parse2 = (line) => {
|
|
3639
3745
|
line = line.split(/(hysteria2|hy2):\/\//)[2];
|
|
3640
3746
|
let ports;
|
|
3641
3747
|
let [
|
|
@@ -3717,14 +3823,14 @@ function URI_Hysteria2() {
|
|
|
3717
3823
|
}
|
|
3718
3824
|
return proxy;
|
|
3719
3825
|
};
|
|
3720
|
-
return { name, test, parse };
|
|
3826
|
+
return { name, test, parse: parse2 };
|
|
3721
3827
|
}
|
|
3722
3828
|
function URI_Hysteria() {
|
|
3723
3829
|
const name = "URI Hysteria Parser";
|
|
3724
3830
|
const test = (line) => {
|
|
3725
3831
|
return /^(hysteria|hy):\/\//.test(line);
|
|
3726
3832
|
};
|
|
3727
|
-
const
|
|
3833
|
+
const parse2 = (line) => {
|
|
3728
3834
|
line = line.split(/(hysteria|hy):\/\//)[2];
|
|
3729
3835
|
let [__, server, ___, port, ____, addons = "", name2] = /^(.*?)(:(\d+))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
3730
3836
|
port = parseInt(`${port}`, 10);
|
|
@@ -3781,14 +3887,14 @@ function URI_Hysteria() {
|
|
|
3781
3887
|
}
|
|
3782
3888
|
return proxy;
|
|
3783
3889
|
};
|
|
3784
|
-
return { name, test, parse };
|
|
3890
|
+
return { name, test, parse: parse2 };
|
|
3785
3891
|
}
|
|
3786
3892
|
function URI_TUIC() {
|
|
3787
3893
|
const name = "URI TUIC Parser";
|
|
3788
3894
|
const test = (line) => {
|
|
3789
3895
|
return /^tuic:\/\//.test(line);
|
|
3790
3896
|
};
|
|
3791
|
-
const
|
|
3897
|
+
const parse2 = (line) => {
|
|
3792
3898
|
line = line.split(/tuic:\/\//)[1];
|
|
3793
3899
|
let [__, auth, server, port, addons = "", name2] = /^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
3794
3900
|
auth = decodeURIComponent(auth);
|
|
@@ -3834,14 +3940,14 @@ function URI_TUIC() {
|
|
|
3834
3940
|
}
|
|
3835
3941
|
return proxy;
|
|
3836
3942
|
};
|
|
3837
|
-
return { name, test, parse };
|
|
3943
|
+
return { name, test, parse: parse2 };
|
|
3838
3944
|
}
|
|
3839
3945
|
function URI_WireGuard() {
|
|
3840
3946
|
const name = "URI WireGuard Parser";
|
|
3841
3947
|
const test = (line) => {
|
|
3842
3948
|
return /^(wireguard|wg):\/\//.test(line);
|
|
3843
3949
|
};
|
|
3844
|
-
const
|
|
3950
|
+
const parse2 = (line) => {
|
|
3845
3951
|
line = line.split(/(wireguard|wg):\/\//)[2];
|
|
3846
3952
|
let [
|
|
3847
3953
|
__,
|
|
@@ -3924,14 +4030,14 @@ function URI_WireGuard() {
|
|
|
3924
4030
|
}
|
|
3925
4031
|
return proxy;
|
|
3926
4032
|
};
|
|
3927
|
-
return { name, test, parse };
|
|
4033
|
+
return { name, test, parse: parse2 };
|
|
3928
4034
|
}
|
|
3929
4035
|
function URI_Trojan() {
|
|
3930
4036
|
const name = "URI Trojan Parser";
|
|
3931
4037
|
const test = (line) => {
|
|
3932
4038
|
return /^trojan:\/\//.test(line);
|
|
3933
4039
|
};
|
|
3934
|
-
const
|
|
4040
|
+
const parse2 = (line) => {
|
|
3935
4041
|
const matched = /^(trojan:\/\/.*?@.*?)(:(\d+))?\/?(\?.*?)?$/.exec(line);
|
|
3936
4042
|
const port = matched?.[2];
|
|
3937
4043
|
if (!port) {
|
|
@@ -3949,7 +4055,7 @@ function URI_Trojan() {
|
|
|
3949
4055
|
}
|
|
3950
4056
|
return proxy;
|
|
3951
4057
|
};
|
|
3952
|
-
return { name, test, parse };
|
|
4058
|
+
return { name, test, parse: parse2 };
|
|
3953
4059
|
}
|
|
3954
4060
|
function Clash_All() {
|
|
3955
4061
|
const name = "Clash Parser";
|
|
@@ -3962,7 +4068,7 @@ function Clash_All() {
|
|
|
3962
4068
|
}
|
|
3963
4069
|
return !!proxy?.type;
|
|
3964
4070
|
};
|
|
3965
|
-
const
|
|
4071
|
+
const parse2 = (line) => {
|
|
3966
4072
|
let proxy;
|
|
3967
4073
|
try {
|
|
3968
4074
|
proxy = JSON5.parse(line);
|
|
@@ -4024,153 +4130,153 @@ function Clash_All() {
|
|
|
4024
4130
|
}
|
|
4025
4131
|
return proxy;
|
|
4026
4132
|
};
|
|
4027
|
-
return { name, test, parse };
|
|
4133
|
+
return { name, test, parse: parse2 };
|
|
4028
4134
|
}
|
|
4029
4135
|
function QX_SS() {
|
|
4030
4136
|
const name = "QX SS Parser";
|
|
4031
4137
|
const test = (line) => {
|
|
4032
4138
|
return /^shadowsocks\s*=/.test(line.split(",")[0].trim()) && line.indexOf("ssr-protocol") === -1;
|
|
4033
4139
|
};
|
|
4034
|
-
const
|
|
4140
|
+
const parse2 = (line) => {
|
|
4035
4141
|
const parser5 = getParser3();
|
|
4036
4142
|
return parser5.parse(line);
|
|
4037
4143
|
};
|
|
4038
|
-
return { name, test, parse };
|
|
4144
|
+
return { name, test, parse: parse2 };
|
|
4039
4145
|
}
|
|
4040
4146
|
function QX_SSR() {
|
|
4041
4147
|
const name = "QX SSR Parser";
|
|
4042
4148
|
const test = (line) => {
|
|
4043
4149
|
return /^shadowsocks\s*=/.test(line.split(",")[0].trim()) && line.indexOf("ssr-protocol") !== -1;
|
|
4044
4150
|
};
|
|
4045
|
-
const
|
|
4046
|
-
return { name, test, parse };
|
|
4151
|
+
const parse2 = (line) => getParser3().parse(line);
|
|
4152
|
+
return { name, test, parse: parse2 };
|
|
4047
4153
|
}
|
|
4048
4154
|
function QX_VMess() {
|
|
4049
4155
|
const name = "QX VMess Parser";
|
|
4050
4156
|
const test = (line) => {
|
|
4051
4157
|
return /^vmess\s*=/.test(line.split(",")[0].trim());
|
|
4052
4158
|
};
|
|
4053
|
-
const
|
|
4054
|
-
return { name, test, parse };
|
|
4159
|
+
const parse2 = (line) => getParser3().parse(line);
|
|
4160
|
+
return { name, test, parse: parse2 };
|
|
4055
4161
|
}
|
|
4056
4162
|
function QX_VLESS() {
|
|
4057
4163
|
const name = "QX VLESS Parser";
|
|
4058
4164
|
const test = (line) => {
|
|
4059
4165
|
return /^vless\s*=/.test(line.split(",")[0].trim());
|
|
4060
4166
|
};
|
|
4061
|
-
const
|
|
4062
|
-
return { name, test, parse };
|
|
4167
|
+
const parse2 = (line) => getParser3().parse(line);
|
|
4168
|
+
return { name, test, parse: parse2 };
|
|
4063
4169
|
}
|
|
4064
4170
|
function QX_AnyTLS() {
|
|
4065
4171
|
const name = "QX AnyTLS Parser";
|
|
4066
4172
|
const test = (line) => {
|
|
4067
4173
|
return /^anytls\s*=/.test(line.split(",")[0].trim());
|
|
4068
4174
|
};
|
|
4069
|
-
const
|
|
4070
|
-
return { name, test, parse };
|
|
4175
|
+
const parse2 = (line) => getParser3().parse(line);
|
|
4176
|
+
return { name, test, parse: parse2 };
|
|
4071
4177
|
}
|
|
4072
4178
|
function QX_Trojan() {
|
|
4073
4179
|
const name = "QX Trojan Parser";
|
|
4074
4180
|
const test = (line) => {
|
|
4075
4181
|
return /^trojan\s*=/.test(line.split(",")[0].trim());
|
|
4076
4182
|
};
|
|
4077
|
-
const
|
|
4078
|
-
return { name, test, parse };
|
|
4183
|
+
const parse2 = (line) => getParser3().parse(line);
|
|
4184
|
+
return { name, test, parse: parse2 };
|
|
4079
4185
|
}
|
|
4080
4186
|
function QX_Http() {
|
|
4081
4187
|
const name = "QX HTTP Parser";
|
|
4082
4188
|
const test = (line) => {
|
|
4083
4189
|
return /^http\s*=/.test(line.split(",")[0].trim());
|
|
4084
4190
|
};
|
|
4085
|
-
const
|
|
4086
|
-
return { name, test, parse };
|
|
4191
|
+
const parse2 = (line) => getParser3().parse(line);
|
|
4192
|
+
return { name, test, parse: parse2 };
|
|
4087
4193
|
}
|
|
4088
4194
|
function QX_Socks5() {
|
|
4089
4195
|
const name = "QX Socks5 Parser";
|
|
4090
4196
|
const test = (line) => {
|
|
4091
4197
|
return /^socks5\s*=/.test(line.split(",")[0].trim());
|
|
4092
4198
|
};
|
|
4093
|
-
const
|
|
4094
|
-
return { name, test, parse };
|
|
4199
|
+
const parse2 = (line) => getParser3().parse(line);
|
|
4200
|
+
return { name, test, parse: parse2 };
|
|
4095
4201
|
}
|
|
4096
4202
|
function Loon_SS() {
|
|
4097
4203
|
const name = "Loon SS Parser";
|
|
4098
4204
|
const test = (line) => {
|
|
4099
4205
|
return line.split(",")[0].split("=")[1].trim().toLowerCase() === "shadowsocks";
|
|
4100
4206
|
};
|
|
4101
|
-
const
|
|
4102
|
-
return { name, test, parse };
|
|
4207
|
+
const parse2 = (line) => getParser2().parse(line);
|
|
4208
|
+
return { name, test, parse: parse2 };
|
|
4103
4209
|
}
|
|
4104
4210
|
function Loon_SSR() {
|
|
4105
4211
|
const name = "Loon SSR Parser";
|
|
4106
4212
|
const test = (line) => {
|
|
4107
4213
|
return line.split(",")[0].split("=")[1].trim().toLowerCase() === "shadowsocksr";
|
|
4108
4214
|
};
|
|
4109
|
-
const
|
|
4110
|
-
return { name, test, parse };
|
|
4215
|
+
const parse2 = (line) => getParser2().parse(line);
|
|
4216
|
+
return { name, test, parse: parse2 };
|
|
4111
4217
|
}
|
|
4112
4218
|
function Loon_VMess() {
|
|
4113
4219
|
const name = "Loon VMess Parser";
|
|
4114
4220
|
const test = (line) => {
|
|
4115
4221
|
return /^.*=\s*vmess/i.test(line.split(",")[0]) && line.indexOf("username") === -1;
|
|
4116
4222
|
};
|
|
4117
|
-
const
|
|
4118
|
-
return { name, test, parse };
|
|
4223
|
+
const parse2 = (line) => getParser2().parse(line);
|
|
4224
|
+
return { name, test, parse: parse2 };
|
|
4119
4225
|
}
|
|
4120
4226
|
function Loon_Vless() {
|
|
4121
4227
|
const name = "Loon Vless Parser";
|
|
4122
4228
|
const test = (line) => {
|
|
4123
4229
|
return /^.*=\s*vless/i.test(line.split(",")[0]);
|
|
4124
4230
|
};
|
|
4125
|
-
const
|
|
4126
|
-
return { name, test, parse };
|
|
4231
|
+
const parse2 = (line) => getParser2().parse(line);
|
|
4232
|
+
return { name, test, parse: parse2 };
|
|
4127
4233
|
}
|
|
4128
4234
|
function Loon_Trojan() {
|
|
4129
4235
|
const name = "Loon Trojan Parser";
|
|
4130
4236
|
const test = (line) => {
|
|
4131
4237
|
return /^.*=\s*trojan/i.test(line.split(",")[0]);
|
|
4132
4238
|
};
|
|
4133
|
-
const
|
|
4134
|
-
return { name, test, parse };
|
|
4239
|
+
const parse2 = (line) => getParser2().parse(line);
|
|
4240
|
+
return { name, test, parse: parse2 };
|
|
4135
4241
|
}
|
|
4136
4242
|
function Loon_AnyTLS() {
|
|
4137
4243
|
const name = "Loon AnyTLS Parser";
|
|
4138
4244
|
const test = (line) => {
|
|
4139
4245
|
return /^.*=\s*anytls/i.test(line.split(",")[0]);
|
|
4140
4246
|
};
|
|
4141
|
-
const
|
|
4142
|
-
return { name, test, parse };
|
|
4247
|
+
const parse2 = (line) => getParser2().parse(line);
|
|
4248
|
+
return { name, test, parse: parse2 };
|
|
4143
4249
|
}
|
|
4144
4250
|
function Loon_Hysteria2() {
|
|
4145
4251
|
const name = "Loon Hysteria2 Parser";
|
|
4146
4252
|
const test = (line) => {
|
|
4147
4253
|
return /^.*=\s*Hysteria2/i.test(line.split(",")[0]);
|
|
4148
4254
|
};
|
|
4149
|
-
const
|
|
4150
|
-
return { name, test, parse };
|
|
4255
|
+
const parse2 = (line) => getParser2().parse(line);
|
|
4256
|
+
return { name, test, parse: parse2 };
|
|
4151
4257
|
}
|
|
4152
4258
|
function Loon_Http() {
|
|
4153
4259
|
const name = "Loon HTTP Parser";
|
|
4154
4260
|
const test = (line) => {
|
|
4155
4261
|
return /^.*=\s*http/i.test(line.split(",")[0]);
|
|
4156
4262
|
};
|
|
4157
|
-
const
|
|
4158
|
-
return { name, test, parse };
|
|
4263
|
+
const parse2 = (line) => getParser2().parse(line);
|
|
4264
|
+
return { name, test, parse: parse2 };
|
|
4159
4265
|
}
|
|
4160
4266
|
function Loon_Socks5() {
|
|
4161
4267
|
const name = "Loon SOCKS5 Parser";
|
|
4162
4268
|
const test = (line) => {
|
|
4163
4269
|
return /^.*=\s*socks5/i.test(line.split(",")[0]);
|
|
4164
4270
|
};
|
|
4165
|
-
const
|
|
4166
|
-
return { name, test, parse };
|
|
4271
|
+
const parse2 = (line) => getParser2().parse(line);
|
|
4272
|
+
return { name, test, parse: parse2 };
|
|
4167
4273
|
}
|
|
4168
4274
|
function Loon_WireGuard() {
|
|
4169
4275
|
const name = "Loon WireGuard Parser";
|
|
4170
4276
|
const test = (line) => {
|
|
4171
4277
|
return /^.*=\s*wireguard/i.test(line.split(",")[0]);
|
|
4172
4278
|
};
|
|
4173
|
-
const
|
|
4279
|
+
const parse2 = (line) => {
|
|
4174
4280
|
const name2 = line.match(
|
|
4175
4281
|
/(^.*?)\s*?=\s*?wireguard\s*?,.+?\s*?=\s*?.+?/i
|
|
4176
4282
|
)?.[1];
|
|
@@ -4263,71 +4369,71 @@ function Loon_WireGuard() {
|
|
|
4263
4369
|
}
|
|
4264
4370
|
return proxy;
|
|
4265
4371
|
};
|
|
4266
|
-
return { name, test, parse };
|
|
4372
|
+
return { name, test, parse: parse2 };
|
|
4267
4373
|
}
|
|
4268
4374
|
function Surge_Direct() {
|
|
4269
4375
|
const name = "Surge Direct Parser";
|
|
4270
4376
|
const test = (line) => {
|
|
4271
4377
|
return /^.*=\s*direct/.test(line.split(",")[0]);
|
|
4272
4378
|
};
|
|
4273
|
-
const
|
|
4274
|
-
return { name, test, parse };
|
|
4379
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4380
|
+
return { name, test, parse: parse2 };
|
|
4275
4381
|
}
|
|
4276
4382
|
function Surge_AnyTLS() {
|
|
4277
4383
|
const name = "Surge AnyTLS Parser";
|
|
4278
4384
|
const test = (line) => {
|
|
4279
4385
|
return /^.*=\s*anytls/.test(line.split(",")[0]);
|
|
4280
4386
|
};
|
|
4281
|
-
const
|
|
4282
|
-
return { name, test, parse };
|
|
4387
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4388
|
+
return { name, test, parse: parse2 };
|
|
4283
4389
|
}
|
|
4284
4390
|
function Surge_TrustTunnel() {
|
|
4285
4391
|
const name = "Surge TrustTunnel Parser";
|
|
4286
4392
|
const test = (line) => {
|
|
4287
4393
|
return /^.*=\s*trust-tunnel/.test(line.split(",")[0]);
|
|
4288
4394
|
};
|
|
4289
|
-
const
|
|
4290
|
-
return { name, test, parse };
|
|
4395
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4396
|
+
return { name, test, parse: parse2 };
|
|
4291
4397
|
}
|
|
4292
4398
|
function Surge_H2Connect() {
|
|
4293
4399
|
const name = "Surge HTTP/2 CONNECT Parser";
|
|
4294
4400
|
const test = (line) => {
|
|
4295
4401
|
return /^.*=\s*h2-connect/.test(line.split(",")[0]);
|
|
4296
4402
|
};
|
|
4297
|
-
const
|
|
4298
|
-
return { name, test, parse };
|
|
4403
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4404
|
+
return { name, test, parse: parse2 };
|
|
4299
4405
|
}
|
|
4300
4406
|
function Surge_SSH() {
|
|
4301
4407
|
const name = "Surge SSH Parser";
|
|
4302
4408
|
const test = (line) => {
|
|
4303
4409
|
return /^.*=\s*ssh/.test(line.split(",")[0]);
|
|
4304
4410
|
};
|
|
4305
|
-
const
|
|
4306
|
-
return { name, test, parse };
|
|
4411
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4412
|
+
return { name, test, parse: parse2 };
|
|
4307
4413
|
}
|
|
4308
4414
|
function Surge_SS() {
|
|
4309
4415
|
const name = "Surge SS Parser";
|
|
4310
4416
|
const test = (line) => {
|
|
4311
4417
|
return /^.*=\s*ss/.test(line.split(",")[0]);
|
|
4312
4418
|
};
|
|
4313
|
-
const
|
|
4314
|
-
return { name, test, parse };
|
|
4419
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4420
|
+
return { name, test, parse: parse2 };
|
|
4315
4421
|
}
|
|
4316
4422
|
function Surge_VMess() {
|
|
4317
4423
|
const name = "Surge VMess Parser";
|
|
4318
4424
|
const test = (line) => {
|
|
4319
4425
|
return /^.*=\s*vmess/.test(line.split(",")[0]) && line.indexOf("username") !== -1;
|
|
4320
4426
|
};
|
|
4321
|
-
const
|
|
4322
|
-
return { name, test, parse };
|
|
4427
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4428
|
+
return { name, test, parse: parse2 };
|
|
4323
4429
|
}
|
|
4324
4430
|
function Surge_Trojan() {
|
|
4325
4431
|
const name = "Surge Trojan Parser";
|
|
4326
4432
|
const test = (line) => {
|
|
4327
4433
|
return /^.*=\s*trojan/.test(line.split(",")[0]);
|
|
4328
4434
|
};
|
|
4329
|
-
const
|
|
4330
|
-
return { name, test, parse };
|
|
4435
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4436
|
+
return { name, test, parse: parse2 };
|
|
4331
4437
|
}
|
|
4332
4438
|
var LOON_ONLY_OPTIONS = /(^|,)\s*(fast-open|over-tls|tls-name|ip-mode|tls-cert-sha256|tls-pubkey-sha256)\s*=/i;
|
|
4333
4439
|
function Surge_Http() {
|
|
@@ -4335,23 +4441,23 @@ function Surge_Http() {
|
|
|
4335
4441
|
const test = (line) => {
|
|
4336
4442
|
return /^.*=\s*https?/.test(line.split(",")[0]) && !LOON_ONLY_OPTIONS.test(line);
|
|
4337
4443
|
};
|
|
4338
|
-
const
|
|
4339
|
-
return { name, test, parse };
|
|
4444
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4445
|
+
return { name, test, parse: parse2 };
|
|
4340
4446
|
}
|
|
4341
4447
|
function Surge_Socks5() {
|
|
4342
4448
|
const name = "Surge Socks5 Parser";
|
|
4343
4449
|
const test = (line) => {
|
|
4344
4450
|
return /^.*=\s*socks5(-tls)?/.test(line.split(",")[0]) && !LOON_ONLY_OPTIONS.test(line);
|
|
4345
4451
|
};
|
|
4346
|
-
const
|
|
4347
|
-
return { name, test, parse };
|
|
4452
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4453
|
+
return { name, test, parse: parse2 };
|
|
4348
4454
|
}
|
|
4349
4455
|
function Surge_External() {
|
|
4350
4456
|
const name = "Surge External Parser";
|
|
4351
4457
|
const test = (line) => {
|
|
4352
4458
|
return /^.*=\s*external/.test(line.split(",")[0]);
|
|
4353
4459
|
};
|
|
4354
|
-
const
|
|
4460
|
+
const parse2 = (line) => {
|
|
4355
4461
|
let parsed = /^\s*(.*?)\s*?=\s*?external\s*?,\s*(.*?)\s*$/.exec(line);
|
|
4356
4462
|
let [_3, name2, other] = parsed;
|
|
4357
4463
|
line = other;
|
|
@@ -4404,49 +4510,49 @@ function Surge_External() {
|
|
|
4404
4510
|
};
|
|
4405
4511
|
return proxy;
|
|
4406
4512
|
};
|
|
4407
|
-
return { name, test, parse };
|
|
4513
|
+
return { name, test, parse: parse2 };
|
|
4408
4514
|
}
|
|
4409
4515
|
function Surge_Snell() {
|
|
4410
4516
|
const name = "Surge Snell Parser";
|
|
4411
4517
|
const test = (line) => {
|
|
4412
4518
|
return /^.*=\s*snell/.test(line.split(",")[0]);
|
|
4413
4519
|
};
|
|
4414
|
-
const
|
|
4415
|
-
return { name, test, parse };
|
|
4520
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4521
|
+
return { name, test, parse: parse2 };
|
|
4416
4522
|
}
|
|
4417
4523
|
function Surge_Tuic() {
|
|
4418
4524
|
const name = "Surge Tuic Parser";
|
|
4419
4525
|
const test = (line) => {
|
|
4420
4526
|
return /^.*=\s*tuic(-v5)?/.test(line.split(",")[0]);
|
|
4421
4527
|
};
|
|
4422
|
-
const
|
|
4528
|
+
const parse2 = (raw) => {
|
|
4423
4529
|
const { port_hopping, line } = surge_port_hopping(raw);
|
|
4424
4530
|
const proxy = getParser().parse(line);
|
|
4425
4531
|
proxy["ports"] = port_hopping;
|
|
4426
4532
|
return proxy;
|
|
4427
4533
|
};
|
|
4428
|
-
return { name, test, parse };
|
|
4534
|
+
return { name, test, parse: parse2 };
|
|
4429
4535
|
}
|
|
4430
4536
|
function Surge_WireGuard() {
|
|
4431
4537
|
const name = "Surge WireGuard Parser";
|
|
4432
4538
|
const test = (line) => {
|
|
4433
4539
|
return /^.*=\s*wireguard/.test(line.split(",")[0]);
|
|
4434
4540
|
};
|
|
4435
|
-
const
|
|
4436
|
-
return { name, test, parse };
|
|
4541
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4542
|
+
return { name, test, parse: parse2 };
|
|
4437
4543
|
}
|
|
4438
4544
|
function Surge_Hysteria2() {
|
|
4439
4545
|
const name = "Surge Hysteria2 Parser";
|
|
4440
4546
|
const test = (line) => {
|
|
4441
4547
|
return /^.*=\s*hysteria2/.test(line.split(",")[0]);
|
|
4442
4548
|
};
|
|
4443
|
-
const
|
|
4549
|
+
const parse2 = (raw) => {
|
|
4444
4550
|
const { port_hopping, line } = surge_port_hopping(raw);
|
|
4445
4551
|
const proxy = getParser().parse(line);
|
|
4446
4552
|
proxy["ports"] = port_hopping;
|
|
4447
4553
|
return proxy;
|
|
4448
4554
|
};
|
|
4449
|
-
return { name, test, parse };
|
|
4555
|
+
return { name, test, parse: parse2 };
|
|
4450
4556
|
}
|
|
4451
4557
|
function isIP(ip) {
|
|
4452
4558
|
return isIPv4(ip) || isIPv6(ip);
|
|
@@ -4533,8 +4639,8 @@ function normalizeClashYaml(raw) {
|
|
|
4533
4639
|
function HTML() {
|
|
4534
4640
|
const name = "HTML";
|
|
4535
4641
|
const test = (raw) => /^<!DOCTYPE html>/.test(raw);
|
|
4536
|
-
const
|
|
4537
|
-
return { name, test, parse };
|
|
4642
|
+
const parse2 = () => "";
|
|
4643
|
+
return { name, test, parse: parse2 };
|
|
4538
4644
|
}
|
|
4539
4645
|
function Base64Encoded() {
|
|
4540
4646
|
const name = "Base64 Pre-processor";
|
|
@@ -4571,7 +4677,7 @@ function Base64Encoded() {
|
|
|
4571
4677
|
const test = function(raw) {
|
|
4572
4678
|
return !/^\w+:\/\/\w+/im.test(raw) && keys.some((k) => raw.indexOf(k) !== -1);
|
|
4573
4679
|
};
|
|
4574
|
-
const
|
|
4680
|
+
const parse2 = function(raw) {
|
|
4575
4681
|
const decoded = Base642.decode(raw);
|
|
4576
4682
|
if (!/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(decoded)) {
|
|
4577
4683
|
app_default.error(
|
|
@@ -4581,14 +4687,14 @@ function Base64Encoded() {
|
|
|
4581
4687
|
}
|
|
4582
4688
|
return decoded;
|
|
4583
4689
|
};
|
|
4584
|
-
return { name, test, parse };
|
|
4690
|
+
return { name, test, parse: parse2 };
|
|
4585
4691
|
}
|
|
4586
4692
|
function fallbackBase64Encoded() {
|
|
4587
4693
|
const name = "Fallback Base64 Pre-processor";
|
|
4588
4694
|
const test = function(raw) {
|
|
4589
4695
|
return true;
|
|
4590
4696
|
};
|
|
4591
|
-
const
|
|
4697
|
+
const parse2 = function(raw) {
|
|
4592
4698
|
const decoded = Base642.decode(raw);
|
|
4593
4699
|
if (!/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(decoded)) {
|
|
4594
4700
|
app_default.error(
|
|
@@ -4598,7 +4704,7 @@ function fallbackBase64Encoded() {
|
|
|
4598
4704
|
}
|
|
4599
4705
|
return decoded;
|
|
4600
4706
|
};
|
|
4601
|
-
return { name, test, parse };
|
|
4707
|
+
return { name, test, parse: parse2 };
|
|
4602
4708
|
}
|
|
4603
4709
|
function Clash() {
|
|
4604
4710
|
const name = "Clash Pre-processor";
|
|
@@ -4607,7 +4713,7 @@ function Clash() {
|
|
|
4607
4713
|
const content = safeLoad(raw);
|
|
4608
4714
|
return content.proxies && Array.isArray(content.proxies);
|
|
4609
4715
|
};
|
|
4610
|
-
const
|
|
4716
|
+
const parse2 = function(raw, includeProxies) {
|
|
4611
4717
|
const afterReplace = normalizeClashYaml(raw);
|
|
4612
4718
|
const { proxies } = safeLoad(afterReplace);
|
|
4613
4719
|
return (includeProxies ? "proxies:\n" : "") + proxies.map((p) => {
|
|
@@ -4617,14 +4723,14 @@ function Clash() {
|
|
|
4617
4723
|
`;
|
|
4618
4724
|
}).join("");
|
|
4619
4725
|
};
|
|
4620
|
-
return { name, test, parse };
|
|
4726
|
+
return { name, test, parse: parse2 };
|
|
4621
4727
|
}
|
|
4622
4728
|
function SSD() {
|
|
4623
4729
|
const name = "SSD Pre-processor";
|
|
4624
4730
|
const test = function(raw) {
|
|
4625
4731
|
return raw.indexOf("ssd://") === 0;
|
|
4626
4732
|
};
|
|
4627
|
-
const
|
|
4733
|
+
const parse2 = function(raw) {
|
|
4628
4734
|
const output = [];
|
|
4629
4735
|
let ssdinfo = JSON.parse(Base642.decode(raw.split("ssd://")[1]));
|
|
4630
4736
|
let port = ssdinfo.port;
|
|
@@ -4646,20 +4752,20 @@ function SSD() {
|
|
|
4646
4752
|
}
|
|
4647
4753
|
return output.join("\n");
|
|
4648
4754
|
};
|
|
4649
|
-
return { name, test, parse };
|
|
4755
|
+
return { name, test, parse: parse2 };
|
|
4650
4756
|
}
|
|
4651
4757
|
function FullConfig() {
|
|
4652
4758
|
const name = "Full Config Preprocessor";
|
|
4653
4759
|
const test = function(raw) {
|
|
4654
4760
|
return /^(\[server_local\]|\[Proxy\])/gm.test(raw);
|
|
4655
4761
|
};
|
|
4656
|
-
const
|
|
4762
|
+
const parse2 = function(raw) {
|
|
4657
4763
|
const match = raw.match(
|
|
4658
4764
|
/^\[server_local|Proxy\]([\s\S]+?)^\[.+?\](\r?\n|$)/im
|
|
4659
4765
|
)?.[1];
|
|
4660
4766
|
return match || raw;
|
|
4661
4767
|
};
|
|
4662
|
-
return { name, test, parse };
|
|
4768
|
+
return { name, test, parse: parse2 };
|
|
4663
4769
|
}
|
|
4664
4770
|
var preprocessors_default = [
|
|
4665
4771
|
HTML(),
|
|
@@ -4804,6 +4910,37 @@ function quoteSurgeValue(value) {
|
|
|
4804
4910
|
function hasNonBlankValue(value) {
|
|
4805
4911
|
return value != null && `${value}`.trim().length > 0;
|
|
4806
4912
|
}
|
|
4913
|
+
function formatSurgeAlpn(alpn) {
|
|
4914
|
+
const values = Array.isArray(alpn) ? alpn : stripSurgeQuotes(`${alpn || ""}`).split(",");
|
|
4915
|
+
return values.filter((item) => item != null).map((item) => String(stripSurgeQuotes(item)).trim()).filter((item) => item !== "").join(",");
|
|
4916
|
+
}
|
|
4917
|
+
function appendAlpn(result, proxy) {
|
|
4918
|
+
const alpn = formatSurgeAlpn(proxy.alpn);
|
|
4919
|
+
if (alpn) result.append(`,alpn="${alpn}"`);
|
|
4920
|
+
}
|
|
4921
|
+
function getShadowTLSAlpn(proxy) {
|
|
4922
|
+
return formatSurgeAlpn(proxy?.["plugin-opts"]?.alpn ?? proxy?.alpn);
|
|
4923
|
+
}
|
|
4924
|
+
function appendShadowTLS(result, proxy, includeUdpPort = false) {
|
|
4925
|
+
if (proxy.plugin !== "shadow-tls" || !proxy["plugin-opts"]) return;
|
|
4926
|
+
const password = proxy["plugin-opts"].password;
|
|
4927
|
+
const host = proxy["plugin-opts"].host;
|
|
4928
|
+
const version = proxy["plugin-opts"].version;
|
|
4929
|
+
if (!password) return;
|
|
4930
|
+
result.append(`,shadow-tls-password="${password}"`);
|
|
4931
|
+
if (host) result.append(`,shadow-tls-sni=${host}`);
|
|
4932
|
+
if (version) {
|
|
4933
|
+
if (version < 2) {
|
|
4934
|
+
throw unsupported(`shadow-tls version ${version} is not supported`);
|
|
4935
|
+
}
|
|
4936
|
+
result.append(`,shadow-tls-version=${version}`);
|
|
4937
|
+
}
|
|
4938
|
+
const alpn = getShadowTLSAlpn(proxy);
|
|
4939
|
+
if (alpn) result.append(`,alpn="${alpn}"`);
|
|
4940
|
+
if (includeUdpPort) {
|
|
4941
|
+
result.appendIfPresent(`,udp-port=${proxy["udp-port"]}`, "udp-port");
|
|
4942
|
+
}
|
|
4943
|
+
}
|
|
4807
4944
|
function appendTlsProxyParams(result, proxy, enabled = true) {
|
|
4808
4945
|
if (!enabled) {
|
|
4809
4946
|
return;
|
|
@@ -4813,6 +4950,9 @@ function appendTlsProxyParams(result, proxy, enabled = true) {
|
|
|
4813
4950
|
"tls-fingerprint"
|
|
4814
4951
|
);
|
|
4815
4952
|
result.appendIfPresent(`,sni="${proxy.sni}"`, "sni");
|
|
4953
|
+
if (proxy.plugin !== "shadow-tls") {
|
|
4954
|
+
appendAlpn(result, proxy);
|
|
4955
|
+
}
|
|
4816
4956
|
result.appendIfPresent(
|
|
4817
4957
|
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
4818
4958
|
"skip-cert-verify"
|
|
@@ -4978,40 +5118,7 @@ function shadowsocks(proxy) {
|
|
|
4978
5118
|
"interface-name"
|
|
4979
5119
|
);
|
|
4980
5120
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
4981
|
-
|
|
4982
|
-
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
4983
|
-
result.appendIfPresent(
|
|
4984
|
-
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
4985
|
-
"shadow-tls-version"
|
|
4986
|
-
);
|
|
4987
|
-
result.appendIfPresent(
|
|
4988
|
-
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
4989
|
-
"shadow-tls-sni"
|
|
4990
|
-
);
|
|
4991
|
-
result.appendIfPresent(`,udp-port=${proxy["udp-port"]}`, "udp-port");
|
|
4992
|
-
} else if (["shadow-tls"].includes(proxy.plugin) && proxy["plugin-opts"]) {
|
|
4993
|
-
const password = proxy["plugin-opts"].password;
|
|
4994
|
-
const host = proxy["plugin-opts"].host;
|
|
4995
|
-
const version = proxy["plugin-opts"].version;
|
|
4996
|
-
if (password) {
|
|
4997
|
-
result.append(`,shadow-tls-password="${password}"`);
|
|
4998
|
-
if (host) {
|
|
4999
|
-
result.append(`,shadow-tls-sni=${host}`);
|
|
5000
|
-
}
|
|
5001
|
-
if (version) {
|
|
5002
|
-
if (version < 2) {
|
|
5003
|
-
throw unsupported(
|
|
5004
|
-
`shadow-tls version ${version} is not supported`
|
|
5005
|
-
);
|
|
5006
|
-
}
|
|
5007
|
-
result.append(`,shadow-tls-version=${version}`);
|
|
5008
|
-
}
|
|
5009
|
-
result.appendIfPresent(
|
|
5010
|
-
`,udp-port=${proxy["udp-port"]}`,
|
|
5011
|
-
"udp-port"
|
|
5012
|
-
);
|
|
5013
|
-
}
|
|
5014
|
-
}
|
|
5121
|
+
appendShadowTLS(result, proxy, true);
|
|
5015
5122
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5016
5123
|
result.appendIfPresent(
|
|
5017
5124
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5051,17 +5158,7 @@ function trojan(proxy) {
|
|
|
5051
5158
|
"interface-name"
|
|
5052
5159
|
);
|
|
5053
5160
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
5054
|
-
|
|
5055
|
-
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
5056
|
-
result.appendIfPresent(
|
|
5057
|
-
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
5058
|
-
"shadow-tls-version"
|
|
5059
|
-
);
|
|
5060
|
-
result.appendIfPresent(
|
|
5061
|
-
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
5062
|
-
"shadow-tls-sni"
|
|
5063
|
-
);
|
|
5064
|
-
}
|
|
5161
|
+
appendShadowTLS(result, proxy);
|
|
5065
5162
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5066
5163
|
result.appendIfPresent(
|
|
5067
5164
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5191,17 +5288,7 @@ function h2Connect(proxy) {
|
|
|
5191
5288
|
"interface-name"
|
|
5192
5289
|
);
|
|
5193
5290
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
5194
|
-
|
|
5195
|
-
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
5196
|
-
result.appendIfPresent(
|
|
5197
|
-
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
5198
|
-
"shadow-tls-version"
|
|
5199
|
-
);
|
|
5200
|
-
result.appendIfPresent(
|
|
5201
|
-
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
5202
|
-
"shadow-tls-sni"
|
|
5203
|
-
);
|
|
5204
|
-
}
|
|
5291
|
+
appendShadowTLS(result, proxy);
|
|
5205
5292
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5206
5293
|
result.appendIfPresent(
|
|
5207
5294
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5250,17 +5337,7 @@ function vmess(proxy, includeUnsupportedProxy) {
|
|
|
5250
5337
|
"interface-name"
|
|
5251
5338
|
);
|
|
5252
5339
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
5253
|
-
|
|
5254
|
-
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
5255
|
-
result.appendIfPresent(
|
|
5256
|
-
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
5257
|
-
"shadow-tls-version"
|
|
5258
|
-
);
|
|
5259
|
-
result.appendIfPresent(
|
|
5260
|
-
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
5261
|
-
"shadow-tls-sni"
|
|
5262
|
-
);
|
|
5263
|
-
}
|
|
5340
|
+
appendShadowTLS(result, proxy);
|
|
5264
5341
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5265
5342
|
result.appendIfPresent(
|
|
5266
5343
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5347,17 +5424,7 @@ function http(proxy) {
|
|
|
5347
5424
|
"interface-name"
|
|
5348
5425
|
);
|
|
5349
5426
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
5350
|
-
|
|
5351
|
-
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
5352
|
-
result.appendIfPresent(
|
|
5353
|
-
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
5354
|
-
"shadow-tls-version"
|
|
5355
|
-
);
|
|
5356
|
-
result.appendIfPresent(
|
|
5357
|
-
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
5358
|
-
"shadow-tls-sni"
|
|
5359
|
-
);
|
|
5360
|
-
}
|
|
5427
|
+
appendShadowTLS(result, proxy);
|
|
5361
5428
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5362
5429
|
result.appendIfPresent(
|
|
5363
5430
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5435,17 +5502,7 @@ function socks5(proxy) {
|
|
|
5435
5502
|
"interface-name"
|
|
5436
5503
|
);
|
|
5437
5504
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
5438
|
-
|
|
5439
|
-
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
5440
|
-
result.appendIfPresent(
|
|
5441
|
-
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
5442
|
-
"shadow-tls-version"
|
|
5443
|
-
);
|
|
5444
|
-
result.appendIfPresent(
|
|
5445
|
-
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
5446
|
-
"shadow-tls-sni"
|
|
5447
|
-
);
|
|
5448
|
-
}
|
|
5505
|
+
appendShadowTLS(result, proxy);
|
|
5449
5506
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5450
5507
|
result.appendIfPresent(
|
|
5451
5508
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5479,6 +5536,9 @@ function snell(proxy) {
|
|
|
5479
5536
|
result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`);
|
|
5480
5537
|
result.appendIfPresent(`,version=${proxy.version}`, "version");
|
|
5481
5538
|
result.appendIfPresent(`,psk="${proxy.psk}"`, "psk");
|
|
5539
|
+
if (Number(proxy.version) === 6) {
|
|
5540
|
+
result.appendIfPresent(`,mode=${proxy.mode}`, "mode");
|
|
5541
|
+
}
|
|
5482
5542
|
const ip_version = ipVersions[proxy["ip-version"]] || proxy["ip-version"];
|
|
5483
5543
|
result.appendIfPresent(`,ip-version=${ip_version}`, "ip-version");
|
|
5484
5544
|
result.appendIfPresent(
|
|
@@ -5516,17 +5576,7 @@ function snell(proxy) {
|
|
|
5516
5576
|
"interface-name"
|
|
5517
5577
|
);
|
|
5518
5578
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
5519
|
-
|
|
5520
|
-
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
5521
|
-
result.appendIfPresent(
|
|
5522
|
-
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
5523
|
-
"shadow-tls-version"
|
|
5524
|
-
);
|
|
5525
|
-
result.appendIfPresent(
|
|
5526
|
-
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
5527
|
-
"shadow-tls-sni"
|
|
5528
|
-
);
|
|
5529
|
-
}
|
|
5579
|
+
appendShadowTLS(result, proxy);
|
|
5530
5580
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5531
5581
|
result.appendIfPresent(
|
|
5532
5582
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5545,10 +5595,6 @@ function tuic(proxy) {
|
|
|
5545
5595
|
result.appendIfPresent(`,uuid=${proxy.uuid}`, "uuid");
|
|
5546
5596
|
result.appendIfPresent(`,password="${proxy.password}"`, "password");
|
|
5547
5597
|
result.appendIfPresent(`,token=${proxy.token}`, "token");
|
|
5548
|
-
result.appendIfPresent(
|
|
5549
|
-
`,alpn=${Array.isArray(proxy.alpn) ? proxy.alpn[0] : proxy.alpn}`,
|
|
5550
|
-
"alpn"
|
|
5551
|
-
);
|
|
5552
5598
|
if (hasNonBlankValue(proxy.ports)) {
|
|
5553
5599
|
result.append(
|
|
5554
5600
|
`,port-hopping="${String(proxy.ports).replace(/,/g, ";")}"`
|
|
@@ -5586,17 +5632,7 @@ function tuic(proxy) {
|
|
|
5586
5632
|
"interface-name"
|
|
5587
5633
|
);
|
|
5588
5634
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
5589
|
-
|
|
5590
|
-
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
5591
|
-
result.appendIfPresent(
|
|
5592
|
-
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
5593
|
-
"shadow-tls-version"
|
|
5594
|
-
);
|
|
5595
|
-
result.appendIfPresent(
|
|
5596
|
-
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
5597
|
-
"shadow-tls-sni"
|
|
5598
|
-
);
|
|
5599
|
-
}
|
|
5635
|
+
appendShadowTLS(result, proxy);
|
|
5600
5636
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5601
5637
|
result.appendIfPresent(
|
|
5602
5638
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5647,17 +5683,7 @@ function wireguard(proxy) {
|
|
|
5647
5683
|
"interface-name"
|
|
5648
5684
|
);
|
|
5649
5685
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
5650
|
-
|
|
5651
|
-
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
5652
|
-
result.appendIfPresent(
|
|
5653
|
-
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
5654
|
-
"shadow-tls-version"
|
|
5655
|
-
);
|
|
5656
|
-
result.appendIfPresent(
|
|
5657
|
-
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
5658
|
-
"shadow-tls-sni"
|
|
5659
|
-
);
|
|
5660
|
-
}
|
|
5686
|
+
appendShadowTLS(result, proxy);
|
|
5661
5687
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5662
5688
|
result.appendIfPresent(
|
|
5663
5689
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5731,17 +5757,7 @@ function wireguard_surge(proxy) {
|
|
|
5731
5757
|
"interface-name"
|
|
5732
5758
|
);
|
|
5733
5759
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
5734
|
-
|
|
5735
|
-
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
5736
|
-
result.appendIfPresent(
|
|
5737
|
-
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
5738
|
-
"shadow-tls-version"
|
|
5739
|
-
);
|
|
5740
|
-
result.appendIfPresent(
|
|
5741
|
-
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
5742
|
-
"shadow-tls-sni"
|
|
5743
|
-
);
|
|
5744
|
-
}
|
|
5760
|
+
appendShadowTLS(result, proxy);
|
|
5745
5761
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5746
5762
|
result.appendIfPresent(
|
|
5747
5763
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5750,8 +5766,12 @@ function wireguard_surge(proxy) {
|
|
|
5750
5766
|
return result.toString();
|
|
5751
5767
|
}
|
|
5752
5768
|
function hysteria2(proxy) {
|
|
5753
|
-
|
|
5754
|
-
|
|
5769
|
+
const obfsPasswordField = {
|
|
5770
|
+
salamander: "salamander-password",
|
|
5771
|
+
gecko: "gecko-password"
|
|
5772
|
+
}[proxy.obfs];
|
|
5773
|
+
if (proxy["obfs-password"] && !obfsPasswordField) {
|
|
5774
|
+
throw unsupported(`only salamander and gecko obfs are supported`);
|
|
5755
5775
|
}
|
|
5756
5776
|
const result = new Result(proxy);
|
|
5757
5777
|
result.append(`${proxy.name}=hysteria2,${proxy.server},${proxy.port}`);
|
|
@@ -5764,8 +5784,8 @@ function hysteria2(proxy) {
|
|
|
5764
5784
|
if (hasNonBlankValue(proxy["hop-interval"])) {
|
|
5765
5785
|
result.append(`,port-hopping-interval=${proxy["hop-interval"]}`);
|
|
5766
5786
|
}
|
|
5767
|
-
if (proxy["obfs-password"] &&
|
|
5768
|
-
result.append(
|
|
5787
|
+
if (proxy["obfs-password"] && obfsPasswordField) {
|
|
5788
|
+
result.append(`,${obfsPasswordField}="${proxy["obfs-password"]}"`);
|
|
5769
5789
|
}
|
|
5770
5790
|
const ip_version = ipVersions[proxy["ip-version"]] || proxy["ip-version"];
|
|
5771
5791
|
result.appendIfPresent(`,ip-version=${ip_version}`, "ip-version");
|
|
@@ -5796,17 +5816,7 @@ function hysteria2(proxy) {
|
|
|
5796
5816
|
"interface-name"
|
|
5797
5817
|
);
|
|
5798
5818
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
5799
|
-
|
|
5800
|
-
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
5801
|
-
result.appendIfPresent(
|
|
5802
|
-
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
5803
|
-
"shadow-tls-version"
|
|
5804
|
-
);
|
|
5805
|
-
result.appendIfPresent(
|
|
5806
|
-
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
5807
|
-
"shadow-tls-sni"
|
|
5808
|
-
);
|
|
5809
|
-
}
|
|
5819
|
+
appendShadowTLS(result, proxy);
|
|
5810
5820
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5811
5821
|
result.appendIfPresent(
|
|
5812
5822
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5888,13 +5898,13 @@ function ClashMeta_Producer() {
|
|
|
5888
5898
|
if (opts["include-unsupported-proxy"]) return true;
|
|
5889
5899
|
if (proxy.type === "h2-connect") {
|
|
5890
5900
|
app_default.error(
|
|
5891
|
-
`
|
|
5901
|
+
`mihomo does not support HTTP/2 CONNECT proxy type. Proxy ${proxy.name} has been filtered.`
|
|
5892
5902
|
);
|
|
5893
5903
|
return false;
|
|
5894
5904
|
}
|
|
5895
5905
|
if (hasRootHeaders(proxy) && proxy.type === "trusttunnel") {
|
|
5896
5906
|
app_default.error(
|
|
5897
|
-
`
|
|
5907
|
+
`mihomo does not support headers for TrustTunnel proxy ${proxy.name}. Proxy has been filtered.`
|
|
5898
5908
|
);
|
|
5899
5909
|
return false;
|
|
5900
5910
|
}
|
|
@@ -5902,11 +5912,16 @@ function ClashMeta_Producer() {
|
|
|
5902
5912
|
return false;
|
|
5903
5913
|
} else if (proxy.type === "snell" && !isSupportedMihomoVersion(proxy.version, [1, 2, 3, 4, 5])) {
|
|
5904
5914
|
return false;
|
|
5905
|
-
} else if (hasMihomoShadowTls(proxy) && (proxy.type
|
|
5915
|
+
} else if (hasMihomoShadowTls(proxy) && (!["ss", "snell"].includes(proxy.type) || !isSupportedMihomoVersion(
|
|
5906
5916
|
getMihomoShadowTlsVersion(proxy),
|
|
5907
5917
|
[1, 2, 3]
|
|
5908
5918
|
))) {
|
|
5909
5919
|
return false;
|
|
5920
|
+
} else if (hasMihomoSnellShadowTlsObfsConflict(proxy)) {
|
|
5921
|
+
app_default.error(
|
|
5922
|
+
`Platform Mihomo does not support Snell shadow-tls with obfs for proxy ${proxy.name}. Proxy has been filtered.`
|
|
5923
|
+
);
|
|
5924
|
+
return false;
|
|
5910
5925
|
} else if (["juicity", "naive"].includes(proxy.type)) {
|
|
5911
5926
|
return false;
|
|
5912
5927
|
} else if (["ss"].includes(proxy.type) && ![
|
|
@@ -6009,24 +6024,28 @@ function ClashMeta_Producer() {
|
|
|
6009
6024
|
ds["reality-opts"] = { "public-key": "" };
|
|
6010
6025
|
}
|
|
6011
6026
|
}
|
|
6012
|
-
} else if (proxy.type === "ss") {
|
|
6013
|
-
if (isPresent2(proxy, "shadow-tls-password") && !isPresent2(proxy, "plugin")) {
|
|
6014
|
-
proxy.plugin = "shadow-tls";
|
|
6015
|
-
proxy["plugin-opts"] = {
|
|
6016
|
-
host: proxy["shadow-tls-sni"],
|
|
6017
|
-
password: proxy["shadow-tls-password"],
|
|
6018
|
-
version: proxy["shadow-tls-version"]
|
|
6019
|
-
};
|
|
6020
|
-
delete proxy["shadow-tls-password"];
|
|
6021
|
-
delete proxy["shadow-tls-sni"];
|
|
6022
|
-
delete proxy["shadow-tls-version"];
|
|
6023
|
-
}
|
|
6024
6027
|
}
|
|
6025
6028
|
if (isPresent2(proxy, "plugin-opts.mux")) {
|
|
6026
6029
|
proxy["plugin-opts"].mux = normalizePluginMuxBooleanValue(
|
|
6027
6030
|
proxy["plugin-opts"].mux
|
|
6028
6031
|
);
|
|
6029
6032
|
}
|
|
6033
|
+
if (proxy.type === "snell") {
|
|
6034
|
+
const shadowTLSOpts = getMihomoShadowTlsOpts(proxy);
|
|
6035
|
+
if (shadowTLSOpts) {
|
|
6036
|
+
proxy["obfs-opts"] = {
|
|
6037
|
+
mode: "shadow-tls",
|
|
6038
|
+
host: shadowTLSOpts.host,
|
|
6039
|
+
password: shadowTLSOpts.password,
|
|
6040
|
+
version: shadowTLSOpts.version
|
|
6041
|
+
};
|
|
6042
|
+
if (shadowTLSOpts.alpn) {
|
|
6043
|
+
proxy["obfs-opts"].alpn = shadowTLSOpts.alpn;
|
|
6044
|
+
}
|
|
6045
|
+
delete proxy.plugin;
|
|
6046
|
+
delete proxy["plugin-opts"];
|
|
6047
|
+
}
|
|
6048
|
+
}
|
|
6030
6049
|
if (["vmess", "vless"].includes(proxy.type) && proxy.network === "http") {
|
|
6031
6050
|
let httpPath = proxy["http-opts"]?.path;
|
|
6032
6051
|
if (isPresent2(proxy, "http-opts.path") && !Array.isArray(httpPath)) {
|
|
@@ -6135,14 +6154,20 @@ function isSupportedMihomoVersion(version, supportedVersions) {
|
|
|
6135
6154
|
return Number.isInteger(parsed) && supportedVersions.includes(parsed);
|
|
6136
6155
|
}
|
|
6137
6156
|
function hasMihomoShadowTls(proxy) {
|
|
6138
|
-
return
|
|
6157
|
+
return Boolean(getMihomoShadowTlsOpts(proxy));
|
|
6158
|
+
}
|
|
6159
|
+
function hasMihomoSnellShadowTlsObfsConflict(proxy) {
|
|
6160
|
+
return proxy?.type === "snell" && proxy?.plugin === "shadow-tls" && (isPresent2(proxy, "obfs-opts.mode") || isPresent2(proxy, "obfs-opts.host") || isPresent2(proxy, "obfs-opts.path"));
|
|
6139
6161
|
}
|
|
6140
6162
|
function getMihomoShadowTlsVersion(proxy) {
|
|
6141
|
-
|
|
6142
|
-
|
|
6163
|
+
return getMihomoShadowTlsOpts(proxy)?.version;
|
|
6164
|
+
}
|
|
6165
|
+
function getMihomoShadowTlsOpts(proxy) {
|
|
6166
|
+
if (proxy?.plugin === "shadow-tls" && proxy?.["plugin-opts"]) {
|
|
6167
|
+
return proxy["plugin-opts"];
|
|
6143
6168
|
}
|
|
6144
|
-
if (proxy?.
|
|
6145
|
-
return proxy
|
|
6169
|
+
if (proxy?.type === "snell" && proxy?.["obfs-opts"]?.mode === "shadow-tls") {
|
|
6170
|
+
return proxy["obfs-opts"];
|
|
6146
6171
|
}
|
|
6147
6172
|
return void 0;
|
|
6148
6173
|
}
|
|
@@ -6170,7 +6195,7 @@ function SurgeMac_Producer() {
|
|
|
6170
6195
|
throw e;
|
|
6171
6196
|
}
|
|
6172
6197
|
app_default.log(
|
|
6173
|
-
`${proxy.name} is not supported on ${targetPlatform2}, try to use
|
|
6198
|
+
`${proxy.name} is not supported on ${targetPlatform2}, try to use mihomo(SurgeMac - External Proxy Program) instead`
|
|
6174
6199
|
);
|
|
6175
6200
|
return output;
|
|
6176
6201
|
}
|
|
@@ -6773,9 +6798,9 @@ function Loon_Producer() {
|
|
|
6773
6798
|
return hysteria22(proxy);
|
|
6774
6799
|
}
|
|
6775
6800
|
if (proxy.type === "anytls") {
|
|
6776
|
-
if (proxy.network &&
|
|
6801
|
+
if (proxy.network && !["tcp"].includes(proxy.network)) {
|
|
6777
6802
|
throw new Error(
|
|
6778
|
-
`Platform ${targetPlatform3} does not support proxy type ${proxy.type} with network
|
|
6803
|
+
`Platform ${targetPlatform3} does not support proxy type ${proxy.type} with network ${proxy.network}`
|
|
6779
6804
|
);
|
|
6780
6805
|
}
|
|
6781
6806
|
return anytls2(proxy);
|
|
@@ -6790,10 +6815,45 @@ function appendTlsProfile(result, proxy) {
|
|
|
6790
6815
|
const tlsProfile = getLoonTlsProfile(proxy);
|
|
6791
6816
|
if (tlsProfile) result.append(`,tls-profile=${tlsProfile}`);
|
|
6792
6817
|
}
|
|
6793
|
-
function
|
|
6818
|
+
function appendAlpn2(result, proxy) {
|
|
6794
6819
|
const alpn = getLoonAlpn(proxy);
|
|
6795
6820
|
if (alpn) result.append(`,alpn="${alpn}"`);
|
|
6796
6821
|
}
|
|
6822
|
+
function getLoonShadowTLSAlpn(proxy) {
|
|
6823
|
+
const values = proxy?.["plugin-opts"]?.alpn ?? proxy?.alpn;
|
|
6824
|
+
const normalized = Array.isArray(values) ? values : `${values || ""}`.split(",");
|
|
6825
|
+
return normalized.map((item) => `${item}`.trim()).filter((item) => item !== "").join(",");
|
|
6826
|
+
}
|
|
6827
|
+
function appendShadowTLS2(result, proxy) {
|
|
6828
|
+
if (proxy.plugin !== "shadow-tls" || !proxy["plugin-opts"]) return;
|
|
6829
|
+
const password = proxy["plugin-opts"].password;
|
|
6830
|
+
const host = proxy["plugin-opts"].host;
|
|
6831
|
+
const version = proxy["plugin-opts"].version;
|
|
6832
|
+
if (!password) return;
|
|
6833
|
+
result.append(`,shadow-tls-password=${password}`);
|
|
6834
|
+
if (host) result.append(`,shadow-tls-sni=${host}`);
|
|
6835
|
+
if (version) {
|
|
6836
|
+
if (version < 2) {
|
|
6837
|
+
throw new Error(`shadow-tls version ${version} is not supported`);
|
|
6838
|
+
}
|
|
6839
|
+
result.append(`,shadow-tls-version=${version}`);
|
|
6840
|
+
}
|
|
6841
|
+
appendTlsProfile(result, proxy);
|
|
6842
|
+
const alpn = getLoonShadowTLSAlpn(proxy);
|
|
6843
|
+
if (alpn) result.append(`,alpn="${alpn}"`);
|
|
6844
|
+
result.appendIfPresent(`,udp-port=${proxy["udp-port"]}`, "udp-port");
|
|
6845
|
+
}
|
|
6846
|
+
function appendReality(result, proxy) {
|
|
6847
|
+
result.appendIfPresent(`,sni=${proxy.sni}`, "sni");
|
|
6848
|
+
result.appendIfPresent(
|
|
6849
|
+
`,public-key="${proxy["reality-opts"]["public-key"]}"`,
|
|
6850
|
+
"reality-opts.public-key"
|
|
6851
|
+
);
|
|
6852
|
+
result.appendIfPresent(
|
|
6853
|
+
`,short-id=${proxy["reality-opts"]["short-id"]}`,
|
|
6854
|
+
"reality-opts.short-id"
|
|
6855
|
+
);
|
|
6856
|
+
}
|
|
6797
6857
|
function getLoonAlpn(proxy) {
|
|
6798
6858
|
const values = Array.isArray(proxy.alpn) ? proxy.alpn : `${proxy.alpn || ""}`.split(",");
|
|
6799
6859
|
return values.map((item) => `${item}`.trim()).filter((item) => item !== "").join(",");
|
|
@@ -6843,11 +6903,6 @@ function shadowsocks2(proxy) {
|
|
|
6843
6903
|
);
|
|
6844
6904
|
if (isPresent2(proxy, "plugin")) {
|
|
6845
6905
|
if (proxy.plugin === "obfs") {
|
|
6846
|
-
if (proxy["plugin-opts"]?.mode && proxy.cipher.startsWith("2022-")) {
|
|
6847
|
-
throw new Error(
|
|
6848
|
-
`${proxy.cipher} ${proxy.plugin} is not supported`
|
|
6849
|
-
);
|
|
6850
|
-
}
|
|
6851
6906
|
result.append(`,obfs-name=${proxy["plugin-opts"].mode}`);
|
|
6852
6907
|
result.appendIfPresent(
|
|
6853
6908
|
`,obfs-host=${proxy["plugin-opts"].host}`,
|
|
@@ -6861,40 +6916,7 @@ function shadowsocks2(proxy) {
|
|
|
6861
6916
|
throw new Error(`plugin ${proxy.plugin} is not supported`);
|
|
6862
6917
|
}
|
|
6863
6918
|
}
|
|
6864
|
-
|
|
6865
|
-
result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
|
|
6866
|
-
result.appendIfPresent(
|
|
6867
|
-
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
6868
|
-
"shadow-tls-version"
|
|
6869
|
-
);
|
|
6870
|
-
result.appendIfPresent(
|
|
6871
|
-
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
6872
|
-
"shadow-tls-sni"
|
|
6873
|
-
);
|
|
6874
|
-
result.appendIfPresent(`,udp-port=${proxy["udp-port"]}`, "udp-port");
|
|
6875
|
-
} else if (["shadow-tls"].includes(proxy.plugin) && proxy["plugin-opts"]) {
|
|
6876
|
-
const password = proxy["plugin-opts"].password;
|
|
6877
|
-
const host = proxy["plugin-opts"].host;
|
|
6878
|
-
const version = proxy["plugin-opts"].version;
|
|
6879
|
-
if (password) {
|
|
6880
|
-
result.append(`,shadow-tls-password=${password}`);
|
|
6881
|
-
if (host) {
|
|
6882
|
-
result.append(`,shadow-tls-sni=${host}`);
|
|
6883
|
-
}
|
|
6884
|
-
if (version) {
|
|
6885
|
-
if (version < 2) {
|
|
6886
|
-
throw new Error(
|
|
6887
|
-
`shadow-tls version ${version} is not supported`
|
|
6888
|
-
);
|
|
6889
|
-
}
|
|
6890
|
-
result.append(`,shadow-tls-version=${version}`);
|
|
6891
|
-
}
|
|
6892
|
-
result.appendIfPresent(
|
|
6893
|
-
`,udp-port=${proxy["udp-port"]}`,
|
|
6894
|
-
"udp-port"
|
|
6895
|
-
);
|
|
6896
|
-
}
|
|
6897
|
-
}
|
|
6919
|
+
appendShadowTLS2(result, proxy);
|
|
6898
6920
|
if (proxy["udp-over-tcp"]) {
|
|
6899
6921
|
if (proxy["udp-over-tcp-version"] === 2) {
|
|
6900
6922
|
if (proxy.plugin === "obfs") {
|
|
@@ -6935,40 +6957,7 @@ function shadowsocksr(proxy) {
|
|
|
6935
6957
|
);
|
|
6936
6958
|
result.appendIfPresent(`,obfs=${proxy.obfs}`, "obfs");
|
|
6937
6959
|
result.appendIfPresent(`,obfs-param=${proxy["obfs-param"]}`, "obfs-param");
|
|
6938
|
-
|
|
6939
|
-
result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
|
|
6940
|
-
result.appendIfPresent(
|
|
6941
|
-
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
6942
|
-
"shadow-tls-version"
|
|
6943
|
-
);
|
|
6944
|
-
result.appendIfPresent(
|
|
6945
|
-
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
6946
|
-
"shadow-tls-sni"
|
|
6947
|
-
);
|
|
6948
|
-
result.appendIfPresent(`,udp-port=${proxy["udp-port"]}`, "udp-port");
|
|
6949
|
-
} else if (["shadow-tls"].includes(proxy.plugin) && proxy["plugin-opts"]) {
|
|
6950
|
-
const password = proxy["plugin-opts"].password;
|
|
6951
|
-
const host = proxy["plugin-opts"].host;
|
|
6952
|
-
const version = proxy["plugin-opts"].version;
|
|
6953
|
-
if (password) {
|
|
6954
|
-
result.append(`,shadow-tls-password=${password}`);
|
|
6955
|
-
if (host) {
|
|
6956
|
-
result.append(`,shadow-tls-sni=${host}`);
|
|
6957
|
-
}
|
|
6958
|
-
if (version) {
|
|
6959
|
-
if (version < 2) {
|
|
6960
|
-
throw new Error(
|
|
6961
|
-
`shadow-tls version ${version} is not supported`
|
|
6962
|
-
);
|
|
6963
|
-
}
|
|
6964
|
-
result.append(`,shadow-tls-version=${version}`);
|
|
6965
|
-
}
|
|
6966
|
-
result.appendIfPresent(
|
|
6967
|
-
`,udp-port=${proxy["udp-port"]}`,
|
|
6968
|
-
"udp-port"
|
|
6969
|
-
);
|
|
6970
|
-
}
|
|
6971
|
-
}
|
|
6960
|
+
appendShadowTLS2(result, proxy);
|
|
6972
6961
|
result.appendIfPresent(`,fast-open=${proxy.tfo}`, "tfo");
|
|
6973
6962
|
if (proxy["block-quic"] === "on") {
|
|
6974
6963
|
result.append(",block-quic=true");
|
|
@@ -6983,6 +6972,7 @@ function shadowsocksr(proxy) {
|
|
|
6983
6972
|
return result.toString();
|
|
6984
6973
|
}
|
|
6985
6974
|
function trojan2(proxy) {
|
|
6975
|
+
const isReality = !!proxy["reality-opts"];
|
|
6986
6976
|
const result = new Result(proxy);
|
|
6987
6977
|
result.append(
|
|
6988
6978
|
`${proxy.name}=trojan,${proxy.server},${proxy.port},"${proxy.password}"`
|
|
@@ -7010,16 +7000,20 @@ function trojan2(proxy) {
|
|
|
7010
7000
|
"skip-cert-verify"
|
|
7011
7001
|
);
|
|
7012
7002
|
appendTlsProfile(result, proxy);
|
|
7013
|
-
|
|
7014
|
-
|
|
7015
|
-
|
|
7016
|
-
|
|
7017
|
-
|
|
7018
|
-
|
|
7019
|
-
|
|
7020
|
-
|
|
7021
|
-
|
|
7022
|
-
|
|
7003
|
+
appendAlpn2(result, proxy);
|
|
7004
|
+
if (isReality) {
|
|
7005
|
+
appendReality(result, proxy);
|
|
7006
|
+
} else {
|
|
7007
|
+
result.appendIfPresent(`,tls-name=${proxy.sni}`, "sni");
|
|
7008
|
+
result.appendIfPresent(
|
|
7009
|
+
`,tls-cert-sha256=${proxy["tls-fingerprint"]}`,
|
|
7010
|
+
"tls-fingerprint"
|
|
7011
|
+
);
|
|
7012
|
+
result.appendIfPresent(
|
|
7013
|
+
`,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
|
|
7014
|
+
"tls-pubkey-sha256"
|
|
7015
|
+
);
|
|
7016
|
+
}
|
|
7023
7017
|
result.appendIfPresent(`,fast-open=${proxy.tfo}`, "tfo");
|
|
7024
7018
|
if (proxy["block-quic"] === "on") {
|
|
7025
7019
|
result.append(",block-quic=true");
|
|
@@ -7034,6 +7028,7 @@ function trojan2(proxy) {
|
|
|
7034
7028
|
return result.toString();
|
|
7035
7029
|
}
|
|
7036
7030
|
function anytls2(proxy) {
|
|
7031
|
+
const isReality = !!proxy["reality-opts"];
|
|
7037
7032
|
const result = new Result(proxy);
|
|
7038
7033
|
result.append(
|
|
7039
7034
|
`${proxy.name}=anytls,${proxy.server},${proxy.port},"${proxy.password}"`
|
|
@@ -7053,16 +7048,20 @@ function anytls2(proxy) {
|
|
|
7053
7048
|
"skip-cert-verify"
|
|
7054
7049
|
);
|
|
7055
7050
|
appendTlsProfile(result, proxy);
|
|
7056
|
-
|
|
7057
|
-
|
|
7058
|
-
|
|
7059
|
-
|
|
7060
|
-
|
|
7061
|
-
|
|
7062
|
-
|
|
7063
|
-
|
|
7064
|
-
|
|
7065
|
-
|
|
7051
|
+
appendAlpn2(result, proxy);
|
|
7052
|
+
if (isReality) {
|
|
7053
|
+
appendReality(result, proxy);
|
|
7054
|
+
} else {
|
|
7055
|
+
result.appendIfPresent(`,tls-name=${proxy.sni}`, "sni");
|
|
7056
|
+
result.appendIfPresent(
|
|
7057
|
+
`,tls-cert-sha256=${proxy["tls-fingerprint"]}`,
|
|
7058
|
+
"tls-fingerprint"
|
|
7059
|
+
);
|
|
7060
|
+
result.appendIfPresent(
|
|
7061
|
+
`,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
|
|
7062
|
+
"tls-pubkey-sha256"
|
|
7063
|
+
);
|
|
7064
|
+
}
|
|
7066
7065
|
result.appendIfPresent(`,fast-open=${proxy.tfo}`, "tfo");
|
|
7067
7066
|
if (proxy["block-quic"] === "on") {
|
|
7068
7067
|
result.append(",block-quic=true");
|
|
@@ -7122,18 +7121,10 @@ function vmess2(proxy) {
|
|
|
7122
7121
|
);
|
|
7123
7122
|
if (proxy.tls || isReality) {
|
|
7124
7123
|
appendTlsProfile(result, proxy);
|
|
7125
|
-
|
|
7124
|
+
appendAlpn2(result, proxy);
|
|
7126
7125
|
}
|
|
7127
7126
|
if (isReality) {
|
|
7128
|
-
result
|
|
7129
|
-
result.appendIfPresent(
|
|
7130
|
-
`,public-key="${proxy["reality-opts"]["public-key"]}"`,
|
|
7131
|
-
"reality-opts.public-key"
|
|
7132
|
-
);
|
|
7133
|
-
result.appendIfPresent(
|
|
7134
|
-
`,short-id=${proxy["reality-opts"]["short-id"]}`,
|
|
7135
|
-
"reality-opts.short-id"
|
|
7136
|
-
);
|
|
7127
|
+
appendReality(result, proxy);
|
|
7137
7128
|
} else {
|
|
7138
7129
|
result.appendIfPresent(`,tls-name=${proxy.sni}`, "sni");
|
|
7139
7130
|
result.appendIfPresent(
|
|
@@ -7218,21 +7209,13 @@ function vless(proxy) {
|
|
|
7218
7209
|
);
|
|
7219
7210
|
if (proxy.tls || isReality || isXtls) {
|
|
7220
7211
|
appendTlsProfile(result, proxy);
|
|
7221
|
-
|
|
7212
|
+
appendAlpn2(result, proxy);
|
|
7222
7213
|
}
|
|
7223
7214
|
if (isXtls) {
|
|
7224
7215
|
result.appendIfPresent(`,flow=${proxy.flow}`, "flow");
|
|
7225
7216
|
}
|
|
7226
7217
|
if (isReality) {
|
|
7227
|
-
result
|
|
7228
|
-
result.appendIfPresent(
|
|
7229
|
-
`,public-key="${proxy["reality-opts"]["public-key"]}"`,
|
|
7230
|
-
"reality-opts.public-key"
|
|
7231
|
-
);
|
|
7232
|
-
result.appendIfPresent(
|
|
7233
|
-
`,short-id=${proxy["reality-opts"]["short-id"]}`,
|
|
7234
|
-
"reality-opts.short-id"
|
|
7235
|
-
);
|
|
7218
|
+
appendReality(result, proxy);
|
|
7236
7219
|
} else {
|
|
7237
7220
|
result.appendIfPresent(`,tls-name=${proxy.sni}`, "sni");
|
|
7238
7221
|
result.appendIfPresent(
|
|
@@ -7270,7 +7253,7 @@ function http2(proxy) {
|
|
|
7270
7253
|
);
|
|
7271
7254
|
if (proxy.tls) {
|
|
7272
7255
|
appendTlsProfile(result, proxy);
|
|
7273
|
-
|
|
7256
|
+
appendAlpn2(result, proxy);
|
|
7274
7257
|
}
|
|
7275
7258
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
7276
7259
|
if (proxy["block-quic"] === "on") {
|
|
@@ -7295,7 +7278,7 @@ function socks52(proxy) {
|
|
|
7295
7278
|
);
|
|
7296
7279
|
if (proxy.tls) {
|
|
7297
7280
|
appendTlsProfile(result, proxy);
|
|
7298
|
-
|
|
7281
|
+
appendAlpn2(result, proxy);
|
|
7299
7282
|
}
|
|
7300
7283
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
7301
7284
|
if (proxy["block-quic"] === "on") {
|
|
@@ -7395,7 +7378,7 @@ function hysteria22(proxy) {
|
|
|
7395
7378
|
"skip-cert-verify"
|
|
7396
7379
|
);
|
|
7397
7380
|
appendTlsProfile(result, proxy);
|
|
7398
|
-
|
|
7381
|
+
appendAlpn2(result, proxy);
|
|
7399
7382
|
if (proxy["obfs-password"] && proxy.obfs == "salamander") {
|
|
7400
7383
|
result.append(`,salamander-password=${proxy["obfs-password"]}`);
|
|
7401
7384
|
}
|
|
@@ -9220,11 +9203,15 @@ function Shadowrocket_Producer() {
|
|
|
9220
9203
|
return false;
|
|
9221
9204
|
} else if (proxy.type === "snell" && ![1, 2, 3, 4, 5].includes(proxy.version)) {
|
|
9222
9205
|
return false;
|
|
9206
|
+
} else if (hasShadowrocketSnellShadowTlsObfsConflict(proxy)) {
|
|
9207
|
+
app_default.error(
|
|
9208
|
+
`Platform Shadowrocket does not support Snell shadow-tls with obfs for proxy ${proxy.name}. Proxy has been filtered.`
|
|
9209
|
+
);
|
|
9210
|
+
return false;
|
|
9223
9211
|
} else if ([
|
|
9224
9212
|
"tailscale",
|
|
9225
9213
|
"sudoku",
|
|
9226
9214
|
"naive",
|
|
9227
|
-
"masque",
|
|
9228
9215
|
"openvpn",
|
|
9229
9216
|
"gost-relay"
|
|
9230
9217
|
].includes(proxy.type)) {
|
|
@@ -9283,25 +9270,29 @@ function Shadowrocket_Producer() {
|
|
|
9283
9270
|
proxy["pre-shared-key"] = proxy["preshared-key"];
|
|
9284
9271
|
proxy.ip = getWireGuardAddressWithCIDR(proxy, "ipv4");
|
|
9285
9272
|
proxy.ipv6 = getWireGuardAddressWithCIDR(proxy, "ipv6");
|
|
9286
|
-
} else if (proxy.type === "snell"
|
|
9287
|
-
|
|
9273
|
+
} else if (proxy.type === "snell") {
|
|
9274
|
+
if (proxy.version < 3) {
|
|
9275
|
+
delete proxy.udp;
|
|
9276
|
+
}
|
|
9277
|
+
if (proxy.plugin === "shadow-tls" && proxy["plugin-opts"]) {
|
|
9278
|
+
proxy["obfs-opts"] = {
|
|
9279
|
+
mode: "shadow-tls",
|
|
9280
|
+
host: proxy["plugin-opts"].host,
|
|
9281
|
+
password: proxy["plugin-opts"].password,
|
|
9282
|
+
version: proxy["plugin-opts"].version
|
|
9283
|
+
};
|
|
9284
|
+
if (proxy["plugin-opts"].alpn) {
|
|
9285
|
+
proxy["obfs-opts"].alpn = proxy["plugin-opts"].alpn;
|
|
9286
|
+
}
|
|
9287
|
+
delete proxy.plugin;
|
|
9288
|
+
delete proxy["plugin-opts"];
|
|
9289
|
+
}
|
|
9288
9290
|
} else if (proxy.type === "vless") {
|
|
9289
9291
|
if (isPresent2(proxy, "sni")) {
|
|
9290
9292
|
proxy.servername = proxy.sni;
|
|
9291
9293
|
delete proxy.sni;
|
|
9292
9294
|
}
|
|
9293
9295
|
} else if (proxy.type === "ss") {
|
|
9294
|
-
if (isPresent2(proxy, "shadow-tls-password") && !isPresent2(proxy, "plugin")) {
|
|
9295
|
-
proxy.plugin = "shadow-tls";
|
|
9296
|
-
proxy["plugin-opts"] = {
|
|
9297
|
-
host: proxy["shadow-tls-sni"],
|
|
9298
|
-
password: proxy["shadow-tls-password"],
|
|
9299
|
-
version: proxy["shadow-tls-version"]
|
|
9300
|
-
};
|
|
9301
|
-
delete proxy["shadow-tls-password"];
|
|
9302
|
-
delete proxy["shadow-tls-sni"];
|
|
9303
|
-
delete proxy["shadow-tls-version"];
|
|
9304
|
-
}
|
|
9305
9296
|
if (isShadowsocksOverTls(proxy)) {
|
|
9306
9297
|
if (isPresent2(proxy, "sni")) {
|
|
9307
9298
|
proxy.servername = proxy.sni;
|
|
@@ -9398,6 +9389,9 @@ function Shadowrocket_Producer() {
|
|
|
9398
9389
|
};
|
|
9399
9390
|
return { type, produce: produce2 };
|
|
9400
9391
|
}
|
|
9392
|
+
function hasShadowrocketSnellShadowTlsObfsConflict(proxy) {
|
|
9393
|
+
return proxy?.type === "snell" && proxy?.plugin === "shadow-tls" && (isPresent2(proxy, "obfs-opts.mode") || isPresent2(proxy, "obfs-opts.host") || isPresent2(proxy, "obfs-opts.path"));
|
|
9394
|
+
}
|
|
9401
9395
|
|
|
9402
9396
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/surfboard.js
|
|
9403
9397
|
var targetPlatform5 = "Surfboard";
|
|
@@ -9459,8 +9453,8 @@ function Surfboard_Producer() {
|
|
|
9459
9453
|
return { produce: produce2 };
|
|
9460
9454
|
}
|
|
9461
9455
|
function hysteria23(proxy) {
|
|
9462
|
-
if (proxy.obfs || proxy["obfs-password"]) {
|
|
9463
|
-
throw new Error(`Surfboard Hysteria2
|
|
9456
|
+
if (proxy.obfs && proxy.obfs !== "salamander" || proxy["obfs-password"] && proxy.obfs !== "salamander") {
|
|
9457
|
+
throw new Error(`Surfboard Hysteria2 only supports salamander obfs`);
|
|
9464
9458
|
}
|
|
9465
9459
|
const result = new Result(proxy);
|
|
9466
9460
|
result.append(`${proxy.name}=hysteria2,${proxy.server},${proxy.port}`);
|
|
@@ -9473,6 +9467,9 @@ function hysteria23(proxy) {
|
|
|
9473
9467
|
if (hasNonBlankValue2(proxy["hop-interval"])) {
|
|
9474
9468
|
result.append(`,port-hopping-interval=${proxy["hop-interval"]}`);
|
|
9475
9469
|
}
|
|
9470
|
+
if (proxy["obfs-password"]) {
|
|
9471
|
+
result.append(`,salamander-password="${proxy["obfs-password"]}"`);
|
|
9472
|
+
}
|
|
9476
9473
|
appendTlsProxyParams2(result, proxy);
|
|
9477
9474
|
result.appendIfPresent(
|
|
9478
9475
|
`,download-bandwidth=${`${proxy["down"]}`.match(/\d+/)?.[0] || 0}`,
|
|
@@ -10132,11 +10129,12 @@ var getShadowTLSPluginOpts = (proxy = {}) => {
|
|
|
10132
10129
|
if (proxy.plugin === "shadow-tls" && proxy["plugin-opts"]) {
|
|
10133
10130
|
return proxy["plugin-opts"];
|
|
10134
10131
|
}
|
|
10135
|
-
if (proxy
|
|
10132
|
+
if (proxy.type === "snell" && proxy["obfs-opts"]?.mode === "shadow-tls") {
|
|
10136
10133
|
return {
|
|
10137
|
-
host: proxy["
|
|
10138
|
-
password: proxy["
|
|
10139
|
-
version: proxy["
|
|
10134
|
+
host: proxy["obfs-opts"].host,
|
|
10135
|
+
password: proxy["obfs-opts"].password,
|
|
10136
|
+
version: proxy["obfs-opts"].version,
|
|
10137
|
+
alpn: proxy["obfs-opts"].alpn
|
|
10140
10138
|
};
|
|
10141
10139
|
}
|
|
10142
10140
|
return void 0;
|
|
@@ -10160,16 +10158,18 @@ var shadowTLSOutboundParser = (proxy = {}, pluginOpts) => {
|
|
|
10160
10158
|
password: pluginOpts.password,
|
|
10161
10159
|
tls: {
|
|
10162
10160
|
enabled: true,
|
|
10163
|
-
server_name: pluginOpts.host
|
|
10164
|
-
utls: {
|
|
10165
|
-
enabled: true,
|
|
10166
|
-
fingerprint
|
|
10167
|
-
}
|
|
10161
|
+
server_name: pluginOpts.host
|
|
10168
10162
|
}
|
|
10169
10163
|
};
|
|
10164
|
+
if (fingerprint) {
|
|
10165
|
+
stPart.tls.utls = {
|
|
10166
|
+
enabled: true,
|
|
10167
|
+
fingerprint
|
|
10168
|
+
};
|
|
10169
|
+
}
|
|
10170
10170
|
if (stPart.server_port < 0 || stPart.server_port > 65535)
|
|
10171
10171
|
throw "\u7AEF\u53E3\u503C\u975E\u6CD5";
|
|
10172
|
-
const alpn = normalizeALPN(pluginOpts.alpn);
|
|
10172
|
+
const alpn = normalizeALPN(pluginOpts.alpn) ?? normalizeALPN(proxy.alpn);
|
|
10173
10173
|
if (alpn) stPart.tls.alpn = alpn;
|
|
10174
10174
|
if (proxy["fast-open"] === true) stPart.udp_fragment = true;
|
|
10175
10175
|
tfoParser(proxy, stPart);
|
|
@@ -10312,9 +10312,9 @@ var snellParser = (proxy = {}) => {
|
|
|
10312
10312
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10313
10313
|
throw "invalid port";
|
|
10314
10314
|
if (version != null) parsedProxy.version = version;
|
|
10315
|
-
if (proxy["obfs-opts"]?.mode)
|
|
10315
|
+
if (proxy["obfs-opts"]?.mode && proxy["obfs-opts"].mode !== "shadow-tls")
|
|
10316
10316
|
parsedProxy.obfs_mode = proxy["obfs-opts"].mode;
|
|
10317
|
-
if (proxy["obfs-opts"]?.host)
|
|
10317
|
+
if (proxy["obfs-opts"]?.host && proxy["obfs-opts"]?.mode !== "shadow-tls")
|
|
10318
10318
|
parsedProxy.obfs_host = proxy["obfs-opts"].host;
|
|
10319
10319
|
if (proxy.reuse && (version == null || version >= 4))
|
|
10320
10320
|
parsedProxy.reuse = true;
|
|
@@ -10790,8 +10790,30 @@ function singbox_Producer() {
|
|
|
10790
10790
|
const type = "ALL";
|
|
10791
10791
|
const produce2 = (proxies, type2, opts = {}) => {
|
|
10792
10792
|
const list = [];
|
|
10793
|
+
const originalSnellShadowTLS = new Map(
|
|
10794
|
+
proxies.filter(
|
|
10795
|
+
(proxy) => proxy?.type === "snell" && proxy?.plugin === "shadow-tls" && proxy?.["plugin-opts"]
|
|
10796
|
+
).map((proxy) => [
|
|
10797
|
+
proxy,
|
|
10798
|
+
{
|
|
10799
|
+
plugin: proxy.plugin,
|
|
10800
|
+
"plugin-opts": proxy["plugin-opts"] ? JSON.parse(JSON.stringify(proxy["plugin-opts"])) : void 0,
|
|
10801
|
+
"obfs-opts": proxy["obfs-opts"] ? JSON.parse(JSON.stringify(proxy["obfs-opts"])) : void 0
|
|
10802
|
+
}
|
|
10803
|
+
])
|
|
10804
|
+
);
|
|
10793
10805
|
ClashMeta_Producer().produce(proxies, "internal", { "include-unsupported-proxy": true }).map((proxy) => {
|
|
10794
10806
|
try {
|
|
10807
|
+
const originalShadowTLS = originalSnellShadowTLS.get(proxy);
|
|
10808
|
+
if (originalShadowTLS) {
|
|
10809
|
+
proxy.plugin = originalShadowTLS.plugin;
|
|
10810
|
+
proxy["plugin-opts"] = originalShadowTLS["plugin-opts"];
|
|
10811
|
+
if (originalShadowTLS["obfs-opts"]) {
|
|
10812
|
+
proxy["obfs-opts"] = originalShadowTLS["obfs-opts"];
|
|
10813
|
+
} else {
|
|
10814
|
+
delete proxy["obfs-opts"];
|
|
10815
|
+
}
|
|
10816
|
+
}
|
|
10795
10817
|
if (["xhttp"].includes(proxy.network))
|
|
10796
10818
|
throw new Error(
|
|
10797
10819
|
`Platform sing-box does not support network: ${proxy.network}`
|
|
@@ -11371,16 +11393,7 @@ function Egern_Producer() {
|
|
|
11371
11393
|
"anytls",
|
|
11372
11394
|
"ssh"
|
|
11373
11395
|
].includes(original.type)) {
|
|
11374
|
-
if (
|
|
11375
|
-
if (original["shadow-tls-version"] != 3)
|
|
11376
|
-
throw new Error(
|
|
11377
|
-
`shadow-tls version ${original["shadow-tls-version"]} is not supported`
|
|
11378
|
-
);
|
|
11379
|
-
proxy.shadow_tls = {
|
|
11380
|
-
password: original["shadow-tls-password"],
|
|
11381
|
-
sni: original["shadow-tls-sni"]
|
|
11382
|
-
};
|
|
11383
|
-
} else if (["shadow-tls"].includes(original.plugin) && original["plugin-opts"]) {
|
|
11396
|
+
if (["shadow-tls"].includes(original.plugin) && original["plugin-opts"]) {
|
|
11384
11397
|
if (original["plugin-opts"].version != 3)
|
|
11385
11398
|
throw new Error(
|
|
11386
11399
|
`shadow-tls version ${original["plugin-opts"].version} is not supported`
|
|
@@ -11480,7 +11493,7 @@ function getUdpRelay(proxy) {
|
|
|
11480
11493
|
return proxy.udp ?? proxy.udp_relay;
|
|
11481
11494
|
}
|
|
11482
11495
|
function hasShadowTls(proxy) {
|
|
11483
|
-
return proxy.plugin === "shadow-tls"
|
|
11496
|
+
return proxy.plugin === "shadow-tls";
|
|
11484
11497
|
}
|
|
11485
11498
|
function getNonEmptyValue(value) {
|
|
11486
11499
|
if (value == null) return void 0;
|