sub-store-convert 2.24.22 → 2.36.10
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 +1170 -1003
- package/package.json +4 -4
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/cert_verify_name/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/cert_verify_name/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/cert_verify_name/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/cert_verify_name/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") {
|
|
@@ -448,11 +470,11 @@ snell = tag equals "snell" address (snell_version/snell_mode/snell_psk/obfs/obfs
|
|
|
448
470
|
}
|
|
449
471
|
handleShadowTLS();
|
|
450
472
|
}
|
|
451
|
-
tuic = tag equals "tuic" address (alpn/token/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/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* {
|
|
473
|
+
tuic = tag equals "tuic" address (alpn/token/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/cert_verify_name/fast_open/tfo/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* {
|
|
452
474
|
proxy.type = "tuic";
|
|
453
475
|
handleShadowTLS();
|
|
454
476
|
}
|
|
455
|
-
tuic_v5 = tag equals "tuic-v5" address (alpn/passwordk/uuidk/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/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* {
|
|
477
|
+
tuic_v5 = tag equals "tuic-v5" address (alpn/passwordk/uuidk/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/cert_verify_name/fast_open/tfo/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* {
|
|
456
478
|
proxy.type = "tuic";
|
|
457
479
|
proxy.version = 5;
|
|
458
480
|
handleShadowTLS();
|
|
@@ -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/cert_verify_name/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/cert_verify_name/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/cert_verify_name/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/cert_verify_name/alpn/fast_open/tfo/block_quic/others)* {
|
|
482
504
|
proxy.type = "trusttunnel";
|
|
483
505
|
proxy.tls = true;
|
|
484
506
|
}
|
|
@@ -555,6 +577,7 @@ sni = comma "sni" equals match:[^,]+ {
|
|
|
555
577
|
proxy.sni = sni;
|
|
556
578
|
}
|
|
557
579
|
}
|
|
580
|
+
cert_verify_name = comma "server-cert-verify-name" equals match:[^,]+ { proxy["name-cert-verify"] = stripQuotes(match.join("")); }
|
|
558
581
|
tls_verification = comma "skip-cert-verify" equals flag:bool { proxy["skip-cert-verify"] = flag; }
|
|
559
582
|
tls_fingerprint = comma "server-cert-fingerprint-sha256" equals tls_fingerprint:$[^,]+ { proxy["tls-fingerprint"] = tls_fingerprint.trim(); }
|
|
560
583
|
client_cert = comma "client-cert" equals match:[^,]+ { proxy["keystore-client-cert"] = stripQuotes(match.join("")); }
|
|
@@ -629,13 +652,18 @@ private_key = comma "private-key" equals match:[^,]+ { proxy["keystore-private-k
|
|
|
629
652
|
server_fingerprint = comma "server-fingerprint" equals match:[^,]+ { proxy["server-fingerprint"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
|
630
653
|
block_quic = comma "block-quic" equals match:[^,]+ { proxy["block-quic"] = match.join(""); }
|
|
631
654
|
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:[^,]+ {
|
|
655
|
+
shadow_tls_version = comma "shadow-tls-version" equals match:$[0-9]+ { shadowTLS.version = parseInt(match.trim()); }
|
|
656
|
+
shadow_tls_sni = comma "shadow-tls-sni" equals match:[^,]+ { shadowTLS.host = match.join(""); }
|
|
657
|
+
shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { shadowTLS.password = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
|
635
658
|
token = comma "token" equals match:[^,]+ { proxy.token = match.join(""); }
|
|
636
|
-
alpn = comma "alpn" equals match:
|
|
659
|
+
alpn = comma "alpn" equals match:quoted_value {
|
|
660
|
+
const values = parseAlpn(match);
|
|
661
|
+
if (values.length > 0) proxy.alpn = values;
|
|
662
|
+
}
|
|
663
|
+
quoted_value = '"' match:$[^"]* '"' { return match; } / "'" match:$[^']* "'" { return match; } / match:$[^,]+ { return match; }
|
|
637
664
|
uuidk = comma "uuid" equals match:[^,]+ { proxy.uuid = match.join(""); }
|
|
638
665
|
salamander_password = comma "salamander-password" equals match:[^,]+ { proxy['obfs-password'] = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); proxy.obfs = 'salamander'; }
|
|
666
|
+
gecko_password = comma "gecko-password" equals match:[^,]+ { proxy['obfs-password'] = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); proxy.obfs = 'gecko'; }
|
|
639
667
|
|
|
640
668
|
tag = match:[^=,]* { proxy.name = match.join("").trim(); }
|
|
641
669
|
comma = _ "," _
|
|
@@ -674,6 +702,7 @@ var grammars2 = String.raw`
|
|
|
674
702
|
const proxy = {};
|
|
675
703
|
const obfs = {};
|
|
676
704
|
const transport = {};
|
|
705
|
+
const shadowTLS = {};
|
|
677
706
|
const $ = {};
|
|
678
707
|
|
|
679
708
|
function handleTransport() {
|
|
@@ -689,6 +718,24 @@ var grammars2 = String.raw`
|
|
|
689
718
|
}
|
|
690
719
|
}
|
|
691
720
|
|
|
721
|
+
function handleShadowTLS() {
|
|
722
|
+
if (shadowTLS.password) {
|
|
723
|
+
if (shadowTLS.version < 2) {
|
|
724
|
+
throw new Error("shadow-tls version " + shadowTLS.version + " is not supported");
|
|
725
|
+
}
|
|
726
|
+
proxy.plugin = "shadow-tls";
|
|
727
|
+
proxy["plugin-opts"] = {
|
|
728
|
+
host: shadowTLS.host,
|
|
729
|
+
password: shadowTLS.password,
|
|
730
|
+
version: shadowTLS.version,
|
|
731
|
+
};
|
|
732
|
+
if (proxy.alpn) {
|
|
733
|
+
$set(proxy, "plugin-opts.alpn", proxy.alpn);
|
|
734
|
+
delete proxy.alpn;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
|
|
692
739
|
function normalizeVmessSecurity(security) {
|
|
693
740
|
const normalized = String(security || "").trim().toLowerCase();
|
|
694
741
|
const supported = ["none", "auto", "aes-128-gcm", "chacha20-ietf-poly1305"];
|
|
@@ -711,12 +758,13 @@ start = (shadowsocksr/shadowsocks/vmess/vless/trojan/https/http/socks5/hysteria2
|
|
|
711
758
|
return proxy;
|
|
712
759
|
}
|
|
713
760
|
|
|
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)*{
|
|
761
|
+
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
762
|
proxy.type = "ssr";
|
|
716
763
|
// handle ssr obfs
|
|
717
764
|
proxy.obfs = obfs.type;
|
|
765
|
+
handleShadowTLS();
|
|
718
766
|
}
|
|
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)* {
|
|
767
|
+
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
768
|
proxy.type = "ss";
|
|
721
769
|
// handle ss obfs
|
|
722
770
|
if (obfs.type == "http" || obfs.type === "tls") {
|
|
@@ -725,6 +773,7 @@ shadowsocks = tag equals "shadowsocks"i address method password (obfs_typev obfs
|
|
|
725
773
|
$set(proxy, "plugin-opts.host", obfs.host);
|
|
726
774
|
$set(proxy, "plugin-opts.path", obfs.path);
|
|
727
775
|
}
|
|
776
|
+
handleShadowTLS();
|
|
728
777
|
}
|
|
729
778
|
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
779
|
proxy.type = "vmess";
|
|
@@ -849,9 +898,9 @@ ssr_protocol_param = comma "protocol-param" equals param:$[^=,]+ { proxy["protoc
|
|
|
849
898
|
vmess_alterId = comma "alterId" equals alterId:$[0-9]+ { proxy.alterId = parseInt(alterId); }
|
|
850
899
|
|
|
851
900
|
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:[^,]+ {
|
|
901
|
+
shadow_tls_version = comma "shadow-tls-version" equals match:$[0-9]+ { shadowTLS.version = parseInt(match.trim()); }
|
|
902
|
+
shadow_tls_sni = comma "shadow-tls-sni" equals match:[^,]+ { shadowTLS.host = match.join(""); }
|
|
903
|
+
shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { shadowTLS.password = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
|
855
904
|
|
|
856
905
|
over_tls = comma "over-tls" equals flag:bool { proxy.tls = flag; }
|
|
857
906
|
tls_name = comma sni:("tls-name") equals match:[^,]+ { proxy.sni = match.join("").replace(/^"(.*)"$/, '$1'); }
|
|
@@ -1174,279 +1223,325 @@ function getParser3() {
|
|
|
1174
1223
|
return parser3;
|
|
1175
1224
|
}
|
|
1176
1225
|
|
|
1177
|
-
// src/vendors/Sub-Store/backend/src/core/proxy-utils/
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
{
|
|
1182
|
-
|
|
1183
|
-
if (Object(obj) !== obj) return obj;
|
|
1184
|
-
if (!Array.isArray(path)) path = path.toString().match(/[^.[\]]+/g) || [];
|
|
1185
|
-
path
|
|
1186
|
-
.slice(0, -1)
|
|
1187
|
-
.reduce((a, c, i) => (Object(a[c]) === a[c] ? a[c] : (a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1] ? [] : {})), obj)[
|
|
1188
|
-
path[path.length - 1]
|
|
1189
|
-
] = value;
|
|
1190
|
-
return obj;
|
|
1191
|
-
}
|
|
1192
|
-
|
|
1193
|
-
function toBool(str) {
|
|
1194
|
-
if (typeof str === 'undefined' || str === null) return undefined;
|
|
1195
|
-
return /(TRUE)|1/i.test(str);
|
|
1226
|
+
// src/vendors/Sub-Store/backend/src/core/proxy-utils/transport-path.js
|
|
1227
|
+
function decodeQueryComponent(value) {
|
|
1228
|
+
try {
|
|
1229
|
+
return decodeURIComponent(`${value}`.replace(/\+/g, "%20"));
|
|
1230
|
+
} catch (e) {
|
|
1231
|
+
return value;
|
|
1196
1232
|
}
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1233
|
+
}
|
|
1234
|
+
function splitQueryPart(part) {
|
|
1235
|
+
const separatorIndex = part.indexOf("=");
|
|
1236
|
+
if (separatorIndex === -1) {
|
|
1237
|
+
return {
|
|
1238
|
+
key: decodeQueryComponent(part),
|
|
1239
|
+
value: ""
|
|
1240
|
+
};
|
|
1204
1241
|
}
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1242
|
+
return {
|
|
1243
|
+
key: decodeQueryComponent(part.slice(0, separatorIndex)),
|
|
1244
|
+
value: decodeQueryComponent(part.slice(separatorIndex + 1))
|
|
1245
|
+
};
|
|
1246
|
+
}
|
|
1247
|
+
function parseSafeIntegerValue(value) {
|
|
1248
|
+
if (!/^\d+$/.test(`${value}`))
|
|
1249
|
+
return null;
|
|
1250
|
+
const parsed = parseInt(`${value}`, 10);
|
|
1251
|
+
return Number.isSafeInteger(parsed) ? parsed : null;
|
|
1252
|
+
}
|
|
1253
|
+
function extractPathQueryParam(rawPath, paramName) {
|
|
1254
|
+
const path = rawPath == null ? "" : `${rawPath}`;
|
|
1255
|
+
const queryIndex = path.indexOf("?");
|
|
1256
|
+
if (queryIndex === -1) {
|
|
1215
1257
|
return {
|
|
1216
|
-
|
|
1217
|
-
value:
|
|
1258
|
+
path,
|
|
1259
|
+
value: ""
|
|
1218
1260
|
};
|
|
1219
1261
|
}
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
return parsed.value;
|
|
1262
|
+
const basePath = path.slice(0, queryIndex);
|
|
1263
|
+
const query = path.slice(queryIndex + 1);
|
|
1264
|
+
const keptParts = [];
|
|
1265
|
+
let value = "";
|
|
1266
|
+
for (const part of query.split("&")) {
|
|
1267
|
+
if (part === "")
|
|
1268
|
+
continue;
|
|
1269
|
+
const parsed = splitQueryPart(part);
|
|
1270
|
+
if (parsed.key === paramName) {
|
|
1271
|
+
if (value === "" && parsed.value !== "") {
|
|
1272
|
+
value = parsed.value;
|
|
1232
1273
|
}
|
|
1274
|
+
continue;
|
|
1233
1275
|
}
|
|
1234
|
-
|
|
1235
|
-
return '';
|
|
1276
|
+
keptParts.push(part);
|
|
1236
1277
|
}
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
const parsed = splitQueryPart(part);
|
|
1256
|
-
if (parsed.key === paramName) {
|
|
1257
|
-
if (value === '' && parsed.value !== '') {
|
|
1258
|
-
value = parsed.value;
|
|
1259
|
-
}
|
|
1260
|
-
continue;
|
|
1261
|
-
}
|
|
1262
|
-
|
|
1263
|
-
keptParts.push(part);
|
|
1278
|
+
return {
|
|
1279
|
+
path: keptParts.length > 0 ? `${basePath}?${keptParts.join("&")}` : basePath,
|
|
1280
|
+
value
|
|
1281
|
+
};
|
|
1282
|
+
}
|
|
1283
|
+
function getPathQueryParam(rawPath, paramName) {
|
|
1284
|
+
const path = rawPath == null ? "" : `${rawPath}`;
|
|
1285
|
+
const queryIndex = path.indexOf("?");
|
|
1286
|
+
if (queryIndex === -1)
|
|
1287
|
+
return "";
|
|
1288
|
+
const query = path.slice(queryIndex + 1);
|
|
1289
|
+
for (const part of query.split("&")) {
|
|
1290
|
+
if (part === "")
|
|
1291
|
+
continue;
|
|
1292
|
+
const parsed = splitQueryPart(part);
|
|
1293
|
+
if (parsed.key === paramName && parsed.value !== "") {
|
|
1294
|
+
return parsed.value;
|
|
1264
1295
|
}
|
|
1265
|
-
|
|
1296
|
+
}
|
|
1297
|
+
return "";
|
|
1298
|
+
}
|
|
1299
|
+
function getSafeIntegerPathQueryParam(rawPath, paramName) {
|
|
1300
|
+
const value = getPathQueryParam(rawPath, paramName);
|
|
1301
|
+
const parsed = parseSafeIntegerValue(value);
|
|
1302
|
+
if (parsed == null) {
|
|
1266
1303
|
return {
|
|
1267
|
-
|
|
1268
|
-
|
|
1304
|
+
value: "",
|
|
1305
|
+
parsed: null
|
|
1269
1306
|
};
|
|
1270
1307
|
}
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1308
|
+
return {
|
|
1309
|
+
value,
|
|
1310
|
+
parsed
|
|
1311
|
+
};
|
|
1312
|
+
}
|
|
1313
|
+
function appendPathQueryParam(path, paramName, value) {
|
|
1314
|
+
const separator = path.includes("?") ? path.endsWith("?") || path.endsWith("&") ? "" : "&" : "?";
|
|
1315
|
+
return `${path}${separator}${encodeURIComponent(
|
|
1316
|
+
paramName
|
|
1317
|
+
)}=${encodeURIComponent(`${value}`)}`;
|
|
1318
|
+
}
|
|
1319
|
+
function setPathQueryParam(rawPath, paramName, value) {
|
|
1320
|
+
const path = rawPath == null || rawPath === "" ? "/" : `${rawPath}`;
|
|
1321
|
+
const { path: pathWithoutParam } = extractPathQueryParam(path, paramName);
|
|
1322
|
+
return appendPathQueryParam(pathWithoutParam, paramName, value);
|
|
1323
|
+
}
|
|
1324
|
+
function normalizeWebSocketEarlyDataPath(wsOpts) {
|
|
1325
|
+
const networkPath = wsOpts?.path;
|
|
1326
|
+
if (!wsOpts)
|
|
1327
|
+
return;
|
|
1328
|
+
const { value: ed, parsed: maxEarlyData } = getSafeIntegerPathQueryParam(
|
|
1329
|
+
networkPath,
|
|
1330
|
+
"ed"
|
|
1331
|
+
);
|
|
1332
|
+
if (wsOpts["v2ray-http-upgrade"]) {
|
|
1333
|
+
if (ed !== "") {
|
|
1334
|
+
wsOpts.path = extractPathQueryParam(networkPath, "ed").path;
|
|
1335
|
+
wsOpts["v2ray-http-upgrade-fast-open"] = true;
|
|
1336
|
+
if (wsOpts["_v2ray-http-upgrade-ed"] == null || `${wsOpts["_v2ray-http-upgrade-ed"]}` === "") {
|
|
1337
|
+
wsOpts["_v2ray-http-upgrade-ed"] = ed;
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
delete wsOpts["early-data-header-name"];
|
|
1341
|
+
delete wsOpts["max-early-data"];
|
|
1342
|
+
return;
|
|
1277
1343
|
}
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1344
|
+
if (ed === "")
|
|
1345
|
+
return;
|
|
1346
|
+
wsOpts.path = extractPathQueryParam(networkPath, "ed").path;
|
|
1347
|
+
if (wsOpts["early-data-header-name"] == null) {
|
|
1348
|
+
wsOpts["early-data-header-name"] = "Sec-WebSocket-Protocol";
|
|
1349
|
+
}
|
|
1350
|
+
if (wsOpts["max-early-data"] == null) {
|
|
1351
|
+
wsOpts["max-early-data"] = maxEarlyData;
|
|
1281
1352
|
}
|
|
1282
|
-
}}
|
|
1283
|
-
|
|
1284
|
-
{
|
|
1285
|
-
const proxy = {};
|
|
1286
|
-
const obfs = {};
|
|
1287
|
-
const $ = {};
|
|
1288
|
-
const params = {};
|
|
1289
1353
|
}
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1354
|
+
function deleteHttpUpgradeEarlyDataMetadata(wsOpts) {
|
|
1355
|
+
if (!wsOpts)
|
|
1356
|
+
return;
|
|
1357
|
+
delete wsOpts["_v2ray-http-upgrade-ed"];
|
|
1293
1358
|
}
|
|
1294
1359
|
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
if (
|
|
1304
|
-
|
|
1305
|
-
}
|
|
1306
|
-
};
|
|
1307
|
-
|
|
1308
|
-
password = match:$[^@]+ {
|
|
1309
|
-
return decodeURIComponent(match);
|
|
1310
|
-
};
|
|
1311
|
-
|
|
1312
|
-
server = ip/domain;
|
|
1313
|
-
|
|
1314
|
-
domain = match:[0-9a-zA-z-_.]+ {
|
|
1315
|
-
const domain = match.join("");
|
|
1316
|
-
if (/(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/.test(domain)) {
|
|
1317
|
-
return domain;
|
|
1360
|
+
// src/vendors/Sub-Store/backend/src/core/proxy-utils/parsers/peggy/trojan-uri.js
|
|
1361
|
+
var unsafePathSegments = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
1362
|
+
var parser4;
|
|
1363
|
+
function $set(obj, path, value) {
|
|
1364
|
+
if (Object(obj) !== obj)
|
|
1365
|
+
return obj;
|
|
1366
|
+
if (!Array.isArray(path))
|
|
1367
|
+
path = path.toString().match(/[^.[\]]+/g) || [];
|
|
1368
|
+
if (path.some((segment) => unsafePathSegments.has(segment))) {
|
|
1369
|
+
throw new Error("Unsafe property path");
|
|
1318
1370
|
}
|
|
1371
|
+
path.slice(0, -1).reduce((a, c, i) => Object.prototype.hasOwnProperty.call(a, c) && Object(a[c]) === a[c] ? a[c] : a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1] ? [] : {}, obj)[path[path.length - 1]] = value;
|
|
1372
|
+
return obj;
|
|
1319
1373
|
}
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
} { return $.ip; }
|
|
1334
|
-
|
|
1335
|
-
port = digits:[0-9]+ {
|
|
1336
|
-
const port = parseInt(digits.join(""), 10);
|
|
1337
|
-
if (port >= 0 && port <= 65535) {
|
|
1338
|
-
return port;
|
|
1339
|
-
} else {
|
|
1340
|
-
throw new Error("Invalid port: " + port);
|
|
1374
|
+
function toBool(str) {
|
|
1375
|
+
if (str == null)
|
|
1376
|
+
return void 0;
|
|
1377
|
+
return /(TRUE)|1/i.test(str);
|
|
1378
|
+
}
|
|
1379
|
+
function isNumericEarlyData(value) {
|
|
1380
|
+
return parseSafeIntegerValue(value) != null;
|
|
1381
|
+
}
|
|
1382
|
+
function decode(value) {
|
|
1383
|
+
try {
|
|
1384
|
+
return decodeURIComponent(value);
|
|
1385
|
+
} catch {
|
|
1386
|
+
return value;
|
|
1341
1387
|
}
|
|
1342
1388
|
}
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1389
|
+
function parseTrojan(url) {
|
|
1390
|
+
const proxy = {};
|
|
1391
|
+
const match = url.match(
|
|
1392
|
+
/^trojan:\/\/([^@]+)@(\[[^\]]+\]|[^/?#]+):(\d+)(?:\/)?(?:\?([^#]*))?(?:#(.*))?$/
|
|
1393
|
+
);
|
|
1394
|
+
if (!match) {
|
|
1395
|
+
throw new Error("Invalid trojan url");
|
|
1396
|
+
}
|
|
1397
|
+
const [
|
|
1398
|
+
,
|
|
1399
|
+
password,
|
|
1400
|
+
server,
|
|
1401
|
+
port,
|
|
1402
|
+
query,
|
|
1403
|
+
name
|
|
1404
|
+
] = match;
|
|
1405
|
+
const normalizedServer = server.replace(/^\[|\]$/g, "");
|
|
1406
|
+
if ((server.startsWith("[") || server.includes(":")) && !isIPv6(normalizedServer)) {
|
|
1407
|
+
throw new Error(`Invalid server: ${server}`);
|
|
1347
1408
|
}
|
|
1348
|
-
proxy
|
|
1349
|
-
proxy.
|
|
1350
|
-
proxy
|
|
1351
|
-
proxy
|
|
1352
|
-
proxy.
|
|
1353
|
-
|
|
1354
|
-
|
|
1409
|
+
proxy.type = "trojan";
|
|
1410
|
+
proxy.password = decode(password);
|
|
1411
|
+
proxy.server = server;
|
|
1412
|
+
proxy.port = Number(port);
|
|
1413
|
+
if (!Number.isSafeInteger(proxy.port) || proxy.port < 1 || proxy.port > 65535) {
|
|
1414
|
+
throw new Error(`Invalid port: ${port}`);
|
|
1415
|
+
}
|
|
1416
|
+
proxy.name = name ? decode(name) : `${server}:${port}`;
|
|
1417
|
+
const params = {};
|
|
1418
|
+
if (query) {
|
|
1419
|
+
for (const item of query.split("&")) {
|
|
1420
|
+
const separatorIndex = item.indexOf("=");
|
|
1421
|
+
const key = separatorIndex === -1 ? item : item.slice(0, separatorIndex);
|
|
1422
|
+
params[key] = separatorIndex === -1 ? true : decode(item.slice(separatorIndex + 1));
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
proxy["skip-cert-verify"] = toBool(params.allowInsecure);
|
|
1426
|
+
proxy.sni = params.sni || params.peer;
|
|
1427
|
+
proxy["client-fingerprint"] = params.fp;
|
|
1428
|
+
proxy["tls-fingerprint"] = params.pcs;
|
|
1429
|
+
proxy._vcn = params.vcn?.split(",").map((name2) => name2.trim()).filter(Boolean);
|
|
1430
|
+
proxy["name-cert-verify"] = proxy._vcn?.[0];
|
|
1431
|
+
if (params.alpn) {
|
|
1432
|
+
proxy.alpn = params.alpn.split(",");
|
|
1433
|
+
}
|
|
1434
|
+
if (toBool(params.ws)) {
|
|
1355
1435
|
proxy.network = "ws";
|
|
1356
|
-
$set(
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1436
|
+
$set(
|
|
1437
|
+
proxy,
|
|
1438
|
+
"ws-opts.path",
|
|
1439
|
+
params.wspath
|
|
1440
|
+
);
|
|
1441
|
+
}
|
|
1442
|
+
if (params.type) {
|
|
1443
|
+
let httpupgrade = false;
|
|
1444
|
+
let httpUpgradeEd = "";
|
|
1445
|
+
let pathEarlyData = "";
|
|
1446
|
+
proxy.network = params.type;
|
|
1447
|
+
if (proxy.network === "httpupgrade") {
|
|
1448
|
+
proxy.network = "ws";
|
|
1449
|
+
httpupgrade = true;
|
|
1450
|
+
}
|
|
1451
|
+
if (proxy.network === "grpc") {
|
|
1452
|
+
proxy["grpc-opts"] = {
|
|
1453
|
+
"grpc-service-name": params.serviceName,
|
|
1454
|
+
"_grpc-type": params.mode,
|
|
1455
|
+
"_grpc-authority": params.authority
|
|
1456
|
+
};
|
|
1374
1457
|
} else {
|
|
1375
|
-
if (params
|
|
1376
|
-
let
|
|
1377
|
-
if (proxy.network ===
|
|
1378
|
-
const
|
|
1379
|
-
if (isNumericEarlyData(
|
|
1380
|
-
|
|
1381
|
-
if (httpupgrade)
|
|
1382
|
-
httpUpgradeEd =
|
|
1383
|
-
|
|
1384
|
-
pathEarlyData =
|
|
1385
|
-
}
|
|
1458
|
+
if (params.path) {
|
|
1459
|
+
let path = params.path;
|
|
1460
|
+
if (proxy.network === "ws") {
|
|
1461
|
+
const ed = getPathQueryParam(path, "ed");
|
|
1462
|
+
if (isNumericEarlyData(ed)) {
|
|
1463
|
+
path = extractPathQueryParam(path, "ed").path;
|
|
1464
|
+
if (httpupgrade)
|
|
1465
|
+
httpUpgradeEd = ed;
|
|
1466
|
+
else
|
|
1467
|
+
pathEarlyData = ed;
|
|
1386
1468
|
}
|
|
1387
1469
|
}
|
|
1388
|
-
$set(
|
|
1470
|
+
$set(
|
|
1471
|
+
proxy,
|
|
1472
|
+
`${proxy.network}-opts.path`,
|
|
1473
|
+
path
|
|
1474
|
+
);
|
|
1389
1475
|
}
|
|
1390
|
-
if (params
|
|
1391
|
-
$set(
|
|
1476
|
+
if (params.host) {
|
|
1477
|
+
$set(
|
|
1478
|
+
proxy,
|
|
1479
|
+
`${proxy.network}-opts.headers.Host`,
|
|
1480
|
+
params.host
|
|
1481
|
+
);
|
|
1392
1482
|
}
|
|
1393
1483
|
if (httpupgrade) {
|
|
1394
|
-
httpUpgradeEd = httpUpgradeEd || (isNumericEarlyData(params.ed) ? String(params.ed) :
|
|
1395
|
-
$set(
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1484
|
+
httpUpgradeEd = httpUpgradeEd || (isNumericEarlyData(params.ed) ? String(params.ed) : "");
|
|
1485
|
+
$set(
|
|
1486
|
+
proxy,
|
|
1487
|
+
"ws-opts.v2ray-http-upgrade",
|
|
1488
|
+
true
|
|
1489
|
+
);
|
|
1490
|
+
if (httpUpgradeEd) {
|
|
1491
|
+
$set(
|
|
1492
|
+
proxy,
|
|
1493
|
+
"ws-opts.v2ray-http-upgrade-fast-open",
|
|
1494
|
+
true
|
|
1495
|
+
);
|
|
1496
|
+
$set(
|
|
1497
|
+
proxy,
|
|
1498
|
+
"ws-opts._v2ray-http-upgrade-ed",
|
|
1499
|
+
httpUpgradeEd
|
|
1500
|
+
);
|
|
1399
1501
|
}
|
|
1400
|
-
} else if (proxy.network ===
|
|
1401
|
-
$set(
|
|
1402
|
-
|
|
1502
|
+
} else if (proxy.network === "ws" && pathEarlyData) {
|
|
1503
|
+
$set(
|
|
1504
|
+
proxy,
|
|
1505
|
+
"ws-opts.max-early-data",
|
|
1506
|
+
parseSafeIntegerValue(pathEarlyData)
|
|
1507
|
+
);
|
|
1508
|
+
$set(
|
|
1509
|
+
proxy,
|
|
1510
|
+
"ws-opts.early-data-header-name",
|
|
1511
|
+
"Sec-WebSocket-Protocol"
|
|
1512
|
+
);
|
|
1403
1513
|
}
|
|
1404
1514
|
}
|
|
1405
|
-
if (
|
|
1515
|
+
if (params.security === "reality") {
|
|
1406
1516
|
const opts = {};
|
|
1407
|
-
if (params.pbk)
|
|
1408
|
-
opts[
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
if (params.
|
|
1414
|
-
opts['_spider-x'] = params.spx;
|
|
1415
|
-
}
|
|
1416
|
-
if (params.mode) {
|
|
1517
|
+
if (params.pbk)
|
|
1518
|
+
opts["public-key"] = params.pbk;
|
|
1519
|
+
if (params.sid)
|
|
1520
|
+
opts["short-id"] = params.sid;
|
|
1521
|
+
if (params.spx)
|
|
1522
|
+
opts["_spider-x"] = params.spx;
|
|
1523
|
+
if (params.mode)
|
|
1417
1524
|
proxy._mode = params.mode;
|
|
1418
|
-
|
|
1419
|
-
if (params.extra) {
|
|
1525
|
+
if (params.extra)
|
|
1420
1526
|
proxy._extra = params.extra;
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1527
|
+
if (Object.keys(opts).length) {
|
|
1528
|
+
$set(
|
|
1529
|
+
proxy,
|
|
1530
|
+
"reality-opts",
|
|
1531
|
+
opts
|
|
1532
|
+
);
|
|
1424
1533
|
}
|
|
1425
1534
|
}
|
|
1426
1535
|
}
|
|
1427
|
-
|
|
1428
|
-
proxy.
|
|
1429
|
-
proxy
|
|
1430
|
-
}
|
|
1431
|
-
|
|
1432
|
-
param = kv/single;
|
|
1433
|
-
|
|
1434
|
-
kv = key:$[a-z]i+ "=" value:$[^&#]i* {
|
|
1435
|
-
params[key] = value;
|
|
1536
|
+
proxy.udp = toBool(params.udp);
|
|
1537
|
+
proxy.tfo = toBool(params.tfo);
|
|
1538
|
+
return proxy;
|
|
1436
1539
|
}
|
|
1437
|
-
|
|
1438
|
-
single = key:$[a-z]i+ {
|
|
1439
|
-
params[key] = true;
|
|
1440
|
-
};
|
|
1441
|
-
|
|
1442
|
-
name = "#" + match:$.* {
|
|
1443
|
-
return decodeURIComponent(match);
|
|
1444
|
-
}
|
|
1445
|
-
`;
|
|
1446
|
-
var parser4;
|
|
1447
1540
|
function getParser4() {
|
|
1448
1541
|
if (!parser4) {
|
|
1449
|
-
parser4 =
|
|
1542
|
+
parser4 = {
|
|
1543
|
+
parse: parseTrojan
|
|
1544
|
+
};
|
|
1450
1545
|
}
|
|
1451
1546
|
return parser4;
|
|
1452
1547
|
}
|
|
@@ -1458,7 +1553,11 @@ var app_default = console;
|
|
|
1458
1553
|
import JSON5 from "json5";
|
|
1459
1554
|
|
|
1460
1555
|
// src/vendors/Sub-Store/backend/src/utils/yaml.js
|
|
1461
|
-
import
|
|
1556
|
+
import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
|
|
1557
|
+
var DEFAULT_PARSE_OPTIONS = {
|
|
1558
|
+
logLevel: "error",
|
|
1559
|
+
merge: true
|
|
1560
|
+
};
|
|
1462
1561
|
function retry(fn, content, ...args) {
|
|
1463
1562
|
try {
|
|
1464
1563
|
return fn(content, ...args);
|
|
@@ -1474,17 +1573,65 @@ function retry(fn, content, ...args) {
|
|
|
1474
1573
|
);
|
|
1475
1574
|
}
|
|
1476
1575
|
}
|
|
1576
|
+
function toSerializable(content) {
|
|
1577
|
+
return JSON.parse(JSON.stringify(content));
|
|
1578
|
+
}
|
|
1579
|
+
function normalizeParseOptions(options) {
|
|
1580
|
+
return {
|
|
1581
|
+
...DEFAULT_PARSE_OPTIONS,
|
|
1582
|
+
...options || {}
|
|
1583
|
+
};
|
|
1584
|
+
}
|
|
1585
|
+
function normalizeStringifyOptions(options = {}) {
|
|
1586
|
+
const {
|
|
1587
|
+
forceQuotes,
|
|
1588
|
+
lineWidth,
|
|
1589
|
+
noArrayIndent,
|
|
1590
|
+
noRefs,
|
|
1591
|
+
quotingType,
|
|
1592
|
+
sortKeys,
|
|
1593
|
+
...rest
|
|
1594
|
+
} = options || {};
|
|
1595
|
+
const normalized = { ...rest };
|
|
1596
|
+
if (typeof lineWidth === "number") {
|
|
1597
|
+
normalized.lineWidth = lineWidth <= 0 ? 0 : lineWidth;
|
|
1598
|
+
}
|
|
1599
|
+
if (typeof noArrayIndent === "boolean") {
|
|
1600
|
+
normalized.indentSeq = !noArrayIndent;
|
|
1601
|
+
}
|
|
1602
|
+
if (typeof noRefs === "boolean") {
|
|
1603
|
+
normalized.aliasDuplicateObjects = !noRefs;
|
|
1604
|
+
}
|
|
1605
|
+
if (typeof sortKeys !== "undefined") {
|
|
1606
|
+
normalized.sortMapEntries = sortKeys;
|
|
1607
|
+
}
|
|
1608
|
+
if (quotingType === "'") {
|
|
1609
|
+
normalized.singleQuote = true;
|
|
1610
|
+
} else if (quotingType === '"') {
|
|
1611
|
+
normalized.singleQuote = false;
|
|
1612
|
+
}
|
|
1613
|
+
if (forceQuotes) {
|
|
1614
|
+
normalized.defaultStringType = quotingType === "'" ? "QUOTE_SINGLE" : "QUOTE_DOUBLE";
|
|
1615
|
+
}
|
|
1616
|
+
return normalized;
|
|
1617
|
+
}
|
|
1618
|
+
function parse(content, options) {
|
|
1619
|
+
return parseYaml(content, normalizeParseOptions(options));
|
|
1620
|
+
}
|
|
1621
|
+
function stringify(content, options) {
|
|
1622
|
+
return stringifyYaml(content, normalizeStringifyOptions(options));
|
|
1623
|
+
}
|
|
1477
1624
|
function safeLoad(content, ...args) {
|
|
1478
|
-
return retry(
|
|
1625
|
+
return retry(parse, toSerializable(content), ...args);
|
|
1479
1626
|
}
|
|
1480
1627
|
function load(content, ...args) {
|
|
1481
|
-
return retry(
|
|
1628
|
+
return retry(parse, toSerializable(content), ...args);
|
|
1482
1629
|
}
|
|
1483
1630
|
function safeDump(content, ...args) {
|
|
1484
|
-
return
|
|
1631
|
+
return stringify(toSerializable(content), ...args);
|
|
1485
1632
|
}
|
|
1486
1633
|
function dump(content, ...args) {
|
|
1487
|
-
return
|
|
1634
|
+
return stringify(toSerializable(content), ...args);
|
|
1488
1635
|
}
|
|
1489
1636
|
var yaml_default = {
|
|
1490
1637
|
safeLoad,
|
|
@@ -1608,133 +1755,6 @@ function normalizeXhttpIntegerValue(value, { allowNegative = true } = {}) {
|
|
|
1608
1755
|
return parsedInteger;
|
|
1609
1756
|
}
|
|
1610
1757
|
|
|
1611
|
-
// src/vendors/Sub-Store/backend/src/core/proxy-utils/transport-path.js
|
|
1612
|
-
function decodeQueryComponent(value) {
|
|
1613
|
-
try {
|
|
1614
|
-
return decodeURIComponent(`${value}`.replace(/\+/g, "%20"));
|
|
1615
|
-
} catch (e) {
|
|
1616
|
-
return value;
|
|
1617
|
-
}
|
|
1618
|
-
}
|
|
1619
|
-
function splitQueryPart(part) {
|
|
1620
|
-
const separatorIndex = part.indexOf("=");
|
|
1621
|
-
if (separatorIndex === -1) {
|
|
1622
|
-
return {
|
|
1623
|
-
key: decodeQueryComponent(part),
|
|
1624
|
-
value: ""
|
|
1625
|
-
};
|
|
1626
|
-
}
|
|
1627
|
-
return {
|
|
1628
|
-
key: decodeQueryComponent(part.slice(0, separatorIndex)),
|
|
1629
|
-
value: decodeQueryComponent(part.slice(separatorIndex + 1))
|
|
1630
|
-
};
|
|
1631
|
-
}
|
|
1632
|
-
function parseSafeIntegerValue(value) {
|
|
1633
|
-
if (!/^\d+$/.test(`${value}`)) return null;
|
|
1634
|
-
const parsed = parseInt(`${value}`, 10);
|
|
1635
|
-
return Number.isSafeInteger(parsed) ? parsed : null;
|
|
1636
|
-
}
|
|
1637
|
-
function extractPathQueryParam(rawPath, paramName) {
|
|
1638
|
-
const path = rawPath == null ? "" : `${rawPath}`;
|
|
1639
|
-
const queryIndex = path.indexOf("?");
|
|
1640
|
-
if (queryIndex === -1) {
|
|
1641
|
-
return {
|
|
1642
|
-
path,
|
|
1643
|
-
value: ""
|
|
1644
|
-
};
|
|
1645
|
-
}
|
|
1646
|
-
const basePath = path.slice(0, queryIndex);
|
|
1647
|
-
const query = path.slice(queryIndex + 1);
|
|
1648
|
-
const keptParts = [];
|
|
1649
|
-
let value = "";
|
|
1650
|
-
for (const part of query.split("&")) {
|
|
1651
|
-
if (part === "") continue;
|
|
1652
|
-
const parsed = splitQueryPart(part);
|
|
1653
|
-
if (parsed.key === paramName) {
|
|
1654
|
-
if (value === "" && parsed.value !== "") {
|
|
1655
|
-
value = parsed.value;
|
|
1656
|
-
}
|
|
1657
|
-
continue;
|
|
1658
|
-
}
|
|
1659
|
-
keptParts.push(part);
|
|
1660
|
-
}
|
|
1661
|
-
return {
|
|
1662
|
-
path: keptParts.length > 0 ? `${basePath}?${keptParts.join("&")}` : basePath,
|
|
1663
|
-
value
|
|
1664
|
-
};
|
|
1665
|
-
}
|
|
1666
|
-
function getPathQueryParam(rawPath, paramName) {
|
|
1667
|
-
const path = rawPath == null ? "" : `${rawPath}`;
|
|
1668
|
-
const queryIndex = path.indexOf("?");
|
|
1669
|
-
if (queryIndex === -1) return "";
|
|
1670
|
-
const query = path.slice(queryIndex + 1);
|
|
1671
|
-
for (const part of query.split("&")) {
|
|
1672
|
-
if (part === "") continue;
|
|
1673
|
-
const parsed = splitQueryPart(part);
|
|
1674
|
-
if (parsed.key === paramName && parsed.value !== "") {
|
|
1675
|
-
return parsed.value;
|
|
1676
|
-
}
|
|
1677
|
-
}
|
|
1678
|
-
return "";
|
|
1679
|
-
}
|
|
1680
|
-
function getSafeIntegerPathQueryParam(rawPath, paramName) {
|
|
1681
|
-
const value = getPathQueryParam(rawPath, paramName);
|
|
1682
|
-
const parsed = parseSafeIntegerValue(value);
|
|
1683
|
-
if (parsed == null) {
|
|
1684
|
-
return {
|
|
1685
|
-
value: "",
|
|
1686
|
-
parsed: null
|
|
1687
|
-
};
|
|
1688
|
-
}
|
|
1689
|
-
return {
|
|
1690
|
-
value,
|
|
1691
|
-
parsed
|
|
1692
|
-
};
|
|
1693
|
-
}
|
|
1694
|
-
function appendPathQueryParam(path, paramName, value) {
|
|
1695
|
-
const separator = path.includes("?") ? path.endsWith("?") || path.endsWith("&") ? "" : "&" : "?";
|
|
1696
|
-
return `${path}${separator}${encodeURIComponent(
|
|
1697
|
-
paramName
|
|
1698
|
-
)}=${encodeURIComponent(`${value}`)}`;
|
|
1699
|
-
}
|
|
1700
|
-
function setPathQueryParam(rawPath, paramName, value) {
|
|
1701
|
-
const path = rawPath == null || rawPath === "" ? "/" : `${rawPath}`;
|
|
1702
|
-
const { path: pathWithoutParam } = extractPathQueryParam(path, paramName);
|
|
1703
|
-
return appendPathQueryParam(pathWithoutParam, paramName, value);
|
|
1704
|
-
}
|
|
1705
|
-
function normalizeWebSocketEarlyDataPath(wsOpts) {
|
|
1706
|
-
const networkPath = wsOpts?.path;
|
|
1707
|
-
if (!wsOpts) return;
|
|
1708
|
-
const { value: ed, parsed: maxEarlyData } = getSafeIntegerPathQueryParam(
|
|
1709
|
-
networkPath,
|
|
1710
|
-
"ed"
|
|
1711
|
-
);
|
|
1712
|
-
if (wsOpts["v2ray-http-upgrade"]) {
|
|
1713
|
-
if (ed !== "") {
|
|
1714
|
-
wsOpts.path = extractPathQueryParam(networkPath, "ed").path;
|
|
1715
|
-
wsOpts["v2ray-http-upgrade-fast-open"] = true;
|
|
1716
|
-
if (wsOpts["_v2ray-http-upgrade-ed"] == null || `${wsOpts["_v2ray-http-upgrade-ed"]}` === "") {
|
|
1717
|
-
wsOpts["_v2ray-http-upgrade-ed"] = ed;
|
|
1718
|
-
}
|
|
1719
|
-
}
|
|
1720
|
-
delete wsOpts["early-data-header-name"];
|
|
1721
|
-
delete wsOpts["max-early-data"];
|
|
1722
|
-
return;
|
|
1723
|
-
}
|
|
1724
|
-
if (ed === "") return;
|
|
1725
|
-
wsOpts.path = extractPathQueryParam(networkPath, "ed").path;
|
|
1726
|
-
if (wsOpts["early-data-header-name"] == null) {
|
|
1727
|
-
wsOpts["early-data-header-name"] = "Sec-WebSocket-Protocol";
|
|
1728
|
-
}
|
|
1729
|
-
if (wsOpts["max-early-data"] == null) {
|
|
1730
|
-
wsOpts["max-early-data"] = maxEarlyData;
|
|
1731
|
-
}
|
|
1732
|
-
}
|
|
1733
|
-
function deleteHttpUpgradeEarlyDataMetadata(wsOpts) {
|
|
1734
|
-
if (!wsOpts) return;
|
|
1735
|
-
delete wsOpts["_v2ray-http-upgrade-ed"];
|
|
1736
|
-
}
|
|
1737
|
-
|
|
1738
1758
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/ech-utils.js
|
|
1739
1759
|
var ECH_DNS_FIELD = "_dns";
|
|
1740
1760
|
var ECH_FORCE_QUERY_FIELD = "_force-query";
|
|
@@ -1862,7 +1882,8 @@ var VMESS_SECURITY_ALIASES = {
|
|
|
1862
1882
|
"chacha20-ietf-poly1305": "chacha20-poly1305"
|
|
1863
1883
|
};
|
|
1864
1884
|
function normalizeSecurityValue(security) {
|
|
1865
|
-
if (security == null)
|
|
1885
|
+
if (security == null)
|
|
1886
|
+
return "";
|
|
1866
1887
|
return `${security}`.trim().toLowerCase();
|
|
1867
1888
|
}
|
|
1868
1889
|
function canonicalizeVmessSecurity(security) {
|
|
@@ -1870,7 +1891,8 @@ function canonicalizeVmessSecurity(security) {
|
|
|
1870
1891
|
}
|
|
1871
1892
|
function normalizeVmessSecurity(security, supportedValues = VMESS_SECURITY_COMMON_VALUES, { acceptAliases = true, fallback = VMESS_SECURITY_AUTO } = {}) {
|
|
1872
1893
|
const normalized = normalizeSecurityValue(security);
|
|
1873
|
-
if (!normalized)
|
|
1894
|
+
if (!normalized)
|
|
1895
|
+
return fallback;
|
|
1874
1896
|
const normalizedSupported = supportedValues.map(normalizeSecurityValue);
|
|
1875
1897
|
if (normalizedSupported.includes(normalized)) {
|
|
1876
1898
|
return canonicalizeVmessSecurity(normalized);
|
|
@@ -1901,7 +1923,8 @@ function formatSurgeVmessEncryptMethod(security) {
|
|
|
1901
1923
|
"aes-128-gcm",
|
|
1902
1924
|
"chacha20-poly1305"
|
|
1903
1925
|
]);
|
|
1904
|
-
if (normalized === VMESS_SECURITY_AUTO)
|
|
1926
|
+
if (normalized === VMESS_SECURITY_AUTO)
|
|
1927
|
+
return void 0;
|
|
1905
1928
|
return normalized === "chacha20-poly1305" ? "chacha20-ietf-poly1305" : normalized;
|
|
1906
1929
|
}
|
|
1907
1930
|
|
|
@@ -1936,13 +1959,14 @@ function decodeShadowsocksUserInfo(rawUserInfoStr) {
|
|
|
1936
1959
|
}
|
|
1937
1960
|
return Base64.decode(decodedUserInfoStr);
|
|
1938
1961
|
}
|
|
1939
|
-
function
|
|
1940
|
-
if (value == null || !/^\d+$/.test(`${value}`))
|
|
1962
|
+
function isNumericEarlyData2(value) {
|
|
1963
|
+
if (value == null || !/^\d+$/.test(`${value}`))
|
|
1964
|
+
return false;
|
|
1941
1965
|
return Number.isSafeInteger(parseInt(`${value}`, 10));
|
|
1942
1966
|
}
|
|
1943
1967
|
function extractEarlyDataFromPath(path) {
|
|
1944
1968
|
const ed = getPathQueryParam(path, "ed");
|
|
1945
|
-
if (!
|
|
1969
|
+
if (!isNumericEarlyData2(ed)) {
|
|
1946
1970
|
return {
|
|
1947
1971
|
path,
|
|
1948
1972
|
ed: ""
|
|
@@ -1975,16 +1999,21 @@ function splitURIHostList(host) {
|
|
|
1975
1999
|
return hosts.length > 0 ? hosts : void 0;
|
|
1976
2000
|
}
|
|
1977
2001
|
function parseWireGuardURIAddressValue(value) {
|
|
1978
|
-
if (value == null)
|
|
2002
|
+
if (value == null)
|
|
2003
|
+
return null;
|
|
1979
2004
|
const raw = `${value}`.trim();
|
|
1980
|
-
if (!raw)
|
|
2005
|
+
if (!raw)
|
|
2006
|
+
return null;
|
|
1981
2007
|
const [, hostRaw = raw, cidrRaw] = /^(.*?)(?:\/(\d+))?$/.exec(raw) || [];
|
|
1982
2008
|
const host = `${hostRaw}`.trim().replace(/^\[/, "").replace(/\]$/, "");
|
|
1983
2009
|
const normalizeCIDR = (cidr, max) => {
|
|
1984
|
-
if (cidr == null)
|
|
1985
|
-
|
|
2010
|
+
if (cidr == null)
|
|
2011
|
+
return void 0;
|
|
2012
|
+
if (!/^\d+$/.test(cidr))
|
|
2013
|
+
return void 0;
|
|
1986
2014
|
const parsed = parseInt(cidr, 10);
|
|
1987
|
-
if (parsed < 0 || parsed > max)
|
|
2015
|
+
if (parsed < 0 || parsed > max)
|
|
2016
|
+
return void 0;
|
|
1988
2017
|
return parsed;
|
|
1989
2018
|
};
|
|
1990
2019
|
if (isIPv4(host)) {
|
|
@@ -2008,7 +2037,7 @@ function URI_PROXY() {
|
|
|
2008
2037
|
const test = (line) => {
|
|
2009
2038
|
return /^(socks5\+tls|socks5|http|https):\/\//.test(line);
|
|
2010
2039
|
};
|
|
2011
|
-
const
|
|
2040
|
+
const parse2 = (line) => {
|
|
2012
2041
|
let [__, type, tls, username, password, server, port, query, name2] = line.match(
|
|
2013
2042
|
/^(socks5|http|http)(\+tls|s)?:\/\/(?:(.*?):(.*?)@)?(.*?)(?::(\d+?))?\/?(\?.*?)?(?:#(.*?))?$/
|
|
2014
2043
|
);
|
|
@@ -2036,14 +2065,14 @@ function URI_PROXY() {
|
|
|
2036
2065
|
};
|
|
2037
2066
|
return proxy;
|
|
2038
2067
|
};
|
|
2039
|
-
return { name, test, parse };
|
|
2068
|
+
return { name, test, parse: parse2 };
|
|
2040
2069
|
}
|
|
2041
2070
|
function URI_SOCKS() {
|
|
2042
2071
|
const name = "URI SOCKS Parser";
|
|
2043
2072
|
const test = (line) => {
|
|
2044
2073
|
return /^socks:\/\//.test(line);
|
|
2045
2074
|
};
|
|
2046
|
-
const
|
|
2075
|
+
const parse2 = (line) => {
|
|
2047
2076
|
let [__, type, auth, server, port, query, name2] = line.match(
|
|
2048
2077
|
/^(socks)?:\/\/(?:(.*)@)?(.*?)(?::(\d+?))?(\?.*?)?(?:#(.*?))?$/
|
|
2049
2078
|
);
|
|
@@ -2069,14 +2098,14 @@ function URI_SOCKS() {
|
|
|
2069
2098
|
};
|
|
2070
2099
|
return proxy;
|
|
2071
2100
|
};
|
|
2072
|
-
return { name, test, parse };
|
|
2101
|
+
return { name, test, parse: parse2 };
|
|
2073
2102
|
}
|
|
2074
2103
|
function URI_SS() {
|
|
2075
2104
|
const name = "URI SS Parser";
|
|
2076
2105
|
const test = (line) => {
|
|
2077
2106
|
return /^ss:\/\//.test(line);
|
|
2078
2107
|
};
|
|
2079
|
-
const
|
|
2108
|
+
const parse2 = (line) => {
|
|
2080
2109
|
let { content, fragment: name2 } = splitURIFragment(
|
|
2081
2110
|
line.split("ss://")[1]
|
|
2082
2111
|
);
|
|
@@ -2167,7 +2196,7 @@ function URI_SS() {
|
|
|
2167
2196
|
);
|
|
2168
2197
|
}
|
|
2169
2198
|
if (httpupgrade) {
|
|
2170
|
-
httpUpgradeEd = httpUpgradeEd || (
|
|
2199
|
+
httpUpgradeEd = httpUpgradeEd || (isNumericEarlyData2(params.ed) ? `${params.ed}` : "");
|
|
2171
2200
|
_.set(
|
|
2172
2201
|
proxy,
|
|
2173
2202
|
proxy.network + "-opts.v2ray-http-upgrade",
|
|
@@ -2239,12 +2268,14 @@ function URI_SS() {
|
|
|
2239
2268
|
for (const item of pluginInfo) {
|
|
2240
2269
|
const separatorIndex = item.indexOf("=");
|
|
2241
2270
|
if (separatorIndex === -1) {
|
|
2242
|
-
if (item)
|
|
2271
|
+
if (item)
|
|
2272
|
+
params2[item] = true;
|
|
2243
2273
|
continue;
|
|
2244
2274
|
}
|
|
2245
2275
|
const key = item.slice(0, separatorIndex);
|
|
2246
2276
|
const val = item.slice(separatorIndex + 1).replace(/\\=/g, "=");
|
|
2247
|
-
if (key)
|
|
2277
|
+
if (key)
|
|
2278
|
+
params2[key] = val || true;
|
|
2248
2279
|
}
|
|
2249
2280
|
switch (params2.plugin) {
|
|
2250
2281
|
case "obfs-local":
|
|
@@ -2339,14 +2370,14 @@ function URI_SS() {
|
|
|
2339
2370
|
proxy.name = name2 ?? `SS ${proxy.server}:${proxy.port}`;
|
|
2340
2371
|
return proxy;
|
|
2341
2372
|
};
|
|
2342
|
-
return { name, test, parse };
|
|
2373
|
+
return { name, test, parse: parse2 };
|
|
2343
2374
|
}
|
|
2344
2375
|
function URI_SSR() {
|
|
2345
2376
|
const name = "URI SSR Parser";
|
|
2346
2377
|
const test = (line) => {
|
|
2347
2378
|
return /^ssr:\/\//.test(line);
|
|
2348
2379
|
};
|
|
2349
|
-
const
|
|
2380
|
+
const parse2 = (line) => {
|
|
2350
2381
|
line = Base64.decode(line.split("ssr://")[1]);
|
|
2351
2382
|
let splitIdx = line.indexOf(":origin");
|
|
2352
2383
|
if (splitIdx === -1) {
|
|
@@ -2393,14 +2424,14 @@ function URI_SSR() {
|
|
|
2393
2424
|
};
|
|
2394
2425
|
return proxy;
|
|
2395
2426
|
};
|
|
2396
|
-
return { name, test, parse };
|
|
2427
|
+
return { name, test, parse: parse2 };
|
|
2397
2428
|
}
|
|
2398
2429
|
function URI_VMess() {
|
|
2399
2430
|
const name = "URI VMess Parser";
|
|
2400
2431
|
const test = (line) => {
|
|
2401
2432
|
return /^vmess:\/\//.test(line);
|
|
2402
2433
|
};
|
|
2403
|
-
const
|
|
2434
|
+
const parse2 = (line) => {
|
|
2404
2435
|
let { content: lineWithoutFragment, fragment: fragmentName } = splitURIFragment(line.split("vmess://")[1]);
|
|
2405
2436
|
let content = Base64.decode(lineWithoutFragment.replace(/\?.*?$/, ""));
|
|
2406
2437
|
if (/=\s*vmess/.test(content)) {
|
|
@@ -2593,7 +2624,7 @@ function URI_VMess() {
|
|
|
2593
2624
|
}
|
|
2594
2625
|
if (httpupgrade) {
|
|
2595
2626
|
opts["v2ray-http-upgrade"] = true;
|
|
2596
|
-
httpUpgradeEd = httpUpgradeEd || (
|
|
2627
|
+
httpUpgradeEd = httpUpgradeEd || (isNumericEarlyData2(params.ed) ? `${params.ed}` : "");
|
|
2597
2628
|
if (httpUpgradeEd !== "") {
|
|
2598
2629
|
opts["v2ray-http-upgrade-fast-open"] = true;
|
|
2599
2630
|
opts["_v2ray-http-upgrade-ed"] = httpUpgradeEd;
|
|
@@ -2616,14 +2647,14 @@ function URI_VMess() {
|
|
|
2616
2647
|
return proxy;
|
|
2617
2648
|
}
|
|
2618
2649
|
};
|
|
2619
|
-
return { name, test, parse };
|
|
2650
|
+
return { name, test, parse: parse2 };
|
|
2620
2651
|
}
|
|
2621
2652
|
function URI_VLESS() {
|
|
2622
2653
|
const name = "URI VLESS Parser";
|
|
2623
2654
|
const test = (line) => {
|
|
2624
2655
|
return /^vless:\/\//.test(line);
|
|
2625
2656
|
};
|
|
2626
|
-
const
|
|
2657
|
+
const parse2 = (line) => {
|
|
2627
2658
|
const mapXmuxToReuseSettings = (xmux) => {
|
|
2628
2659
|
if (!isPlainObject(xmux)) {
|
|
2629
2660
|
return void 0;
|
|
@@ -3396,6 +3427,8 @@ function URI_VLESS() {
|
|
|
3396
3427
|
proxy["ech-opts"] = echOpts;
|
|
3397
3428
|
}
|
|
3398
3429
|
proxy["tls-fingerprint"] = getIfPresent(params.pcs);
|
|
3430
|
+
proxy._vcn = params.vcn?.split(",").map((name3) => name3.trim()).filter(Boolean);
|
|
3431
|
+
proxy["name-cert-verify"] = proxy._vcn?.[0];
|
|
3399
3432
|
proxy._h2 = /(TRUE)|1/i.test(params.h2);
|
|
3400
3433
|
switch (`${params.packetEncoding || ""}`.trim().toLowerCase()) {
|
|
3401
3434
|
case "none":
|
|
@@ -3582,14 +3615,14 @@ function URI_VLESS() {
|
|
|
3582
3615
|
}
|
|
3583
3616
|
return proxy;
|
|
3584
3617
|
};
|
|
3585
|
-
return { name, test, parse };
|
|
3618
|
+
return { name, test, parse: parse2 };
|
|
3586
3619
|
}
|
|
3587
3620
|
function URI_AnyTLS() {
|
|
3588
3621
|
const name = "URI AnyTLS Parser";
|
|
3589
3622
|
const test = (line) => {
|
|
3590
3623
|
return /^anytls:\/\//.test(line);
|
|
3591
3624
|
};
|
|
3592
|
-
const
|
|
3625
|
+
const parse2 = (line) => {
|
|
3593
3626
|
const parsed = URI_VLESS().parse(line.replace("anytls", "vless"));
|
|
3594
3627
|
line = line.split(/anytls:\/\//)[1];
|
|
3595
3628
|
let [__, password, server, port, addons = "", name2] = /^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
@@ -3634,14 +3667,14 @@ function URI_AnyTLS() {
|
|
|
3634
3667
|
}
|
|
3635
3668
|
return proxy;
|
|
3636
3669
|
};
|
|
3637
|
-
return { name, test, parse };
|
|
3670
|
+
return { name, test, parse: parse2 };
|
|
3638
3671
|
}
|
|
3639
3672
|
function URI_Hysteria2() {
|
|
3640
3673
|
const name = "URI Hysteria2 Parser";
|
|
3641
3674
|
const test = (line) => {
|
|
3642
3675
|
return /^(hysteria2|hy2):\/\//.test(line);
|
|
3643
3676
|
};
|
|
3644
|
-
const
|
|
3677
|
+
const parse2 = (line) => {
|
|
3645
3678
|
line = line.split(/(hysteria2|hy2):\/\//)[2];
|
|
3646
3679
|
let ports;
|
|
3647
3680
|
let [
|
|
@@ -3721,16 +3754,22 @@ function URI_Hysteria2() {
|
|
|
3721
3754
|
if (params.downmbps) {
|
|
3722
3755
|
proxy.down = params.downmbps;
|
|
3723
3756
|
}
|
|
3757
|
+
const echOpts = buildMihomoEchOptsFromXrayFields({
|
|
3758
|
+
echConfigList: params.ech
|
|
3759
|
+
});
|
|
3760
|
+
if (echOpts) {
|
|
3761
|
+
proxy["ech-opts"] = echOpts;
|
|
3762
|
+
}
|
|
3724
3763
|
return proxy;
|
|
3725
3764
|
};
|
|
3726
|
-
return { name, test, parse };
|
|
3765
|
+
return { name, test, parse: parse2 };
|
|
3727
3766
|
}
|
|
3728
3767
|
function URI_Hysteria() {
|
|
3729
3768
|
const name = "URI Hysteria Parser";
|
|
3730
3769
|
const test = (line) => {
|
|
3731
3770
|
return /^(hysteria|hy):\/\//.test(line);
|
|
3732
3771
|
};
|
|
3733
|
-
const
|
|
3772
|
+
const parse2 = (line) => {
|
|
3734
3773
|
line = line.split(/(hysteria|hy):\/\//)[2];
|
|
3735
3774
|
let [__, server, ___, port, ____, addons = "", name2] = /^(.*?)(:(\d+))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
3736
3775
|
port = parseInt(`${port}`, 10);
|
|
@@ -3787,14 +3826,14 @@ function URI_Hysteria() {
|
|
|
3787
3826
|
}
|
|
3788
3827
|
return proxy;
|
|
3789
3828
|
};
|
|
3790
|
-
return { name, test, parse };
|
|
3829
|
+
return { name, test, parse: parse2 };
|
|
3791
3830
|
}
|
|
3792
3831
|
function URI_TUIC() {
|
|
3793
3832
|
const name = "URI TUIC Parser";
|
|
3794
3833
|
const test = (line) => {
|
|
3795
3834
|
return /^tuic:\/\//.test(line);
|
|
3796
3835
|
};
|
|
3797
|
-
const
|
|
3836
|
+
const parse2 = (line) => {
|
|
3798
3837
|
line = line.split(/tuic:\/\//)[1];
|
|
3799
3838
|
let [__, auth, server, port, addons = "", name2] = /^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
3800
3839
|
auth = decodeURIComponent(auth);
|
|
@@ -3840,14 +3879,14 @@ function URI_TUIC() {
|
|
|
3840
3879
|
}
|
|
3841
3880
|
return proxy;
|
|
3842
3881
|
};
|
|
3843
|
-
return { name, test, parse };
|
|
3882
|
+
return { name, test, parse: parse2 };
|
|
3844
3883
|
}
|
|
3845
3884
|
function URI_WireGuard() {
|
|
3846
3885
|
const name = "URI WireGuard Parser";
|
|
3847
3886
|
const test = (line) => {
|
|
3848
3887
|
return /^(wireguard|wg):\/\//.test(line);
|
|
3849
3888
|
};
|
|
3850
|
-
const
|
|
3889
|
+
const parse2 = (line) => {
|
|
3851
3890
|
line = line.split(/(wireguard|wg):\/\//)[2];
|
|
3852
3891
|
let [
|
|
3853
3892
|
__,
|
|
@@ -3899,7 +3938,8 @@ function URI_WireGuard() {
|
|
|
3899
3938
|
} else if (["address", "ip"].includes(key)) {
|
|
3900
3939
|
value.split(",").map((i) => {
|
|
3901
3940
|
const parsed = parseWireGuardURIAddressValue(i);
|
|
3902
|
-
if (!parsed)
|
|
3941
|
+
if (!parsed)
|
|
3942
|
+
return;
|
|
3903
3943
|
if (parsed.family === "ipv4") {
|
|
3904
3944
|
proxy.ip = parsed.address;
|
|
3905
3945
|
if (typeof parsed.cidr !== "undefined") {
|
|
@@ -3930,14 +3970,14 @@ function URI_WireGuard() {
|
|
|
3930
3970
|
}
|
|
3931
3971
|
return proxy;
|
|
3932
3972
|
};
|
|
3933
|
-
return { name, test, parse };
|
|
3973
|
+
return { name, test, parse: parse2 };
|
|
3934
3974
|
}
|
|
3935
3975
|
function URI_Trojan() {
|
|
3936
3976
|
const name = "URI Trojan Parser";
|
|
3937
3977
|
const test = (line) => {
|
|
3938
3978
|
return /^trojan:\/\//.test(line);
|
|
3939
3979
|
};
|
|
3940
|
-
const
|
|
3980
|
+
const parse2 = (line) => {
|
|
3941
3981
|
const matched = /^(trojan:\/\/.*?@.*?)(:(\d+))?\/?(\?.*?)?$/.exec(line);
|
|
3942
3982
|
const port = matched?.[2];
|
|
3943
3983
|
if (!port) {
|
|
@@ -3955,7 +3995,7 @@ function URI_Trojan() {
|
|
|
3955
3995
|
}
|
|
3956
3996
|
return proxy;
|
|
3957
3997
|
};
|
|
3958
|
-
return { name, test, parse };
|
|
3998
|
+
return { name, test, parse: parse2 };
|
|
3959
3999
|
}
|
|
3960
4000
|
function Clash_All() {
|
|
3961
4001
|
const name = "Clash Parser";
|
|
@@ -3968,7 +4008,7 @@ function Clash_All() {
|
|
|
3968
4008
|
}
|
|
3969
4009
|
return !!proxy?.type;
|
|
3970
4010
|
};
|
|
3971
|
-
const
|
|
4011
|
+
const parse2 = (line) => {
|
|
3972
4012
|
let proxy;
|
|
3973
4013
|
try {
|
|
3974
4014
|
proxy = JSON5.parse(line);
|
|
@@ -3976,6 +4016,7 @@ function Clash_All() {
|
|
|
3976
4016
|
proxy = yaml_default.parse(line);
|
|
3977
4017
|
}
|
|
3978
4018
|
if (![
|
|
4019
|
+
"shadowquic",
|
|
3979
4020
|
"gost-relay",
|
|
3980
4021
|
"openvpn",
|
|
3981
4022
|
"tailscale",
|
|
@@ -4030,153 +4071,153 @@ function Clash_All() {
|
|
|
4030
4071
|
}
|
|
4031
4072
|
return proxy;
|
|
4032
4073
|
};
|
|
4033
|
-
return { name, test, parse };
|
|
4074
|
+
return { name, test, parse: parse2 };
|
|
4034
4075
|
}
|
|
4035
4076
|
function QX_SS() {
|
|
4036
4077
|
const name = "QX SS Parser";
|
|
4037
4078
|
const test = (line) => {
|
|
4038
4079
|
return /^shadowsocks\s*=/.test(line.split(",")[0].trim()) && line.indexOf("ssr-protocol") === -1;
|
|
4039
4080
|
};
|
|
4040
|
-
const
|
|
4081
|
+
const parse2 = (line) => {
|
|
4041
4082
|
const parser5 = getParser3();
|
|
4042
4083
|
return parser5.parse(line);
|
|
4043
4084
|
};
|
|
4044
|
-
return { name, test, parse };
|
|
4085
|
+
return { name, test, parse: parse2 };
|
|
4045
4086
|
}
|
|
4046
4087
|
function QX_SSR() {
|
|
4047
4088
|
const name = "QX SSR Parser";
|
|
4048
4089
|
const test = (line) => {
|
|
4049
4090
|
return /^shadowsocks\s*=/.test(line.split(",")[0].trim()) && line.indexOf("ssr-protocol") !== -1;
|
|
4050
4091
|
};
|
|
4051
|
-
const
|
|
4052
|
-
return { name, test, parse };
|
|
4092
|
+
const parse2 = (line) => getParser3().parse(line);
|
|
4093
|
+
return { name, test, parse: parse2 };
|
|
4053
4094
|
}
|
|
4054
4095
|
function QX_VMess() {
|
|
4055
4096
|
const name = "QX VMess Parser";
|
|
4056
4097
|
const test = (line) => {
|
|
4057
4098
|
return /^vmess\s*=/.test(line.split(",")[0].trim());
|
|
4058
4099
|
};
|
|
4059
|
-
const
|
|
4060
|
-
return { name, test, parse };
|
|
4100
|
+
const parse2 = (line) => getParser3().parse(line);
|
|
4101
|
+
return { name, test, parse: parse2 };
|
|
4061
4102
|
}
|
|
4062
4103
|
function QX_VLESS() {
|
|
4063
4104
|
const name = "QX VLESS Parser";
|
|
4064
4105
|
const test = (line) => {
|
|
4065
4106
|
return /^vless\s*=/.test(line.split(",")[0].trim());
|
|
4066
4107
|
};
|
|
4067
|
-
const
|
|
4068
|
-
return { name, test, parse };
|
|
4108
|
+
const parse2 = (line) => getParser3().parse(line);
|
|
4109
|
+
return { name, test, parse: parse2 };
|
|
4069
4110
|
}
|
|
4070
4111
|
function QX_AnyTLS() {
|
|
4071
4112
|
const name = "QX AnyTLS Parser";
|
|
4072
4113
|
const test = (line) => {
|
|
4073
4114
|
return /^anytls\s*=/.test(line.split(",")[0].trim());
|
|
4074
4115
|
};
|
|
4075
|
-
const
|
|
4076
|
-
return { name, test, parse };
|
|
4116
|
+
const parse2 = (line) => getParser3().parse(line);
|
|
4117
|
+
return { name, test, parse: parse2 };
|
|
4077
4118
|
}
|
|
4078
4119
|
function QX_Trojan() {
|
|
4079
4120
|
const name = "QX Trojan Parser";
|
|
4080
4121
|
const test = (line) => {
|
|
4081
4122
|
return /^trojan\s*=/.test(line.split(",")[0].trim());
|
|
4082
4123
|
};
|
|
4083
|
-
const
|
|
4084
|
-
return { name, test, parse };
|
|
4124
|
+
const parse2 = (line) => getParser3().parse(line);
|
|
4125
|
+
return { name, test, parse: parse2 };
|
|
4085
4126
|
}
|
|
4086
4127
|
function QX_Http() {
|
|
4087
4128
|
const name = "QX HTTP Parser";
|
|
4088
4129
|
const test = (line) => {
|
|
4089
4130
|
return /^http\s*=/.test(line.split(",")[0].trim());
|
|
4090
4131
|
};
|
|
4091
|
-
const
|
|
4092
|
-
return { name, test, parse };
|
|
4132
|
+
const parse2 = (line) => getParser3().parse(line);
|
|
4133
|
+
return { name, test, parse: parse2 };
|
|
4093
4134
|
}
|
|
4094
4135
|
function QX_Socks5() {
|
|
4095
4136
|
const name = "QX Socks5 Parser";
|
|
4096
4137
|
const test = (line) => {
|
|
4097
4138
|
return /^socks5\s*=/.test(line.split(",")[0].trim());
|
|
4098
4139
|
};
|
|
4099
|
-
const
|
|
4100
|
-
return { name, test, parse };
|
|
4140
|
+
const parse2 = (line) => getParser3().parse(line);
|
|
4141
|
+
return { name, test, parse: parse2 };
|
|
4101
4142
|
}
|
|
4102
4143
|
function Loon_SS() {
|
|
4103
4144
|
const name = "Loon SS Parser";
|
|
4104
4145
|
const test = (line) => {
|
|
4105
4146
|
return line.split(",")[0].split("=")[1].trim().toLowerCase() === "shadowsocks";
|
|
4106
4147
|
};
|
|
4107
|
-
const
|
|
4108
|
-
return { name, test, parse };
|
|
4148
|
+
const parse2 = (line) => getParser2().parse(line);
|
|
4149
|
+
return { name, test, parse: parse2 };
|
|
4109
4150
|
}
|
|
4110
4151
|
function Loon_SSR() {
|
|
4111
4152
|
const name = "Loon SSR Parser";
|
|
4112
4153
|
const test = (line) => {
|
|
4113
4154
|
return line.split(",")[0].split("=")[1].trim().toLowerCase() === "shadowsocksr";
|
|
4114
4155
|
};
|
|
4115
|
-
const
|
|
4116
|
-
return { name, test, parse };
|
|
4156
|
+
const parse2 = (line) => getParser2().parse(line);
|
|
4157
|
+
return { name, test, parse: parse2 };
|
|
4117
4158
|
}
|
|
4118
4159
|
function Loon_VMess() {
|
|
4119
4160
|
const name = "Loon VMess Parser";
|
|
4120
4161
|
const test = (line) => {
|
|
4121
4162
|
return /^.*=\s*vmess/i.test(line.split(",")[0]) && line.indexOf("username") === -1;
|
|
4122
4163
|
};
|
|
4123
|
-
const
|
|
4124
|
-
return { name, test, parse };
|
|
4164
|
+
const parse2 = (line) => getParser2().parse(line);
|
|
4165
|
+
return { name, test, parse: parse2 };
|
|
4125
4166
|
}
|
|
4126
4167
|
function Loon_Vless() {
|
|
4127
4168
|
const name = "Loon Vless Parser";
|
|
4128
4169
|
const test = (line) => {
|
|
4129
4170
|
return /^.*=\s*vless/i.test(line.split(",")[0]);
|
|
4130
4171
|
};
|
|
4131
|
-
const
|
|
4132
|
-
return { name, test, parse };
|
|
4172
|
+
const parse2 = (line) => getParser2().parse(line);
|
|
4173
|
+
return { name, test, parse: parse2 };
|
|
4133
4174
|
}
|
|
4134
4175
|
function Loon_Trojan() {
|
|
4135
4176
|
const name = "Loon Trojan Parser";
|
|
4136
4177
|
const test = (line) => {
|
|
4137
4178
|
return /^.*=\s*trojan/i.test(line.split(",")[0]);
|
|
4138
4179
|
};
|
|
4139
|
-
const
|
|
4140
|
-
return { name, test, parse };
|
|
4180
|
+
const parse2 = (line) => getParser2().parse(line);
|
|
4181
|
+
return { name, test, parse: parse2 };
|
|
4141
4182
|
}
|
|
4142
4183
|
function Loon_AnyTLS() {
|
|
4143
4184
|
const name = "Loon AnyTLS Parser";
|
|
4144
4185
|
const test = (line) => {
|
|
4145
4186
|
return /^.*=\s*anytls/i.test(line.split(",")[0]);
|
|
4146
4187
|
};
|
|
4147
|
-
const
|
|
4148
|
-
return { name, test, parse };
|
|
4188
|
+
const parse2 = (line) => getParser2().parse(line);
|
|
4189
|
+
return { name, test, parse: parse2 };
|
|
4149
4190
|
}
|
|
4150
4191
|
function Loon_Hysteria2() {
|
|
4151
4192
|
const name = "Loon Hysteria2 Parser";
|
|
4152
4193
|
const test = (line) => {
|
|
4153
4194
|
return /^.*=\s*Hysteria2/i.test(line.split(",")[0]);
|
|
4154
4195
|
};
|
|
4155
|
-
const
|
|
4156
|
-
return { name, test, parse };
|
|
4196
|
+
const parse2 = (line) => getParser2().parse(line);
|
|
4197
|
+
return { name, test, parse: parse2 };
|
|
4157
4198
|
}
|
|
4158
4199
|
function Loon_Http() {
|
|
4159
4200
|
const name = "Loon HTTP Parser";
|
|
4160
4201
|
const test = (line) => {
|
|
4161
4202
|
return /^.*=\s*http/i.test(line.split(",")[0]);
|
|
4162
4203
|
};
|
|
4163
|
-
const
|
|
4164
|
-
return { name, test, parse };
|
|
4204
|
+
const parse2 = (line) => getParser2().parse(line);
|
|
4205
|
+
return { name, test, parse: parse2 };
|
|
4165
4206
|
}
|
|
4166
4207
|
function Loon_Socks5() {
|
|
4167
4208
|
const name = "Loon SOCKS5 Parser";
|
|
4168
4209
|
const test = (line) => {
|
|
4169
4210
|
return /^.*=\s*socks5/i.test(line.split(",")[0]);
|
|
4170
4211
|
};
|
|
4171
|
-
const
|
|
4172
|
-
return { name, test, parse };
|
|
4212
|
+
const parse2 = (line) => getParser2().parse(line);
|
|
4213
|
+
return { name, test, parse: parse2 };
|
|
4173
4214
|
}
|
|
4174
4215
|
function Loon_WireGuard() {
|
|
4175
4216
|
const name = "Loon WireGuard Parser";
|
|
4176
4217
|
const test = (line) => {
|
|
4177
4218
|
return /^.*=\s*wireguard/i.test(line.split(",")[0]);
|
|
4178
4219
|
};
|
|
4179
|
-
const
|
|
4220
|
+
const parse2 = (line) => {
|
|
4180
4221
|
const name2 = line.match(
|
|
4181
4222
|
/(^.*?)\s*?=\s*?wireguard\s*?,.+?\s*?=\s*?.+?/i
|
|
4182
4223
|
)?.[1];
|
|
@@ -4269,71 +4310,71 @@ function Loon_WireGuard() {
|
|
|
4269
4310
|
}
|
|
4270
4311
|
return proxy;
|
|
4271
4312
|
};
|
|
4272
|
-
return { name, test, parse };
|
|
4313
|
+
return { name, test, parse: parse2 };
|
|
4273
4314
|
}
|
|
4274
4315
|
function Surge_Direct() {
|
|
4275
4316
|
const name = "Surge Direct Parser";
|
|
4276
4317
|
const test = (line) => {
|
|
4277
4318
|
return /^.*=\s*direct/.test(line.split(",")[0]);
|
|
4278
4319
|
};
|
|
4279
|
-
const
|
|
4280
|
-
return { name, test, parse };
|
|
4320
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4321
|
+
return { name, test, parse: parse2 };
|
|
4281
4322
|
}
|
|
4282
4323
|
function Surge_AnyTLS() {
|
|
4283
4324
|
const name = "Surge AnyTLS Parser";
|
|
4284
4325
|
const test = (line) => {
|
|
4285
4326
|
return /^.*=\s*anytls/.test(line.split(",")[0]);
|
|
4286
4327
|
};
|
|
4287
|
-
const
|
|
4288
|
-
return { name, test, parse };
|
|
4328
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4329
|
+
return { name, test, parse: parse2 };
|
|
4289
4330
|
}
|
|
4290
4331
|
function Surge_TrustTunnel() {
|
|
4291
4332
|
const name = "Surge TrustTunnel Parser";
|
|
4292
4333
|
const test = (line) => {
|
|
4293
4334
|
return /^.*=\s*trust-tunnel/.test(line.split(",")[0]);
|
|
4294
4335
|
};
|
|
4295
|
-
const
|
|
4296
|
-
return { name, test, parse };
|
|
4336
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4337
|
+
return { name, test, parse: parse2 };
|
|
4297
4338
|
}
|
|
4298
4339
|
function Surge_H2Connect() {
|
|
4299
4340
|
const name = "Surge HTTP/2 CONNECT Parser";
|
|
4300
4341
|
const test = (line) => {
|
|
4301
4342
|
return /^.*=\s*h2-connect/.test(line.split(",")[0]);
|
|
4302
4343
|
};
|
|
4303
|
-
const
|
|
4304
|
-
return { name, test, parse };
|
|
4344
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4345
|
+
return { name, test, parse: parse2 };
|
|
4305
4346
|
}
|
|
4306
4347
|
function Surge_SSH() {
|
|
4307
4348
|
const name = "Surge SSH Parser";
|
|
4308
4349
|
const test = (line) => {
|
|
4309
4350
|
return /^.*=\s*ssh/.test(line.split(",")[0]);
|
|
4310
4351
|
};
|
|
4311
|
-
const
|
|
4312
|
-
return { name, test, parse };
|
|
4352
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4353
|
+
return { name, test, parse: parse2 };
|
|
4313
4354
|
}
|
|
4314
4355
|
function Surge_SS() {
|
|
4315
4356
|
const name = "Surge SS Parser";
|
|
4316
4357
|
const test = (line) => {
|
|
4317
4358
|
return /^.*=\s*ss/.test(line.split(",")[0]);
|
|
4318
4359
|
};
|
|
4319
|
-
const
|
|
4320
|
-
return { name, test, parse };
|
|
4360
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4361
|
+
return { name, test, parse: parse2 };
|
|
4321
4362
|
}
|
|
4322
4363
|
function Surge_VMess() {
|
|
4323
4364
|
const name = "Surge VMess Parser";
|
|
4324
4365
|
const test = (line) => {
|
|
4325
4366
|
return /^.*=\s*vmess/.test(line.split(",")[0]) && line.indexOf("username") !== -1;
|
|
4326
4367
|
};
|
|
4327
|
-
const
|
|
4328
|
-
return { name, test, parse };
|
|
4368
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4369
|
+
return { name, test, parse: parse2 };
|
|
4329
4370
|
}
|
|
4330
4371
|
function Surge_Trojan() {
|
|
4331
4372
|
const name = "Surge Trojan Parser";
|
|
4332
4373
|
const test = (line) => {
|
|
4333
4374
|
return /^.*=\s*trojan/.test(line.split(",")[0]);
|
|
4334
4375
|
};
|
|
4335
|
-
const
|
|
4336
|
-
return { name, test, parse };
|
|
4376
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4377
|
+
return { name, test, parse: parse2 };
|
|
4337
4378
|
}
|
|
4338
4379
|
var LOON_ONLY_OPTIONS = /(^|,)\s*(fast-open|over-tls|tls-name|ip-mode|tls-cert-sha256|tls-pubkey-sha256)\s*=/i;
|
|
4339
4380
|
function Surge_Http() {
|
|
@@ -4341,23 +4382,23 @@ function Surge_Http() {
|
|
|
4341
4382
|
const test = (line) => {
|
|
4342
4383
|
return /^.*=\s*https?/.test(line.split(",")[0]) && !LOON_ONLY_OPTIONS.test(line);
|
|
4343
4384
|
};
|
|
4344
|
-
const
|
|
4345
|
-
return { name, test, parse };
|
|
4385
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4386
|
+
return { name, test, parse: parse2 };
|
|
4346
4387
|
}
|
|
4347
4388
|
function Surge_Socks5() {
|
|
4348
4389
|
const name = "Surge Socks5 Parser";
|
|
4349
4390
|
const test = (line) => {
|
|
4350
4391
|
return /^.*=\s*socks5(-tls)?/.test(line.split(",")[0]) && !LOON_ONLY_OPTIONS.test(line);
|
|
4351
4392
|
};
|
|
4352
|
-
const
|
|
4353
|
-
return { name, test, parse };
|
|
4393
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4394
|
+
return { name, test, parse: parse2 };
|
|
4354
4395
|
}
|
|
4355
4396
|
function Surge_External() {
|
|
4356
4397
|
const name = "Surge External Parser";
|
|
4357
4398
|
const test = (line) => {
|
|
4358
4399
|
return /^.*=\s*external/.test(line.split(",")[0]);
|
|
4359
4400
|
};
|
|
4360
|
-
const
|
|
4401
|
+
const parse2 = (line) => {
|
|
4361
4402
|
let parsed = /^\s*(.*?)\s*?=\s*?external\s*?,\s*(.*?)\s*$/.exec(line);
|
|
4362
4403
|
let [_3, name2, other] = parsed;
|
|
4363
4404
|
line = other;
|
|
@@ -4410,49 +4451,49 @@ function Surge_External() {
|
|
|
4410
4451
|
};
|
|
4411
4452
|
return proxy;
|
|
4412
4453
|
};
|
|
4413
|
-
return { name, test, parse };
|
|
4454
|
+
return { name, test, parse: parse2 };
|
|
4414
4455
|
}
|
|
4415
4456
|
function Surge_Snell() {
|
|
4416
4457
|
const name = "Surge Snell Parser";
|
|
4417
4458
|
const test = (line) => {
|
|
4418
4459
|
return /^.*=\s*snell/.test(line.split(",")[0]);
|
|
4419
4460
|
};
|
|
4420
|
-
const
|
|
4421
|
-
return { name, test, parse };
|
|
4461
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4462
|
+
return { name, test, parse: parse2 };
|
|
4422
4463
|
}
|
|
4423
4464
|
function Surge_Tuic() {
|
|
4424
4465
|
const name = "Surge Tuic Parser";
|
|
4425
4466
|
const test = (line) => {
|
|
4426
4467
|
return /^.*=\s*tuic(-v5)?/.test(line.split(",")[0]);
|
|
4427
4468
|
};
|
|
4428
|
-
const
|
|
4469
|
+
const parse2 = (raw) => {
|
|
4429
4470
|
const { port_hopping, line } = surge_port_hopping(raw);
|
|
4430
4471
|
const proxy = getParser().parse(line);
|
|
4431
4472
|
proxy["ports"] = port_hopping;
|
|
4432
4473
|
return proxy;
|
|
4433
4474
|
};
|
|
4434
|
-
return { name, test, parse };
|
|
4475
|
+
return { name, test, parse: parse2 };
|
|
4435
4476
|
}
|
|
4436
4477
|
function Surge_WireGuard() {
|
|
4437
4478
|
const name = "Surge WireGuard Parser";
|
|
4438
4479
|
const test = (line) => {
|
|
4439
4480
|
return /^.*=\s*wireguard/.test(line.split(",")[0]);
|
|
4440
4481
|
};
|
|
4441
|
-
const
|
|
4442
|
-
return { name, test, parse };
|
|
4482
|
+
const parse2 = (line) => getParser().parse(line);
|
|
4483
|
+
return { name, test, parse: parse2 };
|
|
4443
4484
|
}
|
|
4444
4485
|
function Surge_Hysteria2() {
|
|
4445
4486
|
const name = "Surge Hysteria2 Parser";
|
|
4446
4487
|
const test = (line) => {
|
|
4447
4488
|
return /^.*=\s*hysteria2/.test(line.split(",")[0]);
|
|
4448
4489
|
};
|
|
4449
|
-
const
|
|
4490
|
+
const parse2 = (raw) => {
|
|
4450
4491
|
const { port_hopping, line } = surge_port_hopping(raw);
|
|
4451
4492
|
const proxy = getParser().parse(line);
|
|
4452
4493
|
proxy["ports"] = port_hopping;
|
|
4453
4494
|
return proxy;
|
|
4454
4495
|
};
|
|
4455
|
-
return { name, test, parse };
|
|
4496
|
+
return { name, test, parse: parse2 };
|
|
4456
4497
|
}
|
|
4457
4498
|
function isIP(ip) {
|
|
4458
4499
|
return isIPv4(ip) || isIPv6(ip);
|
|
@@ -4539,8 +4580,8 @@ function normalizeClashYaml(raw) {
|
|
|
4539
4580
|
function HTML() {
|
|
4540
4581
|
const name = "HTML";
|
|
4541
4582
|
const test = (raw) => /^<!DOCTYPE html>/.test(raw);
|
|
4542
|
-
const
|
|
4543
|
-
return { name, test, parse };
|
|
4583
|
+
const parse2 = () => "";
|
|
4584
|
+
return { name, test, parse: parse2 };
|
|
4544
4585
|
}
|
|
4545
4586
|
function Base64Encoded() {
|
|
4546
4587
|
const name = "Base64 Pre-processor";
|
|
@@ -4575,9 +4616,9 @@ function Base64Encoded() {
|
|
|
4575
4616
|
// tuic://
|
|
4576
4617
|
];
|
|
4577
4618
|
const test = function(raw) {
|
|
4578
|
-
return !/^\w+:\/\/\w+/im.test(raw) && keys.some((k) => raw.indexOf(k) !== -1);
|
|
4619
|
+
return Base642.isValid(raw) && !/^\w+:\/\/\w+/im.test(raw) && keys.some((k) => raw.indexOf(k) !== -1);
|
|
4579
4620
|
};
|
|
4580
|
-
const
|
|
4621
|
+
const parse2 = function(raw) {
|
|
4581
4622
|
const decoded = Base642.decode(raw);
|
|
4582
4623
|
if (!/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(decoded)) {
|
|
4583
4624
|
app_default.error(
|
|
@@ -4587,14 +4628,14 @@ function Base64Encoded() {
|
|
|
4587
4628
|
}
|
|
4588
4629
|
return decoded;
|
|
4589
4630
|
};
|
|
4590
|
-
return { name, test, parse };
|
|
4631
|
+
return { name, test, parse: parse2 };
|
|
4591
4632
|
}
|
|
4592
4633
|
function fallbackBase64Encoded() {
|
|
4593
4634
|
const name = "Fallback Base64 Pre-processor";
|
|
4594
4635
|
const test = function(raw) {
|
|
4595
|
-
return
|
|
4636
|
+
return Base642.isValid(raw);
|
|
4596
4637
|
};
|
|
4597
|
-
const
|
|
4638
|
+
const parse2 = function(raw) {
|
|
4598
4639
|
const decoded = Base642.decode(raw);
|
|
4599
4640
|
if (!/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(decoded)) {
|
|
4600
4641
|
app_default.error(
|
|
@@ -4604,33 +4645,34 @@ function fallbackBase64Encoded() {
|
|
|
4604
4645
|
}
|
|
4605
4646
|
return decoded;
|
|
4606
4647
|
};
|
|
4607
|
-
return { name, test, parse };
|
|
4648
|
+
return { name, test, parse: parse2 };
|
|
4608
4649
|
}
|
|
4609
4650
|
function Clash() {
|
|
4610
4651
|
const name = "Clash Pre-processor";
|
|
4611
4652
|
const test = function(raw) {
|
|
4612
|
-
if (!/proxies/.test(raw))
|
|
4653
|
+
if (!/proxies/.test(raw))
|
|
4654
|
+
return false;
|
|
4613
4655
|
const content = safeLoad(raw);
|
|
4614
|
-
return content.proxies
|
|
4656
|
+
return Array.isArray(content.proxies) || Array.isArray(content["proxy-groups"]);
|
|
4615
4657
|
};
|
|
4616
|
-
const
|
|
4658
|
+
const parse2 = function(raw, includeProxies) {
|
|
4617
4659
|
const afterReplace = normalizeClashYaml(raw);
|
|
4618
4660
|
const { proxies } = safeLoad(afterReplace);
|
|
4619
|
-
return (includeProxies ? "proxies:\n" : "") + proxies.map((p) => {
|
|
4661
|
+
return (includeProxies ? "proxies:\n" : "") + (Array.isArray(proxies) ? proxies : []).map((p) => {
|
|
4620
4662
|
return `${includeProxies ? " - " : ""}${JSON.stringify(
|
|
4621
4663
|
p
|
|
4622
4664
|
)}
|
|
4623
4665
|
`;
|
|
4624
4666
|
}).join("");
|
|
4625
4667
|
};
|
|
4626
|
-
return { name, test, parse };
|
|
4668
|
+
return { name, test, parse: parse2 };
|
|
4627
4669
|
}
|
|
4628
4670
|
function SSD() {
|
|
4629
4671
|
const name = "SSD Pre-processor";
|
|
4630
4672
|
const test = function(raw) {
|
|
4631
4673
|
return raw.indexOf("ssd://") === 0;
|
|
4632
4674
|
};
|
|
4633
|
-
const
|
|
4675
|
+
const parse2 = function(raw) {
|
|
4634
4676
|
const output = [];
|
|
4635
4677
|
let ssdinfo = JSON.parse(Base642.decode(raw.split("ssd://")[1]));
|
|
4636
4678
|
let port = ssdinfo.port;
|
|
@@ -4652,20 +4694,20 @@ function SSD() {
|
|
|
4652
4694
|
}
|
|
4653
4695
|
return output.join("\n");
|
|
4654
4696
|
};
|
|
4655
|
-
return { name, test, parse };
|
|
4697
|
+
return { name, test, parse: parse2 };
|
|
4656
4698
|
}
|
|
4657
4699
|
function FullConfig() {
|
|
4658
4700
|
const name = "Full Config Preprocessor";
|
|
4659
4701
|
const test = function(raw) {
|
|
4660
4702
|
return /^(\[server_local\]|\[Proxy\])/gm.test(raw);
|
|
4661
4703
|
};
|
|
4662
|
-
const
|
|
4704
|
+
const parse2 = function(raw) {
|
|
4663
4705
|
const match = raw.match(
|
|
4664
4706
|
/^\[server_local|Proxy\]([\s\S]+?)^\[.+?\](\r?\n|$)/im
|
|
4665
4707
|
)?.[1];
|
|
4666
4708
|
return match || raw;
|
|
4667
4709
|
};
|
|
4668
|
-
return { name, test, parse };
|
|
4710
|
+
return { name, test, parse: parse2 };
|
|
4669
4711
|
}
|
|
4670
4712
|
var preprocessors_default = [
|
|
4671
4713
|
HTML(),
|
|
@@ -4706,12 +4748,16 @@ function isShadowsocksOverTls(proxy) {
|
|
|
4706
4748
|
return proxy?.type === "ss" && proxy?.tls === true && !isPresent2(proxy, "plugin") && (!isPresent2(proxy, "network") || normalizedNetwork === "tcp");
|
|
4707
4749
|
}
|
|
4708
4750
|
function normalizePluginMuxValue(mux) {
|
|
4709
|
-
if (typeof mux === "boolean")
|
|
4751
|
+
if (typeof mux === "boolean")
|
|
4752
|
+
return Number(mux);
|
|
4710
4753
|
if (typeof mux === "string") {
|
|
4711
4754
|
const normalized = mux.trim().toLowerCase();
|
|
4712
|
-
if (normalized === "true")
|
|
4713
|
-
|
|
4714
|
-
if (
|
|
4755
|
+
if (normalized === "true")
|
|
4756
|
+
return 1;
|
|
4757
|
+
if (normalized === "false")
|
|
4758
|
+
return 0;
|
|
4759
|
+
if (/^\d+$/.test(normalized))
|
|
4760
|
+
return parseInt(normalized, 10);
|
|
4715
4761
|
}
|
|
4716
4762
|
return mux;
|
|
4717
4763
|
}
|
|
@@ -4719,27 +4765,34 @@ function normalizePluginMuxBooleanValue(mux) {
|
|
|
4719
4765
|
return Boolean(normalizePluginMuxValue(mux));
|
|
4720
4766
|
}
|
|
4721
4767
|
function supportsShadowsocksV2rayPluginMode(proxy, supportedModes) {
|
|
4722
|
-
if (proxy?.type !== "ss" || proxy?.plugin !== "v2ray-plugin")
|
|
4768
|
+
if (proxy?.type !== "ss" || proxy?.plugin !== "v2ray-plugin")
|
|
4769
|
+
return true;
|
|
4723
4770
|
const normalizedMode = typeof proxy?.["plugin-opts"]?.mode === "string" ? proxy["plugin-opts"].mode.trim().toLowerCase() : proxy?.["plugin-opts"]?.mode;
|
|
4724
4771
|
return supportedModes.includes(normalizedMode);
|
|
4725
4772
|
}
|
|
4726
4773
|
function parseWireGuardCIDR(cidr, max) {
|
|
4727
|
-
if (cidr == null)
|
|
4774
|
+
if (cidr == null)
|
|
4775
|
+
return void 0;
|
|
4728
4776
|
const normalized = `${cidr}`.trim();
|
|
4729
|
-
if (!/^\d+$/.test(normalized))
|
|
4777
|
+
if (!/^\d+$/.test(normalized))
|
|
4778
|
+
return void 0;
|
|
4730
4779
|
const parsed = parseInt(normalized, 10);
|
|
4731
|
-
if (parsed < 0 || parsed > max)
|
|
4780
|
+
if (parsed < 0 || parsed > max)
|
|
4781
|
+
return void 0;
|
|
4732
4782
|
return parsed;
|
|
4733
4783
|
}
|
|
4734
4784
|
function parseWireGuardInterfaceAddress(value, family) {
|
|
4735
|
-
if (value == null)
|
|
4785
|
+
if (value == null)
|
|
4786
|
+
return null;
|
|
4736
4787
|
const raw = `${value}`.trim();
|
|
4737
|
-
if (!raw)
|
|
4788
|
+
if (!raw)
|
|
4789
|
+
return null;
|
|
4738
4790
|
const [, hostRaw = raw, cidrRaw] = /^(.*?)(?:\/(\d+))?$/.exec(raw) || [];
|
|
4739
4791
|
const host = `${hostRaw}`.trim().replace(/^\[/, "").replace(/\]$/, "");
|
|
4740
4792
|
const isIPv4Family = family === "ipv4";
|
|
4741
4793
|
const isValid = isIPv4Family ? isIPv4(host) : isIPv6(host);
|
|
4742
|
-
if (!isValid)
|
|
4794
|
+
if (!isValid)
|
|
4795
|
+
return null;
|
|
4743
4796
|
const max = isIPv4Family ? 32 : 128;
|
|
4744
4797
|
return {
|
|
4745
4798
|
address: host,
|
|
@@ -4752,7 +4805,8 @@ function getWireGuardAddressWithCIDR(proxy = {}, family = "ipv4") {
|
|
|
4752
4805
|
proxy[config.addressKey],
|
|
4753
4806
|
family
|
|
4754
4807
|
);
|
|
4755
|
-
if (!parsed)
|
|
4808
|
+
if (!parsed)
|
|
4809
|
+
return void 0;
|
|
4756
4810
|
const normalizedCIDR = parseWireGuardCIDR(
|
|
4757
4811
|
proxy[config.cidrKey],
|
|
4758
4812
|
config.defaultCIDR
|
|
@@ -4760,7 +4814,8 @@ function getWireGuardAddressWithCIDR(proxy = {}, family = "ipv4") {
|
|
|
4760
4814
|
return `${parsed.address}/${normalizedCIDR ?? parsed.cidr ?? config.defaultCIDR}`;
|
|
4761
4815
|
}
|
|
4762
4816
|
function produceProxyListOutput(list, type, opts = {}) {
|
|
4763
|
-
if (type === "internal")
|
|
4817
|
+
if (type === "internal")
|
|
4818
|
+
return list;
|
|
4764
4819
|
if (opts.prettyYaml || opts["pretty-yaml"]) {
|
|
4765
4820
|
return normalizeClashYaml(
|
|
4766
4821
|
yaml_default.safeDump(
|
|
@@ -4795,7 +4850,8 @@ var ipVersions = {
|
|
|
4795
4850
|
"ipv6-prefer": "prefer-v6"
|
|
4796
4851
|
};
|
|
4797
4852
|
function stripSurgeQuotes(value) {
|
|
4798
|
-
if (typeof value !== "string")
|
|
4853
|
+
if (typeof value !== "string")
|
|
4854
|
+
return value;
|
|
4799
4855
|
const trimmed = value.trim();
|
|
4800
4856
|
const quote = trimmed[0];
|
|
4801
4857
|
if ((quote === '"' || quote === "'") && trimmed[trimmed.length - 1] === quote) {
|
|
@@ -4810,6 +4866,42 @@ function quoteSurgeValue(value) {
|
|
|
4810
4866
|
function hasNonBlankValue(value) {
|
|
4811
4867
|
return value != null && `${value}`.trim().length > 0;
|
|
4812
4868
|
}
|
|
4869
|
+
function formatSurgeAlpn(alpn) {
|
|
4870
|
+
const values = Array.isArray(alpn) ? alpn : stripSurgeQuotes(`${alpn || ""}`).split(",");
|
|
4871
|
+
return values.filter((item) => item != null).map((item) => String(stripSurgeQuotes(item)).trim()).filter((item) => item !== "").join(",");
|
|
4872
|
+
}
|
|
4873
|
+
function appendAlpn(result, proxy) {
|
|
4874
|
+
const alpn = formatSurgeAlpn(proxy.alpn);
|
|
4875
|
+
if (alpn)
|
|
4876
|
+
result.append(`,alpn="${alpn}"`);
|
|
4877
|
+
}
|
|
4878
|
+
function getShadowTLSAlpn(proxy) {
|
|
4879
|
+
return formatSurgeAlpn(proxy?.["plugin-opts"]?.alpn ?? proxy?.alpn);
|
|
4880
|
+
}
|
|
4881
|
+
function appendShadowTLS(result, proxy, includeUdpPort = false) {
|
|
4882
|
+
if (proxy.plugin !== "shadow-tls" || !proxy["plugin-opts"])
|
|
4883
|
+
return;
|
|
4884
|
+
const password = proxy["plugin-opts"].password;
|
|
4885
|
+
const host = proxy["plugin-opts"].host;
|
|
4886
|
+
const version = proxy["plugin-opts"].version;
|
|
4887
|
+
if (!password)
|
|
4888
|
+
return;
|
|
4889
|
+
result.append(`,shadow-tls-password="${password}"`);
|
|
4890
|
+
if (host)
|
|
4891
|
+
result.append(`,shadow-tls-sni=${host}`);
|
|
4892
|
+
if (version) {
|
|
4893
|
+
if (version < 2) {
|
|
4894
|
+
throw unsupported(`shadow-tls version ${version} is not supported`);
|
|
4895
|
+
}
|
|
4896
|
+
result.append(`,shadow-tls-version=${version}`);
|
|
4897
|
+
}
|
|
4898
|
+
const alpn = getShadowTLSAlpn(proxy);
|
|
4899
|
+
if (alpn)
|
|
4900
|
+
result.append(`,alpn="${alpn}"`);
|
|
4901
|
+
if (includeUdpPort) {
|
|
4902
|
+
result.appendIfPresent(`,udp-port=${proxy["udp-port"]}`, "udp-port");
|
|
4903
|
+
}
|
|
4904
|
+
}
|
|
4813
4905
|
function appendTlsProxyParams(result, proxy, enabled = true) {
|
|
4814
4906
|
if (!enabled) {
|
|
4815
4907
|
return;
|
|
@@ -4819,6 +4911,15 @@ function appendTlsProxyParams(result, proxy, enabled = true) {
|
|
|
4819
4911
|
"tls-fingerprint"
|
|
4820
4912
|
);
|
|
4821
4913
|
result.appendIfPresent(`,sni="${proxy.sni}"`, "sni");
|
|
4914
|
+
result.appendIfPresent(
|
|
4915
|
+
`,server-cert-verify-name=${quoteSurgeValue(
|
|
4916
|
+
proxy["name-cert-verify"]
|
|
4917
|
+
)}`,
|
|
4918
|
+
"name-cert-verify"
|
|
4919
|
+
);
|
|
4920
|
+
if (proxy.plugin !== "shadow-tls") {
|
|
4921
|
+
appendAlpn(result, proxy);
|
|
4922
|
+
}
|
|
4822
4923
|
result.appendIfPresent(
|
|
4823
4924
|
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
4824
4925
|
"skip-cert-verify"
|
|
@@ -4835,9 +4936,11 @@ function appendSshPrivateKey(result, proxy) {
|
|
|
4835
4936
|
}
|
|
4836
4937
|
}
|
|
4837
4938
|
function warnMaxStreamsIfNeeded(proxy) {
|
|
4838
|
-
if (!isPresent2(proxy, "max-streams"))
|
|
4939
|
+
if (!isPresent2(proxy, "max-streams"))
|
|
4940
|
+
return;
|
|
4839
4941
|
const maxStreams = Number(stripSurgeQuotes(proxy["max-streams"]));
|
|
4840
|
-
if (!Number.isInteger(maxStreams) || maxStreams <= 3)
|
|
4942
|
+
if (!Number.isInteger(maxStreams) || maxStreams <= 3)
|
|
4943
|
+
return;
|
|
4841
4944
|
app_default.warn(
|
|
4842
4945
|
`Surge ${proxy.type} proxy ${proxy.name}: max-streams=${maxStreams} is greater than 3. Too many streams sharing one TCP connection may hurt performance.`
|
|
4843
4946
|
);
|
|
@@ -4984,40 +5087,7 @@ function shadowsocks(proxy) {
|
|
|
4984
5087
|
"interface-name"
|
|
4985
5088
|
);
|
|
4986
5089
|
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
|
-
}
|
|
5090
|
+
appendShadowTLS(result, proxy, true);
|
|
5021
5091
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5022
5092
|
result.appendIfPresent(
|
|
5023
5093
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5057,17 +5127,7 @@ function trojan(proxy) {
|
|
|
5057
5127
|
"interface-name"
|
|
5058
5128
|
);
|
|
5059
5129
|
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
|
-
}
|
|
5130
|
+
appendShadowTLS(result, proxy);
|
|
5071
5131
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5072
5132
|
result.appendIfPresent(
|
|
5073
5133
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5197,17 +5257,7 @@ function h2Connect(proxy) {
|
|
|
5197
5257
|
"interface-name"
|
|
5198
5258
|
);
|
|
5199
5259
|
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
|
-
}
|
|
5260
|
+
appendShadowTLS(result, proxy);
|
|
5211
5261
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5212
5262
|
result.appendIfPresent(
|
|
5213
5263
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5256,17 +5306,7 @@ function vmess(proxy, includeUnsupportedProxy) {
|
|
|
5256
5306
|
"interface-name"
|
|
5257
5307
|
);
|
|
5258
5308
|
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
|
-
}
|
|
5309
|
+
appendShadowTLS(result, proxy);
|
|
5270
5310
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5271
5311
|
result.appendIfPresent(
|
|
5272
5312
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5353,17 +5393,7 @@ function http(proxy) {
|
|
|
5353
5393
|
"interface-name"
|
|
5354
5394
|
);
|
|
5355
5395
|
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
|
-
}
|
|
5396
|
+
appendShadowTLS(result, proxy);
|
|
5367
5397
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5368
5398
|
result.appendIfPresent(
|
|
5369
5399
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5441,17 +5471,7 @@ function socks5(proxy) {
|
|
|
5441
5471
|
"interface-name"
|
|
5442
5472
|
);
|
|
5443
5473
|
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
|
-
}
|
|
5474
|
+
appendShadowTLS(result, proxy);
|
|
5455
5475
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5456
5476
|
result.appendIfPresent(
|
|
5457
5477
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5525,17 +5545,7 @@ function snell(proxy) {
|
|
|
5525
5545
|
"interface-name"
|
|
5526
5546
|
);
|
|
5527
5547
|
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
|
-
}
|
|
5548
|
+
appendShadowTLS(result, proxy);
|
|
5539
5549
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5540
5550
|
result.appendIfPresent(
|
|
5541
5551
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5554,10 +5564,6 @@ function tuic(proxy) {
|
|
|
5554
5564
|
result.appendIfPresent(`,uuid=${proxy.uuid}`, "uuid");
|
|
5555
5565
|
result.appendIfPresent(`,password="${proxy.password}"`, "password");
|
|
5556
5566
|
result.appendIfPresent(`,token=${proxy.token}`, "token");
|
|
5557
|
-
result.appendIfPresent(
|
|
5558
|
-
`,alpn=${Array.isArray(proxy.alpn) ? proxy.alpn[0] : proxy.alpn}`,
|
|
5559
|
-
"alpn"
|
|
5560
|
-
);
|
|
5561
5567
|
if (hasNonBlankValue(proxy.ports)) {
|
|
5562
5568
|
result.append(
|
|
5563
5569
|
`,port-hopping="${String(proxy.ports).replace(/,/g, ";")}"`
|
|
@@ -5595,17 +5601,7 @@ function tuic(proxy) {
|
|
|
5595
5601
|
"interface-name"
|
|
5596
5602
|
);
|
|
5597
5603
|
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
|
-
}
|
|
5604
|
+
appendShadowTLS(result, proxy);
|
|
5609
5605
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5610
5606
|
result.appendIfPresent(
|
|
5611
5607
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5656,17 +5652,7 @@ function wireguard(proxy) {
|
|
|
5656
5652
|
"interface-name"
|
|
5657
5653
|
);
|
|
5658
5654
|
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
|
-
}
|
|
5655
|
+
appendShadowTLS(result, proxy);
|
|
5670
5656
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5671
5657
|
result.appendIfPresent(
|
|
5672
5658
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5740,17 +5726,7 @@ function wireguard_surge(proxy) {
|
|
|
5740
5726
|
"interface-name"
|
|
5741
5727
|
);
|
|
5742
5728
|
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
|
-
}
|
|
5729
|
+
appendShadowTLS(result, proxy);
|
|
5754
5730
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5755
5731
|
result.appendIfPresent(
|
|
5756
5732
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5759,8 +5735,12 @@ function wireguard_surge(proxy) {
|
|
|
5759
5735
|
return result.toString();
|
|
5760
5736
|
}
|
|
5761
5737
|
function hysteria2(proxy) {
|
|
5762
|
-
|
|
5763
|
-
|
|
5738
|
+
const obfsPasswordField = {
|
|
5739
|
+
salamander: "salamander-password",
|
|
5740
|
+
gecko: "gecko-password"
|
|
5741
|
+
}[proxy.obfs];
|
|
5742
|
+
if (proxy["obfs-password"] && !obfsPasswordField) {
|
|
5743
|
+
throw unsupported(`only salamander and gecko obfs are supported`);
|
|
5764
5744
|
}
|
|
5765
5745
|
const result = new Result(proxy);
|
|
5766
5746
|
result.append(`${proxy.name}=hysteria2,${proxy.server},${proxy.port}`);
|
|
@@ -5773,8 +5753,8 @@ function hysteria2(proxy) {
|
|
|
5773
5753
|
if (hasNonBlankValue(proxy["hop-interval"])) {
|
|
5774
5754
|
result.append(`,port-hopping-interval=${proxy["hop-interval"]}`);
|
|
5775
5755
|
}
|
|
5776
|
-
if (proxy["obfs-password"] &&
|
|
5777
|
-
result.append(
|
|
5756
|
+
if (proxy["obfs-password"] && obfsPasswordField) {
|
|
5757
|
+
result.append(`,${obfsPasswordField}="${proxy["obfs-password"]}"`);
|
|
5778
5758
|
}
|
|
5779
5759
|
const ip_version = ipVersions[proxy["ip-version"]] || proxy["ip-version"];
|
|
5780
5760
|
result.appendIfPresent(`,ip-version=${ip_version}`, "ip-version");
|
|
@@ -5805,17 +5785,7 @@ function hysteria2(proxy) {
|
|
|
5805
5785
|
"interface-name"
|
|
5806
5786
|
);
|
|
5807
5787
|
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
|
-
}
|
|
5788
|
+
appendShadowTLS(result, proxy);
|
|
5819
5789
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
5820
5790
|
result.appendIfPresent(
|
|
5821
5791
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -5894,16 +5864,17 @@ function ClashMeta_Producer() {
|
|
|
5894
5864
|
const type = "ALL";
|
|
5895
5865
|
const produce2 = (proxies, type2, opts = {}) => {
|
|
5896
5866
|
const list = proxies.filter((proxy) => {
|
|
5897
|
-
if (opts["include-unsupported-proxy"])
|
|
5867
|
+
if (opts["include-unsupported-proxy"])
|
|
5868
|
+
return true;
|
|
5898
5869
|
if (proxy.type === "h2-connect") {
|
|
5899
5870
|
app_default.error(
|
|
5900
|
-
`
|
|
5871
|
+
`mihomo does not support HTTP/2 CONNECT proxy type. Proxy ${proxy.name} has been filtered.`
|
|
5901
5872
|
);
|
|
5902
5873
|
return false;
|
|
5903
5874
|
}
|
|
5904
5875
|
if (hasRootHeaders(proxy) && proxy.type === "trusttunnel") {
|
|
5905
5876
|
app_default.error(
|
|
5906
|
-
`
|
|
5877
|
+
`mihomo does not support headers for TrustTunnel proxy ${proxy.name}. Proxy has been filtered.`
|
|
5907
5878
|
);
|
|
5908
5879
|
return false;
|
|
5909
5880
|
}
|
|
@@ -5911,11 +5882,16 @@ function ClashMeta_Producer() {
|
|
|
5911
5882
|
return false;
|
|
5912
5883
|
} else if (proxy.type === "snell" && !isSupportedMihomoVersion(proxy.version, [1, 2, 3, 4, 5])) {
|
|
5913
5884
|
return false;
|
|
5914
|
-
} else if (hasMihomoShadowTls(proxy) && (proxy.type
|
|
5885
|
+
} else if (hasMihomoShadowTls(proxy) && (!["ss", "snell"].includes(proxy.type) || !isSupportedMihomoVersion(
|
|
5915
5886
|
getMihomoShadowTlsVersion(proxy),
|
|
5916
5887
|
[1, 2, 3]
|
|
5917
5888
|
))) {
|
|
5918
5889
|
return false;
|
|
5890
|
+
} else if (hasMihomoSnellShadowTlsObfsConflict(proxy)) {
|
|
5891
|
+
app_default.error(
|
|
5892
|
+
`Platform Mihomo does not support Snell shadow-tls with obfs for proxy ${proxy.name}. Proxy has been filtered.`
|
|
5893
|
+
);
|
|
5894
|
+
return false;
|
|
5919
5895
|
} else if (["juicity", "naive"].includes(proxy.type)) {
|
|
5920
5896
|
return false;
|
|
5921
5897
|
} else if (["ss"].includes(proxy.type) && ![
|
|
@@ -6018,24 +5994,31 @@ function ClashMeta_Producer() {
|
|
|
6018
5994
|
ds["reality-opts"] = { "public-key": "" };
|
|
6019
5995
|
}
|
|
6020
5996
|
}
|
|
6021
|
-
} else if (proxy.type
|
|
6022
|
-
|
|
6023
|
-
|
|
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
|
-
}
|
|
5997
|
+
} else if (["anytls"].includes(proxy.type) && proxy.reuse != null && !proxy.reuse) {
|
|
5998
|
+
proxy["disable-reuse"] = true;
|
|
5999
|
+
delete proxy.reuse;
|
|
6033
6000
|
}
|
|
6034
6001
|
if (isPresent2(proxy, "plugin-opts.mux")) {
|
|
6035
6002
|
proxy["plugin-opts"].mux = normalizePluginMuxBooleanValue(
|
|
6036
6003
|
proxy["plugin-opts"].mux
|
|
6037
6004
|
);
|
|
6038
6005
|
}
|
|
6006
|
+
if (proxy.type === "snell") {
|
|
6007
|
+
const shadowTLSOpts = getMihomoShadowTlsOpts(proxy);
|
|
6008
|
+
if (shadowTLSOpts) {
|
|
6009
|
+
proxy["obfs-opts"] = {
|
|
6010
|
+
mode: "shadow-tls",
|
|
6011
|
+
host: shadowTLSOpts.host,
|
|
6012
|
+
password: shadowTLSOpts.password,
|
|
6013
|
+
version: shadowTLSOpts.version
|
|
6014
|
+
};
|
|
6015
|
+
if (shadowTLSOpts.alpn) {
|
|
6016
|
+
proxy["obfs-opts"].alpn = shadowTLSOpts.alpn;
|
|
6017
|
+
}
|
|
6018
|
+
delete proxy.plugin;
|
|
6019
|
+
delete proxy["plugin-opts"];
|
|
6020
|
+
}
|
|
6021
|
+
}
|
|
6039
6022
|
if (["vmess", "vless"].includes(proxy.type) && proxy.network === "http") {
|
|
6040
6023
|
let httpPath = proxy["http-opts"]?.path;
|
|
6041
6024
|
if (isPresent2(proxy, "http-opts.path") && !Array.isArray(httpPath)) {
|
|
@@ -6084,7 +6067,9 @@ function ClashMeta_Producer() {
|
|
|
6084
6067
|
"juicity",
|
|
6085
6068
|
"anytls",
|
|
6086
6069
|
"trusttunnel",
|
|
6087
|
-
"naive"
|
|
6070
|
+
"naive",
|
|
6071
|
+
"masque",
|
|
6072
|
+
"shadowquic"
|
|
6088
6073
|
].includes(proxy.type)) {
|
|
6089
6074
|
delete proxy.tls;
|
|
6090
6075
|
}
|
|
@@ -6144,14 +6129,20 @@ function isSupportedMihomoVersion(version, supportedVersions) {
|
|
|
6144
6129
|
return Number.isInteger(parsed) && supportedVersions.includes(parsed);
|
|
6145
6130
|
}
|
|
6146
6131
|
function hasMihomoShadowTls(proxy) {
|
|
6147
|
-
return
|
|
6132
|
+
return Boolean(getMihomoShadowTlsOpts(proxy));
|
|
6133
|
+
}
|
|
6134
|
+
function hasMihomoSnellShadowTlsObfsConflict(proxy) {
|
|
6135
|
+
return proxy?.type === "snell" && proxy?.plugin === "shadow-tls" && (isPresent2(proxy, "obfs-opts.mode") || isPresent2(proxy, "obfs-opts.host") || isPresent2(proxy, "obfs-opts.path"));
|
|
6148
6136
|
}
|
|
6149
6137
|
function getMihomoShadowTlsVersion(proxy) {
|
|
6150
|
-
|
|
6151
|
-
|
|
6138
|
+
return getMihomoShadowTlsOpts(proxy)?.version;
|
|
6139
|
+
}
|
|
6140
|
+
function getMihomoShadowTlsOpts(proxy) {
|
|
6141
|
+
if (proxy?.plugin === "shadow-tls" && proxy?.["plugin-opts"]) {
|
|
6142
|
+
return proxy["plugin-opts"];
|
|
6152
6143
|
}
|
|
6153
|
-
if (proxy?.
|
|
6154
|
-
return proxy
|
|
6144
|
+
if (proxy?.type === "snell" && proxy?.["obfs-opts"]?.mode === "shadow-tls") {
|
|
6145
|
+
return proxy["obfs-opts"];
|
|
6155
6146
|
}
|
|
6156
6147
|
return void 0;
|
|
6157
6148
|
}
|
|
@@ -6164,8 +6155,6 @@ function SurgeMac_Producer() {
|
|
|
6164
6155
|
switch (proxy.type) {
|
|
6165
6156
|
case "external":
|
|
6166
6157
|
return external(proxy);
|
|
6167
|
-
// case 'ssr':
|
|
6168
|
-
// return shadowsocksr(proxy);
|
|
6169
6158
|
default: {
|
|
6170
6159
|
if (opts.mihomoExternal || proxy._mihomoExternal) {
|
|
6171
6160
|
return mihomo(proxy, type, opts) || "";
|
|
@@ -6179,7 +6168,7 @@ function SurgeMac_Producer() {
|
|
|
6179
6168
|
throw e;
|
|
6180
6169
|
}
|
|
6181
6170
|
app_default.log(
|
|
6182
|
-
`${proxy.name} is not supported on ${targetPlatform2}, try to use
|
|
6171
|
+
`${proxy.name} is not supported on ${targetPlatform2}, try to use mihomo(SurgeMac - External Proxy Program) instead`
|
|
6183
6172
|
);
|
|
6184
6173
|
return output;
|
|
6185
6174
|
}
|
|
@@ -6352,7 +6341,8 @@ function Clash_Producer() {
|
|
|
6352
6341
|
const type = "ALL";
|
|
6353
6342
|
const produce2 = (proxies, type2, opts = {}) => {
|
|
6354
6343
|
const list = proxies.filter((proxy) => {
|
|
6355
|
-
if (opts["include-unsupported-proxy"])
|
|
6344
|
+
if (opts["include-unsupported-proxy"])
|
|
6345
|
+
return true;
|
|
6356
6346
|
if (![
|
|
6357
6347
|
"ss",
|
|
6358
6348
|
"ssr",
|
|
@@ -6507,7 +6497,8 @@ function Stash_Producer() {
|
|
|
6507
6497
|
const type = "ALL";
|
|
6508
6498
|
const produce2 = (proxies, type2, opts = {}) => {
|
|
6509
6499
|
const list = proxies.filter((proxy) => {
|
|
6510
|
-
if (opts["include-unsupported-proxy"])
|
|
6500
|
+
if (opts["include-unsupported-proxy"])
|
|
6501
|
+
return true;
|
|
6511
6502
|
if (![
|
|
6512
6503
|
"ss",
|
|
6513
6504
|
"ssr",
|
|
@@ -6797,11 +6788,41 @@ function Loon_Producer() {
|
|
|
6797
6788
|
}
|
|
6798
6789
|
function appendTlsProfile(result, proxy) {
|
|
6799
6790
|
const tlsProfile = getLoonTlsProfile(proxy);
|
|
6800
|
-
if (tlsProfile)
|
|
6791
|
+
if (tlsProfile)
|
|
6792
|
+
result.append(`,tls-profile=${tlsProfile}`);
|
|
6801
6793
|
}
|
|
6802
|
-
function
|
|
6794
|
+
function appendAlpn2(result, proxy) {
|
|
6803
6795
|
const alpn = getLoonAlpn(proxy);
|
|
6804
|
-
if (alpn)
|
|
6796
|
+
if (alpn)
|
|
6797
|
+
result.append(`,alpn="${alpn}"`);
|
|
6798
|
+
}
|
|
6799
|
+
function getLoonShadowTLSAlpn(proxy) {
|
|
6800
|
+
const values = proxy?.["plugin-opts"]?.alpn ?? proxy?.alpn;
|
|
6801
|
+
const normalized = Array.isArray(values) ? values : `${values || ""}`.split(",");
|
|
6802
|
+
return normalized.map((item) => `${item}`.trim()).filter((item) => item !== "").join(",");
|
|
6803
|
+
}
|
|
6804
|
+
function appendShadowTLS2(result, proxy) {
|
|
6805
|
+
if (proxy.plugin !== "shadow-tls" || !proxy["plugin-opts"])
|
|
6806
|
+
return;
|
|
6807
|
+
const password = proxy["plugin-opts"].password;
|
|
6808
|
+
const host = proxy["plugin-opts"].host;
|
|
6809
|
+
const version = proxy["plugin-opts"].version;
|
|
6810
|
+
if (!password)
|
|
6811
|
+
return;
|
|
6812
|
+
result.append(`,shadow-tls-password=${password}`);
|
|
6813
|
+
if (host)
|
|
6814
|
+
result.append(`,shadow-tls-sni=${host}`);
|
|
6815
|
+
if (version) {
|
|
6816
|
+
if (version < 2) {
|
|
6817
|
+
throw new Error(`shadow-tls version ${version} is not supported`);
|
|
6818
|
+
}
|
|
6819
|
+
result.append(`,shadow-tls-version=${version}`);
|
|
6820
|
+
}
|
|
6821
|
+
appendTlsProfile(result, proxy);
|
|
6822
|
+
const alpn = getLoonShadowTLSAlpn(proxy);
|
|
6823
|
+
if (alpn)
|
|
6824
|
+
result.append(`,alpn="${alpn}"`);
|
|
6825
|
+
result.appendIfPresent(`,udp-port=${proxy["udp-port"]}`, "udp-port");
|
|
6805
6826
|
}
|
|
6806
6827
|
function appendReality(result, proxy) {
|
|
6807
6828
|
result.appendIfPresent(`,sni=${proxy.sni}`, "sni");
|
|
@@ -6876,40 +6897,7 @@ function shadowsocks2(proxy) {
|
|
|
6876
6897
|
throw new Error(`plugin ${proxy.plugin} is not supported`);
|
|
6877
6898
|
}
|
|
6878
6899
|
}
|
|
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
|
-
}
|
|
6900
|
+
appendShadowTLS2(result, proxy);
|
|
6913
6901
|
if (proxy["udp-over-tcp"]) {
|
|
6914
6902
|
if (proxy["udp-over-tcp-version"] === 2) {
|
|
6915
6903
|
if (proxy.plugin === "obfs") {
|
|
@@ -6950,40 +6938,7 @@ function shadowsocksr(proxy) {
|
|
|
6950
6938
|
);
|
|
6951
6939
|
result.appendIfPresent(`,obfs=${proxy.obfs}`, "obfs");
|
|
6952
6940
|
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
|
-
}
|
|
6941
|
+
appendShadowTLS2(result, proxy);
|
|
6987
6942
|
result.appendIfPresent(`,fast-open=${proxy.tfo}`, "tfo");
|
|
6988
6943
|
if (proxy["block-quic"] === "on") {
|
|
6989
6944
|
result.append(",block-quic=true");
|
|
@@ -7026,7 +6981,7 @@ function trojan2(proxy) {
|
|
|
7026
6981
|
"skip-cert-verify"
|
|
7027
6982
|
);
|
|
7028
6983
|
appendTlsProfile(result, proxy);
|
|
7029
|
-
|
|
6984
|
+
appendAlpn2(result, proxy);
|
|
7030
6985
|
if (isReality) {
|
|
7031
6986
|
appendReality(result, proxy);
|
|
7032
6987
|
} else {
|
|
@@ -7074,7 +7029,7 @@ function anytls2(proxy) {
|
|
|
7074
7029
|
"skip-cert-verify"
|
|
7075
7030
|
);
|
|
7076
7031
|
appendTlsProfile(result, proxy);
|
|
7077
|
-
|
|
7032
|
+
appendAlpn2(result, proxy);
|
|
7078
7033
|
if (isReality) {
|
|
7079
7034
|
appendReality(result, proxy);
|
|
7080
7035
|
} else {
|
|
@@ -7147,7 +7102,7 @@ function vmess2(proxy) {
|
|
|
7147
7102
|
);
|
|
7148
7103
|
if (proxy.tls || isReality) {
|
|
7149
7104
|
appendTlsProfile(result, proxy);
|
|
7150
|
-
|
|
7105
|
+
appendAlpn2(result, proxy);
|
|
7151
7106
|
}
|
|
7152
7107
|
if (isReality) {
|
|
7153
7108
|
appendReality(result, proxy);
|
|
@@ -7235,7 +7190,7 @@ function vless(proxy) {
|
|
|
7235
7190
|
);
|
|
7236
7191
|
if (proxy.tls || isReality || isXtls) {
|
|
7237
7192
|
appendTlsProfile(result, proxy);
|
|
7238
|
-
|
|
7193
|
+
appendAlpn2(result, proxy);
|
|
7239
7194
|
}
|
|
7240
7195
|
if (isXtls) {
|
|
7241
7196
|
result.appendIfPresent(`,flow=${proxy.flow}`, "flow");
|
|
@@ -7279,7 +7234,7 @@ function http2(proxy) {
|
|
|
7279
7234
|
);
|
|
7280
7235
|
if (proxy.tls) {
|
|
7281
7236
|
appendTlsProfile(result, proxy);
|
|
7282
|
-
|
|
7237
|
+
appendAlpn2(result, proxy);
|
|
7283
7238
|
}
|
|
7284
7239
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
7285
7240
|
if (proxy["block-quic"] === "on") {
|
|
@@ -7304,7 +7259,7 @@ function socks52(proxy) {
|
|
|
7304
7259
|
);
|
|
7305
7260
|
if (proxy.tls) {
|
|
7306
7261
|
appendTlsProfile(result, proxy);
|
|
7307
|
-
|
|
7262
|
+
appendAlpn2(result, proxy);
|
|
7308
7263
|
}
|
|
7309
7264
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
7310
7265
|
if (proxy["block-quic"] === "on") {
|
|
@@ -7404,7 +7359,7 @@ function hysteria22(proxy) {
|
|
|
7404
7359
|
"skip-cert-verify"
|
|
7405
7360
|
);
|
|
7406
7361
|
appendTlsProfile(result, proxy);
|
|
7407
|
-
|
|
7362
|
+
appendAlpn2(result, proxy);
|
|
7408
7363
|
if (proxy["obfs-password"] && proxy.obfs == "salamander") {
|
|
7409
7364
|
result.append(`,salamander-password=${proxy["obfs-password"]}`);
|
|
7410
7365
|
}
|
|
@@ -7449,7 +7404,8 @@ function getHttpUpgradeEarlyData(transportOpts, path) {
|
|
|
7449
7404
|
const httpUpgradeEd = getSafeEarlyDataValue(
|
|
7450
7405
|
transportOpts?.["_v2ray-http-upgrade-ed"]
|
|
7451
7406
|
);
|
|
7452
|
-
if (httpUpgradeEd !== "")
|
|
7407
|
+
if (httpUpgradeEd !== "")
|
|
7408
|
+
return httpUpgradeEd;
|
|
7453
7409
|
const pathEd = getSafeEarlyDataValue(
|
|
7454
7410
|
extractPathQueryParam(path || "/", "ed").value
|
|
7455
7411
|
);
|
|
@@ -7481,7 +7437,8 @@ function setWebSocketEarlyDataPath(path, transportOpts) {
|
|
|
7481
7437
|
return setPathQueryParam(path || "/", "ed", earlyData);
|
|
7482
7438
|
}
|
|
7483
7439
|
function getSafeEarlyDataValue(value) {
|
|
7484
|
-
if (value == null || `${value}` === "")
|
|
7440
|
+
if (value == null || `${value}` === "")
|
|
7441
|
+
return "";
|
|
7485
7442
|
return parseSafeIntegerValue(value) == null ? "" : `${value}`;
|
|
7486
7443
|
}
|
|
7487
7444
|
function parseIntegerLikeValue(value) {
|
|
@@ -7870,6 +7827,11 @@ function vless2(proxy) {
|
|
|
7870
7827
|
if (proxy["tls-fingerprint"]) {
|
|
7871
7828
|
pcs = `&pcs=${encodeURIComponent(proxy["tls-fingerprint"])}`;
|
|
7872
7829
|
}
|
|
7830
|
+
let vcn = "";
|
|
7831
|
+
const certNames = Array.isArray(proxy._vcn) ? proxy._vcn.join(",") : proxy["name-cert-verify"];
|
|
7832
|
+
if (Array.isArray(proxy._vcn) || certNames) {
|
|
7833
|
+
vcn = `&vcn=${encodeURIComponent(certNames)}`;
|
|
7834
|
+
}
|
|
7873
7835
|
let ech = "";
|
|
7874
7836
|
const echConfigList = buildXrayEchConfigListFromMihomo(
|
|
7875
7837
|
proxy["ech-opts"],
|
|
@@ -8021,7 +7983,7 @@ function vless2(proxy) {
|
|
|
8021
7983
|
}
|
|
8022
7984
|
return `vless://${proxy.uuid}@${proxy.server}:${proxy.port}?security=${encodeURIComponent(
|
|
8023
7985
|
security
|
|
8024
|
-
)}${vlessTransport}${packetEncoding}${alpn}${allowInsecure}${pcs}${ech}${h2}${sni}${fp}${flow}${sid}${spx}${pbk}${mode}${extra}${pqv}${encryption}#${encodeURIComponent(
|
|
7986
|
+
)}${vlessTransport}${packetEncoding}${alpn}${allowInsecure}${pcs}${vcn}${ech}${h2}${sni}${fp}${flow}${sid}${spx}${pbk}${mode}${extra}${pqv}${encryption}#${encodeURIComponent(
|
|
8025
7987
|
proxy.name
|
|
8026
7988
|
)}`;
|
|
8027
7989
|
}
|
|
@@ -8341,6 +8303,11 @@ function URI_Producer() {
|
|
|
8341
8303
|
proxy["tls-fingerprint"]
|
|
8342
8304
|
)}`;
|
|
8343
8305
|
}
|
|
8306
|
+
let trojanVcn = "";
|
|
8307
|
+
const trojanCertNames = Array.isArray(proxy._vcn) ? proxy._vcn.join(",") : proxy["name-cert-verify"];
|
|
8308
|
+
if (Array.isArray(proxy._vcn) || trojanCertNames) {
|
|
8309
|
+
trojanVcn = `&vcn=${encodeURIComponent(trojanCertNames)}`;
|
|
8310
|
+
}
|
|
8344
8311
|
let trojanAlpn = "";
|
|
8345
8312
|
if (proxy.alpn) {
|
|
8346
8313
|
trojanAlpn = `&alpn=${encodeURIComponent(
|
|
@@ -8377,7 +8344,7 @@ function URI_Producer() {
|
|
|
8377
8344
|
trojanMode = `&mode=${encodeURIComponent(proxy._mode)}`;
|
|
8378
8345
|
}
|
|
8379
8346
|
}
|
|
8380
|
-
result = `trojan://${proxy.password}@${proxy.server}:${proxy.port}?sni=${encodeURIComponent(proxy.sni || proxy.server)}${proxy["skip-cert-verify"] ? "&allowInsecure=1" : ""}${trojanTransport}${trojanAlpn}${trojanFp}${trojanPcs}${trojanSecurity}${trojanSid}${trojanPbk}${trojanSpx}${trojanMode}${trojanExtra}#${encodeURIComponent(
|
|
8347
|
+
result = `trojan://${proxy.password}@${proxy.server}:${proxy.port}?sni=${encodeURIComponent(proxy.sni || proxy.server)}${proxy["skip-cert-verify"] ? "&allowInsecure=1" : ""}${trojanTransport}${trojanAlpn}${trojanFp}${trojanPcs}${trojanVcn}${trojanSecurity}${trojanSid}${trojanPbk}${trojanSpx}${trojanMode}${trojanExtra}#${encodeURIComponent(
|
|
8381
8348
|
proxy.name
|
|
8382
8349
|
)}`;
|
|
8383
8350
|
break;
|
|
@@ -8424,6 +8391,14 @@ function URI_Producer() {
|
|
|
8424
8391
|
if (proxy.tfo) {
|
|
8425
8392
|
hysteria2params.push(`fastopen=1`);
|
|
8426
8393
|
}
|
|
8394
|
+
const hysteria2Ech = buildXrayEchConfigListFromMihomo(
|
|
8395
|
+
proxy["ech-opts"]
|
|
8396
|
+
);
|
|
8397
|
+
if (hysteria2Ech) {
|
|
8398
|
+
hysteria2params.push(
|
|
8399
|
+
`ech=${encodeURIComponent(hysteria2Ech)}`
|
|
8400
|
+
);
|
|
8401
|
+
}
|
|
8427
8402
|
result = `hysteria2://${encodeURIComponent(proxy.password)}@${proxy.server}:${proxy.port}?${hysteria2params.join(
|
|
8428
8403
|
"&"
|
|
8429
8404
|
)}#${encodeURIComponent(proxy.name)}`;
|
|
@@ -8793,8 +8768,10 @@ function shadowsocks3(proxy) {
|
|
|
8793
8768
|
}
|
|
8794
8769
|
} else if (proxy.plugin === "v2ray-plugin" && proxy["plugin-opts"].mode === "websocket") {
|
|
8795
8770
|
const opts = proxy["plugin-opts"];
|
|
8796
|
-
if (opts.tls)
|
|
8797
|
-
|
|
8771
|
+
if (opts.tls)
|
|
8772
|
+
append(`,obfs=wss`);
|
|
8773
|
+
else
|
|
8774
|
+
append(`,obfs=ws`);
|
|
8798
8775
|
} else {
|
|
8799
8776
|
throw new Error(`plugin is not supported`);
|
|
8800
8777
|
}
|
|
@@ -8882,8 +8859,10 @@ function trojan3(proxy) {
|
|
|
8882
8859
|
append(`,password=${proxy.password}`);
|
|
8883
8860
|
if (isPresent2(proxy, "network")) {
|
|
8884
8861
|
if (proxy.network === "ws") {
|
|
8885
|
-
if (needTls(proxy))
|
|
8886
|
-
|
|
8862
|
+
if (needTls(proxy))
|
|
8863
|
+
append(`,obfs=wss`);
|
|
8864
|
+
else
|
|
8865
|
+
append(`,obfs=ws`);
|
|
8887
8866
|
appendIfPresent(
|
|
8888
8867
|
`,obfs-uri=${proxy["ws-opts"]?.path}`,
|
|
8889
8868
|
"ws-opts.path"
|
|
@@ -8945,12 +8924,15 @@ function vmess3(proxy) {
|
|
|
8945
8924
|
}
|
|
8946
8925
|
if (isPresent2(proxy, "network")) {
|
|
8947
8926
|
if (proxy.network === "ws") {
|
|
8948
|
-
if (proxy.tls)
|
|
8949
|
-
|
|
8927
|
+
if (proxy.tls)
|
|
8928
|
+
append(`,obfs=wss`);
|
|
8929
|
+
else
|
|
8930
|
+
append(`,obfs=ws`);
|
|
8950
8931
|
} else if (proxy.network === "http") {
|
|
8951
8932
|
append(`,obfs=${getQxHttpObfs(proxy)}`);
|
|
8952
8933
|
} else if (["tcp"].includes(proxy.network)) {
|
|
8953
|
-
if (proxy.tls)
|
|
8934
|
+
if (proxy.tls)
|
|
8935
|
+
append(`,obfs=over-tls`);
|
|
8954
8936
|
} else if (!["tcp"].includes(proxy.network)) {
|
|
8955
8937
|
throw new Error(`network ${proxy.network} is unsupported`);
|
|
8956
8938
|
}
|
|
@@ -8965,7 +8947,8 @@ function vmess3(proxy) {
|
|
|
8965
8947
|
`${proxy.network}-opts.headers.Host`
|
|
8966
8948
|
);
|
|
8967
8949
|
} else {
|
|
8968
|
-
if (proxy.tls)
|
|
8950
|
+
if (proxy.tls)
|
|
8951
|
+
append(`,obfs=over-tls`);
|
|
8969
8952
|
}
|
|
8970
8953
|
if (needTls(proxy)) {
|
|
8971
8954
|
appendIfPresent(
|
|
@@ -9020,12 +9003,15 @@ function vless3(proxy) {
|
|
|
9020
9003
|
}
|
|
9021
9004
|
if (isPresent2(proxy, "network")) {
|
|
9022
9005
|
if (proxy.network === "ws") {
|
|
9023
|
-
if (proxy.tls)
|
|
9024
|
-
|
|
9006
|
+
if (proxy.tls)
|
|
9007
|
+
append(`,obfs=wss`);
|
|
9008
|
+
else
|
|
9009
|
+
append(`,obfs=ws`);
|
|
9025
9010
|
} else if (proxy.network === "http") {
|
|
9026
9011
|
append(`,obfs=${getQxHttpObfs(proxy)}`);
|
|
9027
9012
|
} else if (["tcp"].includes(proxy.network)) {
|
|
9028
|
-
if (proxy.tls)
|
|
9013
|
+
if (proxy.tls)
|
|
9014
|
+
append(`,obfs=over-tls`);
|
|
9029
9015
|
} else if (!["tcp"].includes(proxy.network)) {
|
|
9030
9016
|
throw new Error(`network ${proxy.network} is unsupported`);
|
|
9031
9017
|
}
|
|
@@ -9040,7 +9026,8 @@ function vless3(proxy) {
|
|
|
9040
9026
|
`${proxy.network}-opts.headers.Host`
|
|
9041
9027
|
);
|
|
9042
9028
|
} else {
|
|
9043
|
-
if (proxy.tls)
|
|
9029
|
+
if (proxy.tls)
|
|
9030
|
+
append(`,obfs=over-tls`);
|
|
9044
9031
|
}
|
|
9045
9032
|
if (needTls(proxy)) {
|
|
9046
9033
|
appendIfPresent(
|
|
@@ -9218,7 +9205,8 @@ function Shadowrocket_Producer() {
|
|
|
9218
9205
|
const type = "ALL";
|
|
9219
9206
|
const produce2 = (proxies, type2, opts = {}) => {
|
|
9220
9207
|
const list = proxies.filter((proxy) => {
|
|
9221
|
-
if (opts["include-unsupported-proxy"])
|
|
9208
|
+
if (opts["include-unsupported-proxy"])
|
|
9209
|
+
return true;
|
|
9222
9210
|
if (!supportsShadowsocksV2rayPluginMode(proxy, [
|
|
9223
9211
|
"websocket",
|
|
9224
9212
|
"quic",
|
|
@@ -9229,13 +9217,18 @@ function Shadowrocket_Producer() {
|
|
|
9229
9217
|
return false;
|
|
9230
9218
|
} else if (proxy.type === "snell" && ![1, 2, 3, 4, 5].includes(proxy.version)) {
|
|
9231
9219
|
return false;
|
|
9220
|
+
} else if (hasShadowrocketSnellShadowTlsObfsConflict(proxy)) {
|
|
9221
|
+
app_default.error(
|
|
9222
|
+
`Platform Shadowrocket does not support Snell shadow-tls with obfs for proxy ${proxy.name}. Proxy has been filtered.`
|
|
9223
|
+
);
|
|
9224
|
+
return false;
|
|
9232
9225
|
} else if ([
|
|
9233
9226
|
"tailscale",
|
|
9234
9227
|
"sudoku",
|
|
9235
9228
|
"naive",
|
|
9236
|
-
"masque",
|
|
9237
9229
|
"openvpn",
|
|
9238
|
-
"gost-relay"
|
|
9230
|
+
"gost-relay",
|
|
9231
|
+
"shadowquic"
|
|
9239
9232
|
].includes(proxy.type)) {
|
|
9240
9233
|
return false;
|
|
9241
9234
|
} else if (["xhttp"].includes(proxy.network)) {
|
|
@@ -9292,30 +9285,37 @@ function Shadowrocket_Producer() {
|
|
|
9292
9285
|
proxy["pre-shared-key"] = proxy["preshared-key"];
|
|
9293
9286
|
proxy.ip = getWireGuardAddressWithCIDR(proxy, "ipv4");
|
|
9294
9287
|
proxy.ipv6 = getWireGuardAddressWithCIDR(proxy, "ipv6");
|
|
9295
|
-
} else if (proxy.type === "snell"
|
|
9296
|
-
|
|
9288
|
+
} else if (proxy.type === "snell") {
|
|
9289
|
+
if (proxy.version < 3) {
|
|
9290
|
+
delete proxy.udp;
|
|
9291
|
+
}
|
|
9292
|
+
if (proxy.plugin === "shadow-tls" && proxy["plugin-opts"]) {
|
|
9293
|
+
proxy["obfs-opts"] = {
|
|
9294
|
+
mode: "shadow-tls",
|
|
9295
|
+
host: proxy["plugin-opts"].host,
|
|
9296
|
+
password: proxy["plugin-opts"].password,
|
|
9297
|
+
version: proxy["plugin-opts"].version
|
|
9298
|
+
};
|
|
9299
|
+
if (proxy["plugin-opts"].alpn) {
|
|
9300
|
+
proxy["obfs-opts"].alpn = proxy["plugin-opts"].alpn;
|
|
9301
|
+
}
|
|
9302
|
+
delete proxy.plugin;
|
|
9303
|
+
delete proxy["plugin-opts"];
|
|
9304
|
+
}
|
|
9297
9305
|
} else if (proxy.type === "vless") {
|
|
9298
9306
|
if (isPresent2(proxy, "sni")) {
|
|
9299
9307
|
proxy.servername = proxy.sni;
|
|
9300
9308
|
delete proxy.sni;
|
|
9301
9309
|
}
|
|
9302
9310
|
} 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
9311
|
if (isShadowsocksOverTls(proxy)) {
|
|
9315
9312
|
if (isPresent2(proxy, "sni")) {
|
|
9316
9313
|
proxy.servername = proxy.sni;
|
|
9317
9314
|
}
|
|
9318
9315
|
}
|
|
9316
|
+
} else if (["anytls"].includes(proxy.type) && proxy.reuse != null && !proxy.reuse) {
|
|
9317
|
+
proxy["disable-reuse"] = true;
|
|
9318
|
+
delete proxy.reuse;
|
|
9319
9319
|
}
|
|
9320
9320
|
if (["vmess", "vless"].includes(proxy.type) && proxy.network === "http") {
|
|
9321
9321
|
let httpPath = proxy["http-opts"]?.path;
|
|
@@ -9407,6 +9407,9 @@ function Shadowrocket_Producer() {
|
|
|
9407
9407
|
};
|
|
9408
9408
|
return { type, produce: produce2 };
|
|
9409
9409
|
}
|
|
9410
|
+
function hasShadowrocketSnellShadowTlsObfsConflict(proxy) {
|
|
9411
|
+
return proxy?.type === "snell" && proxy?.plugin === "shadow-tls" && (isPresent2(proxy, "obfs-opts.mode") || isPresent2(proxy, "obfs-opts.host") || isPresent2(proxy, "obfs-opts.path"));
|
|
9412
|
+
}
|
|
9410
9413
|
|
|
9411
9414
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/surfboard.js
|
|
9412
9415
|
var targetPlatform5 = "Surfboard";
|
|
@@ -9468,8 +9471,8 @@ function Surfboard_Producer() {
|
|
|
9468
9471
|
return { produce: produce2 };
|
|
9469
9472
|
}
|
|
9470
9473
|
function hysteria23(proxy) {
|
|
9471
|
-
if (proxy.obfs || proxy["obfs-password"]) {
|
|
9472
|
-
throw new Error(`Surfboard Hysteria2
|
|
9474
|
+
if (proxy.obfs && proxy.obfs !== "salamander" || proxy["obfs-password"] && proxy.obfs !== "salamander") {
|
|
9475
|
+
throw new Error(`Surfboard Hysteria2 only supports salamander obfs`);
|
|
9473
9476
|
}
|
|
9474
9477
|
const result = new Result(proxy);
|
|
9475
9478
|
result.append(`${proxy.name}=hysteria2,${proxy.server},${proxy.port}`);
|
|
@@ -9482,6 +9485,9 @@ function hysteria23(proxy) {
|
|
|
9482
9485
|
if (hasNonBlankValue2(proxy["hop-interval"])) {
|
|
9483
9486
|
result.append(`,port-hopping-interval=${proxy["hop-interval"]}`);
|
|
9484
9487
|
}
|
|
9488
|
+
if (proxy["obfs-password"]) {
|
|
9489
|
+
result.append(`,salamander-password="${proxy["obfs-password"]}"`);
|
|
9490
|
+
}
|
|
9485
9491
|
appendTlsProxyParams2(result, proxy);
|
|
9486
9492
|
result.appendIfPresent(
|
|
9487
9493
|
`,download-bandwidth=${`${proxy["down"]}`.match(/\d+/)?.[0] || 0}`,
|
|
@@ -9693,17 +9699,27 @@ var ipVersionParser = (proxy, parsedProxy) => {
|
|
|
9693
9699
|
}
|
|
9694
9700
|
};
|
|
9695
9701
|
var domainResolverParser = (proxy, parsedProxy) => {
|
|
9696
|
-
if (proxy._domain_resolver) {
|
|
9702
|
+
if (!proxy._domain_resolver) {
|
|
9703
|
+
return;
|
|
9704
|
+
}
|
|
9705
|
+
if (typeof proxy._domain_resolver === "string") {
|
|
9706
|
+
parsedProxy.domain_resolver = {
|
|
9707
|
+
...parsedProxy.domain_resolver ?? {},
|
|
9708
|
+
server: proxy._domain_resolver
|
|
9709
|
+
};
|
|
9710
|
+
} else {
|
|
9697
9711
|
parsedProxy.domain_resolver = {
|
|
9698
|
-
...parsedProxy.domain_resolver,
|
|
9712
|
+
...parsedProxy.domain_resolver ?? {},
|
|
9699
9713
|
...proxy._domain_resolver
|
|
9700
9714
|
};
|
|
9701
9715
|
}
|
|
9702
9716
|
};
|
|
9703
9717
|
var hasControlHTTPClient = (proxy) => {
|
|
9704
9718
|
const value = proxy["control-http-client"];
|
|
9705
|
-
if (value === void 0 || value === null)
|
|
9706
|
-
|
|
9719
|
+
if (value === void 0 || value === null)
|
|
9720
|
+
return false;
|
|
9721
|
+
if (typeof value === "string")
|
|
9722
|
+
return value.trim() !== "";
|
|
9707
9723
|
if (isPlainObject(value)) {
|
|
9708
9724
|
return Object.values(value).some(
|
|
9709
9725
|
(item) => item !== void 0 && item !== null && item !== ""
|
|
@@ -9725,13 +9741,18 @@ var networkParser = (proxy, parsedProxy) => {
|
|
|
9725
9741
|
};
|
|
9726
9742
|
var tfoParser = (proxy, parsedProxy) => {
|
|
9727
9743
|
parsedProxy.tcp_fast_open = false;
|
|
9728
|
-
if (proxy.tfo)
|
|
9729
|
-
|
|
9730
|
-
if (proxy
|
|
9731
|
-
|
|
9744
|
+
if (proxy.tfo)
|
|
9745
|
+
parsedProxy.tcp_fast_open = true;
|
|
9746
|
+
if (proxy.tcp_fast_open)
|
|
9747
|
+
parsedProxy.tcp_fast_open = true;
|
|
9748
|
+
if (proxy["tcp-fast-open"])
|
|
9749
|
+
parsedProxy.tcp_fast_open = true;
|
|
9750
|
+
if (!parsedProxy.tcp_fast_open)
|
|
9751
|
+
delete parsedProxy.tcp_fast_open;
|
|
9732
9752
|
};
|
|
9733
9753
|
var smuxParser = (smux, proxy) => {
|
|
9734
|
-
if (!smux || !smux.enabled)
|
|
9754
|
+
if (!smux || !smux.enabled)
|
|
9755
|
+
return;
|
|
9735
9756
|
proxy.multiplex = { enabled: true };
|
|
9736
9757
|
proxy.multiplex.protocol = smux.protocol;
|
|
9737
9758
|
if (smux["max-connections"])
|
|
@@ -9743,7 +9764,8 @@ var smuxParser = (smux, proxy) => {
|
|
|
9743
9764
|
proxy.multiplex.max_streams = parseInt(`${smux["max-streams"]}`, 10);
|
|
9744
9765
|
if (smux["min-streams"])
|
|
9745
9766
|
proxy.multiplex.min_streams = parseInt(`${smux["min-streams"]}`, 10);
|
|
9746
|
-
if (smux.padding)
|
|
9767
|
+
if (smux.padding)
|
|
9768
|
+
proxy.multiplex.padding = true;
|
|
9747
9769
|
if (smux["brutal-opts"]?.up || smux["brutal-opts"]?.down) {
|
|
9748
9770
|
proxy.multiplex.brutal = {
|
|
9749
9771
|
enabled: true
|
|
@@ -9771,20 +9793,25 @@ var wsParser = (proxy, parsedProxy) => {
|
|
|
9771
9793
|
} = proxy["ws-opts"];
|
|
9772
9794
|
transport.early_data_header_name = early_data_header_name;
|
|
9773
9795
|
transport.max_early_data = max_early_data ? parseInt(max_early_data, 10) : void 0;
|
|
9774
|
-
if (wsPath !== "")
|
|
9796
|
+
if (wsPath !== "")
|
|
9797
|
+
transport.path = `${wsPath}`;
|
|
9775
9798
|
if (Object.keys(wsHeaders).length > 0) {
|
|
9776
9799
|
const headers = {};
|
|
9777
9800
|
for (const key of Object.keys(wsHeaders)) {
|
|
9778
9801
|
let value = wsHeaders[key];
|
|
9779
|
-
if (value === "")
|
|
9780
|
-
|
|
9781
|
-
if (value
|
|
9802
|
+
if (value === "")
|
|
9803
|
+
continue;
|
|
9804
|
+
if (!Array.isArray(value))
|
|
9805
|
+
value = [`${value}`];
|
|
9806
|
+
if (value.length > 0)
|
|
9807
|
+
headers[key] = value;
|
|
9782
9808
|
}
|
|
9783
9809
|
const { Host: wsHost } = headers;
|
|
9784
9810
|
if (wsHost.length === 1)
|
|
9785
9811
|
for (const item of `Host:${wsHost[0]}`.split("\n")) {
|
|
9786
9812
|
const [key, value] = item.split(":");
|
|
9787
|
-
if (value.trim() === "")
|
|
9813
|
+
if (value.trim() === "")
|
|
9814
|
+
continue;
|
|
9788
9815
|
headers[key.trim()] = value.trim().split(",");
|
|
9789
9816
|
}
|
|
9790
9817
|
transport.headers = headers;
|
|
@@ -9794,15 +9821,19 @@ var wsParser = (proxy, parsedProxy) => {
|
|
|
9794
9821
|
const headers = {};
|
|
9795
9822
|
for (const key of Object.keys(proxy["ws-headers"])) {
|
|
9796
9823
|
let value = proxy["ws-headers"][key];
|
|
9797
|
-
if (value === "")
|
|
9798
|
-
|
|
9799
|
-
if (value
|
|
9824
|
+
if (value === "")
|
|
9825
|
+
continue;
|
|
9826
|
+
if (!Array.isArray(value))
|
|
9827
|
+
value = [`${value}`];
|
|
9828
|
+
if (value.length > 0)
|
|
9829
|
+
headers[key] = value;
|
|
9800
9830
|
}
|
|
9801
9831
|
const { Host: wsHost } = headers;
|
|
9802
9832
|
if (wsHost.length === 1)
|
|
9803
9833
|
for (const item of `Host:${wsHost[0]}`.split("\n")) {
|
|
9804
9834
|
const [key, value] = item.split(":");
|
|
9805
|
-
if (value.trim() === "")
|
|
9835
|
+
if (value.trim() === "")
|
|
9836
|
+
continue;
|
|
9806
9837
|
headers[key.trim()] = value.trim().split(",");
|
|
9807
9838
|
}
|
|
9808
9839
|
for (const key of Object.keys(headers))
|
|
@@ -9826,13 +9857,15 @@ var wsParser = (proxy, parsedProxy) => {
|
|
|
9826
9857
|
transport.host = transport.headers.Host[0];
|
|
9827
9858
|
delete transport.headers.Host;
|
|
9828
9859
|
}
|
|
9829
|
-
if (transport.max_early_data)
|
|
9860
|
+
if (transport.max_early_data)
|
|
9861
|
+
delete transport.max_early_data;
|
|
9830
9862
|
if (transport.early_data_header_name)
|
|
9831
9863
|
delete transport.early_data_header_name;
|
|
9832
9864
|
}
|
|
9833
9865
|
for (const key of Object.keys(transport.headers)) {
|
|
9834
9866
|
const value = transport.headers[key];
|
|
9835
|
-
if (value.length === 1)
|
|
9867
|
+
if (value.length === 1)
|
|
9868
|
+
transport.headers[key] = value[0];
|
|
9836
9869
|
}
|
|
9837
9870
|
parsedProxy.transport = transport;
|
|
9838
9871
|
};
|
|
@@ -9844,43 +9877,52 @@ var h1Parser = (proxy, parsedProxy) => {
|
|
|
9844
9877
|
path: h1Path = "",
|
|
9845
9878
|
headers: h1Headers = {}
|
|
9846
9879
|
} = proxy["http-opts"];
|
|
9847
|
-
if (method !== "")
|
|
9880
|
+
if (method !== "")
|
|
9881
|
+
transport.method = method;
|
|
9848
9882
|
if (Array.isArray(h1Path)) {
|
|
9849
9883
|
transport.path = `${h1Path[0]}`;
|
|
9850
|
-
} else if (h1Path !== "")
|
|
9884
|
+
} else if (h1Path !== "")
|
|
9885
|
+
transport.path = `${h1Path}`;
|
|
9851
9886
|
for (const key of Object.keys(h1Headers)) {
|
|
9852
9887
|
let value = h1Headers[key];
|
|
9853
|
-
if (value === "")
|
|
9888
|
+
if (value === "")
|
|
9889
|
+
continue;
|
|
9854
9890
|
if (key.toLowerCase() === "host") {
|
|
9855
9891
|
let host = value;
|
|
9856
9892
|
if (!Array.isArray(host))
|
|
9857
9893
|
host = `${host}`.split(",").map((i) => i.trim());
|
|
9858
|
-
if (host.length > 0)
|
|
9894
|
+
if (host.length > 0)
|
|
9895
|
+
transport.host = host;
|
|
9859
9896
|
continue;
|
|
9860
9897
|
}
|
|
9861
9898
|
if (!Array.isArray(value))
|
|
9862
9899
|
value = `${value}`.split(",").map((i) => i.trim());
|
|
9863
|
-
if (value.length > 0)
|
|
9900
|
+
if (value.length > 0)
|
|
9901
|
+
transport.headers[key] = value;
|
|
9864
9902
|
}
|
|
9865
9903
|
}
|
|
9866
9904
|
if (proxy["http-host"] && proxy["http-host"] !== "") {
|
|
9867
9905
|
let host = proxy["http-host"];
|
|
9868
9906
|
if (!Array.isArray(host))
|
|
9869
9907
|
host = `${host}`.split(",").map((i) => i.trim());
|
|
9870
|
-
if (host.length > 0)
|
|
9908
|
+
if (host.length > 0)
|
|
9909
|
+
transport.host = host;
|
|
9871
9910
|
}
|
|
9872
9911
|
if (proxy["http-path"] && proxy["http-path"] !== "") {
|
|
9873
9912
|
const path = proxy["http-path"];
|
|
9874
9913
|
if (Array.isArray(path)) {
|
|
9875
9914
|
transport.path = `${path[0]}`;
|
|
9876
|
-
} else if (path !== "")
|
|
9915
|
+
} else if (path !== "")
|
|
9916
|
+
transport.path = `${path}`;
|
|
9877
9917
|
}
|
|
9878
9918
|
if (parsedProxy.tls.insecure)
|
|
9879
9919
|
parsedProxy.tls.server_name = transport.host[0];
|
|
9880
|
-
if (transport.host?.length === 1)
|
|
9920
|
+
if (transport.host?.length === 1)
|
|
9921
|
+
transport.host = transport.host[0];
|
|
9881
9922
|
for (const key of Object.keys(transport.headers)) {
|
|
9882
9923
|
const value = transport.headers[key];
|
|
9883
|
-
if (value.length === 1)
|
|
9924
|
+
if (value.length === 1)
|
|
9925
|
+
transport.headers[key] = value[0];
|
|
9884
9926
|
}
|
|
9885
9927
|
parsedProxy.transport = transport;
|
|
9886
9928
|
};
|
|
@@ -9888,25 +9930,29 @@ var h2Parser = (proxy, parsedProxy) => {
|
|
|
9888
9930
|
const transport = { type: "http" };
|
|
9889
9931
|
if (proxy["h2-opts"]) {
|
|
9890
9932
|
let { host = "", path = "" } = proxy["h2-opts"];
|
|
9891
|
-
if (path !== "")
|
|
9933
|
+
if (path !== "")
|
|
9934
|
+
transport.path = `${path}`;
|
|
9892
9935
|
if (host !== "") {
|
|
9893
9936
|
if (!Array.isArray(host))
|
|
9894
9937
|
host = `${host}`.split(",").map((i) => i.trim());
|
|
9895
|
-
if (host.length > 0)
|
|
9938
|
+
if (host.length > 0)
|
|
9939
|
+
transport.host = host;
|
|
9896
9940
|
}
|
|
9897
9941
|
}
|
|
9898
9942
|
if (proxy["h2-host"] && proxy["h2-host"] !== "") {
|
|
9899
9943
|
let host = proxy["h2-host"];
|
|
9900
9944
|
if (!Array.isArray(host))
|
|
9901
9945
|
host = `${host}`.split(",").map((i) => i.trim());
|
|
9902
|
-
if (host.length > 0)
|
|
9946
|
+
if (host.length > 0)
|
|
9947
|
+
transport.host = host;
|
|
9903
9948
|
}
|
|
9904
9949
|
if (proxy["h2-path"] && proxy["h2-path"] !== "")
|
|
9905
9950
|
transport.path = `${proxy["h2-path"]}`;
|
|
9906
9951
|
parsedProxy.tls.enabled = true;
|
|
9907
9952
|
if (parsedProxy.tls.insecure)
|
|
9908
9953
|
parsedProxy.tls.server_name = transport.host[0];
|
|
9909
|
-
if (transport.host.length === 1)
|
|
9954
|
+
if (transport.host.length === 1)
|
|
9955
|
+
transport.host = transport.host[0];
|
|
9910
9956
|
parsedProxy.transport = transport;
|
|
9911
9957
|
};
|
|
9912
9958
|
var grpcParser = (proxy, parsedProxy) => {
|
|
@@ -9923,13 +9969,16 @@ var normalizePemLines = (value, label) => {
|
|
|
9923
9969
|
const lines = [];
|
|
9924
9970
|
for (const item of items) {
|
|
9925
9971
|
const normalized = `${item}`.trim().replace(/\\r\\n/g, "\n").replace(/\\n/g, "\n");
|
|
9926
|
-
if (normalized === "")
|
|
9972
|
+
if (normalized === "")
|
|
9973
|
+
continue;
|
|
9927
9974
|
for (const line of normalized.split(/\r?\n/)) {
|
|
9928
9975
|
const trimmed = line.trim();
|
|
9929
|
-
if (trimmed !== "")
|
|
9976
|
+
if (trimmed !== "")
|
|
9977
|
+
lines.push(trimmed);
|
|
9930
9978
|
}
|
|
9931
9979
|
}
|
|
9932
|
-
if (lines.length === 0)
|
|
9980
|
+
if (lines.length === 0)
|
|
9981
|
+
return void 0;
|
|
9933
9982
|
if (lines.some((line) => /^-----BEGIN [A-Za-z0-9 -]+-----$/.test(line))) {
|
|
9934
9983
|
return lines;
|
|
9935
9984
|
}
|
|
@@ -9949,24 +9998,34 @@ var singBoxUtlsFingerprints = [
|
|
|
9949
9998
|
];
|
|
9950
9999
|
var getSingBoxUtlsFingerprint = (value) => {
|
|
9951
10000
|
const fingerprint = `${value || ""}`.trim().toLowerCase();
|
|
9952
|
-
if (singBoxUtlsFingerprints.includes(fingerprint))
|
|
10001
|
+
if (singBoxUtlsFingerprints.includes(fingerprint))
|
|
10002
|
+
return fingerprint;
|
|
9953
10003
|
};
|
|
9954
10004
|
var tlsParser = (proxy, parsedProxy) => {
|
|
9955
|
-
if (proxy.tls)
|
|
10005
|
+
if (proxy.tls)
|
|
10006
|
+
parsedProxy.tls.enabled = true;
|
|
9956
10007
|
if (proxy.servername && proxy.servername !== "")
|
|
9957
10008
|
parsedProxy.tls.server_name = proxy.servername;
|
|
9958
10009
|
if (proxy.peer && proxy.peer !== "")
|
|
9959
10010
|
parsedProxy.tls.server_name = proxy.peer;
|
|
9960
|
-
if (proxy.sni && proxy.sni !== "")
|
|
9961
|
-
|
|
9962
|
-
if (proxy
|
|
9963
|
-
|
|
10011
|
+
if (proxy.sni && proxy.sni !== "")
|
|
10012
|
+
parsedProxy.tls.server_name = proxy.sni;
|
|
10013
|
+
if (proxy["skip-cert-verify"])
|
|
10014
|
+
parsedProxy.tls.insecure = true;
|
|
10015
|
+
if (proxy.insecure)
|
|
10016
|
+
parsedProxy.tls.insecure = true;
|
|
10017
|
+
if (proxy["disable-sni"])
|
|
10018
|
+
parsedProxy.tls.disable_sni = true;
|
|
9964
10019
|
if (typeof proxy.alpn === "string") {
|
|
9965
10020
|
parsedProxy.tls.alpn = [proxy.alpn];
|
|
9966
|
-
} else if (Array.isArray(proxy.alpn))
|
|
9967
|
-
|
|
9968
|
-
if (proxy.
|
|
9969
|
-
|
|
10021
|
+
} else if (Array.isArray(proxy.alpn))
|
|
10022
|
+
parsedProxy.tls.alpn = proxy.alpn;
|
|
10023
|
+
if (proxy.ca)
|
|
10024
|
+
parsedProxy.tls.certificate_path = `${proxy.ca}`;
|
|
10025
|
+
if (proxy.ca_str)
|
|
10026
|
+
parsedProxy.tls.certificate = [proxy.ca_str];
|
|
10027
|
+
if (proxy["ca-str"])
|
|
10028
|
+
parsedProxy.tls.certificate = [proxy["ca-str"]];
|
|
9970
10029
|
if (proxy["reality-opts"]) {
|
|
9971
10030
|
parsedProxy.tls.reality = { enabled: true };
|
|
9972
10031
|
if (proxy["reality-opts"]["public-key"])
|
|
@@ -9994,7 +10053,8 @@ var tlsParser = (proxy, parsedProxy) => {
|
|
|
9994
10053
|
const echOptsConfig = proxy["ech-opts"].config;
|
|
9995
10054
|
if (Array.isArray(echOptsConfig) || typeof echOptsConfig === "string") {
|
|
9996
10055
|
const config = normalizePemLines(echOptsConfig, "ECH CONFIGS");
|
|
9997
|
-
if (config)
|
|
10056
|
+
if (config)
|
|
10057
|
+
parsedProxy.tls.ech.config = config;
|
|
9998
10058
|
}
|
|
9999
10059
|
parsedProxy.tls.ech.query_server_name = proxy["ech-opts"]["query-server-name"];
|
|
10000
10060
|
parsedProxy.tls.ech.config_path = proxy["ech-opts"]["config-path"];
|
|
@@ -10005,7 +10065,8 @@ var tlsParser = (proxy, parsedProxy) => {
|
|
|
10005
10065
|
if (proxy._curve_preferences && Array.isArray(proxy._curve_preferences)) {
|
|
10006
10066
|
parsedProxy.tls.curve_preferences = proxy._curve_preferences;
|
|
10007
10067
|
}
|
|
10008
|
-
if (proxy["_fragment"])
|
|
10068
|
+
if (proxy["_fragment"])
|
|
10069
|
+
parsedProxy.tls.fragment = !!proxy["_fragment"];
|
|
10009
10070
|
if (proxy["_fragment_fallback_delay"])
|
|
10010
10071
|
parsedProxy.tls.fragment_fallback_delay = proxy["_fragment_fallback_delay"];
|
|
10011
10072
|
if (proxy["_record_fragment"])
|
|
@@ -10020,10 +10081,12 @@ var tlsParser = (proxy, parsedProxy) => {
|
|
|
10020
10081
|
parsedProxy.tls.client_certificate = proxy["_client_certificate"];
|
|
10021
10082
|
if (proxy["_client_certificate_path"])
|
|
10022
10083
|
parsedProxy.tls.client_certificate_path = proxy["_client_certificate_path"];
|
|
10023
|
-
if (proxy["_client_key"])
|
|
10084
|
+
if (proxy["_client_key"])
|
|
10085
|
+
parsedProxy.tls.client_key = proxy["_client_key"];
|
|
10024
10086
|
if (proxy["_client_key_path"])
|
|
10025
10087
|
parsedProxy.tls.client_key_path = proxy["_client_key_path"];
|
|
10026
|
-
if (!parsedProxy.tls.enabled)
|
|
10088
|
+
if (!parsedProxy.tls.enabled)
|
|
10089
|
+
delete parsedProxy.tls;
|
|
10027
10090
|
};
|
|
10028
10091
|
var sshParser = (proxy = {}) => {
|
|
10029
10092
|
const parsedProxy = {
|
|
@@ -10034,9 +10097,12 @@ var sshParser = (proxy = {}) => {
|
|
|
10034
10097
|
};
|
|
10035
10098
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10036
10099
|
throw "invalid port";
|
|
10037
|
-
if (proxy.username)
|
|
10038
|
-
|
|
10039
|
-
if (proxy
|
|
10100
|
+
if (proxy.username)
|
|
10101
|
+
parsedProxy.user = proxy.username;
|
|
10102
|
+
if (proxy.password)
|
|
10103
|
+
parsedProxy.password = proxy.password;
|
|
10104
|
+
if (proxy["privateKey"])
|
|
10105
|
+
parsedProxy.private_key_path = proxy["privateKey"];
|
|
10040
10106
|
if (proxy["private-key"])
|
|
10041
10107
|
parsedProxy.private_key_path = proxy["private-key"];
|
|
10042
10108
|
if (proxy["private-key-passphrase"])
|
|
@@ -10047,10 +10113,12 @@ var sshParser = (proxy = {}) => {
|
|
|
10047
10113
|
proxy["server-fingerprint"].split(" ")[0]
|
|
10048
10114
|
];
|
|
10049
10115
|
}
|
|
10050
|
-
if (proxy["host-key"])
|
|
10116
|
+
if (proxy["host-key"])
|
|
10117
|
+
parsedProxy.host_key = proxy["host-key"];
|
|
10051
10118
|
if (proxy["host-key-algorithms"])
|
|
10052
10119
|
parsedProxy.host_key_algorithms = proxy["host-key-algorithms"];
|
|
10053
|
-
if (proxy["fast-open"])
|
|
10120
|
+
if (proxy["fast-open"])
|
|
10121
|
+
parsedProxy.udp_fragment = true;
|
|
10054
10122
|
tfoParser(proxy, parsedProxy);
|
|
10055
10123
|
detourParser(proxy, parsedProxy);
|
|
10056
10124
|
ipVersionParser(proxy, parsedProxy);
|
|
@@ -10067,8 +10135,10 @@ var httpParser = (proxy = {}) => {
|
|
|
10067
10135
|
};
|
|
10068
10136
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10069
10137
|
throw "invalid port";
|
|
10070
|
-
if (proxy.username)
|
|
10071
|
-
|
|
10138
|
+
if (proxy.username)
|
|
10139
|
+
parsedProxy.username = proxy.username;
|
|
10140
|
+
if (proxy.password)
|
|
10141
|
+
parsedProxy.password = proxy.password;
|
|
10072
10142
|
if (proxy.headers) {
|
|
10073
10143
|
parsedProxy.headers = {};
|
|
10074
10144
|
for (const k of Object.keys(proxy.headers)) {
|
|
@@ -10077,7 +10147,8 @@ var httpParser = (proxy = {}) => {
|
|
|
10077
10147
|
if (Object.keys(parsedProxy.headers).length === 0)
|
|
10078
10148
|
delete parsedProxy.headers;
|
|
10079
10149
|
}
|
|
10080
|
-
if (proxy["fast-open"])
|
|
10150
|
+
if (proxy["fast-open"])
|
|
10151
|
+
parsedProxy.udp_fragment = true;
|
|
10081
10152
|
tfoParser(proxy, parsedProxy);
|
|
10082
10153
|
detourParser(proxy, parsedProxy);
|
|
10083
10154
|
tlsParser(proxy, parsedProxy);
|
|
@@ -10095,16 +10166,20 @@ var socks5Parser = (proxy = {}) => {
|
|
|
10095
10166
|
};
|
|
10096
10167
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10097
10168
|
throw "invalid port";
|
|
10098
|
-
if (proxy.username)
|
|
10099
|
-
|
|
10100
|
-
if (proxy.
|
|
10169
|
+
if (proxy.username)
|
|
10170
|
+
parsedProxy.username = proxy.username;
|
|
10171
|
+
if (proxy.password)
|
|
10172
|
+
parsedProxy.password = proxy.password;
|
|
10173
|
+
if (proxy.uot)
|
|
10174
|
+
parsedProxy.udp_over_tcp = true;
|
|
10101
10175
|
if (proxy["udp-over-tcp"]) {
|
|
10102
10176
|
parsedProxy.udp_over_tcp = {
|
|
10103
10177
|
enabled: true,
|
|
10104
10178
|
version: !proxy["udp-over-tcp-version"] || proxy["udp-over-tcp-version"] === 1 ? 1 : 2
|
|
10105
10179
|
};
|
|
10106
10180
|
}
|
|
10107
|
-
if (proxy["fast-open"])
|
|
10181
|
+
if (proxy["fast-open"])
|
|
10182
|
+
parsedProxy.udp_fragment = true;
|
|
10108
10183
|
networkParser(proxy, parsedProxy);
|
|
10109
10184
|
tfoParser(proxy, parsedProxy);
|
|
10110
10185
|
detourParser(proxy, parsedProxy);
|
|
@@ -10121,7 +10196,8 @@ var shadowTLSParser = (proxy = {}) => {
|
|
|
10121
10196
|
password: proxy.password,
|
|
10122
10197
|
detour: getShadowTLSTag(proxy)
|
|
10123
10198
|
};
|
|
10124
|
-
if (proxy.uot)
|
|
10199
|
+
if (proxy.uot)
|
|
10200
|
+
ssPart.udp_over_tcp = true;
|
|
10125
10201
|
if (proxy["udp-over-tcp"]) {
|
|
10126
10202
|
ssPart.udp_over_tcp = {
|
|
10127
10203
|
enabled: true,
|
|
@@ -10141,11 +10217,12 @@ var getShadowTLSPluginOpts = (proxy = {}) => {
|
|
|
10141
10217
|
if (proxy.plugin === "shadow-tls" && proxy["plugin-opts"]) {
|
|
10142
10218
|
return proxy["plugin-opts"];
|
|
10143
10219
|
}
|
|
10144
|
-
if (proxy
|
|
10220
|
+
if (proxy.type === "snell" && proxy["obfs-opts"]?.mode === "shadow-tls") {
|
|
10145
10221
|
return {
|
|
10146
|
-
host: proxy["
|
|
10147
|
-
password: proxy["
|
|
10148
|
-
version: proxy["
|
|
10222
|
+
host: proxy["obfs-opts"].host,
|
|
10223
|
+
password: proxy["obfs-opts"].password,
|
|
10224
|
+
version: proxy["obfs-opts"].version,
|
|
10225
|
+
alpn: proxy["obfs-opts"].alpn
|
|
10149
10226
|
};
|
|
10150
10227
|
}
|
|
10151
10228
|
return void 0;
|
|
@@ -10154,11 +10231,13 @@ var normalizeALPN = (alpn) => {
|
|
|
10154
10231
|
if (typeof alpn === "string") {
|
|
10155
10232
|
return alpn.split(",").map((item) => item.trim()).filter((item) => item !== "");
|
|
10156
10233
|
}
|
|
10157
|
-
if (Array.isArray(alpn))
|
|
10234
|
+
if (Array.isArray(alpn))
|
|
10235
|
+
return alpn;
|
|
10158
10236
|
return void 0;
|
|
10159
10237
|
};
|
|
10160
10238
|
var shadowTLSOutboundParser = (proxy = {}, pluginOpts) => {
|
|
10161
|
-
if (!pluginOpts)
|
|
10239
|
+
if (!pluginOpts)
|
|
10240
|
+
throw new Error("shadow-tls plugin options are missing");
|
|
10162
10241
|
const fingerprint = getSingBoxUtlsFingerprint(proxy["client-fingerprint"]);
|
|
10163
10242
|
const stPart = {
|
|
10164
10243
|
tag: getShadowTLSTag(proxy),
|
|
@@ -10169,18 +10248,22 @@ var shadowTLSOutboundParser = (proxy = {}, pluginOpts) => {
|
|
|
10169
10248
|
password: pluginOpts.password,
|
|
10170
10249
|
tls: {
|
|
10171
10250
|
enabled: true,
|
|
10172
|
-
server_name: pluginOpts.host
|
|
10173
|
-
utls: {
|
|
10174
|
-
enabled: true,
|
|
10175
|
-
fingerprint
|
|
10176
|
-
}
|
|
10251
|
+
server_name: pluginOpts.host
|
|
10177
10252
|
}
|
|
10178
10253
|
};
|
|
10254
|
+
if (fingerprint) {
|
|
10255
|
+
stPart.tls.utls = {
|
|
10256
|
+
enabled: true,
|
|
10257
|
+
fingerprint
|
|
10258
|
+
};
|
|
10259
|
+
}
|
|
10179
10260
|
if (stPart.server_port < 0 || stPart.server_port > 65535)
|
|
10180
10261
|
throw "\u7AEF\u53E3\u503C\u975E\u6CD5";
|
|
10181
|
-
const alpn = normalizeALPN(pluginOpts.alpn);
|
|
10182
|
-
if (alpn)
|
|
10183
|
-
|
|
10262
|
+
const alpn = normalizeALPN(pluginOpts.alpn) ?? normalizeALPN(proxy.alpn);
|
|
10263
|
+
if (alpn)
|
|
10264
|
+
stPart.tls.alpn = alpn;
|
|
10265
|
+
if (proxy["fast-open"] === true)
|
|
10266
|
+
stPart.udp_fragment = true;
|
|
10184
10267
|
tfoParser(proxy, stPart);
|
|
10185
10268
|
detourParser(proxy, stPart);
|
|
10186
10269
|
ipVersionParser(proxy, stPart);
|
|
@@ -10198,14 +10281,16 @@ var ssParser = (proxy = {}) => {
|
|
|
10198
10281
|
};
|
|
10199
10282
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10200
10283
|
throw "invalid port";
|
|
10201
|
-
if (proxy.uot)
|
|
10284
|
+
if (proxy.uot)
|
|
10285
|
+
parsedProxy.udp_over_tcp = true;
|
|
10202
10286
|
if (proxy["udp-over-tcp"]) {
|
|
10203
10287
|
parsedProxy.udp_over_tcp = {
|
|
10204
10288
|
enabled: true,
|
|
10205
10289
|
version: !proxy["udp-over-tcp-version"] || proxy["udp-over-tcp-version"] === 1 ? 1 : 2
|
|
10206
10290
|
};
|
|
10207
10291
|
}
|
|
10208
|
-
if (proxy["fast-open"])
|
|
10292
|
+
if (proxy["fast-open"])
|
|
10293
|
+
parsedProxy.udp_fragment = true;
|
|
10209
10294
|
networkParser(proxy, parsedProxy);
|
|
10210
10295
|
tfoParser(proxy, parsedProxy);
|
|
10211
10296
|
detourParser(proxy, parsedProxy);
|
|
@@ -10235,12 +10320,15 @@ var ssParser = (proxy = {}) => {
|
|
|
10235
10320
|
}
|
|
10236
10321
|
if (proxy.plugin === "v2ray-plugin") {
|
|
10237
10322
|
parsedProxy.plugin = "v2ray-plugin";
|
|
10238
|
-
if (proxy["ws-host"])
|
|
10239
|
-
|
|
10323
|
+
if (proxy["ws-host"])
|
|
10324
|
+
proxy["plugin-opts"].host = proxy["ws-host"];
|
|
10325
|
+
if (proxy["ws-path"])
|
|
10326
|
+
proxy["plugin-opts"].path = proxy["ws-path"];
|
|
10240
10327
|
Object.keys(proxy["plugin-opts"]).forEach((k) => {
|
|
10241
10328
|
switch (k) {
|
|
10242
10329
|
case "tls":
|
|
10243
|
-
if (proxy["plugin-opts"].tls)
|
|
10330
|
+
if (proxy["plugin-opts"].tls)
|
|
10331
|
+
optArr.push("tls");
|
|
10244
10332
|
break;
|
|
10245
10333
|
case "host":
|
|
10246
10334
|
optArr.push(`host=${proxy["plugin-opts"].host}`);
|
|
@@ -10259,7 +10347,8 @@ var ssParser = (proxy = {}) => {
|
|
|
10259
10347
|
const mux = normalizePluginMuxValue(
|
|
10260
10348
|
proxy["plugin-opts"].mux
|
|
10261
10349
|
);
|
|
10262
|
-
if (mux)
|
|
10350
|
+
if (mux)
|
|
10351
|
+
parsedProxy.multiplex = { enabled: true };
|
|
10263
10352
|
optArr.push(`mux=${mux}`);
|
|
10264
10353
|
break;
|
|
10265
10354
|
}
|
|
@@ -10285,10 +10374,12 @@ var ssrParser = (proxy = {}) => {
|
|
|
10285
10374
|
};
|
|
10286
10375
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10287
10376
|
throw "invalid port";
|
|
10288
|
-
if (proxy["obfs-param"])
|
|
10377
|
+
if (proxy["obfs-param"])
|
|
10378
|
+
parsedProxy.obfs_param = proxy["obfs-param"];
|
|
10289
10379
|
if (proxy["protocol-param"] && proxy["protocol-param"] !== "")
|
|
10290
10380
|
parsedProxy.protocol_param = proxy["protocol-param"];
|
|
10291
|
-
if (proxy["fast-open"])
|
|
10381
|
+
if (proxy["fast-open"])
|
|
10382
|
+
parsedProxy.udp_fragment = true;
|
|
10292
10383
|
networkParser(proxy, parsedProxy);
|
|
10293
10384
|
tfoParser(proxy, parsedProxy);
|
|
10294
10385
|
detourParser(proxy, parsedProxy);
|
|
@@ -10298,19 +10389,23 @@ var ssrParser = (proxy = {}) => {
|
|
|
10298
10389
|
return parsedProxy;
|
|
10299
10390
|
};
|
|
10300
10391
|
var getSnellVersion = (version) => {
|
|
10301
|
-
if (version == null)
|
|
10392
|
+
if (version == null)
|
|
10393
|
+
return void 0;
|
|
10302
10394
|
const normalized = `${version}`.trim();
|
|
10303
|
-
if (!/^\d+$/.test(normalized))
|
|
10395
|
+
if (!/^\d+$/.test(normalized))
|
|
10396
|
+
return NaN;
|
|
10304
10397
|
return parseInt(normalized, 10);
|
|
10305
10398
|
};
|
|
10306
|
-
var snellParser = (proxy = {}) => {
|
|
10399
|
+
var snellParser = (proxy = {}, includeUnsupportedProxy = false) => {
|
|
10307
10400
|
const version = getSnellVersion(proxy.version);
|
|
10308
10401
|
const shadowTLSPluginOpts = getShadowTLSPluginOpts(proxy);
|
|
10309
|
-
|
|
10402
|
+
const supportedVersions = includeUnsupportedProxy ? [1, 2, 3, 4, 5, 6] : [4, 5, 6];
|
|
10403
|
+
if (version != null && (!supportedVersions.includes(version) || Number.isNaN(version))) {
|
|
10310
10404
|
throw new Error(
|
|
10311
10405
|
`Platform sing-box does not support snell version ${proxy.version}`
|
|
10312
10406
|
);
|
|
10313
10407
|
}
|
|
10408
|
+
const outputVersion = !includeUnsupportedProxy && version === 5 ? 4 : version;
|
|
10314
10409
|
const parsedProxy = {
|
|
10315
10410
|
tag: proxy.name,
|
|
10316
10411
|
type: "snell",
|
|
@@ -10320,11 +10415,19 @@ var snellParser = (proxy = {}) => {
|
|
|
10320
10415
|
};
|
|
10321
10416
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10322
10417
|
throw "invalid port";
|
|
10323
|
-
if (
|
|
10324
|
-
|
|
10325
|
-
|
|
10326
|
-
|
|
10327
|
-
|
|
10418
|
+
if (outputVersion != null)
|
|
10419
|
+
parsedProxy.version = outputVersion;
|
|
10420
|
+
if (proxy._userkey)
|
|
10421
|
+
parsedProxy.userkey = proxy._userkey;
|
|
10422
|
+
if (outputVersion === 6) {
|
|
10423
|
+
if (proxy.mode)
|
|
10424
|
+
parsedProxy.mode = proxy.mode;
|
|
10425
|
+
} else {
|
|
10426
|
+
if (proxy["obfs-opts"]?.mode && proxy["obfs-opts"].mode !== "shadow-tls")
|
|
10427
|
+
parsedProxy.obfs_mode = proxy["obfs-opts"].mode;
|
|
10428
|
+
if (proxy["obfs-opts"]?.host && proxy["obfs-opts"]?.mode !== "shadow-tls")
|
|
10429
|
+
parsedProxy.obfs_host = proxy["obfs-opts"].host;
|
|
10430
|
+
}
|
|
10328
10431
|
if (proxy.reuse && (version == null || version >= 4))
|
|
10329
10432
|
parsedProxy.reuse = true;
|
|
10330
10433
|
networkParser(proxy, parsedProxy);
|
|
@@ -10333,7 +10436,8 @@ var snellParser = (proxy = {}) => {
|
|
|
10333
10436
|
delete parsedProxy.server;
|
|
10334
10437
|
delete parsedProxy.server_port;
|
|
10335
10438
|
} else {
|
|
10336
|
-
if (proxy["fast-open"])
|
|
10439
|
+
if (proxy["fast-open"])
|
|
10440
|
+
parsedProxy.udp_fragment = true;
|
|
10337
10441
|
tfoParser(proxy, parsedProxy);
|
|
10338
10442
|
detourParser(proxy, parsedProxy);
|
|
10339
10443
|
ipVersionParser(proxy, parsedProxy);
|
|
@@ -10385,11 +10489,16 @@ var vmessParser = (proxy = {}) => {
|
|
|
10385
10489
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10386
10490
|
throw "invalid port";
|
|
10387
10491
|
vmessProtocolOptionsParser(proxy, parsedProxy);
|
|
10388
|
-
if (proxy["fast-open"])
|
|
10389
|
-
|
|
10390
|
-
if (proxy.network === "
|
|
10391
|
-
|
|
10392
|
-
if (proxy.network === "
|
|
10492
|
+
if (proxy["fast-open"])
|
|
10493
|
+
parsedProxy.udp_fragment = true;
|
|
10494
|
+
if (proxy.network === "ws")
|
|
10495
|
+
wsParser(proxy, parsedProxy);
|
|
10496
|
+
if (proxy.network === "h2")
|
|
10497
|
+
h2Parser(proxy, parsedProxy);
|
|
10498
|
+
if (proxy.network === "http")
|
|
10499
|
+
h1Parser(proxy, parsedProxy);
|
|
10500
|
+
if (proxy.network === "grpc")
|
|
10501
|
+
grpcParser(proxy, parsedProxy);
|
|
10393
10502
|
networkParser(proxy, parsedProxy);
|
|
10394
10503
|
tfoParser(proxy, parsedProxy);
|
|
10395
10504
|
detourParser(proxy, parsedProxy);
|
|
@@ -10411,12 +10520,18 @@ var vlessParser = (proxy = {}) => {
|
|
|
10411
10520
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10412
10521
|
throw "invalid port";
|
|
10413
10522
|
vmessVlessPacketEncodingParser(proxy, parsedProxy);
|
|
10414
|
-
if (proxy["fast-open"])
|
|
10415
|
-
|
|
10416
|
-
if (proxy.
|
|
10417
|
-
|
|
10418
|
-
if (proxy.network === "
|
|
10419
|
-
|
|
10523
|
+
if (proxy["fast-open"])
|
|
10524
|
+
parsedProxy.udp_fragment = true;
|
|
10525
|
+
if (proxy.flow != null)
|
|
10526
|
+
parsedProxy.flow = proxy.flow;
|
|
10527
|
+
if (proxy.network === "ws")
|
|
10528
|
+
wsParser(proxy, parsedProxy);
|
|
10529
|
+
if (proxy.network === "h2")
|
|
10530
|
+
h2Parser(proxy, parsedProxy);
|
|
10531
|
+
if (proxy.network === "http")
|
|
10532
|
+
h1Parser(proxy, parsedProxy);
|
|
10533
|
+
if (proxy.network === "grpc")
|
|
10534
|
+
grpcParser(proxy, parsedProxy);
|
|
10420
10535
|
networkParser(proxy, parsedProxy);
|
|
10421
10536
|
tfoParser(proxy, parsedProxy);
|
|
10422
10537
|
detourParser(proxy, parsedProxy);
|
|
@@ -10437,9 +10552,12 @@ var trojanParser = (proxy = {}) => {
|
|
|
10437
10552
|
};
|
|
10438
10553
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10439
10554
|
throw "invalid port";
|
|
10440
|
-
if (proxy["fast-open"])
|
|
10441
|
-
|
|
10442
|
-
if (proxy.network === "
|
|
10555
|
+
if (proxy["fast-open"])
|
|
10556
|
+
parsedProxy.udp_fragment = true;
|
|
10557
|
+
if (proxy.network === "grpc")
|
|
10558
|
+
grpcParser(proxy, parsedProxy);
|
|
10559
|
+
if (proxy.network === "ws")
|
|
10560
|
+
wsParser(proxy, parsedProxy);
|
|
10443
10561
|
networkParser(proxy, parsedProxy);
|
|
10444
10562
|
tfoParser(proxy, parsedProxy);
|
|
10445
10563
|
detourParser(proxy, parsedProxy);
|
|
@@ -10459,9 +10577,12 @@ var naiveParser = (proxy = {}) => {
|
|
|
10459
10577
|
};
|
|
10460
10578
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10461
10579
|
throw "invalid port";
|
|
10462
|
-
if (proxy.username)
|
|
10463
|
-
|
|
10464
|
-
if (proxy.
|
|
10580
|
+
if (proxy.username)
|
|
10581
|
+
parsedProxy.username = proxy.username;
|
|
10582
|
+
if (proxy.password)
|
|
10583
|
+
parsedProxy.password = proxy.password;
|
|
10584
|
+
if (proxy.uot)
|
|
10585
|
+
parsedProxy.udp_over_tcp = true;
|
|
10465
10586
|
if (proxy["udp-over-tcp"]) {
|
|
10466
10587
|
parsedProxy.udp_over_tcp = {
|
|
10467
10588
|
enabled: true,
|
|
@@ -10476,10 +10597,12 @@ var naiveParser = (proxy = {}) => {
|
|
|
10476
10597
|
parsedProxy.insecure_concurrency = insecure_concurrency;
|
|
10477
10598
|
if (proxy["extra-headers"])
|
|
10478
10599
|
parsedProxy.extra_headers = proxy["extra-headers"];
|
|
10479
|
-
if (proxy.quic)
|
|
10600
|
+
if (proxy.quic)
|
|
10601
|
+
parsedProxy.quic = !!proxy.quic;
|
|
10480
10602
|
if (proxy["quic-congestion-control"])
|
|
10481
10603
|
parsedProxy.quic_congestion_control = proxy["quic-congestion-control"];
|
|
10482
|
-
if (proxy["fast-open"])
|
|
10604
|
+
if (proxy["fast-open"])
|
|
10605
|
+
parsedProxy.udp_fragment = true;
|
|
10483
10606
|
tfoParser(proxy, parsedProxy);
|
|
10484
10607
|
detourParser(proxy, parsedProxy);
|
|
10485
10608
|
tlsParser(proxy, parsedProxy);
|
|
@@ -10512,9 +10635,12 @@ var hysteriaParser = (proxy = {}) => {
|
|
|
10512
10635
|
const range = p.replace(/\s*-\s*/g, ":");
|
|
10513
10636
|
return range.includes(":") ? range : `${range}:${range}`;
|
|
10514
10637
|
});
|
|
10515
|
-
if (proxy.auth_str)
|
|
10516
|
-
|
|
10517
|
-
if (proxy["
|
|
10638
|
+
if (proxy.auth_str)
|
|
10639
|
+
parsedProxy.auth_str = `${proxy.auth_str}`;
|
|
10640
|
+
if (proxy["auth-str"])
|
|
10641
|
+
parsedProxy.auth_str = `${proxy["auth-str"]}`;
|
|
10642
|
+
if (proxy["fast-open"])
|
|
10643
|
+
parsedProxy.udp_fragment = true;
|
|
10518
10644
|
const reg = new RegExp("^[0-9]+[ ]*[KMGT]*[Bb]ps$");
|
|
10519
10645
|
if (reg.test(`${proxy.up}`) && !`${proxy.up}`.endsWith("Mbps")) {
|
|
10520
10646
|
parsedProxy.up = `${proxy.up}`;
|
|
@@ -10526,13 +10652,16 @@ var hysteriaParser = (proxy = {}) => {
|
|
|
10526
10652
|
} else {
|
|
10527
10653
|
parsedProxy.down_mbps = parseInt(`${proxy.down}`, 10);
|
|
10528
10654
|
}
|
|
10529
|
-
if (proxy.obfs)
|
|
10655
|
+
if (proxy.obfs)
|
|
10656
|
+
parsedProxy.obfs = proxy.obfs;
|
|
10530
10657
|
if (proxy.recv_window_conn)
|
|
10531
10658
|
parsedProxy.recv_window_conn = proxy.recv_window_conn;
|
|
10532
10659
|
if (proxy["recv-window-conn"])
|
|
10533
10660
|
parsedProxy.recv_window_conn = proxy["recv-window-conn"];
|
|
10534
|
-
if (proxy.recv_window)
|
|
10535
|
-
|
|
10661
|
+
if (proxy.recv_window)
|
|
10662
|
+
parsedProxy.recv_window = proxy.recv_window;
|
|
10663
|
+
if (proxy["recv-window"])
|
|
10664
|
+
parsedProxy.recv_window = proxy["recv-window"];
|
|
10536
10665
|
if (proxy.disable_mtu_discovery) {
|
|
10537
10666
|
if (typeof proxy.disable_mtu_discovery === "boolean") {
|
|
10538
10667
|
parsedProxy.disable_mtu_discovery = proxy.disable_mtu_discovery;
|
|
@@ -10569,8 +10698,10 @@ var hysteria2Parser = (proxy = {}) => {
|
|
|
10569
10698
|
const range = p.replace(/\s*-\s*/g, ":");
|
|
10570
10699
|
return range.includes(":") ? range : `${range}:${range}`;
|
|
10571
10700
|
});
|
|
10572
|
-
if (proxy.up)
|
|
10573
|
-
|
|
10701
|
+
if (proxy.up)
|
|
10702
|
+
parsedProxy.up_mbps = parseInt(`${proxy.up}`, 10);
|
|
10703
|
+
if (proxy.down)
|
|
10704
|
+
parsedProxy.down_mbps = parseInt(`${proxy.down}`, 10);
|
|
10574
10705
|
if (["salamander", "gecko"].includes(proxy.obfs))
|
|
10575
10706
|
parsedProxy.obfs.type = proxy.obfs;
|
|
10576
10707
|
if (proxy.obfs === "gecko") {
|
|
@@ -10594,14 +10725,17 @@ var hysteria2Parser = (proxy = {}) => {
|
|
|
10594
10725
|
`Invalid obfs packet size for proxy ${proxy.name}: min=${minRaw} max=${maxRaw}`
|
|
10595
10726
|
);
|
|
10596
10727
|
} else {
|
|
10597
|
-
if (hasMin)
|
|
10598
|
-
|
|
10728
|
+
if (hasMin)
|
|
10729
|
+
parsedProxy.obfs.min_packet_size = minPacketSize;
|
|
10730
|
+
if (hasMax)
|
|
10731
|
+
parsedProxy.obfs.max_packet_size = maxPacketSize;
|
|
10599
10732
|
}
|
|
10600
10733
|
}
|
|
10601
10734
|
}
|
|
10602
10735
|
if (proxy["obfs-password"])
|
|
10603
10736
|
parsedProxy.obfs.password = proxy["obfs-password"];
|
|
10604
|
-
if (!parsedProxy.obfs.type)
|
|
10737
|
+
if (!parsedProxy.obfs.type)
|
|
10738
|
+
delete parsedProxy.obfs;
|
|
10605
10739
|
networkParser(proxy, parsedProxy);
|
|
10606
10740
|
tlsParser(proxy, parsedProxy);
|
|
10607
10741
|
tfoParser(proxy, parsedProxy);
|
|
@@ -10623,13 +10757,16 @@ var tuic5Parser = (proxy = {}) => {
|
|
|
10623
10757
|
};
|
|
10624
10758
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10625
10759
|
throw "invalid port";
|
|
10626
|
-
if (proxy["fast-open"])
|
|
10760
|
+
if (proxy["fast-open"])
|
|
10761
|
+
parsedProxy.udp_fragment = true;
|
|
10627
10762
|
if (proxy["congestion-controller"] && proxy["congestion-controller"] !== "cubic")
|
|
10628
10763
|
parsedProxy.congestion_control = proxy["congestion-controller"];
|
|
10629
10764
|
if (proxy["udp-relay-mode"] && proxy["udp-relay-mode"] !== "native")
|
|
10630
10765
|
parsedProxy.udp_relay_mode = proxy["udp-relay-mode"];
|
|
10631
|
-
if (proxy["reduce-rtt"])
|
|
10632
|
-
|
|
10766
|
+
if (proxy["reduce-rtt"])
|
|
10767
|
+
parsedProxy.zero_rtt_handshake = true;
|
|
10768
|
+
if (proxy["udp-over-stream"])
|
|
10769
|
+
parsedProxy.udp_over_stream = true;
|
|
10633
10770
|
if (proxy["heartbeat-interval"])
|
|
10634
10771
|
parsedProxy.heartbeat = `${proxy["heartbeat-interval"]}ms`;
|
|
10635
10772
|
networkParser(proxy, parsedProxy);
|
|
@@ -10659,6 +10796,9 @@ var anytlsParser = (proxy = {}) => {
|
|
|
10659
10796
|
`${proxy["min-idle-session"]}`,
|
|
10660
10797
|
10
|
|
10661
10798
|
);
|
|
10799
|
+
if (proxy["disable-reuse"] != null) {
|
|
10800
|
+
parsedProxy.disable_reuse = !!proxy["disable-reuse"];
|
|
10801
|
+
}
|
|
10662
10802
|
detourParser(proxy, parsedProxy);
|
|
10663
10803
|
tlsParser(proxy, parsedProxy);
|
|
10664
10804
|
ipVersionParser(proxy, parsedProxy);
|
|
@@ -10735,11 +10875,13 @@ var wireguardParser = (proxy = {}) => {
|
|
|
10735
10875
|
};
|
|
10736
10876
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10737
10877
|
throw "invalid port";
|
|
10738
|
-
if (proxy["fast-open"])
|
|
10878
|
+
if (proxy["fast-open"])
|
|
10879
|
+
parsedProxy.udp_fragment = true;
|
|
10739
10880
|
if (typeof proxy.reserved === "string") {
|
|
10740
10881
|
parsedProxy.reserved = proxy.reserved;
|
|
10741
10882
|
} else if (Array.isArray(proxy.reserved)) {
|
|
10742
|
-
for (const r of proxy.reserved)
|
|
10883
|
+
for (const r of proxy.reserved)
|
|
10884
|
+
parsedProxy.reserved.push(r);
|
|
10743
10885
|
} else {
|
|
10744
10886
|
delete parsedProxy.reserved;
|
|
10745
10887
|
}
|
|
@@ -10773,7 +10915,8 @@ var wireguardParser = (proxy = {}) => {
|
|
|
10773
10915
|
if (typeof p.reserved === "string") {
|
|
10774
10916
|
peer.reserved.push(p.reserved);
|
|
10775
10917
|
} else if (Array.isArray(p.reserved)) {
|
|
10776
|
-
for (const r of p.reserved)
|
|
10918
|
+
for (const r of p.reserved)
|
|
10919
|
+
peer.reserved.push(r);
|
|
10777
10920
|
} else {
|
|
10778
10921
|
delete peer.reserved;
|
|
10779
10922
|
}
|
|
@@ -10799,8 +10942,30 @@ function singbox_Producer() {
|
|
|
10799
10942
|
const type = "ALL";
|
|
10800
10943
|
const produce2 = (proxies, type2, opts = {}) => {
|
|
10801
10944
|
const list = [];
|
|
10945
|
+
const originalSnellShadowTLS = new Map(
|
|
10946
|
+
proxies.filter(
|
|
10947
|
+
(proxy) => proxy?.type === "snell" && proxy?.plugin === "shadow-tls" && proxy?.["plugin-opts"]
|
|
10948
|
+
).map((proxy) => [
|
|
10949
|
+
proxy,
|
|
10950
|
+
{
|
|
10951
|
+
plugin: proxy.plugin,
|
|
10952
|
+
"plugin-opts": proxy["plugin-opts"] ? JSON.parse(JSON.stringify(proxy["plugin-opts"])) : void 0,
|
|
10953
|
+
"obfs-opts": proxy["obfs-opts"] ? JSON.parse(JSON.stringify(proxy["obfs-opts"])) : void 0
|
|
10954
|
+
}
|
|
10955
|
+
])
|
|
10956
|
+
);
|
|
10802
10957
|
ClashMeta_Producer().produce(proxies, "internal", { "include-unsupported-proxy": true }).map((proxy) => {
|
|
10803
10958
|
try {
|
|
10959
|
+
const originalShadowTLS = originalSnellShadowTLS.get(proxy);
|
|
10960
|
+
if (originalShadowTLS) {
|
|
10961
|
+
proxy.plugin = originalShadowTLS.plugin;
|
|
10962
|
+
proxy["plugin-opts"] = originalShadowTLS["plugin-opts"];
|
|
10963
|
+
if (originalShadowTLS["obfs-opts"]) {
|
|
10964
|
+
proxy["obfs-opts"] = originalShadowTLS["obfs-opts"];
|
|
10965
|
+
} else {
|
|
10966
|
+
delete proxy["obfs-opts"];
|
|
10967
|
+
}
|
|
10968
|
+
}
|
|
10804
10969
|
if (["xhttp"].includes(proxy.network))
|
|
10805
10970
|
throw new Error(
|
|
10806
10971
|
`Platform sing-box does not support network: ${proxy.network}`
|
|
@@ -10839,24 +11004,24 @@ function singbox_Producer() {
|
|
|
10839
11004
|
);
|
|
10840
11005
|
}
|
|
10841
11006
|
break;
|
|
10842
|
-
case "snell":
|
|
10843
|
-
|
|
10844
|
-
|
|
10845
|
-
|
|
10846
|
-
|
|
10847
|
-
|
|
10848
|
-
|
|
10849
|
-
|
|
10850
|
-
|
|
10851
|
-
|
|
10852
|
-
|
|
10853
|
-
|
|
10854
|
-
|
|
10855
|
-
|
|
10856
|
-
`Platform sing-box does not support proxy type: ${proxy.type}`
|
|
11007
|
+
case "snell": {
|
|
11008
|
+
list.push(
|
|
11009
|
+
snellParser(
|
|
11010
|
+
proxy,
|
|
11011
|
+
opts["include-unsupported-proxy"]
|
|
11012
|
+
)
|
|
11013
|
+
);
|
|
11014
|
+
const shadowTLSPluginOpts = getShadowTLSPluginOpts(proxy);
|
|
11015
|
+
if (shadowTLSPluginOpts) {
|
|
11016
|
+
list.push(
|
|
11017
|
+
shadowTLSOutboundParser(
|
|
11018
|
+
proxy,
|
|
11019
|
+
shadowTLSPluginOpts
|
|
11020
|
+
)
|
|
10857
11021
|
);
|
|
10858
11022
|
}
|
|
10859
11023
|
break;
|
|
11024
|
+
}
|
|
10860
11025
|
case "vmess":
|
|
10861
11026
|
if (!proxy.network || ["tcp", "ws", "grpc", "h2", "http"].includes(
|
|
10862
11027
|
proxy.network
|
|
@@ -10932,7 +11097,8 @@ function singbox_Producer() {
|
|
|
10932
11097
|
app_default.error(e.message ?? e);
|
|
10933
11098
|
}
|
|
10934
11099
|
});
|
|
10935
|
-
if (type2 === "internal")
|
|
11100
|
+
if (type2 === "internal")
|
|
11101
|
+
return list;
|
|
10936
11102
|
const categorized = list.reduce(
|
|
10937
11103
|
(result, item) => {
|
|
10938
11104
|
if (["wireguard", "tailscale"].includes(item.type)) {
|
|
@@ -11009,11 +11175,6 @@ function Egern_Producer() {
|
|
|
11009
11175
|
return false;
|
|
11010
11176
|
} else if (proxy.type === "snell" && normalizeSnellVersion(proxy.version) === null) {
|
|
11011
11177
|
return false;
|
|
11012
|
-
} else if (proxy.type === "snell" && hasShadowTls(proxy)) {
|
|
11013
|
-
app_default.error(
|
|
11014
|
-
`Platform Egern does not support Snell shadow-tls proxy ${proxy.name}. Proxy has been filtered.`
|
|
11015
|
-
);
|
|
11016
|
-
return false;
|
|
11017
11178
|
} else if (["anytls"].includes(proxy.type) && proxy.network && !["tcp"].includes(proxy.network)) {
|
|
11018
11179
|
return false;
|
|
11019
11180
|
} else if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
@@ -11290,7 +11451,8 @@ function Egern_Producer() {
|
|
|
11290
11451
|
}
|
|
11291
11452
|
};
|
|
11292
11453
|
flow = proxy.flow;
|
|
11293
|
-
if (flow === "")
|
|
11454
|
+
if (flow === "")
|
|
11455
|
+
flow = void 0;
|
|
11294
11456
|
}
|
|
11295
11457
|
proxy = {
|
|
11296
11458
|
type: "vless",
|
|
@@ -11378,18 +11540,10 @@ function Egern_Producer() {
|
|
|
11378
11540
|
"vless",
|
|
11379
11541
|
"vmess",
|
|
11380
11542
|
"anytls",
|
|
11381
|
-
"ssh"
|
|
11543
|
+
"ssh",
|
|
11544
|
+
"snell"
|
|
11382
11545
|
].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"]) {
|
|
11546
|
+
if (["shadow-tls"].includes(original.plugin) && original["plugin-opts"]) {
|
|
11393
11547
|
if (original["plugin-opts"].version != 3)
|
|
11394
11548
|
throw new Error(
|
|
11395
11549
|
`shadow-tls version ${original["plugin-opts"].version} is not supported`
|
|
@@ -11488,22 +11642,24 @@ function getTfo(proxy) {
|
|
|
11488
11642
|
function getUdpRelay(proxy) {
|
|
11489
11643
|
return proxy.udp ?? proxy.udp_relay;
|
|
11490
11644
|
}
|
|
11491
|
-
function hasShadowTls(proxy) {
|
|
11492
|
-
return proxy.plugin === "shadow-tls" || isPresent2(proxy, "shadow-tls-password") || isPresent2(proxy, "shadow-tls-sni") || isPresent2(proxy, "shadow-tls-version");
|
|
11493
|
-
}
|
|
11494
11645
|
function getNonEmptyValue(value) {
|
|
11495
|
-
if (value == null)
|
|
11496
|
-
|
|
11646
|
+
if (value == null)
|
|
11647
|
+
return void 0;
|
|
11648
|
+
if (typeof value === "string" && value.length === 0)
|
|
11649
|
+
return void 0;
|
|
11497
11650
|
return value;
|
|
11498
11651
|
}
|
|
11499
11652
|
function getReality(proxy) {
|
|
11500
11653
|
const realityOpts = proxy?.["reality-opts"];
|
|
11501
|
-
if (!realityOpts)
|
|
11654
|
+
if (!realityOpts)
|
|
11655
|
+
return void 0;
|
|
11502
11656
|
const reality = {};
|
|
11503
11657
|
const publicKey = getNonEmptyValue(realityOpts["public-key"]);
|
|
11504
11658
|
const shortId = getNonEmptyValue(realityOpts["short-id"]);
|
|
11505
|
-
if (publicKey != null)
|
|
11506
|
-
|
|
11659
|
+
if (publicKey != null)
|
|
11660
|
+
reality.public_key = publicKey;
|
|
11661
|
+
if (shortId != null)
|
|
11662
|
+
reality.short_id = shortId;
|
|
11507
11663
|
return Object.keys(reality).length > 0 ? reality : void 0;
|
|
11508
11664
|
}
|
|
11509
11665
|
function getGrpcTransport(proxy) {
|
|
@@ -11517,21 +11673,26 @@ function getGrpcTransport(proxy) {
|
|
|
11517
11673
|
};
|
|
11518
11674
|
}
|
|
11519
11675
|
function isEgernGrpcGun(proxy) {
|
|
11520
|
-
if (proxy.network !== "grpc")
|
|
11676
|
+
if (proxy.network !== "grpc")
|
|
11677
|
+
return true;
|
|
11521
11678
|
const grpcType = proxy["grpc-opts"]?.["_grpc-type"];
|
|
11522
|
-
if (grpcType == null)
|
|
11679
|
+
if (grpcType == null)
|
|
11680
|
+
return true;
|
|
11523
11681
|
return `${grpcType}`.trim().toLowerCase() === "gun";
|
|
11524
11682
|
}
|
|
11525
11683
|
function normalizeSnellVersion(version) {
|
|
11526
|
-
if (version == null)
|
|
11684
|
+
if (version == null)
|
|
11685
|
+
return void 0;
|
|
11527
11686
|
const normalized = `${version}`.trim();
|
|
11528
|
-
if (!/^[1-5]$/.test(normalized))
|
|
11687
|
+
if (!/^[1-5]$/.test(normalized))
|
|
11688
|
+
return null;
|
|
11529
11689
|
return parseInt(normalized, 10);
|
|
11530
11690
|
}
|
|
11531
11691
|
function getFirstHeaderValue(headers, ...keys) {
|
|
11532
11692
|
for (const key of keys) {
|
|
11533
11693
|
const value = getFirstValue(headers?.[key]);
|
|
11534
|
-
if (value)
|
|
11694
|
+
if (value)
|
|
11695
|
+
return value;
|
|
11535
11696
|
}
|
|
11536
11697
|
return void 0;
|
|
11537
11698
|
}
|
|
@@ -11542,7 +11703,8 @@ function getH2Headers(h2Opts) {
|
|
|
11542
11703
|
const headers = {};
|
|
11543
11704
|
if (h2Opts?.headers && typeof h2Opts.headers === "object" && !Array.isArray(h2Opts.headers)) {
|
|
11544
11705
|
for (const [key, value] of Object.entries(h2Opts.headers)) {
|
|
11545
|
-
if (/^host$/i.test(key))
|
|
11706
|
+
if (/^host$/i.test(key))
|
|
11707
|
+
continue;
|
|
11546
11708
|
const headerValue = getFirstValue(value);
|
|
11547
11709
|
if (headerValue != null) {
|
|
11548
11710
|
headers[key] = headerValue;
|
|
@@ -11556,13 +11718,16 @@ function getH2Headers(h2Opts) {
|
|
|
11556
11718
|
return Object.keys(headers).length > 0 ? headers : void 0;
|
|
11557
11719
|
}
|
|
11558
11720
|
function getFirstValue(value) {
|
|
11559
|
-
if (Array.isArray(value))
|
|
11560
|
-
|
|
11721
|
+
if (Array.isArray(value))
|
|
11722
|
+
return value[0];
|
|
11723
|
+
if (value != null)
|
|
11724
|
+
return value;
|
|
11561
11725
|
return void 0;
|
|
11562
11726
|
}
|
|
11563
11727
|
function getFingerprintSha256(proxy) {
|
|
11564
11728
|
const fingerprint = proxy?.["tls-fingerprint"];
|
|
11565
|
-
if (typeof fingerprint !== "string")
|
|
11729
|
+
if (typeof fingerprint !== "string")
|
|
11730
|
+
return void 0;
|
|
11566
11731
|
const trimmedFingerprint = fingerprint.trim();
|
|
11567
11732
|
return trimmedFingerprint.length > 0 ? trimmedFingerprint : void 0;
|
|
11568
11733
|
}
|
|
@@ -11572,7 +11737,8 @@ function supportsRootFingerprintSha256(original, proxy) {
|
|
|
11572
11737
|
) || original.type === "socks5" && proxy.type === "socks5_tls" || original.type === "http" && proxy.type === "https";
|
|
11573
11738
|
}
|
|
11574
11739
|
function addTransportFingerprintSha256(transport, fingerprintSha256) {
|
|
11575
|
-
if (!transport)
|
|
11740
|
+
if (!transport)
|
|
11741
|
+
return;
|
|
11576
11742
|
for (const key of ["grpc", "http2", "tls", "wss"]) {
|
|
11577
11743
|
if (transport[key]) {
|
|
11578
11744
|
transport[key].fingerprint_sha256 = fingerprintSha256;
|
|
@@ -11674,7 +11840,8 @@ function parseProxyLines(lines, opts) {
|
|
|
11674
11840
|
const proxyList = [];
|
|
11675
11841
|
let lastParser = null;
|
|
11676
11842
|
for (const line of lines) {
|
|
11677
|
-
if (line.length === 0)
|
|
11843
|
+
if (line.length === 0)
|
|
11844
|
+
continue;
|
|
11678
11845
|
let proxy = null;
|
|
11679
11846
|
if (lastParser) {
|
|
11680
11847
|
proxy = tryParseProxy(lastParser, line);
|