sub-store-convert 2.24.22 → 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 +422 -418
- 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_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/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
|
}
|
|
@@ -629,13 +651,18 @@ private_key = comma "private-key" equals match:[^,]+ { proxy["keystore-private-k
|
|
|
629
651
|
server_fingerprint = comma "server-fingerprint" equals match:[^,]+ { proxy["server-fingerprint"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
|
630
652
|
block_quic = comma "block-quic" equals match:[^,]+ { proxy["block-quic"] = match.join(""); }
|
|
631
653
|
udp_port = comma "udp-port" equals match:$[0-9]+ { proxy["udp-port"] = parseInt(match.trim()); }
|
|
632
|
-
shadow_tls_version = comma "shadow-tls-version" equals match:$[0-9]+ {
|
|
633
|
-
shadow_tls_sni = comma "shadow-tls-sni" equals match:[^,]+ {
|
|
634
|
-
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'); }
|
|
635
657
|
token = comma "token" equals match:[^,]+ { proxy.token = match.join(""); }
|
|
636
|
-
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; }
|
|
637
663
|
uuidk = comma "uuid" equals match:[^,]+ { proxy.uuid = match.join(""); }
|
|
638
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'; }
|
|
639
666
|
|
|
640
667
|
tag = match:[^=,]* { proxy.name = match.join("").trim(); }
|
|
641
668
|
comma = _ "," _
|
|
@@ -674,6 +701,7 @@ var grammars2 = String.raw`
|
|
|
674
701
|
const proxy = {};
|
|
675
702
|
const obfs = {};
|
|
676
703
|
const transport = {};
|
|
704
|
+
const shadowTLS = {};
|
|
677
705
|
const $ = {};
|
|
678
706
|
|
|
679
707
|
function handleTransport() {
|
|
@@ -689,6 +717,24 @@ var grammars2 = String.raw`
|
|
|
689
717
|
}
|
|
690
718
|
}
|
|
691
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
|
+
|
|
692
738
|
function normalizeVmessSecurity(security) {
|
|
693
739
|
const normalized = String(security || "").trim().toLowerCase();
|
|
694
740
|
const supported = ["none", "auto", "aes-128-gcm", "chacha20-ietf-poly1305"];
|
|
@@ -711,12 +757,13 @@ start = (shadowsocksr/shadowsocks/vmess/vless/trojan/https/http/socks5/hysteria2
|
|
|
711
757
|
return proxy;
|
|
712
758
|
}
|
|
713
759
|
|
|
714
|
-
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)*{
|
|
715
761
|
proxy.type = "ssr";
|
|
716
762
|
// handle ssr obfs
|
|
717
763
|
proxy.obfs = obfs.type;
|
|
764
|
+
handleShadowTLS();
|
|
718
765
|
}
|
|
719
|
-
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)* {
|
|
720
767
|
proxy.type = "ss";
|
|
721
768
|
// handle ss obfs
|
|
722
769
|
if (obfs.type == "http" || obfs.type === "tls") {
|
|
@@ -725,6 +772,7 @@ shadowsocks = tag equals "shadowsocks"i address method password (obfs_typev obfs
|
|
|
725
772
|
$set(proxy, "plugin-opts.host", obfs.host);
|
|
726
773
|
$set(proxy, "plugin-opts.path", obfs.path);
|
|
727
774
|
}
|
|
775
|
+
handleShadowTLS();
|
|
728
776
|
}
|
|
729
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)* {
|
|
730
778
|
proxy.type = "vmess";
|
|
@@ -849,9 +897,9 @@ ssr_protocol_param = comma "protocol-param" equals param:$[^=,]+ { proxy["protoc
|
|
|
849
897
|
vmess_alterId = comma "alterId" equals alterId:$[0-9]+ { proxy.alterId = parseInt(alterId); }
|
|
850
898
|
|
|
851
899
|
udp_port = comma "udp-port" equals match:$[0-9]+ { proxy["udp-port"] = parseInt(match.trim()); }
|
|
852
|
-
shadow_tls_version = comma "shadow-tls-version" equals match:$[0-9]+ {
|
|
853
|
-
shadow_tls_sni = comma "shadow-tls-sni" equals match:[^,]+ {
|
|
854
|
-
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'); }
|
|
855
903
|
|
|
856
904
|
over_tls = comma "over-tls" equals flag:bool { proxy.tls = flag; }
|
|
857
905
|
tls_name = comma sni:("tls-name") equals match:[^,]+ { proxy.sni = match.join("").replace(/^"(.*)"$/, '$1'); }
|
|
@@ -1458,7 +1506,11 @@ var app_default = console;
|
|
|
1458
1506
|
import JSON5 from "json5";
|
|
1459
1507
|
|
|
1460
1508
|
// src/vendors/Sub-Store/backend/src/utils/yaml.js
|
|
1461
|
-
import
|
|
1509
|
+
import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
|
|
1510
|
+
var DEFAULT_PARSE_OPTIONS = {
|
|
1511
|
+
logLevel: "error",
|
|
1512
|
+
merge: true
|
|
1513
|
+
};
|
|
1462
1514
|
function retry(fn, content, ...args) {
|
|
1463
1515
|
try {
|
|
1464
1516
|
return fn(content, ...args);
|
|
@@ -1474,17 +1526,65 @@ function retry(fn, content, ...args) {
|
|
|
1474
1526
|
);
|
|
1475
1527
|
}
|
|
1476
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
|
+
}
|
|
1477
1577
|
function safeLoad(content, ...args) {
|
|
1478
|
-
return retry(
|
|
1578
|
+
return retry(parse, toSerializable(content), ...args);
|
|
1479
1579
|
}
|
|
1480
1580
|
function load(content, ...args) {
|
|
1481
|
-
return retry(
|
|
1581
|
+
return retry(parse, toSerializable(content), ...args);
|
|
1482
1582
|
}
|
|
1483
1583
|
function safeDump(content, ...args) {
|
|
1484
|
-
return
|
|
1584
|
+
return stringify(toSerializable(content), ...args);
|
|
1485
1585
|
}
|
|
1486
1586
|
function dump(content, ...args) {
|
|
1487
|
-
return
|
|
1587
|
+
return stringify(toSerializable(content), ...args);
|
|
1488
1588
|
}
|
|
1489
1589
|
var yaml_default = {
|
|
1490
1590
|
safeLoad,
|
|
@@ -2008,7 +2108,7 @@ function URI_PROXY() {
|
|
|
2008
2108
|
const test = (line) => {
|
|
2009
2109
|
return /^(socks5\+tls|socks5|http|https):\/\//.test(line);
|
|
2010
2110
|
};
|
|
2011
|
-
const
|
|
2111
|
+
const parse2 = (line) => {
|
|
2012
2112
|
let [__, type, tls, username, password, server, port, query, name2] = line.match(
|
|
2013
2113
|
/^(socks5|http|http)(\+tls|s)?:\/\/(?:(.*?):(.*?)@)?(.*?)(?::(\d+?))?\/?(\?.*?)?(?:#(.*?))?$/
|
|
2014
2114
|
);
|
|
@@ -2036,14 +2136,14 @@ function URI_PROXY() {
|
|
|
2036
2136
|
};
|
|
2037
2137
|
return proxy;
|
|
2038
2138
|
};
|
|
2039
|
-
return { name, test, parse };
|
|
2139
|
+
return { name, test, parse: parse2 };
|
|
2040
2140
|
}
|
|
2041
2141
|
function URI_SOCKS() {
|
|
2042
2142
|
const name = "URI SOCKS Parser";
|
|
2043
2143
|
const test = (line) => {
|
|
2044
2144
|
return /^socks:\/\//.test(line);
|
|
2045
2145
|
};
|
|
2046
|
-
const
|
|
2146
|
+
const parse2 = (line) => {
|
|
2047
2147
|
let [__, type, auth, server, port, query, name2] = line.match(
|
|
2048
2148
|
/^(socks)?:\/\/(?:(.*)@)?(.*?)(?::(\d+?))?(\?.*?)?(?:#(.*?))?$/
|
|
2049
2149
|
);
|
|
@@ -2069,14 +2169,14 @@ function URI_SOCKS() {
|
|
|
2069
2169
|
};
|
|
2070
2170
|
return proxy;
|
|
2071
2171
|
};
|
|
2072
|
-
return { name, test, parse };
|
|
2172
|
+
return { name, test, parse: parse2 };
|
|
2073
2173
|
}
|
|
2074
2174
|
function URI_SS() {
|
|
2075
2175
|
const name = "URI SS Parser";
|
|
2076
2176
|
const test = (line) => {
|
|
2077
2177
|
return /^ss:\/\//.test(line);
|
|
2078
2178
|
};
|
|
2079
|
-
const
|
|
2179
|
+
const parse2 = (line) => {
|
|
2080
2180
|
let { content, fragment: name2 } = splitURIFragment(
|
|
2081
2181
|
line.split("ss://")[1]
|
|
2082
2182
|
);
|
|
@@ -2339,14 +2439,14 @@ function URI_SS() {
|
|
|
2339
2439
|
proxy.name = name2 ?? `SS ${proxy.server}:${proxy.port}`;
|
|
2340
2440
|
return proxy;
|
|
2341
2441
|
};
|
|
2342
|
-
return { name, test, parse };
|
|
2442
|
+
return { name, test, parse: parse2 };
|
|
2343
2443
|
}
|
|
2344
2444
|
function URI_SSR() {
|
|
2345
2445
|
const name = "URI SSR Parser";
|
|
2346
2446
|
const test = (line) => {
|
|
2347
2447
|
return /^ssr:\/\//.test(line);
|
|
2348
2448
|
};
|
|
2349
|
-
const
|
|
2449
|
+
const parse2 = (line) => {
|
|
2350
2450
|
line = Base64.decode(line.split("ssr://")[1]);
|
|
2351
2451
|
let splitIdx = line.indexOf(":origin");
|
|
2352
2452
|
if (splitIdx === -1) {
|
|
@@ -2393,14 +2493,14 @@ function URI_SSR() {
|
|
|
2393
2493
|
};
|
|
2394
2494
|
return proxy;
|
|
2395
2495
|
};
|
|
2396
|
-
return { name, test, parse };
|
|
2496
|
+
return { name, test, parse: parse2 };
|
|
2397
2497
|
}
|
|
2398
2498
|
function URI_VMess() {
|
|
2399
2499
|
const name = "URI VMess Parser";
|
|
2400
2500
|
const test = (line) => {
|
|
2401
2501
|
return /^vmess:\/\//.test(line);
|
|
2402
2502
|
};
|
|
2403
|
-
const
|
|
2503
|
+
const parse2 = (line) => {
|
|
2404
2504
|
let { content: lineWithoutFragment, fragment: fragmentName } = splitURIFragment(line.split("vmess://")[1]);
|
|
2405
2505
|
let content = Base64.decode(lineWithoutFragment.replace(/\?.*?$/, ""));
|
|
2406
2506
|
if (/=\s*vmess/.test(content)) {
|
|
@@ -2616,14 +2716,14 @@ function URI_VMess() {
|
|
|
2616
2716
|
return proxy;
|
|
2617
2717
|
}
|
|
2618
2718
|
};
|
|
2619
|
-
return { name, test, parse };
|
|
2719
|
+
return { name, test, parse: parse2 };
|
|
2620
2720
|
}
|
|
2621
2721
|
function URI_VLESS() {
|
|
2622
2722
|
const name = "URI VLESS Parser";
|
|
2623
2723
|
const test = (line) => {
|
|
2624
2724
|
return /^vless:\/\//.test(line);
|
|
2625
2725
|
};
|
|
2626
|
-
const
|
|
2726
|
+
const parse2 = (line) => {
|
|
2627
2727
|
const mapXmuxToReuseSettings = (xmux) => {
|
|
2628
2728
|
if (!isPlainObject(xmux)) {
|
|
2629
2729
|
return void 0;
|
|
@@ -3582,14 +3682,14 @@ function URI_VLESS() {
|
|
|
3582
3682
|
}
|
|
3583
3683
|
return proxy;
|
|
3584
3684
|
};
|
|
3585
|
-
return { name, test, parse };
|
|
3685
|
+
return { name, test, parse: parse2 };
|
|
3586
3686
|
}
|
|
3587
3687
|
function URI_AnyTLS() {
|
|
3588
3688
|
const name = "URI AnyTLS Parser";
|
|
3589
3689
|
const test = (line) => {
|
|
3590
3690
|
return /^anytls:\/\//.test(line);
|
|
3591
3691
|
};
|
|
3592
|
-
const
|
|
3692
|
+
const parse2 = (line) => {
|
|
3593
3693
|
const parsed = URI_VLESS().parse(line.replace("anytls", "vless"));
|
|
3594
3694
|
line = line.split(/anytls:\/\//)[1];
|
|
3595
3695
|
let [__, password, server, port, addons = "", name2] = /^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
@@ -3634,14 +3734,14 @@ function URI_AnyTLS() {
|
|
|
3634
3734
|
}
|
|
3635
3735
|
return proxy;
|
|
3636
3736
|
};
|
|
3637
|
-
return { name, test, parse };
|
|
3737
|
+
return { name, test, parse: parse2 };
|
|
3638
3738
|
}
|
|
3639
3739
|
function URI_Hysteria2() {
|
|
3640
3740
|
const name = "URI Hysteria2 Parser";
|
|
3641
3741
|
const test = (line) => {
|
|
3642
3742
|
return /^(hysteria2|hy2):\/\//.test(line);
|
|
3643
3743
|
};
|
|
3644
|
-
const
|
|
3744
|
+
const parse2 = (line) => {
|
|
3645
3745
|
line = line.split(/(hysteria2|hy2):\/\//)[2];
|
|
3646
3746
|
let ports;
|
|
3647
3747
|
let [
|
|
@@ -3723,14 +3823,14 @@ function URI_Hysteria2() {
|
|
|
3723
3823
|
}
|
|
3724
3824
|
return proxy;
|
|
3725
3825
|
};
|
|
3726
|
-
return { name, test, parse };
|
|
3826
|
+
return { name, test, parse: parse2 };
|
|
3727
3827
|
}
|
|
3728
3828
|
function URI_Hysteria() {
|
|
3729
3829
|
const name = "URI Hysteria Parser";
|
|
3730
3830
|
const test = (line) => {
|
|
3731
3831
|
return /^(hysteria|hy):\/\//.test(line);
|
|
3732
3832
|
};
|
|
3733
|
-
const
|
|
3833
|
+
const parse2 = (line) => {
|
|
3734
3834
|
line = line.split(/(hysteria|hy):\/\//)[2];
|
|
3735
3835
|
let [__, server, ___, port, ____, addons = "", name2] = /^(.*?)(:(\d+))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
3736
3836
|
port = parseInt(`${port}`, 10);
|
|
@@ -3787,14 +3887,14 @@ function URI_Hysteria() {
|
|
|
3787
3887
|
}
|
|
3788
3888
|
return proxy;
|
|
3789
3889
|
};
|
|
3790
|
-
return { name, test, parse };
|
|
3890
|
+
return { name, test, parse: parse2 };
|
|
3791
3891
|
}
|
|
3792
3892
|
function URI_TUIC() {
|
|
3793
3893
|
const name = "URI TUIC Parser";
|
|
3794
3894
|
const test = (line) => {
|
|
3795
3895
|
return /^tuic:\/\//.test(line);
|
|
3796
3896
|
};
|
|
3797
|
-
const
|
|
3897
|
+
const parse2 = (line) => {
|
|
3798
3898
|
line = line.split(/tuic:\/\//)[1];
|
|
3799
3899
|
let [__, auth, server, port, addons = "", name2] = /^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
3800
3900
|
auth = decodeURIComponent(auth);
|
|
@@ -3840,14 +3940,14 @@ function URI_TUIC() {
|
|
|
3840
3940
|
}
|
|
3841
3941
|
return proxy;
|
|
3842
3942
|
};
|
|
3843
|
-
return { name, test, parse };
|
|
3943
|
+
return { name, test, parse: parse2 };
|
|
3844
3944
|
}
|
|
3845
3945
|
function URI_WireGuard() {
|
|
3846
3946
|
const name = "URI WireGuard Parser";
|
|
3847
3947
|
const test = (line) => {
|
|
3848
3948
|
return /^(wireguard|wg):\/\//.test(line);
|
|
3849
3949
|
};
|
|
3850
|
-
const
|
|
3950
|
+
const parse2 = (line) => {
|
|
3851
3951
|
line = line.split(/(wireguard|wg):\/\//)[2];
|
|
3852
3952
|
let [
|
|
3853
3953
|
__,
|
|
@@ -3930,14 +4030,14 @@ function URI_WireGuard() {
|
|
|
3930
4030
|
}
|
|
3931
4031
|
return proxy;
|
|
3932
4032
|
};
|
|
3933
|
-
return { name, test, parse };
|
|
4033
|
+
return { name, test, parse: parse2 };
|
|
3934
4034
|
}
|
|
3935
4035
|
function URI_Trojan() {
|
|
3936
4036
|
const name = "URI Trojan Parser";
|
|
3937
4037
|
const test = (line) => {
|
|
3938
4038
|
return /^trojan:\/\//.test(line);
|
|
3939
4039
|
};
|
|
3940
|
-
const
|
|
4040
|
+
const parse2 = (line) => {
|
|
3941
4041
|
const matched = /^(trojan:\/\/.*?@.*?)(:(\d+))?\/?(\?.*?)?$/.exec(line);
|
|
3942
4042
|
const port = matched?.[2];
|
|
3943
4043
|
if (!port) {
|
|
@@ -3955,7 +4055,7 @@ function URI_Trojan() {
|
|
|
3955
4055
|
}
|
|
3956
4056
|
return proxy;
|
|
3957
4057
|
};
|
|
3958
|
-
return { name, test, parse };
|
|
4058
|
+
return { name, test, parse: parse2 };
|
|
3959
4059
|
}
|
|
3960
4060
|
function Clash_All() {
|
|
3961
4061
|
const name = "Clash Parser";
|
|
@@ -3968,7 +4068,7 @@ function Clash_All() {
|
|
|
3968
4068
|
}
|
|
3969
4069
|
return !!proxy?.type;
|
|
3970
4070
|
};
|
|
3971
|
-
const
|
|
4071
|
+
const parse2 = (line) => {
|
|
3972
4072
|
let proxy;
|
|
3973
4073
|
try {
|
|
3974
4074
|
proxy = JSON5.parse(line);
|
|
@@ -4030,153 +4130,153 @@ function Clash_All() {
|
|
|
4030
4130
|
}
|
|
4031
4131
|
return proxy;
|
|
4032
4132
|
};
|
|
4033
|
-
return { name, test, parse };
|
|
4133
|
+
return { name, test, parse: parse2 };
|
|
4034
4134
|
}
|
|
4035
4135
|
function QX_SS() {
|
|
4036
4136
|
const name = "QX SS Parser";
|
|
4037
4137
|
const test = (line) => {
|
|
4038
4138
|
return /^shadowsocks\s*=/.test(line.split(",")[0].trim()) && line.indexOf("ssr-protocol") === -1;
|
|
4039
4139
|
};
|
|
4040
|
-
const
|
|
4140
|
+
const parse2 = (line) => {
|
|
4041
4141
|
const parser5 = getParser3();
|
|
4042
4142
|
return parser5.parse(line);
|
|
4043
4143
|
};
|
|
4044
|
-
return { name, test, parse };
|
|
4144
|
+
return { name, test, parse: parse2 };
|
|
4045
4145
|
}
|
|
4046
4146
|
function QX_SSR() {
|
|
4047
4147
|
const name = "QX SSR Parser";
|
|
4048
4148
|
const test = (line) => {
|
|
4049
4149
|
return /^shadowsocks\s*=/.test(line.split(",")[0].trim()) && line.indexOf("ssr-protocol") !== -1;
|
|
4050
4150
|
};
|
|
4051
|
-
const
|
|
4052
|
-
return { name, test, parse };
|
|
4151
|
+
const parse2 = (line) => getParser3().parse(line);
|
|
4152
|
+
return { name, test, parse: parse2 };
|
|
4053
4153
|
}
|
|
4054
4154
|
function QX_VMess() {
|
|
4055
4155
|
const name = "QX VMess Parser";
|
|
4056
4156
|
const test = (line) => {
|
|
4057
4157
|
return /^vmess\s*=/.test(line.split(",")[0].trim());
|
|
4058
4158
|
};
|
|
4059
|
-
const
|
|
4060
|
-
return { name, test, parse };
|
|
4159
|
+
const parse2 = (line) => getParser3().parse(line);
|
|
4160
|
+
return { name, test, parse: parse2 };
|
|
4061
4161
|
}
|
|
4062
4162
|
function QX_VLESS() {
|
|
4063
4163
|
const name = "QX VLESS Parser";
|
|
4064
4164
|
const test = (line) => {
|
|
4065
4165
|
return /^vless\s*=/.test(line.split(",")[0].trim());
|
|
4066
4166
|
};
|
|
4067
|
-
const
|
|
4068
|
-
return { name, test, parse };
|
|
4167
|
+
const parse2 = (line) => getParser3().parse(line);
|
|
4168
|
+
return { name, test, parse: parse2 };
|
|
4069
4169
|
}
|
|
4070
4170
|
function QX_AnyTLS() {
|
|
4071
4171
|
const name = "QX AnyTLS Parser";
|
|
4072
4172
|
const test = (line) => {
|
|
4073
4173
|
return /^anytls\s*=/.test(line.split(",")[0].trim());
|
|
4074
4174
|
};
|
|
4075
|
-
const
|
|
4076
|
-
return { name, test, parse };
|
|
4175
|
+
const parse2 = (line) => getParser3().parse(line);
|
|
4176
|
+
return { name, test, parse: parse2 };
|
|
4077
4177
|
}
|
|
4078
4178
|
function QX_Trojan() {
|
|
4079
4179
|
const name = "QX Trojan Parser";
|
|
4080
4180
|
const test = (line) => {
|
|
4081
4181
|
return /^trojan\s*=/.test(line.split(",")[0].trim());
|
|
4082
4182
|
};
|
|
4083
|
-
const
|
|
4084
|
-
return { name, test, parse };
|
|
4183
|
+
const parse2 = (line) => getParser3().parse(line);
|
|
4184
|
+
return { name, test, parse: parse2 };
|
|
4085
4185
|
}
|
|
4086
4186
|
function QX_Http() {
|
|
4087
4187
|
const name = "QX HTTP Parser";
|
|
4088
4188
|
const test = (line) => {
|
|
4089
4189
|
return /^http\s*=/.test(line.split(",")[0].trim());
|
|
4090
4190
|
};
|
|
4091
|
-
const
|
|
4092
|
-
return { name, test, parse };
|
|
4191
|
+
const parse2 = (line) => getParser3().parse(line);
|
|
4192
|
+
return { name, test, parse: parse2 };
|
|
4093
4193
|
}
|
|
4094
4194
|
function QX_Socks5() {
|
|
4095
4195
|
const name = "QX Socks5 Parser";
|
|
4096
4196
|
const test = (line) => {
|
|
4097
4197
|
return /^socks5\s*=/.test(line.split(",")[0].trim());
|
|
4098
4198
|
};
|
|
4099
|
-
const
|
|
4100
|
-
return { name, test, parse };
|
|
4199
|
+
const parse2 = (line) => getParser3().parse(line);
|
|
4200
|
+
return { name, test, parse: parse2 };
|
|
4101
4201
|
}
|
|
4102
4202
|
function Loon_SS() {
|
|
4103
4203
|
const name = "Loon SS Parser";
|
|
4104
4204
|
const test = (line) => {
|
|
4105
4205
|
return line.split(",")[0].split("=")[1].trim().toLowerCase() === "shadowsocks";
|
|
4106
4206
|
};
|
|
4107
|
-
const
|
|
4108
|
-
return { name, test, parse };
|
|
4207
|
+
const parse2 = (line) => getParser2().parse(line);
|
|
4208
|
+
return { name, test, parse: parse2 };
|
|
4109
4209
|
}
|
|
4110
4210
|
function Loon_SSR() {
|
|
4111
4211
|
const name = "Loon SSR Parser";
|
|
4112
4212
|
const test = (line) => {
|
|
4113
4213
|
return line.split(",")[0].split("=")[1].trim().toLowerCase() === "shadowsocksr";
|
|
4114
4214
|
};
|
|
4115
|
-
const
|
|
4116
|
-
return { name, test, parse };
|
|
4215
|
+
const parse2 = (line) => getParser2().parse(line);
|
|
4216
|
+
return { name, test, parse: parse2 };
|
|
4117
4217
|
}
|
|
4118
4218
|
function Loon_VMess() {
|
|
4119
4219
|
const name = "Loon VMess Parser";
|
|
4120
4220
|
const test = (line) => {
|
|
4121
4221
|
return /^.*=\s*vmess/i.test(line.split(",")[0]) && line.indexOf("username") === -1;
|
|
4122
4222
|
};
|
|
4123
|
-
const
|
|
4124
|
-
return { name, test, parse };
|
|
4223
|
+
const parse2 = (line) => getParser2().parse(line);
|
|
4224
|
+
return { name, test, parse: parse2 };
|
|
4125
4225
|
}
|
|
4126
4226
|
function Loon_Vless() {
|
|
4127
4227
|
const name = "Loon Vless Parser";
|
|
4128
4228
|
const test = (line) => {
|
|
4129
4229
|
return /^.*=\s*vless/i.test(line.split(",")[0]);
|
|
4130
4230
|
};
|
|
4131
|
-
const
|
|
4132
|
-
return { name, test, parse };
|
|
4231
|
+
const parse2 = (line) => getParser2().parse(line);
|
|
4232
|
+
return { name, test, parse: parse2 };
|
|
4133
4233
|
}
|
|
4134
4234
|
function Loon_Trojan() {
|
|
4135
4235
|
const name = "Loon Trojan Parser";
|
|
4136
4236
|
const test = (line) => {
|
|
4137
4237
|
return /^.*=\s*trojan/i.test(line.split(",")[0]);
|
|
4138
4238
|
};
|
|
4139
|
-
const
|
|
4140
|
-
return { name, test, parse };
|
|
4239
|
+
const parse2 = (line) => getParser2().parse(line);
|
|
4240
|
+
return { name, test, parse: parse2 };
|
|
4141
4241
|
}
|
|
4142
4242
|
function Loon_AnyTLS() {
|
|
4143
4243
|
const name = "Loon AnyTLS Parser";
|
|
4144
4244
|
const test = (line) => {
|
|
4145
4245
|
return /^.*=\s*anytls/i.test(line.split(",")[0]);
|
|
4146
4246
|
};
|
|
4147
|
-
const
|
|
4148
|
-
return { name, test, parse };
|
|
4247
|
+
const parse2 = (line) => getParser2().parse(line);
|
|
4248
|
+
return { name, test, parse: parse2 };
|
|
4149
4249
|
}
|
|
4150
4250
|
function Loon_Hysteria2() {
|
|
4151
4251
|
const name = "Loon Hysteria2 Parser";
|
|
4152
4252
|
const test = (line) => {
|
|
4153
4253
|
return /^.*=\s*Hysteria2/i.test(line.split(",")[0]);
|
|
4154
4254
|
};
|
|
4155
|
-
const
|
|
4156
|
-
return { name, test, parse };
|
|
4255
|
+
const parse2 = (line) => getParser2().parse(line);
|
|
4256
|
+
return { name, test, parse: parse2 };
|
|
4157
4257
|
}
|
|
4158
4258
|
function Loon_Http() {
|
|
4159
4259
|
const name = "Loon HTTP Parser";
|
|
4160
4260
|
const test = (line) => {
|
|
4161
4261
|
return /^.*=\s*http/i.test(line.split(",")[0]);
|
|
4162
4262
|
};
|
|
4163
|
-
const
|
|
4164
|
-
return { name, test, parse };
|
|
4263
|
+
const parse2 = (line) => getParser2().parse(line);
|
|
4264
|
+
return { name, test, parse: parse2 };
|
|
4165
4265
|
}
|
|
4166
4266
|
function Loon_Socks5() {
|
|
4167
4267
|
const name = "Loon SOCKS5 Parser";
|
|
4168
4268
|
const test = (line) => {
|
|
4169
4269
|
return /^.*=\s*socks5/i.test(line.split(",")[0]);
|
|
4170
4270
|
};
|
|
4171
|
-
const
|
|
4172
|
-
return { name, test, parse };
|
|
4271
|
+
const parse2 = (line) => getParser2().parse(line);
|
|
4272
|
+
return { name, test, parse: parse2 };
|
|
4173
4273
|
}
|
|
4174
4274
|
function Loon_WireGuard() {
|
|
4175
4275
|
const name = "Loon WireGuard Parser";
|
|
4176
4276
|
const test = (line) => {
|
|
4177
4277
|
return /^.*=\s*wireguard/i.test(line.split(",")[0]);
|
|
4178
4278
|
};
|
|
4179
|
-
const
|
|
4279
|
+
const parse2 = (line) => {
|
|
4180
4280
|
const name2 = line.match(
|
|
4181
4281
|
/(^.*?)\s*?=\s*?wireguard\s*?,.+?\s*?=\s*?.+?/i
|
|
4182
4282
|
)?.[1];
|
|
@@ -4269,71 +4369,71 @@ function Loon_WireGuard() {
|
|
|
4269
4369
|
}
|
|
4270
4370
|
return proxy;
|
|
4271
4371
|
};
|
|
4272
|
-
return { name, test, parse };
|
|
4372
|
+
return { name, test, parse: parse2 };
|
|
4273
4373
|
}
|
|
4274
4374
|
function Surge_Direct() {
|
|
4275
4375
|
const name = "Surge Direct Parser";
|
|
4276
4376
|
const test = (line) => {
|
|
4277
4377
|
return /^.*=\s*direct/.test(line.split(",")[0]);
|
|
4278
4378
|
};
|
|
4279
|
-
const
|
|
4280
|
-
return { name, test, parse };
|
|
4379
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4380
|
+
return { name, test, parse: parse2 };
|
|
4281
4381
|
}
|
|
4282
4382
|
function Surge_AnyTLS() {
|
|
4283
4383
|
const name = "Surge AnyTLS Parser";
|
|
4284
4384
|
const test = (line) => {
|
|
4285
4385
|
return /^.*=\s*anytls/.test(line.split(",")[0]);
|
|
4286
4386
|
};
|
|
4287
|
-
const
|
|
4288
|
-
return { name, test, parse };
|
|
4387
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4388
|
+
return { name, test, parse: parse2 };
|
|
4289
4389
|
}
|
|
4290
4390
|
function Surge_TrustTunnel() {
|
|
4291
4391
|
const name = "Surge TrustTunnel Parser";
|
|
4292
4392
|
const test = (line) => {
|
|
4293
4393
|
return /^.*=\s*trust-tunnel/.test(line.split(",")[0]);
|
|
4294
4394
|
};
|
|
4295
|
-
const
|
|
4296
|
-
return { name, test, parse };
|
|
4395
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4396
|
+
return { name, test, parse: parse2 };
|
|
4297
4397
|
}
|
|
4298
4398
|
function Surge_H2Connect() {
|
|
4299
4399
|
const name = "Surge HTTP/2 CONNECT Parser";
|
|
4300
4400
|
const test = (line) => {
|
|
4301
4401
|
return /^.*=\s*h2-connect/.test(line.split(",")[0]);
|
|
4302
4402
|
};
|
|
4303
|
-
const
|
|
4304
|
-
return { name, test, parse };
|
|
4403
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4404
|
+
return { name, test, parse: parse2 };
|
|
4305
4405
|
}
|
|
4306
4406
|
function Surge_SSH() {
|
|
4307
4407
|
const name = "Surge SSH Parser";
|
|
4308
4408
|
const test = (line) => {
|
|
4309
4409
|
return /^.*=\s*ssh/.test(line.split(",")[0]);
|
|
4310
4410
|
};
|
|
4311
|
-
const
|
|
4312
|
-
return { name, test, parse };
|
|
4411
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4412
|
+
return { name, test, parse: parse2 };
|
|
4313
4413
|
}
|
|
4314
4414
|
function Surge_SS() {
|
|
4315
4415
|
const name = "Surge SS Parser";
|
|
4316
4416
|
const test = (line) => {
|
|
4317
4417
|
return /^.*=\s*ss/.test(line.split(",")[0]);
|
|
4318
4418
|
};
|
|
4319
|
-
const
|
|
4320
|
-
return { name, test, parse };
|
|
4419
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4420
|
+
return { name, test, parse: parse2 };
|
|
4321
4421
|
}
|
|
4322
4422
|
function Surge_VMess() {
|
|
4323
4423
|
const name = "Surge VMess Parser";
|
|
4324
4424
|
const test = (line) => {
|
|
4325
4425
|
return /^.*=\s*vmess/.test(line.split(",")[0]) && line.indexOf("username") !== -1;
|
|
4326
4426
|
};
|
|
4327
|
-
const
|
|
4328
|
-
return { name, test, parse };
|
|
4427
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4428
|
+
return { name, test, parse: parse2 };
|
|
4329
4429
|
}
|
|
4330
4430
|
function Surge_Trojan() {
|
|
4331
4431
|
const name = "Surge Trojan Parser";
|
|
4332
4432
|
const test = (line) => {
|
|
4333
4433
|
return /^.*=\s*trojan/.test(line.split(",")[0]);
|
|
4334
4434
|
};
|
|
4335
|
-
const
|
|
4336
|
-
return { name, test, parse };
|
|
4435
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4436
|
+
return { name, test, parse: parse2 };
|
|
4337
4437
|
}
|
|
4338
4438
|
var LOON_ONLY_OPTIONS = /(^|,)\s*(fast-open|over-tls|tls-name|ip-mode|tls-cert-sha256|tls-pubkey-sha256)\s*=/i;
|
|
4339
4439
|
function Surge_Http() {
|
|
@@ -4341,23 +4441,23 @@ function Surge_Http() {
|
|
|
4341
4441
|
const test = (line) => {
|
|
4342
4442
|
return /^.*=\s*https?/.test(line.split(",")[0]) && !LOON_ONLY_OPTIONS.test(line);
|
|
4343
4443
|
};
|
|
4344
|
-
const
|
|
4345
|
-
return { name, test, parse };
|
|
4444
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4445
|
+
return { name, test, parse: parse2 };
|
|
4346
4446
|
}
|
|
4347
4447
|
function Surge_Socks5() {
|
|
4348
4448
|
const name = "Surge Socks5 Parser";
|
|
4349
4449
|
const test = (line) => {
|
|
4350
4450
|
return /^.*=\s*socks5(-tls)?/.test(line.split(",")[0]) && !LOON_ONLY_OPTIONS.test(line);
|
|
4351
4451
|
};
|
|
4352
|
-
const
|
|
4353
|
-
return { name, test, parse };
|
|
4452
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4453
|
+
return { name, test, parse: parse2 };
|
|
4354
4454
|
}
|
|
4355
4455
|
function Surge_External() {
|
|
4356
4456
|
const name = "Surge External Parser";
|
|
4357
4457
|
const test = (line) => {
|
|
4358
4458
|
return /^.*=\s*external/.test(line.split(",")[0]);
|
|
4359
4459
|
};
|
|
4360
|
-
const
|
|
4460
|
+
const parse2 = (line) => {
|
|
4361
4461
|
let parsed = /^\s*(.*?)\s*?=\s*?external\s*?,\s*(.*?)\s*$/.exec(line);
|
|
4362
4462
|
let [_3, name2, other] = parsed;
|
|
4363
4463
|
line = other;
|
|
@@ -4410,49 +4510,49 @@ function Surge_External() {
|
|
|
4410
4510
|
};
|
|
4411
4511
|
return proxy;
|
|
4412
4512
|
};
|
|
4413
|
-
return { name, test, parse };
|
|
4513
|
+
return { name, test, parse: parse2 };
|
|
4414
4514
|
}
|
|
4415
4515
|
function Surge_Snell() {
|
|
4416
4516
|
const name = "Surge Snell Parser";
|
|
4417
4517
|
const test = (line) => {
|
|
4418
4518
|
return /^.*=\s*snell/.test(line.split(",")[0]);
|
|
4419
4519
|
};
|
|
4420
|
-
const
|
|
4421
|
-
return { name, test, parse };
|
|
4520
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4521
|
+
return { name, test, parse: parse2 };
|
|
4422
4522
|
}
|
|
4423
4523
|
function Surge_Tuic() {
|
|
4424
4524
|
const name = "Surge Tuic Parser";
|
|
4425
4525
|
const test = (line) => {
|
|
4426
4526
|
return /^.*=\s*tuic(-v5)?/.test(line.split(",")[0]);
|
|
4427
4527
|
};
|
|
4428
|
-
const
|
|
4528
|
+
const parse2 = (raw) => {
|
|
4429
4529
|
const { port_hopping, line } = surge_port_hopping(raw);
|
|
4430
4530
|
const proxy = getParser().parse(line);
|
|
4431
4531
|
proxy["ports"] = port_hopping;
|
|
4432
4532
|
return proxy;
|
|
4433
4533
|
};
|
|
4434
|
-
return { name, test, parse };
|
|
4534
|
+
return { name, test, parse: parse2 };
|
|
4435
4535
|
}
|
|
4436
4536
|
function Surge_WireGuard() {
|
|
4437
4537
|
const name = "Surge WireGuard Parser";
|
|
4438
4538
|
const test = (line) => {
|
|
4439
4539
|
return /^.*=\s*wireguard/.test(line.split(",")[0]);
|
|
4440
4540
|
};
|
|
4441
|
-
const
|
|
4442
|
-
return { name, test, parse };
|
|
4541
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4542
|
+
return { name, test, parse: parse2 };
|
|
4443
4543
|
}
|
|
4444
4544
|
function Surge_Hysteria2() {
|
|
4445
4545
|
const name = "Surge Hysteria2 Parser";
|
|
4446
4546
|
const test = (line) => {
|
|
4447
4547
|
return /^.*=\s*hysteria2/.test(line.split(",")[0]);
|
|
4448
4548
|
};
|
|
4449
|
-
const
|
|
4549
|
+
const parse2 = (raw) => {
|
|
4450
4550
|
const { port_hopping, line } = surge_port_hopping(raw);
|
|
4451
4551
|
const proxy = getParser().parse(line);
|
|
4452
4552
|
proxy["ports"] = port_hopping;
|
|
4453
4553
|
return proxy;
|
|
4454
4554
|
};
|
|
4455
|
-
return { name, test, parse };
|
|
4555
|
+
return { name, test, parse: parse2 };
|
|
4456
4556
|
}
|
|
4457
4557
|
function isIP(ip) {
|
|
4458
4558
|
return isIPv4(ip) || isIPv6(ip);
|
|
@@ -4539,8 +4639,8 @@ function normalizeClashYaml(raw) {
|
|
|
4539
4639
|
function HTML() {
|
|
4540
4640
|
const name = "HTML";
|
|
4541
4641
|
const test = (raw) => /^<!DOCTYPE html>/.test(raw);
|
|
4542
|
-
const
|
|
4543
|
-
return { name, test, parse };
|
|
4642
|
+
const parse2 = () => "";
|
|
4643
|
+
return { name, test, parse: parse2 };
|
|
4544
4644
|
}
|
|
4545
4645
|
function Base64Encoded() {
|
|
4546
4646
|
const name = "Base64 Pre-processor";
|
|
@@ -4577,7 +4677,7 @@ function Base64Encoded() {
|
|
|
4577
4677
|
const test = function(raw) {
|
|
4578
4678
|
return !/^\w+:\/\/\w+/im.test(raw) && keys.some((k) => raw.indexOf(k) !== -1);
|
|
4579
4679
|
};
|
|
4580
|
-
const
|
|
4680
|
+
const parse2 = function(raw) {
|
|
4581
4681
|
const decoded = Base642.decode(raw);
|
|
4582
4682
|
if (!/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(decoded)) {
|
|
4583
4683
|
app_default.error(
|
|
@@ -4587,14 +4687,14 @@ function Base64Encoded() {
|
|
|
4587
4687
|
}
|
|
4588
4688
|
return decoded;
|
|
4589
4689
|
};
|
|
4590
|
-
return { name, test, parse };
|
|
4690
|
+
return { name, test, parse: parse2 };
|
|
4591
4691
|
}
|
|
4592
4692
|
function fallbackBase64Encoded() {
|
|
4593
4693
|
const name = "Fallback Base64 Pre-processor";
|
|
4594
4694
|
const test = function(raw) {
|
|
4595
4695
|
return true;
|
|
4596
4696
|
};
|
|
4597
|
-
const
|
|
4697
|
+
const parse2 = function(raw) {
|
|
4598
4698
|
const decoded = Base642.decode(raw);
|
|
4599
4699
|
if (!/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(decoded)) {
|
|
4600
4700
|
app_default.error(
|
|
@@ -4604,7 +4704,7 @@ function fallbackBase64Encoded() {
|
|
|
4604
4704
|
}
|
|
4605
4705
|
return decoded;
|
|
4606
4706
|
};
|
|
4607
|
-
return { name, test, parse };
|
|
4707
|
+
return { name, test, parse: parse2 };
|
|
4608
4708
|
}
|
|
4609
4709
|
function Clash() {
|
|
4610
4710
|
const name = "Clash Pre-processor";
|
|
@@ -4613,7 +4713,7 @@ function Clash() {
|
|
|
4613
4713
|
const content = safeLoad(raw);
|
|
4614
4714
|
return content.proxies && Array.isArray(content.proxies);
|
|
4615
4715
|
};
|
|
4616
|
-
const
|
|
4716
|
+
const parse2 = function(raw, includeProxies) {
|
|
4617
4717
|
const afterReplace = normalizeClashYaml(raw);
|
|
4618
4718
|
const { proxies } = safeLoad(afterReplace);
|
|
4619
4719
|
return (includeProxies ? "proxies:\n" : "") + proxies.map((p) => {
|
|
@@ -4623,14 +4723,14 @@ function Clash() {
|
|
|
4623
4723
|
`;
|
|
4624
4724
|
}).join("");
|
|
4625
4725
|
};
|
|
4626
|
-
return { name, test, parse };
|
|
4726
|
+
return { name, test, parse: parse2 };
|
|
4627
4727
|
}
|
|
4628
4728
|
function SSD() {
|
|
4629
4729
|
const name = "SSD Pre-processor";
|
|
4630
4730
|
const test = function(raw) {
|
|
4631
4731
|
return raw.indexOf("ssd://") === 0;
|
|
4632
4732
|
};
|
|
4633
|
-
const
|
|
4733
|
+
const parse2 = function(raw) {
|
|
4634
4734
|
const output = [];
|
|
4635
4735
|
let ssdinfo = JSON.parse(Base642.decode(raw.split("ssd://")[1]));
|
|
4636
4736
|
let port = ssdinfo.port;
|
|
@@ -4652,20 +4752,20 @@ function SSD() {
|
|
|
4652
4752
|
}
|
|
4653
4753
|
return output.join("\n");
|
|
4654
4754
|
};
|
|
4655
|
-
return { name, test, parse };
|
|
4755
|
+
return { name, test, parse: parse2 };
|
|
4656
4756
|
}
|
|
4657
4757
|
function FullConfig() {
|
|
4658
4758
|
const name = "Full Config Preprocessor";
|
|
4659
4759
|
const test = function(raw) {
|
|
4660
4760
|
return /^(\[server_local\]|\[Proxy\])/gm.test(raw);
|
|
4661
4761
|
};
|
|
4662
|
-
const
|
|
4762
|
+
const parse2 = function(raw) {
|
|
4663
4763
|
const match = raw.match(
|
|
4664
4764
|
/^\[server_local|Proxy\]([\s\S]+?)^\[.+?\](\r?\n|$)/im
|
|
4665
4765
|
)?.[1];
|
|
4666
4766
|
return match || raw;
|
|
4667
4767
|
};
|
|
4668
|
-
return { name, test, parse };
|
|
4768
|
+
return { name, test, parse: parse2 };
|
|
4669
4769
|
}
|
|
4670
4770
|
var preprocessors_default = [
|
|
4671
4771
|
HTML(),
|
|
@@ -4810,6 +4910,37 @@ function quoteSurgeValue(value) {
|
|
|
4810
4910
|
function hasNonBlankValue(value) {
|
|
4811
4911
|
return value != null && `${value}`.trim().length > 0;
|
|
4812
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
|
+
}
|
|
4813
4944
|
function appendTlsProxyParams(result, proxy, enabled = true) {
|
|
4814
4945
|
if (!enabled) {
|
|
4815
4946
|
return;
|
|
@@ -4819,6 +4950,9 @@ function appendTlsProxyParams(result, proxy, enabled = true) {
|
|
|
4819
4950
|
"tls-fingerprint"
|
|
4820
4951
|
);
|
|
4821
4952
|
result.appendIfPresent(`,sni="${proxy.sni}"`, "sni");
|
|
4953
|
+
if (proxy.plugin !== "shadow-tls") {
|
|
4954
|
+
appendAlpn(result, proxy);
|
|
4955
|
+
}
|
|
4822
4956
|
result.appendIfPresent(
|
|
4823
4957
|
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
4824
4958
|
"skip-cert-verify"
|
|
@@ -4984,40 +5118,7 @@ function shadowsocks(proxy) {
|
|
|
4984
5118
|
"interface-name"
|
|
4985
5119
|
);
|
|
4986
5120
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
4987
|
-
|
|
4988
|
-
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
4989
|
-
result.appendIfPresent(
|
|
4990
|
-
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
4991
|
-
"shadow-tls-version"
|
|
4992
|
-
);
|
|
4993
|
-
result.appendIfPresent(
|
|
4994
|
-
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
4995
|
-
"shadow-tls-sni"
|
|
4996
|
-
);
|
|
4997
|
-
result.appendIfPresent(`,udp-port=${proxy["udp-port"]}`, "udp-port");
|
|
4998
|
-
} else if (["shadow-tls"].includes(proxy.plugin) && proxy["plugin-opts"]) {
|
|
4999
|
-
const password = proxy["plugin-opts"].password;
|
|
5000
|
-
const host = proxy["plugin-opts"].host;
|
|
5001
|
-
const version = proxy["plugin-opts"].version;
|
|
5002
|
-
if (password) {
|
|
5003
|
-
result.append(`,shadow-tls-password="${password}"`);
|
|
5004
|
-
if (host) {
|
|
5005
|
-
result.append(`,shadow-tls-sni=${host}`);
|
|
5006
|
-
}
|
|
5007
|
-
if (version) {
|
|
5008
|
-
if (version < 2) {
|
|
5009
|
-
throw unsupported(
|
|
5010
|
-
`shadow-tls version ${version} is not supported`
|
|
5011
|
-
);
|
|
5012
|
-
}
|
|
5013
|
-
result.append(`,shadow-tls-version=${version}`);
|
|
5014
|
-
}
|
|
5015
|
-
result.appendIfPresent(
|
|
5016
|
-
`,udp-port=${proxy["udp-port"]}`,
|
|
5017
|
-
"udp-port"
|
|
5018
|
-
);
|
|
5019
|
-
}
|
|
5020
|
-
}
|
|
5121
|
+
appendShadowTLS(result, proxy, true);
|
|
5021
5122
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5022
5123
|
result.appendIfPresent(
|
|
5023
5124
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5057,17 +5158,7 @@ function trojan(proxy) {
|
|
|
5057
5158
|
"interface-name"
|
|
5058
5159
|
);
|
|
5059
5160
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
5060
|
-
|
|
5061
|
-
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
5062
|
-
result.appendIfPresent(
|
|
5063
|
-
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
5064
|
-
"shadow-tls-version"
|
|
5065
|
-
);
|
|
5066
|
-
result.appendIfPresent(
|
|
5067
|
-
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
5068
|
-
"shadow-tls-sni"
|
|
5069
|
-
);
|
|
5070
|
-
}
|
|
5161
|
+
appendShadowTLS(result, proxy);
|
|
5071
5162
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5072
5163
|
result.appendIfPresent(
|
|
5073
5164
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5197,17 +5288,7 @@ function h2Connect(proxy) {
|
|
|
5197
5288
|
"interface-name"
|
|
5198
5289
|
);
|
|
5199
5290
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
5200
|
-
|
|
5201
|
-
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
5202
|
-
result.appendIfPresent(
|
|
5203
|
-
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
5204
|
-
"shadow-tls-version"
|
|
5205
|
-
);
|
|
5206
|
-
result.appendIfPresent(
|
|
5207
|
-
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
5208
|
-
"shadow-tls-sni"
|
|
5209
|
-
);
|
|
5210
|
-
}
|
|
5291
|
+
appendShadowTLS(result, proxy);
|
|
5211
5292
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5212
5293
|
result.appendIfPresent(
|
|
5213
5294
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5256,17 +5337,7 @@ function vmess(proxy, includeUnsupportedProxy) {
|
|
|
5256
5337
|
"interface-name"
|
|
5257
5338
|
);
|
|
5258
5339
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
5259
|
-
|
|
5260
|
-
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
5261
|
-
result.appendIfPresent(
|
|
5262
|
-
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
5263
|
-
"shadow-tls-version"
|
|
5264
|
-
);
|
|
5265
|
-
result.appendIfPresent(
|
|
5266
|
-
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
5267
|
-
"shadow-tls-sni"
|
|
5268
|
-
);
|
|
5269
|
-
}
|
|
5340
|
+
appendShadowTLS(result, proxy);
|
|
5270
5341
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5271
5342
|
result.appendIfPresent(
|
|
5272
5343
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5353,17 +5424,7 @@ function http(proxy) {
|
|
|
5353
5424
|
"interface-name"
|
|
5354
5425
|
);
|
|
5355
5426
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
5356
|
-
|
|
5357
|
-
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
5358
|
-
result.appendIfPresent(
|
|
5359
|
-
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
5360
|
-
"shadow-tls-version"
|
|
5361
|
-
);
|
|
5362
|
-
result.appendIfPresent(
|
|
5363
|
-
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
5364
|
-
"shadow-tls-sni"
|
|
5365
|
-
);
|
|
5366
|
-
}
|
|
5427
|
+
appendShadowTLS(result, proxy);
|
|
5367
5428
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5368
5429
|
result.appendIfPresent(
|
|
5369
5430
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5441,17 +5502,7 @@ function socks5(proxy) {
|
|
|
5441
5502
|
"interface-name"
|
|
5442
5503
|
);
|
|
5443
5504
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
5444
|
-
|
|
5445
|
-
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
5446
|
-
result.appendIfPresent(
|
|
5447
|
-
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
5448
|
-
"shadow-tls-version"
|
|
5449
|
-
);
|
|
5450
|
-
result.appendIfPresent(
|
|
5451
|
-
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
5452
|
-
"shadow-tls-sni"
|
|
5453
|
-
);
|
|
5454
|
-
}
|
|
5505
|
+
appendShadowTLS(result, proxy);
|
|
5455
5506
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5456
5507
|
result.appendIfPresent(
|
|
5457
5508
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5525,17 +5576,7 @@ function snell(proxy) {
|
|
|
5525
5576
|
"interface-name"
|
|
5526
5577
|
);
|
|
5527
5578
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
5528
|
-
|
|
5529
|
-
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
5530
|
-
result.appendIfPresent(
|
|
5531
|
-
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
5532
|
-
"shadow-tls-version"
|
|
5533
|
-
);
|
|
5534
|
-
result.appendIfPresent(
|
|
5535
|
-
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
5536
|
-
"shadow-tls-sni"
|
|
5537
|
-
);
|
|
5538
|
-
}
|
|
5579
|
+
appendShadowTLS(result, proxy);
|
|
5539
5580
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5540
5581
|
result.appendIfPresent(
|
|
5541
5582
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5554,10 +5595,6 @@ function tuic(proxy) {
|
|
|
5554
5595
|
result.appendIfPresent(`,uuid=${proxy.uuid}`, "uuid");
|
|
5555
5596
|
result.appendIfPresent(`,password="${proxy.password}"`, "password");
|
|
5556
5597
|
result.appendIfPresent(`,token=${proxy.token}`, "token");
|
|
5557
|
-
result.appendIfPresent(
|
|
5558
|
-
`,alpn=${Array.isArray(proxy.alpn) ? proxy.alpn[0] : proxy.alpn}`,
|
|
5559
|
-
"alpn"
|
|
5560
|
-
);
|
|
5561
5598
|
if (hasNonBlankValue(proxy.ports)) {
|
|
5562
5599
|
result.append(
|
|
5563
5600
|
`,port-hopping="${String(proxy.ports).replace(/,/g, ";")}"`
|
|
@@ -5595,17 +5632,7 @@ function tuic(proxy) {
|
|
|
5595
5632
|
"interface-name"
|
|
5596
5633
|
);
|
|
5597
5634
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
5598
|
-
|
|
5599
|
-
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
5600
|
-
result.appendIfPresent(
|
|
5601
|
-
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
5602
|
-
"shadow-tls-version"
|
|
5603
|
-
);
|
|
5604
|
-
result.appendIfPresent(
|
|
5605
|
-
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
5606
|
-
"shadow-tls-sni"
|
|
5607
|
-
);
|
|
5608
|
-
}
|
|
5635
|
+
appendShadowTLS(result, proxy);
|
|
5609
5636
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5610
5637
|
result.appendIfPresent(
|
|
5611
5638
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5656,17 +5683,7 @@ function wireguard(proxy) {
|
|
|
5656
5683
|
"interface-name"
|
|
5657
5684
|
);
|
|
5658
5685
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
5659
|
-
|
|
5660
|
-
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
5661
|
-
result.appendIfPresent(
|
|
5662
|
-
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
5663
|
-
"shadow-tls-version"
|
|
5664
|
-
);
|
|
5665
|
-
result.appendIfPresent(
|
|
5666
|
-
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
5667
|
-
"shadow-tls-sni"
|
|
5668
|
-
);
|
|
5669
|
-
}
|
|
5686
|
+
appendShadowTLS(result, proxy);
|
|
5670
5687
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5671
5688
|
result.appendIfPresent(
|
|
5672
5689
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5740,17 +5757,7 @@ function wireguard_surge(proxy) {
|
|
|
5740
5757
|
"interface-name"
|
|
5741
5758
|
);
|
|
5742
5759
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
5743
|
-
|
|
5744
|
-
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
5745
|
-
result.appendIfPresent(
|
|
5746
|
-
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
5747
|
-
"shadow-tls-version"
|
|
5748
|
-
);
|
|
5749
|
-
result.appendIfPresent(
|
|
5750
|
-
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
5751
|
-
"shadow-tls-sni"
|
|
5752
|
-
);
|
|
5753
|
-
}
|
|
5760
|
+
appendShadowTLS(result, proxy);
|
|
5754
5761
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5755
5762
|
result.appendIfPresent(
|
|
5756
5763
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5759,8 +5766,12 @@ function wireguard_surge(proxy) {
|
|
|
5759
5766
|
return result.toString();
|
|
5760
5767
|
}
|
|
5761
5768
|
function hysteria2(proxy) {
|
|
5762
|
-
|
|
5763
|
-
|
|
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`);
|
|
5764
5775
|
}
|
|
5765
5776
|
const result = new Result(proxy);
|
|
5766
5777
|
result.append(`${proxy.name}=hysteria2,${proxy.server},${proxy.port}`);
|
|
@@ -5773,8 +5784,8 @@ function hysteria2(proxy) {
|
|
|
5773
5784
|
if (hasNonBlankValue(proxy["hop-interval"])) {
|
|
5774
5785
|
result.append(`,port-hopping-interval=${proxy["hop-interval"]}`);
|
|
5775
5786
|
}
|
|
5776
|
-
if (proxy["obfs-password"] &&
|
|
5777
|
-
result.append(
|
|
5787
|
+
if (proxy["obfs-password"] && obfsPasswordField) {
|
|
5788
|
+
result.append(`,${obfsPasswordField}="${proxy["obfs-password"]}"`);
|
|
5778
5789
|
}
|
|
5779
5790
|
const ip_version = ipVersions[proxy["ip-version"]] || proxy["ip-version"];
|
|
5780
5791
|
result.appendIfPresent(`,ip-version=${ip_version}`, "ip-version");
|
|
@@ -5805,17 +5816,7 @@ function hysteria2(proxy) {
|
|
|
5805
5816
|
"interface-name"
|
|
5806
5817
|
);
|
|
5807
5818
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
5808
|
-
|
|
5809
|
-
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
5810
|
-
result.appendIfPresent(
|
|
5811
|
-
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
5812
|
-
"shadow-tls-version"
|
|
5813
|
-
);
|
|
5814
|
-
result.appendIfPresent(
|
|
5815
|
-
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
5816
|
-
"shadow-tls-sni"
|
|
5817
|
-
);
|
|
5818
|
-
}
|
|
5819
|
+
appendShadowTLS(result, proxy);
|
|
5819
5820
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5820
5821
|
result.appendIfPresent(
|
|
5821
5822
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5897,13 +5898,13 @@ function ClashMeta_Producer() {
|
|
|
5897
5898
|
if (opts["include-unsupported-proxy"]) return true;
|
|
5898
5899
|
if (proxy.type === "h2-connect") {
|
|
5899
5900
|
app_default.error(
|
|
5900
|
-
`
|
|
5901
|
+
`mihomo does not support HTTP/2 CONNECT proxy type. Proxy ${proxy.name} has been filtered.`
|
|
5901
5902
|
);
|
|
5902
5903
|
return false;
|
|
5903
5904
|
}
|
|
5904
5905
|
if (hasRootHeaders(proxy) && proxy.type === "trusttunnel") {
|
|
5905
5906
|
app_default.error(
|
|
5906
|
-
`
|
|
5907
|
+
`mihomo does not support headers for TrustTunnel proxy ${proxy.name}. Proxy has been filtered.`
|
|
5907
5908
|
);
|
|
5908
5909
|
return false;
|
|
5909
5910
|
}
|
|
@@ -5911,11 +5912,16 @@ function ClashMeta_Producer() {
|
|
|
5911
5912
|
return false;
|
|
5912
5913
|
} else if (proxy.type === "snell" && !isSupportedMihomoVersion(proxy.version, [1, 2, 3, 4, 5])) {
|
|
5913
5914
|
return false;
|
|
5914
|
-
} else if (hasMihomoShadowTls(proxy) && (proxy.type
|
|
5915
|
+
} else if (hasMihomoShadowTls(proxy) && (!["ss", "snell"].includes(proxy.type) || !isSupportedMihomoVersion(
|
|
5915
5916
|
getMihomoShadowTlsVersion(proxy),
|
|
5916
5917
|
[1, 2, 3]
|
|
5917
5918
|
))) {
|
|
5918
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;
|
|
5919
5925
|
} else if (["juicity", "naive"].includes(proxy.type)) {
|
|
5920
5926
|
return false;
|
|
5921
5927
|
} else if (["ss"].includes(proxy.type) && ![
|
|
@@ -6018,24 +6024,28 @@ function ClashMeta_Producer() {
|
|
|
6018
6024
|
ds["reality-opts"] = { "public-key": "" };
|
|
6019
6025
|
}
|
|
6020
6026
|
}
|
|
6021
|
-
} else if (proxy.type === "ss") {
|
|
6022
|
-
if (isPresent2(proxy, "shadow-tls-password") && !isPresent2(proxy, "plugin")) {
|
|
6023
|
-
proxy.plugin = "shadow-tls";
|
|
6024
|
-
proxy["plugin-opts"] = {
|
|
6025
|
-
host: proxy["shadow-tls-sni"],
|
|
6026
|
-
password: proxy["shadow-tls-password"],
|
|
6027
|
-
version: proxy["shadow-tls-version"]
|
|
6028
|
-
};
|
|
6029
|
-
delete proxy["shadow-tls-password"];
|
|
6030
|
-
delete proxy["shadow-tls-sni"];
|
|
6031
|
-
delete proxy["shadow-tls-version"];
|
|
6032
|
-
}
|
|
6033
6027
|
}
|
|
6034
6028
|
if (isPresent2(proxy, "plugin-opts.mux")) {
|
|
6035
6029
|
proxy["plugin-opts"].mux = normalizePluginMuxBooleanValue(
|
|
6036
6030
|
proxy["plugin-opts"].mux
|
|
6037
6031
|
);
|
|
6038
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
|
+
}
|
|
6039
6049
|
if (["vmess", "vless"].includes(proxy.type) && proxy.network === "http") {
|
|
6040
6050
|
let httpPath = proxy["http-opts"]?.path;
|
|
6041
6051
|
if (isPresent2(proxy, "http-opts.path") && !Array.isArray(httpPath)) {
|
|
@@ -6144,14 +6154,20 @@ function isSupportedMihomoVersion(version, supportedVersions) {
|
|
|
6144
6154
|
return Number.isInteger(parsed) && supportedVersions.includes(parsed);
|
|
6145
6155
|
}
|
|
6146
6156
|
function hasMihomoShadowTls(proxy) {
|
|
6147
|
-
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"));
|
|
6148
6161
|
}
|
|
6149
6162
|
function getMihomoShadowTlsVersion(proxy) {
|
|
6150
|
-
|
|
6151
|
-
|
|
6163
|
+
return getMihomoShadowTlsOpts(proxy)?.version;
|
|
6164
|
+
}
|
|
6165
|
+
function getMihomoShadowTlsOpts(proxy) {
|
|
6166
|
+
if (proxy?.plugin === "shadow-tls" && proxy?.["plugin-opts"]) {
|
|
6167
|
+
return proxy["plugin-opts"];
|
|
6152
6168
|
}
|
|
6153
|
-
if (proxy?.
|
|
6154
|
-
return proxy
|
|
6169
|
+
if (proxy?.type === "snell" && proxy?.["obfs-opts"]?.mode === "shadow-tls") {
|
|
6170
|
+
return proxy["obfs-opts"];
|
|
6155
6171
|
}
|
|
6156
6172
|
return void 0;
|
|
6157
6173
|
}
|
|
@@ -6179,7 +6195,7 @@ function SurgeMac_Producer() {
|
|
|
6179
6195
|
throw e;
|
|
6180
6196
|
}
|
|
6181
6197
|
app_default.log(
|
|
6182
|
-
`${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`
|
|
6183
6199
|
);
|
|
6184
6200
|
return output;
|
|
6185
6201
|
}
|
|
@@ -6799,10 +6815,34 @@ function appendTlsProfile(result, proxy) {
|
|
|
6799
6815
|
const tlsProfile = getLoonTlsProfile(proxy);
|
|
6800
6816
|
if (tlsProfile) result.append(`,tls-profile=${tlsProfile}`);
|
|
6801
6817
|
}
|
|
6802
|
-
function
|
|
6818
|
+
function appendAlpn2(result, proxy) {
|
|
6803
6819
|
const alpn = getLoonAlpn(proxy);
|
|
6804
6820
|
if (alpn) result.append(`,alpn="${alpn}"`);
|
|
6805
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
|
+
}
|
|
6806
6846
|
function appendReality(result, proxy) {
|
|
6807
6847
|
result.appendIfPresent(`,sni=${proxy.sni}`, "sni");
|
|
6808
6848
|
result.appendIfPresent(
|
|
@@ -6876,40 +6916,7 @@ function shadowsocks2(proxy) {
|
|
|
6876
6916
|
throw new Error(`plugin ${proxy.plugin} is not supported`);
|
|
6877
6917
|
}
|
|
6878
6918
|
}
|
|
6879
|
-
|
|
6880
|
-
result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
|
|
6881
|
-
result.appendIfPresent(
|
|
6882
|
-
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
6883
|
-
"shadow-tls-version"
|
|
6884
|
-
);
|
|
6885
|
-
result.appendIfPresent(
|
|
6886
|
-
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
6887
|
-
"shadow-tls-sni"
|
|
6888
|
-
);
|
|
6889
|
-
result.appendIfPresent(`,udp-port=${proxy["udp-port"]}`, "udp-port");
|
|
6890
|
-
} else if (["shadow-tls"].includes(proxy.plugin) && proxy["plugin-opts"]) {
|
|
6891
|
-
const password = proxy["plugin-opts"].password;
|
|
6892
|
-
const host = proxy["plugin-opts"].host;
|
|
6893
|
-
const version = proxy["plugin-opts"].version;
|
|
6894
|
-
if (password) {
|
|
6895
|
-
result.append(`,shadow-tls-password=${password}`);
|
|
6896
|
-
if (host) {
|
|
6897
|
-
result.append(`,shadow-tls-sni=${host}`);
|
|
6898
|
-
}
|
|
6899
|
-
if (version) {
|
|
6900
|
-
if (version < 2) {
|
|
6901
|
-
throw new Error(
|
|
6902
|
-
`shadow-tls version ${version} is not supported`
|
|
6903
|
-
);
|
|
6904
|
-
}
|
|
6905
|
-
result.append(`,shadow-tls-version=${version}`);
|
|
6906
|
-
}
|
|
6907
|
-
result.appendIfPresent(
|
|
6908
|
-
`,udp-port=${proxy["udp-port"]}`,
|
|
6909
|
-
"udp-port"
|
|
6910
|
-
);
|
|
6911
|
-
}
|
|
6912
|
-
}
|
|
6919
|
+
appendShadowTLS2(result, proxy);
|
|
6913
6920
|
if (proxy["udp-over-tcp"]) {
|
|
6914
6921
|
if (proxy["udp-over-tcp-version"] === 2) {
|
|
6915
6922
|
if (proxy.plugin === "obfs") {
|
|
@@ -6950,40 +6957,7 @@ function shadowsocksr(proxy) {
|
|
|
6950
6957
|
);
|
|
6951
6958
|
result.appendIfPresent(`,obfs=${proxy.obfs}`, "obfs");
|
|
6952
6959
|
result.appendIfPresent(`,obfs-param=${proxy["obfs-param"]}`, "obfs-param");
|
|
6953
|
-
|
|
6954
|
-
result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
|
|
6955
|
-
result.appendIfPresent(
|
|
6956
|
-
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
6957
|
-
"shadow-tls-version"
|
|
6958
|
-
);
|
|
6959
|
-
result.appendIfPresent(
|
|
6960
|
-
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
6961
|
-
"shadow-tls-sni"
|
|
6962
|
-
);
|
|
6963
|
-
result.appendIfPresent(`,udp-port=${proxy["udp-port"]}`, "udp-port");
|
|
6964
|
-
} else if (["shadow-tls"].includes(proxy.plugin) && proxy["plugin-opts"]) {
|
|
6965
|
-
const password = proxy["plugin-opts"].password;
|
|
6966
|
-
const host = proxy["plugin-opts"].host;
|
|
6967
|
-
const version = proxy["plugin-opts"].version;
|
|
6968
|
-
if (password) {
|
|
6969
|
-
result.append(`,shadow-tls-password=${password}`);
|
|
6970
|
-
if (host) {
|
|
6971
|
-
result.append(`,shadow-tls-sni=${host}`);
|
|
6972
|
-
}
|
|
6973
|
-
if (version) {
|
|
6974
|
-
if (version < 2) {
|
|
6975
|
-
throw new Error(
|
|
6976
|
-
`shadow-tls version ${version} is not supported`
|
|
6977
|
-
);
|
|
6978
|
-
}
|
|
6979
|
-
result.append(`,shadow-tls-version=${version}`);
|
|
6980
|
-
}
|
|
6981
|
-
result.appendIfPresent(
|
|
6982
|
-
`,udp-port=${proxy["udp-port"]}`,
|
|
6983
|
-
"udp-port"
|
|
6984
|
-
);
|
|
6985
|
-
}
|
|
6986
|
-
}
|
|
6960
|
+
appendShadowTLS2(result, proxy);
|
|
6987
6961
|
result.appendIfPresent(`,fast-open=${proxy.tfo}`, "tfo");
|
|
6988
6962
|
if (proxy["block-quic"] === "on") {
|
|
6989
6963
|
result.append(",block-quic=true");
|
|
@@ -7026,7 +7000,7 @@ function trojan2(proxy) {
|
|
|
7026
7000
|
"skip-cert-verify"
|
|
7027
7001
|
);
|
|
7028
7002
|
appendTlsProfile(result, proxy);
|
|
7029
|
-
|
|
7003
|
+
appendAlpn2(result, proxy);
|
|
7030
7004
|
if (isReality) {
|
|
7031
7005
|
appendReality(result, proxy);
|
|
7032
7006
|
} else {
|
|
@@ -7074,7 +7048,7 @@ function anytls2(proxy) {
|
|
|
7074
7048
|
"skip-cert-verify"
|
|
7075
7049
|
);
|
|
7076
7050
|
appendTlsProfile(result, proxy);
|
|
7077
|
-
|
|
7051
|
+
appendAlpn2(result, proxy);
|
|
7078
7052
|
if (isReality) {
|
|
7079
7053
|
appendReality(result, proxy);
|
|
7080
7054
|
} else {
|
|
@@ -7147,7 +7121,7 @@ function vmess2(proxy) {
|
|
|
7147
7121
|
);
|
|
7148
7122
|
if (proxy.tls || isReality) {
|
|
7149
7123
|
appendTlsProfile(result, proxy);
|
|
7150
|
-
|
|
7124
|
+
appendAlpn2(result, proxy);
|
|
7151
7125
|
}
|
|
7152
7126
|
if (isReality) {
|
|
7153
7127
|
appendReality(result, proxy);
|
|
@@ -7235,7 +7209,7 @@ function vless(proxy) {
|
|
|
7235
7209
|
);
|
|
7236
7210
|
if (proxy.tls || isReality || isXtls) {
|
|
7237
7211
|
appendTlsProfile(result, proxy);
|
|
7238
|
-
|
|
7212
|
+
appendAlpn2(result, proxy);
|
|
7239
7213
|
}
|
|
7240
7214
|
if (isXtls) {
|
|
7241
7215
|
result.appendIfPresent(`,flow=${proxy.flow}`, "flow");
|
|
@@ -7279,7 +7253,7 @@ function http2(proxy) {
|
|
|
7279
7253
|
);
|
|
7280
7254
|
if (proxy.tls) {
|
|
7281
7255
|
appendTlsProfile(result, proxy);
|
|
7282
|
-
|
|
7256
|
+
appendAlpn2(result, proxy);
|
|
7283
7257
|
}
|
|
7284
7258
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
7285
7259
|
if (proxy["block-quic"] === "on") {
|
|
@@ -7304,7 +7278,7 @@ function socks52(proxy) {
|
|
|
7304
7278
|
);
|
|
7305
7279
|
if (proxy.tls) {
|
|
7306
7280
|
appendTlsProfile(result, proxy);
|
|
7307
|
-
|
|
7281
|
+
appendAlpn2(result, proxy);
|
|
7308
7282
|
}
|
|
7309
7283
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
7310
7284
|
if (proxy["block-quic"] === "on") {
|
|
@@ -7404,7 +7378,7 @@ function hysteria22(proxy) {
|
|
|
7404
7378
|
"skip-cert-verify"
|
|
7405
7379
|
);
|
|
7406
7380
|
appendTlsProfile(result, proxy);
|
|
7407
|
-
|
|
7381
|
+
appendAlpn2(result, proxy);
|
|
7408
7382
|
if (proxy["obfs-password"] && proxy.obfs == "salamander") {
|
|
7409
7383
|
result.append(`,salamander-password=${proxy["obfs-password"]}`);
|
|
7410
7384
|
}
|
|
@@ -9229,11 +9203,15 @@ function Shadowrocket_Producer() {
|
|
|
9229
9203
|
return false;
|
|
9230
9204
|
} else if (proxy.type === "snell" && ![1, 2, 3, 4, 5].includes(proxy.version)) {
|
|
9231
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;
|
|
9232
9211
|
} else if ([
|
|
9233
9212
|
"tailscale",
|
|
9234
9213
|
"sudoku",
|
|
9235
9214
|
"naive",
|
|
9236
|
-
"masque",
|
|
9237
9215
|
"openvpn",
|
|
9238
9216
|
"gost-relay"
|
|
9239
9217
|
].includes(proxy.type)) {
|
|
@@ -9292,25 +9270,29 @@ function Shadowrocket_Producer() {
|
|
|
9292
9270
|
proxy["pre-shared-key"] = proxy["preshared-key"];
|
|
9293
9271
|
proxy.ip = getWireGuardAddressWithCIDR(proxy, "ipv4");
|
|
9294
9272
|
proxy.ipv6 = getWireGuardAddressWithCIDR(proxy, "ipv6");
|
|
9295
|
-
} else if (proxy.type === "snell"
|
|
9296
|
-
|
|
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
|
+
}
|
|
9297
9290
|
} else if (proxy.type === "vless") {
|
|
9298
9291
|
if (isPresent2(proxy, "sni")) {
|
|
9299
9292
|
proxy.servername = proxy.sni;
|
|
9300
9293
|
delete proxy.sni;
|
|
9301
9294
|
}
|
|
9302
9295
|
} else if (proxy.type === "ss") {
|
|
9303
|
-
if (isPresent2(proxy, "shadow-tls-password") && !isPresent2(proxy, "plugin")) {
|
|
9304
|
-
proxy.plugin = "shadow-tls";
|
|
9305
|
-
proxy["plugin-opts"] = {
|
|
9306
|
-
host: proxy["shadow-tls-sni"],
|
|
9307
|
-
password: proxy["shadow-tls-password"],
|
|
9308
|
-
version: proxy["shadow-tls-version"]
|
|
9309
|
-
};
|
|
9310
|
-
delete proxy["shadow-tls-password"];
|
|
9311
|
-
delete proxy["shadow-tls-sni"];
|
|
9312
|
-
delete proxy["shadow-tls-version"];
|
|
9313
|
-
}
|
|
9314
9296
|
if (isShadowsocksOverTls(proxy)) {
|
|
9315
9297
|
if (isPresent2(proxy, "sni")) {
|
|
9316
9298
|
proxy.servername = proxy.sni;
|
|
@@ -9407,6 +9389,9 @@ function Shadowrocket_Producer() {
|
|
|
9407
9389
|
};
|
|
9408
9390
|
return { type, produce: produce2 };
|
|
9409
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
|
+
}
|
|
9410
9395
|
|
|
9411
9396
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/surfboard.js
|
|
9412
9397
|
var targetPlatform5 = "Surfboard";
|
|
@@ -9468,8 +9453,8 @@ function Surfboard_Producer() {
|
|
|
9468
9453
|
return { produce: produce2 };
|
|
9469
9454
|
}
|
|
9470
9455
|
function hysteria23(proxy) {
|
|
9471
|
-
if (proxy.obfs || proxy["obfs-password"]) {
|
|
9472
|
-
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`);
|
|
9473
9458
|
}
|
|
9474
9459
|
const result = new Result(proxy);
|
|
9475
9460
|
result.append(`${proxy.name}=hysteria2,${proxy.server},${proxy.port}`);
|
|
@@ -9482,6 +9467,9 @@ function hysteria23(proxy) {
|
|
|
9482
9467
|
if (hasNonBlankValue2(proxy["hop-interval"])) {
|
|
9483
9468
|
result.append(`,port-hopping-interval=${proxy["hop-interval"]}`);
|
|
9484
9469
|
}
|
|
9470
|
+
if (proxy["obfs-password"]) {
|
|
9471
|
+
result.append(`,salamander-password="${proxy["obfs-password"]}"`);
|
|
9472
|
+
}
|
|
9485
9473
|
appendTlsProxyParams2(result, proxy);
|
|
9486
9474
|
result.appendIfPresent(
|
|
9487
9475
|
`,download-bandwidth=${`${proxy["down"]}`.match(/\d+/)?.[0] || 0}`,
|
|
@@ -10141,11 +10129,12 @@ var getShadowTLSPluginOpts = (proxy = {}) => {
|
|
|
10141
10129
|
if (proxy.plugin === "shadow-tls" && proxy["plugin-opts"]) {
|
|
10142
10130
|
return proxy["plugin-opts"];
|
|
10143
10131
|
}
|
|
10144
|
-
if (proxy
|
|
10132
|
+
if (proxy.type === "snell" && proxy["obfs-opts"]?.mode === "shadow-tls") {
|
|
10145
10133
|
return {
|
|
10146
|
-
host: proxy["
|
|
10147
|
-
password: proxy["
|
|
10148
|
-
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
|
|
10149
10138
|
};
|
|
10150
10139
|
}
|
|
10151
10140
|
return void 0;
|
|
@@ -10169,16 +10158,18 @@ var shadowTLSOutboundParser = (proxy = {}, pluginOpts) => {
|
|
|
10169
10158
|
password: pluginOpts.password,
|
|
10170
10159
|
tls: {
|
|
10171
10160
|
enabled: true,
|
|
10172
|
-
server_name: pluginOpts.host
|
|
10173
|
-
utls: {
|
|
10174
|
-
enabled: true,
|
|
10175
|
-
fingerprint
|
|
10176
|
-
}
|
|
10161
|
+
server_name: pluginOpts.host
|
|
10177
10162
|
}
|
|
10178
10163
|
};
|
|
10164
|
+
if (fingerprint) {
|
|
10165
|
+
stPart.tls.utls = {
|
|
10166
|
+
enabled: true,
|
|
10167
|
+
fingerprint
|
|
10168
|
+
};
|
|
10169
|
+
}
|
|
10179
10170
|
if (stPart.server_port < 0 || stPart.server_port > 65535)
|
|
10180
10171
|
throw "\u7AEF\u53E3\u503C\u975E\u6CD5";
|
|
10181
|
-
const alpn = normalizeALPN(pluginOpts.alpn);
|
|
10172
|
+
const alpn = normalizeALPN(pluginOpts.alpn) ?? normalizeALPN(proxy.alpn);
|
|
10182
10173
|
if (alpn) stPart.tls.alpn = alpn;
|
|
10183
10174
|
if (proxy["fast-open"] === true) stPart.udp_fragment = true;
|
|
10184
10175
|
tfoParser(proxy, stPart);
|
|
@@ -10321,9 +10312,9 @@ var snellParser = (proxy = {}) => {
|
|
|
10321
10312
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10322
10313
|
throw "invalid port";
|
|
10323
10314
|
if (version != null) parsedProxy.version = version;
|
|
10324
|
-
if (proxy["obfs-opts"]?.mode)
|
|
10315
|
+
if (proxy["obfs-opts"]?.mode && proxy["obfs-opts"].mode !== "shadow-tls")
|
|
10325
10316
|
parsedProxy.obfs_mode = proxy["obfs-opts"].mode;
|
|
10326
|
-
if (proxy["obfs-opts"]?.host)
|
|
10317
|
+
if (proxy["obfs-opts"]?.host && proxy["obfs-opts"]?.mode !== "shadow-tls")
|
|
10327
10318
|
parsedProxy.obfs_host = proxy["obfs-opts"].host;
|
|
10328
10319
|
if (proxy.reuse && (version == null || version >= 4))
|
|
10329
10320
|
parsedProxy.reuse = true;
|
|
@@ -10799,8 +10790,30 @@ function singbox_Producer() {
|
|
|
10799
10790
|
const type = "ALL";
|
|
10800
10791
|
const produce2 = (proxies, type2, opts = {}) => {
|
|
10801
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
|
+
);
|
|
10802
10805
|
ClashMeta_Producer().produce(proxies, "internal", { "include-unsupported-proxy": true }).map((proxy) => {
|
|
10803
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
|
+
}
|
|
10804
10817
|
if (["xhttp"].includes(proxy.network))
|
|
10805
10818
|
throw new Error(
|
|
10806
10819
|
`Platform sing-box does not support network: ${proxy.network}`
|
|
@@ -11380,16 +11393,7 @@ function Egern_Producer() {
|
|
|
11380
11393
|
"anytls",
|
|
11381
11394
|
"ssh"
|
|
11382
11395
|
].includes(original.type)) {
|
|
11383
|
-
if (
|
|
11384
|
-
if (original["shadow-tls-version"] != 3)
|
|
11385
|
-
throw new Error(
|
|
11386
|
-
`shadow-tls version ${original["shadow-tls-version"]} is not supported`
|
|
11387
|
-
);
|
|
11388
|
-
proxy.shadow_tls = {
|
|
11389
|
-
password: original["shadow-tls-password"],
|
|
11390
|
-
sni: original["shadow-tls-sni"]
|
|
11391
|
-
};
|
|
11392
|
-
} else if (["shadow-tls"].includes(original.plugin) && original["plugin-opts"]) {
|
|
11396
|
+
if (["shadow-tls"].includes(original.plugin) && original["plugin-opts"]) {
|
|
11393
11397
|
if (original["plugin-opts"].version != 3)
|
|
11394
11398
|
throw new Error(
|
|
11395
11399
|
`shadow-tls version ${original["plugin-opts"].version} is not supported`
|
|
@@ -11489,7 +11493,7 @@ function getUdpRelay(proxy) {
|
|
|
11489
11493
|
return proxy.udp ?? proxy.udp_relay;
|
|
11490
11494
|
}
|
|
11491
11495
|
function hasShadowTls(proxy) {
|
|
11492
|
-
return proxy.plugin === "shadow-tls"
|
|
11496
|
+
return proxy.plugin === "shadow-tls";
|
|
11493
11497
|
}
|
|
11494
11498
|
function getNonEmptyValue(value) {
|
|
11495
11499
|
if (value == null) return void 0;
|