sub-store-convert 2.15.11 → 2.20.29
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/README.md +0 -5
- package/package.json +17 -16
- package/{build → packages/core/build}/index.js +1420 -395
|
@@ -80,7 +80,7 @@ start = (shadowsocks/vmess/trojan/https/http/snell/socks5/socks5_tls/tuic/tuic_v
|
|
|
80
80
|
return proxy;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
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/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/udp_port/others)* {
|
|
83
|
+
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)* {
|
|
84
84
|
proxy.type = "ss";
|
|
85
85
|
// handle obfs
|
|
86
86
|
if (obfs.type == "http" || obfs.type === "tls") {
|
|
@@ -91,36 +91,37 @@ shadowsocks = tag equals "ss" address (method/passwordk/obfs/obfs_host/obfs_uri/
|
|
|
91
91
|
}
|
|
92
92
|
handleShadowTLS();
|
|
93
93
|
}
|
|
94
|
-
vmess = tag equals "vmess" address (vmess_uuid/vmess_aead/ws/ws_path/ws_headers/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/fast_open/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
94
|
+
vmess = tag equals "vmess" address (vmess_uuid/vmess_aead/ws/ws_path/ws_headers/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/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
95
95
|
proxy.type = "vmess";
|
|
96
96
|
proxy.cipher = proxy.cipher || "none";
|
|
97
|
+
// Surfboard 与 Surge 默认不一致, 不管 Surfboard https://getsurfboard.com/docs/profile-format/proxy/external-proxy/vmess
|
|
97
98
|
if (proxy.aead) {
|
|
98
99
|
proxy.alterId = 0;
|
|
99
100
|
} else {
|
|
100
|
-
proxy.alterId =
|
|
101
|
+
proxy.alterId = 1;
|
|
101
102
|
}
|
|
102
103
|
handleWebsocket();
|
|
103
104
|
handleShadowTLS();
|
|
104
105
|
}
|
|
105
|
-
trojan = tag equals "trojan" address (passwordk/ws/ws_path/ws_headers/tls/sni/tls_fingerprint/tls_verification/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
106
|
+
trojan = tag equals "trojan" address (passwordk/ws/ws_path/ws_headers/tls/sni/tls_fingerprint/tls_verification/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)* {
|
|
106
107
|
proxy.type = "trojan";
|
|
107
108
|
handleWebsocket();
|
|
108
109
|
handleShadowTLS();
|
|
109
110
|
}
|
|
110
|
-
https = tag equals "https" address (username password)? (usernamek passwordk)? (sni/tls_fingerprint/tls_verification/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
111
|
+
https = tag equals "https" address (username password)? (usernamek passwordk)? (sni/tls_fingerprint/tls_verification/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)* {
|
|
111
112
|
proxy.type = "http";
|
|
112
113
|
proxy.tls = true;
|
|
113
114
|
handleShadowTLS();
|
|
114
115
|
}
|
|
115
|
-
http = tag equals "http" address (username password)? (usernamek passwordk)? (ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
116
|
+
http = tag equals "http" address (username password)? (usernamek passwordk)? (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)* {
|
|
116
117
|
proxy.type = "http";
|
|
117
118
|
handleShadowTLS();
|
|
118
119
|
}
|
|
119
|
-
ssh = tag equals "ssh" address (username password)? (usernamek passwordk)? (server_fingerprint/idle_timeout/private_key/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
120
|
+
ssh = tag equals "ssh" address (username password)? (usernamek passwordk)? (server_fingerprint/idle_timeout/private_key/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)* {
|
|
120
121
|
proxy.type = "ssh";
|
|
121
122
|
handleShadowTLS();
|
|
122
123
|
}
|
|
123
|
-
snell = tag equals "snell" address (snell_version/snell_psk/obfs/obfs_host/obfs_uri/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/udp_relay/reuse/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
124
|
+
snell = tag equals "snell" address (snell_version/snell_psk/obfs/obfs_host/obfs_uri/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/reuse/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
124
125
|
proxy.type = "snell";
|
|
125
126
|
// handle obfs
|
|
126
127
|
if (obfs.type == "http" || obfs.type === "tls") {
|
|
@@ -147,19 +148,18 @@ hysteria2 = tag equals "hysteria2" address (no_error_alert/ip_version/underlying
|
|
|
147
148
|
proxy.type = "hysteria2";
|
|
148
149
|
handleShadowTLS();
|
|
149
150
|
}
|
|
150
|
-
socks5 = tag equals "socks5" 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/fast_open/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
151
|
+
socks5 = tag equals "socks5" 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/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
151
152
|
proxy.type = "socks5";
|
|
152
153
|
handleShadowTLS();
|
|
153
154
|
}
|
|
154
|
-
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/fast_open/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
155
|
+
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/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
155
156
|
proxy.type = "socks5";
|
|
156
157
|
proxy.tls = true;
|
|
157
158
|
handleShadowTLS();
|
|
158
159
|
}
|
|
159
|
-
direct = tag equals "direct" (udp_relay/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/block_quic/others)* {
|
|
160
|
+
direct = tag equals "direct" (udp_relay/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/block_quic/others)* {
|
|
160
161
|
proxy.type = "direct";
|
|
161
162
|
}
|
|
162
|
-
|
|
163
163
|
address = comma server:server comma port:port {
|
|
164
164
|
proxy.server = server;
|
|
165
165
|
proxy.port = port;
|
|
@@ -217,8 +217,8 @@ username = & {
|
|
|
217
217
|
peg$currPos = end;
|
|
218
218
|
return true;
|
|
219
219
|
}
|
|
220
|
-
} { proxy.username = $.username; }
|
|
221
|
-
password = comma match:[^,]+ { proxy.password = match.join(""); }
|
|
220
|
+
} { proxy.username = $.username.trim().replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
|
221
|
+
password = comma match:[^,]+ { proxy.password = match.join("").replace(/^"(.*)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
|
222
222
|
|
|
223
223
|
tls = comma "tls" equals flag:bool { proxy.tls = flag; }
|
|
224
224
|
sni = comma "sni" equals sni:("off"/domain) {
|
|
@@ -234,7 +234,7 @@ tls_fingerprint = comma "server-cert-fingerprint-sha256" equals tls_fingerprint:
|
|
|
234
234
|
snell_psk = comma "psk" equals match:[^,]+ { proxy.psk = match.join(""); }
|
|
235
235
|
snell_version = comma "version" equals match:$[0-9]+ { proxy.version = parseInt(match.trim()); }
|
|
236
236
|
|
|
237
|
-
usernamek = comma "username" equals match:[^,]+ { proxy.username = match.join(""); }
|
|
237
|
+
usernamek = comma "username" equals match:[^,]+ { proxy.username = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
|
238
238
|
passwordk = comma "password" equals match:[^,]+ { proxy.password = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
|
239
239
|
vmess_uuid = comma "username" equals match:[^,]+ { proxy.uuid = match.join(""); }
|
|
240
240
|
vmess_aead = comma "vmess-aead" equals flag:bool { proxy.aead = flag; }
|
|
@@ -250,11 +250,11 @@ ws_headers = comma "ws-headers" equals headers:$[^,]+ {
|
|
|
250
250
|
const result = {};
|
|
251
251
|
pairs.forEach(pair => {
|
|
252
252
|
const [key, value] = pair.trim().split(":");
|
|
253
|
-
result[key.trim()] = value.trim();
|
|
253
|
+
result[key.trim()] = value.trim().replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1');
|
|
254
254
|
})
|
|
255
255
|
obfs["ws-headers"] = result;
|
|
256
256
|
}
|
|
257
|
-
ws_path = comma "ws-path" equals path:uri { obfs.path = path; }
|
|
257
|
+
ws_path = comma "ws-path" equals path:uri { obfs.path = path.trim().replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
|
258
258
|
|
|
259
259
|
obfs = comma "obfs" equals type:("http"/"tls") { obfs.type = type; }
|
|
260
260
|
obfs_host = comma "obfs-host" equals host:domain { obfs.host = host; };
|
|
@@ -285,7 +285,7 @@ block_quic = comma "block-quic" equals match:[^,]+ { proxy["block-quic"] = match
|
|
|
285
285
|
udp_port = comma "udp-port" equals match:$[0-9]+ { proxy["udp-port"] = parseInt(match.trim()); }
|
|
286
286
|
shadow_tls_version = comma "shadow-tls-version" equals match:$[0-9]+ { proxy["shadow-tls-version"] = parseInt(match.trim()); }
|
|
287
287
|
shadow_tls_sni = comma "shadow-tls-sni" equals match:[^,]+ { proxy["shadow-tls-sni"] = match.join(""); }
|
|
288
|
-
shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { proxy["shadow-tls-password"] = match.join(""); }
|
|
288
|
+
shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { proxy["shadow-tls-password"] = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
|
289
289
|
token = comma "token" equals match:[^,]+ { proxy.token = match.join(""); }
|
|
290
290
|
alpn = comma "alpn" equals match:[^,]+ { proxy.alpn = match.join(""); }
|
|
291
291
|
uuidk = comma "uuid" equals match:[^,]+ { proxy.uuid = match.join(""); }
|
|
@@ -347,12 +347,12 @@ start = (shadowsocksr/shadowsocks/vmess/vless/trojan/https/http/socks5/hysteria2
|
|
|
347
347
|
return proxy;
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
-
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/others)*{
|
|
350
|
+
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)*{
|
|
351
351
|
proxy.type = "ssr";
|
|
352
352
|
// handle ssr obfs
|
|
353
353
|
proxy.obfs = obfs.type;
|
|
354
354
|
}
|
|
355
|
-
shadowsocks = tag equals "shadowsocks"i address method password (obfs_typev obfs_hostv)? (obfs_ss/obfs_host/obfs_uri/fast_open/udp_relay/others)* {
|
|
355
|
+
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/others)* {
|
|
356
356
|
proxy.type = "ss";
|
|
357
357
|
// handle ss obfs
|
|
358
358
|
if (obfs.type == "http" || obfs.type === "tls") {
|
|
@@ -362,31 +362,31 @@ shadowsocks = tag equals "shadowsocks"i address method password (obfs_typev obfs
|
|
|
362
362
|
$set(proxy, "plugin-opts.path", obfs.path);
|
|
363
363
|
}
|
|
364
364
|
}
|
|
365
|
-
vmess = tag equals "vmess"i address method uuid (transport/transport_host/transport_path/over_tls/
|
|
365
|
+
vmess = tag equals "vmess"i address method uuid (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/vmess_alterId/fast_open/udp_relay/ip_mode/public_key/short_id/block_quic/others)* {
|
|
366
366
|
proxy.type = "vmess";
|
|
367
367
|
proxy.cipher = proxy.cipher || "none";
|
|
368
368
|
proxy.alterId = proxy.alterId || 0;
|
|
369
369
|
handleTransport();
|
|
370
370
|
}
|
|
371
|
-
vless = tag equals "vless"i address uuid (transport/transport_host/transport_path/over_tls/
|
|
371
|
+
vless = tag equals "vless"i address uuid (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/flow/public_key/short_id/block_quic/others)* {
|
|
372
372
|
proxy.type = "vless";
|
|
373
373
|
handleTransport();
|
|
374
374
|
}
|
|
375
|
-
trojan = tag equals "trojan"i address password (transport/transport_host/transport_path/over_tls/
|
|
375
|
+
trojan = tag equals "trojan"i address password (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/block_quic/others)* {
|
|
376
376
|
proxy.type = "trojan";
|
|
377
377
|
handleTransport();
|
|
378
378
|
}
|
|
379
|
-
hysteria2 = tag equals "hysteria2"i address password (
|
|
379
|
+
hysteria2 = tag equals "hysteria2"i address password (tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/udp_relay/fast_open/download_bandwidth/salamander_password/ecn/ip_mode/block_quic/others)* {
|
|
380
380
|
proxy.type = "hysteria2";
|
|
381
381
|
}
|
|
382
|
-
https = tag equals "https"i address (username password)? (
|
|
382
|
+
https = tag equals "https"i address (username password)? (tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/block_quic/others)* {
|
|
383
383
|
proxy.type = "http";
|
|
384
384
|
proxy.tls = true;
|
|
385
385
|
}
|
|
386
|
-
http = tag equals "http"i address (username password)? (fast_open/udp_relay/others)* {
|
|
386
|
+
http = tag equals "http"i address (username password)? (fast_open/udp_relay/ip_mode/block_quic/others)* {
|
|
387
387
|
proxy.type = "http";
|
|
388
388
|
}
|
|
389
|
-
socks5 = tag equals "socks5"i address (username password)? (over_tls/
|
|
389
|
+
socks5 = tag equals "socks5"i address (username password)? (over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/block_quic/others)* {
|
|
390
390
|
proxy.type = "socks5";
|
|
391
391
|
}
|
|
392
392
|
|
|
@@ -477,19 +477,32 @@ ssr_protocol_param = comma "protocol-param" equals param:$[^=,]+ { proxy["protoc
|
|
|
477
477
|
|
|
478
478
|
vmess_alterId = comma "alterId" equals alterId:$[0-9]+ { proxy.alterId = parseInt(alterId); }
|
|
479
479
|
|
|
480
|
+
udp_port = comma "udp-port" equals match:$[0-9]+ { proxy["udp-port"] = parseInt(match.trim()); }
|
|
481
|
+
shadow_tls_version = comma "shadow-tls-version" equals match:$[0-9]+ { proxy["shadow-tls-version"] = parseInt(match.trim()); }
|
|
482
|
+
shadow_tls_sni = comma "shadow-tls-sni" equals match:[^,]+ { proxy["shadow-tls-sni"] = match.join(""); }
|
|
483
|
+
shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { proxy["shadow-tls-password"] = match.join(""); }
|
|
484
|
+
|
|
480
485
|
over_tls = comma "over-tls" equals flag:bool { proxy.tls = flag; }
|
|
481
|
-
|
|
486
|
+
tls_name = comma sni:("tls-name") equals host:domain { proxy.sni = host; }
|
|
487
|
+
sni = comma sni:("sni") equals host:domain { proxy.sni = host; }
|
|
482
488
|
tls_verification = comma "skip-cert-verify" equals flag:bool { proxy["skip-cert-verify"] = flag; }
|
|
483
489
|
tls_cert_sha256 = comma "tls-cert-sha256" equals match:[^,]+ { proxy["tls-fingerprint"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
|
484
490
|
tls_pubkey_sha256 = comma "tls-pubkey-sha256" equals match:[^,]+ { proxy["tls-pubkey-sha256"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
|
485
491
|
|
|
492
|
+
flow = comma "flow" equals match:[^,]+ { proxy["flow"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
|
493
|
+
public_key = comma "public-key" equals match:[^,]+ { proxy["reality-opts"] = proxy["reality-opts"] || {}; proxy["reality-opts"]["public-key"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
|
494
|
+
short_id = comma "short-id" equals match:[^,]+ { proxy["reality-opts"] = proxy["reality-opts"] || {}; proxy["reality-opts"]["short-id"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
|
495
|
+
|
|
486
496
|
fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; }
|
|
487
497
|
udp_relay = comma "udp" equals flag:bool { proxy.udp = flag; }
|
|
498
|
+
ip_mode = comma "ip-mode" equals match:[^,]+ { proxy["ip-version"] = match.join(""); }
|
|
488
499
|
|
|
489
500
|
ecn = comma "ecn" equals flag:bool { proxy.ecn = flag; }
|
|
490
501
|
download_bandwidth = comma "download-bandwidth" equals match:[^,]+ { proxy.down = match.join(""); }
|
|
491
502
|
salamander_password = comma "salamander-password" equals match:[^,]+ { proxy['obfs-password'] = match.join(""); proxy.obfs = 'salamander'; }
|
|
492
503
|
|
|
504
|
+
block_quic = comma "block-quic" equals flag:bool { if(flag) proxy["block-quic"] = "on"; else proxy["block-quic"] = "off"; }
|
|
505
|
+
|
|
493
506
|
tag = match:[^=,]* { proxy.name = match.join("").trim(); }
|
|
494
507
|
comma = _ "," _
|
|
495
508
|
equals = _ "=" _
|
|
@@ -557,7 +570,7 @@ trojan = "trojan" equals address
|
|
|
557
570
|
}
|
|
558
571
|
|
|
559
572
|
shadowsocks = "shadowsocks" equals address
|
|
560
|
-
(password/method/obfs_ssr/obfs_ss/obfs_host/obfs_uri/ssr_protocol/ssr_protocol_param/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/udp_relay/
|
|
573
|
+
(password/method/obfs_ssr/obfs_ss/obfs_host/obfs_uri/ssr_protocol/ssr_protocol_param/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/udp_relay/udp_over_tcp_new/fast_open/tag/server_check_url/others)* {
|
|
561
574
|
if (proxy.protocol || proxy.type === "ssr") {
|
|
562
575
|
proxy.type = "ssr";
|
|
563
576
|
if (!proxy.protocol) {
|
|
@@ -594,10 +607,10 @@ vmess = "vmess" equals address
|
|
|
594
607
|
(uuid/method/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/obfs/obfs_host/obfs_uri/udp_relay/udp_over_tcp/fast_open/aead/server_check_url/others)* {
|
|
595
608
|
proxy.type = "vmess";
|
|
596
609
|
proxy.cipher = proxy.cipher || "none";
|
|
597
|
-
if (proxy.aead) {
|
|
598
|
-
proxy.alterId =
|
|
610
|
+
if (proxy.aead === false) {
|
|
611
|
+
proxy.alterId = 1;
|
|
599
612
|
} else {
|
|
600
|
-
proxy.alterId =
|
|
613
|
+
proxy.alterId = 0;
|
|
601
614
|
}
|
|
602
615
|
handleObfs();
|
|
603
616
|
}
|
|
@@ -653,18 +666,20 @@ port = digits:[0-9]+ {
|
|
|
653
666
|
}
|
|
654
667
|
}
|
|
655
668
|
|
|
656
|
-
username = comma "username" equals username:[
|
|
657
|
-
password = comma "password" equals password:[
|
|
658
|
-
uuid = comma "password" equals uuid:[
|
|
669
|
+
username = comma "username" equals username:[^,]+ { proxy.username = username.join("").trim(); }
|
|
670
|
+
password = comma "password" equals password:[^,]+ { proxy.password = password.join("").trim(); }
|
|
671
|
+
uuid = comma "password" equals uuid:[^,]+ { proxy.uuid = uuid.join("").trim(); }
|
|
659
672
|
|
|
660
673
|
method = comma "method" equals cipher:cipher {
|
|
661
674
|
proxy.cipher = cipher;
|
|
662
675
|
};
|
|
663
|
-
cipher = ("aes-128-cfb"/"aes-128-ctr"/"aes-128-gcm"/"aes-192-cfb"/"aes-192-ctr"/"aes-192-gcm"/"aes-256-cfb"/"aes-256-ctr"/"aes-256-gcm"/"bf-cfb"/"cast5-cfb"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"des-cfb"/"none"/"rc2-cfb"/"rc4-md5-6"/"rc4-md5"/"salsa20"/"xchacha20-ietf-poly1305");
|
|
676
|
+
cipher = ("aes-128-cfb"/"aes-128-ctr"/"aes-128-gcm"/"aes-192-cfb"/"aes-192-ctr"/"aes-192-gcm"/"aes-256-cfb"/"aes-256-ctr"/"aes-256-gcm"/"bf-cfb"/"cast5-cfb"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"des-cfb"/"none"/"rc2-cfb"/"rc4-md5-6"/"rc4-md5"/"salsa20"/"xchacha20-ietf-poly1305"/"2022-blake3-aes-128-gcm"/"2022-blake3-aes-256-gcm");
|
|
664
677
|
aead = comma "aead" equals flag:bool { proxy.aead = flag; }
|
|
665
678
|
|
|
666
679
|
udp_relay = comma "udp-relay" equals flag:bool { proxy.udp = flag; }
|
|
667
680
|
udp_over_tcp = comma "udp-over-tcp" equals flag:bool { throw new Error("UDP over TCP is not supported"); }
|
|
681
|
+
udp_over_tcp_new = comma "udp-over-tcp" equals param:$[^=,]+ { if (param === "sp.v1") { proxy["udp-over-tcp"] = true; proxy["udp-over-tcp-version"] = 1; } else if (param === "sp.v2") { proxy["udp-over-tcp"] = true; proxy["udp-over-tcp-version"] = 2; } else if (param === "true") { proxy["_ssr_python_uot"] = true; } else { throw new Error("Invalid value for udp-over-tcp"); } }
|
|
682
|
+
|
|
668
683
|
fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; }
|
|
669
684
|
|
|
670
685
|
over_tls = comma "over-tls" equals flag:bool { proxy.tls = flag; }
|
|
@@ -794,6 +809,9 @@ port = digits:[0-9]+ {
|
|
|
794
809
|
}
|
|
795
810
|
|
|
796
811
|
params = "?" head:param tail:("&"@param)* {
|
|
812
|
+
for (const [key, value] of Object.entries(params)) {
|
|
813
|
+
params[key] = decodeURIComponent(value);
|
|
814
|
+
}
|
|
797
815
|
proxy["skip-cert-verify"] = toBool(params["allowInsecure"]);
|
|
798
816
|
proxy.sni = params["sni"] || params["peer"];
|
|
799
817
|
proxy['client-fingerprint'] = params.fp;
|
|
@@ -829,6 +847,27 @@ params = "?" head:param tail:("&"@param)* {
|
|
|
829
847
|
$set(proxy, proxy.network+"-opts.v2ray-http-upgrade-fast-open", true);
|
|
830
848
|
}
|
|
831
849
|
}
|
|
850
|
+
if (['reality'].includes(params.security)) {
|
|
851
|
+
const opts = {};
|
|
852
|
+
if (params.pbk) {
|
|
853
|
+
opts['public-key'] = params.pbk;
|
|
854
|
+
}
|
|
855
|
+
if (params.sid) {
|
|
856
|
+
opts['short-id'] = params.sid;
|
|
857
|
+
}
|
|
858
|
+
if (params.spx) {
|
|
859
|
+
opts['_spider-x'] = params.spx;
|
|
860
|
+
}
|
|
861
|
+
if (params.mode) {
|
|
862
|
+
proxy._mode = params.mode;
|
|
863
|
+
}
|
|
864
|
+
if (params.extra) {
|
|
865
|
+
proxy._extra = params.extra;
|
|
866
|
+
}
|
|
867
|
+
if (Object.keys(opts).length > 0) {
|
|
868
|
+
$set(proxy, params.security+"-opts", opts);
|
|
869
|
+
}
|
|
870
|
+
}
|
|
832
871
|
}
|
|
833
872
|
|
|
834
873
|
proxy.udp = toBool(params["udp"]);
|
|
@@ -857,6 +896,59 @@ function getParser4() {
|
|
|
857
896
|
return parser4;
|
|
858
897
|
}
|
|
859
898
|
|
|
899
|
+
// src/core/app/index.js
|
|
900
|
+
var app_default = new Proxy(console, {
|
|
901
|
+
get: function(target, prop) {
|
|
902
|
+
if (prop in target) {
|
|
903
|
+
return target[prop];
|
|
904
|
+
}
|
|
905
|
+
return function() {
|
|
906
|
+
return void 0;
|
|
907
|
+
};
|
|
908
|
+
}
|
|
909
|
+
});
|
|
910
|
+
|
|
911
|
+
// src/vendors/Sub-Store/backend/src/core/proxy-utils/parsers/index.js
|
|
912
|
+
import JSON5 from "json5";
|
|
913
|
+
|
|
914
|
+
// src/vendors/Sub-Store/backend/src/utils/yaml.js
|
|
915
|
+
import YAML from "static-js-yaml";
|
|
916
|
+
function retry(fn, content, ...args) {
|
|
917
|
+
try {
|
|
918
|
+
return fn(content, ...args);
|
|
919
|
+
} catch (e) {
|
|
920
|
+
return fn(
|
|
921
|
+
dump(
|
|
922
|
+
fn(
|
|
923
|
+
content.replace(/!<str>\s*/g, "__SubStoreJSYAMLString__"),
|
|
924
|
+
...args
|
|
925
|
+
)
|
|
926
|
+
).replace(/__SubStoreJSYAMLString__/g, ""),
|
|
927
|
+
...args
|
|
928
|
+
);
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
function safeLoad(content, ...args) {
|
|
932
|
+
return retry(YAML.safeLoad, JSON.parse(JSON.stringify(content)), ...args);
|
|
933
|
+
}
|
|
934
|
+
function load(content, ...args) {
|
|
935
|
+
return retry(YAML.load, JSON.parse(JSON.stringify(content)), ...args);
|
|
936
|
+
}
|
|
937
|
+
function safeDump(content, ...args) {
|
|
938
|
+
return YAML.safeDump(JSON.parse(JSON.stringify(content)), ...args);
|
|
939
|
+
}
|
|
940
|
+
function dump(content, ...args) {
|
|
941
|
+
return YAML.dump(JSON.parse(JSON.stringify(content)), ...args);
|
|
942
|
+
}
|
|
943
|
+
var yaml_default = {
|
|
944
|
+
safeLoad,
|
|
945
|
+
load,
|
|
946
|
+
safeDump,
|
|
947
|
+
dump,
|
|
948
|
+
parse: safeLoad,
|
|
949
|
+
stringify: safeDump
|
|
950
|
+
};
|
|
951
|
+
|
|
860
952
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/parsers/index.js
|
|
861
953
|
import { Base64 } from "js-base64";
|
|
862
954
|
function surge_port_hopping(raw) {
|
|
@@ -875,8 +967,21 @@ function URI_PROXY() {
|
|
|
875
967
|
};
|
|
876
968
|
const parse = (line) => {
|
|
877
969
|
let [__, type, tls, username, password, server, port, query, name2] = line.match(
|
|
878
|
-
/^(socks5|http|http)(\+tls|s)?:\/\/(?:(.*?):(.*?)@)?(.*?)
|
|
970
|
+
/^(socks5|http|http)(\+tls|s)?:\/\/(?:(.*?):(.*?)@)?(.*?)(?::(\d+?))?\/?(\?.*?)?(?:#(.*?))?$/
|
|
879
971
|
);
|
|
972
|
+
if (port) {
|
|
973
|
+
port = parseInt(port, 10);
|
|
974
|
+
} else {
|
|
975
|
+
if (tls) {
|
|
976
|
+
port = 443;
|
|
977
|
+
} else if (type === "http") {
|
|
978
|
+
port = 80;
|
|
979
|
+
} else {
|
|
980
|
+
app_default.error(`port is not present in line: ${line}`);
|
|
981
|
+
throw new Error(`port is not present in line: ${line}`);
|
|
982
|
+
}
|
|
983
|
+
app_default.info(`port is not present in line: ${line}, set to ${port}`);
|
|
984
|
+
}
|
|
880
985
|
const proxy = {
|
|
881
986
|
name: name2 != null ? decodeURIComponent(name2) : `${type} ${server}:${port}`,
|
|
882
987
|
type,
|
|
@@ -890,6 +995,39 @@ function URI_PROXY() {
|
|
|
890
995
|
};
|
|
891
996
|
return { name, test, parse };
|
|
892
997
|
}
|
|
998
|
+
function URI_SOCKS() {
|
|
999
|
+
const name = "URI SOCKS Parser";
|
|
1000
|
+
const test = (line) => {
|
|
1001
|
+
return /^socks:\/\//.test(line);
|
|
1002
|
+
};
|
|
1003
|
+
const parse = (line) => {
|
|
1004
|
+
let [__, type, auth, server, port, query, name2] = line.match(
|
|
1005
|
+
/^(socks)?:\/\/(?:(.*)@)?(.*?)(?::(\d+?))?(\?.*?)?(?:#(.*?))?$/
|
|
1006
|
+
);
|
|
1007
|
+
if (port) {
|
|
1008
|
+
port = parseInt(port, 10);
|
|
1009
|
+
} else {
|
|
1010
|
+
app_default.error(`port is not present in line: ${line}`);
|
|
1011
|
+
throw new Error(`port is not present in line: ${line}`);
|
|
1012
|
+
}
|
|
1013
|
+
let username, password;
|
|
1014
|
+
if (auth) {
|
|
1015
|
+
const parsed = Base64.decode(decodeURIComponent(auth)).split(":");
|
|
1016
|
+
username = parsed[0];
|
|
1017
|
+
password = parsed[1];
|
|
1018
|
+
}
|
|
1019
|
+
const proxy = {
|
|
1020
|
+
name: name2 != null ? decodeURIComponent(name2) : `${type} ${server}:${port}`,
|
|
1021
|
+
type: "socks5",
|
|
1022
|
+
server,
|
|
1023
|
+
port,
|
|
1024
|
+
username,
|
|
1025
|
+
password
|
|
1026
|
+
};
|
|
1027
|
+
return proxy;
|
|
1028
|
+
};
|
|
1029
|
+
return { name, test, parse };
|
|
1030
|
+
}
|
|
893
1031
|
function URI_SS() {
|
|
894
1032
|
const name = "URI SS Parser";
|
|
895
1033
|
const test = (line) => {
|
|
@@ -897,12 +1035,12 @@ function URI_SS() {
|
|
|
897
1035
|
};
|
|
898
1036
|
const parse = (line) => {
|
|
899
1037
|
let content = line.split("ss://")[1];
|
|
1038
|
+
let name2 = line.split("#")[1];
|
|
900
1039
|
const proxy = {
|
|
901
|
-
name: decodeURIComponent(line.split("#")[1]),
|
|
902
1040
|
type: "ss"
|
|
903
1041
|
};
|
|
904
1042
|
content = content.split("#")[0];
|
|
905
|
-
let serverAndPortArray = content.match(/@([
|
|
1043
|
+
let serverAndPortArray = content.match(/@([^/?]*)(\/|\?|$)/);
|
|
906
1044
|
let rawUserInfoStr = decodeURIComponent(content.split("@")[0]);
|
|
907
1045
|
let userInfoStr;
|
|
908
1046
|
if (rawUserInfoStr?.startsWith("2022-blake3-")) {
|
|
@@ -931,8 +1069,11 @@ function URI_SS() {
|
|
|
931
1069
|
}
|
|
932
1070
|
content = `${content}${query}`;
|
|
933
1071
|
}
|
|
934
|
-
userInfoStr = content.
|
|
935
|
-
serverAndPortArray = content.match(/@([
|
|
1072
|
+
userInfoStr = content.match(/(^.*)@/)?.[1];
|
|
1073
|
+
serverAndPortArray = content.match(/@([^/@]*)(\/|$)/);
|
|
1074
|
+
} else if (content.includes("?")) {
|
|
1075
|
+
const parsed = content.match(/(\?.*)$/);
|
|
1076
|
+
query = parsed[1];
|
|
936
1077
|
}
|
|
937
1078
|
const serverAndPort = serverAndPortArray[1];
|
|
938
1079
|
const portIdx = serverAndPort.lastIndexOf(":");
|
|
@@ -943,9 +1084,10 @@ function URI_SS() {
|
|
|
943
1084
|
let userInfo = userInfoStr.match(/(^.*?):(.*$)/);
|
|
944
1085
|
proxy.cipher = userInfo?.[1];
|
|
945
1086
|
proxy.password = userInfo?.[2];
|
|
946
|
-
const
|
|
947
|
-
|
|
948
|
-
|
|
1087
|
+
const pluginMatch = content.match(/[?&]plugin=([^&]+)/);
|
|
1088
|
+
const shadowTlsMatch = content.match(/[?&]shadow-tls=([^&]+)/);
|
|
1089
|
+
if (pluginMatch) {
|
|
1090
|
+
const pluginInfo = ("plugin=" + decodeURIComponent(pluginMatch[1])).split(";");
|
|
949
1091
|
const params = {};
|
|
950
1092
|
for (const item of pluginInfo) {
|
|
951
1093
|
const [key, val] = item.split("=");
|
|
@@ -969,18 +1111,50 @@ function URI_SS() {
|
|
|
969
1111
|
tls: getIfPresent(params.tls)
|
|
970
1112
|
};
|
|
971
1113
|
break;
|
|
1114
|
+
case "shadow-tls": {
|
|
1115
|
+
proxy.plugin = "shadow-tls";
|
|
1116
|
+
const version = getIfNotBlank(params["version"]);
|
|
1117
|
+
proxy["plugin-opts"] = {
|
|
1118
|
+
host: getIfNotBlank(params["host"]),
|
|
1119
|
+
password: getIfNotBlank(params["password"]),
|
|
1120
|
+
version: version ? parseInt(version, 10) : void 0
|
|
1121
|
+
};
|
|
1122
|
+
break;
|
|
1123
|
+
}
|
|
972
1124
|
default:
|
|
973
1125
|
throw new Error(
|
|
974
1126
|
`Unsupported plugin option: ${params.plugin}`
|
|
975
1127
|
);
|
|
976
1128
|
}
|
|
977
1129
|
}
|
|
1130
|
+
if (shadowTlsMatch) {
|
|
1131
|
+
const params = JSON.parse(Base64.decode(shadowTlsMatch[1]));
|
|
1132
|
+
const version = getIfNotBlank(params["version"]);
|
|
1133
|
+
const address = getIfNotBlank(params["address"]);
|
|
1134
|
+
const port = getIfNotBlank(params["port"]);
|
|
1135
|
+
proxy.plugin = "shadow-tls";
|
|
1136
|
+
proxy["plugin-opts"] = {
|
|
1137
|
+
host: getIfNotBlank(params["host"]),
|
|
1138
|
+
password: getIfNotBlank(params["password"]),
|
|
1139
|
+
version: version ? parseInt(version, 10) : void 0
|
|
1140
|
+
};
|
|
1141
|
+
if (address) {
|
|
1142
|
+
proxy.server = address;
|
|
1143
|
+
}
|
|
1144
|
+
if (port) {
|
|
1145
|
+
proxy.port = parseInt(port, 10);
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
978
1148
|
if (/(&|\?)uot=(1|true)/i.test(query)) {
|
|
979
1149
|
proxy["udp-over-tcp"] = true;
|
|
980
1150
|
}
|
|
981
1151
|
if (/(&|\?)tfo=(1|true)/i.test(query)) {
|
|
982
1152
|
proxy.tfo = true;
|
|
983
1153
|
}
|
|
1154
|
+
if (name2 != null) {
|
|
1155
|
+
name2 = decodeURIComponent(name2);
|
|
1156
|
+
}
|
|
1157
|
+
proxy.name = name2 ?? `SS ${proxy.server}:${proxy.port}`;
|
|
984
1158
|
return proxy;
|
|
985
1159
|
};
|
|
986
1160
|
return { name, test, parse };
|
|
@@ -1046,7 +1220,7 @@ function URI_VMess() {
|
|
|
1046
1220
|
};
|
|
1047
1221
|
const parse = (line) => {
|
|
1048
1222
|
line = line.split("vmess://")[1];
|
|
1049
|
-
let content = Base64.decode(line);
|
|
1223
|
+
let content = Base64.decode(line.replace(/\?.*?$/, ""));
|
|
1050
1224
|
if (/=\s*vmess/.test(content)) {
|
|
1051
1225
|
const partitions = content.split(",").map((p) => p.trim());
|
|
1052
1226
|
const params = {};
|
|
@@ -1105,9 +1279,9 @@ function URI_VMess() {
|
|
|
1105
1279
|
params[key] = value.split(",");
|
|
1106
1280
|
}
|
|
1107
1281
|
}
|
|
1108
|
-
let [___, cipher,
|
|
1282
|
+
let [___, cipher, uuid2, server2, port2] = /(^[^:]+?):([^:]+?)@(.*):(\d+)$/.exec(content);
|
|
1109
1283
|
params.scy = cipher;
|
|
1110
|
-
params.id =
|
|
1284
|
+
params.id = uuid2;
|
|
1111
1285
|
params.port = port2;
|
|
1112
1286
|
params.add = server2;
|
|
1113
1287
|
}
|
|
@@ -1118,7 +1292,14 @@ function URI_VMess() {
|
|
|
1118
1292
|
type: "vmess",
|
|
1119
1293
|
server,
|
|
1120
1294
|
port,
|
|
1121
|
-
|
|
1295
|
+
// https://github.com/2dust/v2rayN/wiki/Description-of-VMess-share-link
|
|
1296
|
+
// https://github.com/XTLS/Xray-core/issues/91
|
|
1297
|
+
cipher: [
|
|
1298
|
+
"auto",
|
|
1299
|
+
"aes-128-gcm",
|
|
1300
|
+
"chacha20-poly1305",
|
|
1301
|
+
"none"
|
|
1302
|
+
].includes(params.scy) ? params.scy : "auto",
|
|
1122
1303
|
uuid: params.id,
|
|
1123
1304
|
alterId: parseInt(
|
|
1124
1305
|
getIfPresent(params.aid ?? params.alterId, 0),
|
|
@@ -1132,16 +1313,20 @@ function URI_VMess() {
|
|
|
1132
1313
|
params.allowInsecure
|
|
1133
1314
|
);
|
|
1134
1315
|
}
|
|
1135
|
-
if (proxy.tls
|
|
1136
|
-
|
|
1316
|
+
if (proxy.tls) {
|
|
1317
|
+
if (params.sni && params.sni !== "") {
|
|
1318
|
+
proxy.sni = params.sni;
|
|
1319
|
+
} else if (params.peer && params.peer !== "") {
|
|
1320
|
+
proxy.sni = params.peer;
|
|
1321
|
+
}
|
|
1137
1322
|
}
|
|
1138
1323
|
let httpupgrade = false;
|
|
1139
1324
|
if (params.net === "ws" || params.obfs === "websocket") {
|
|
1140
1325
|
proxy.network = "ws";
|
|
1141
1326
|
} else if (["http"].includes(params.net) || ["http"].includes(params.obfs) || ["http"].includes(params.type)) {
|
|
1142
1327
|
proxy.network = "http";
|
|
1143
|
-
} else if (["grpc"].includes(params.net)) {
|
|
1144
|
-
proxy.network =
|
|
1328
|
+
} else if (["grpc", "kcp", "quic"].includes(params.net)) {
|
|
1329
|
+
proxy.network = params.net;
|
|
1145
1330
|
} else if (params.net === "httpupgrade" || proxy.network === "httpupgrade") {
|
|
1146
1331
|
proxy.network = "ws";
|
|
1147
1332
|
httpupgrade = true;
|
|
@@ -1159,6 +1344,9 @@ function URI_VMess() {
|
|
|
1159
1344
|
} catch (e) {
|
|
1160
1345
|
}
|
|
1161
1346
|
let transportPath = params.path;
|
|
1347
|
+
if (["ws"].includes(proxy.network)) {
|
|
1348
|
+
transportPath = transportPath || "/";
|
|
1349
|
+
}
|
|
1162
1350
|
if (proxy.network === "http") {
|
|
1163
1351
|
if (transportHost) {
|
|
1164
1352
|
transportHost = transportHost.split(",").map((i) => i.trim());
|
|
@@ -1170,13 +1358,23 @@ function URI_VMess() {
|
|
|
1170
1358
|
transportPath = "/";
|
|
1171
1359
|
}
|
|
1172
1360
|
}
|
|
1173
|
-
if (transportPath || transportHost) {
|
|
1361
|
+
if (transportPath || transportHost || ["kcp", "quic"].includes(proxy.network)) {
|
|
1174
1362
|
if (["grpc"].includes(proxy.network)) {
|
|
1175
1363
|
proxy[`${proxy.network}-opts`] = {
|
|
1176
1364
|
"grpc-service-name": getIfNotBlank(transportPath),
|
|
1177
1365
|
"_grpc-type": getIfNotBlank(params.type),
|
|
1178
1366
|
"_grpc-authority": getIfNotBlank(params.authority)
|
|
1179
1367
|
};
|
|
1368
|
+
} else if (["kcp", "quic"].includes(proxy.network)) {
|
|
1369
|
+
proxy[`${proxy.network}-opts`] = {
|
|
1370
|
+
[`_${proxy.network}-type`]: getIfNotBlank(
|
|
1371
|
+
params.type
|
|
1372
|
+
),
|
|
1373
|
+
[`_${proxy.network}-host`]: getIfNotBlank(
|
|
1374
|
+
getIfNotBlank(transportHost)
|
|
1375
|
+
),
|
|
1376
|
+
[`_${proxy.network}-path`]: getIfNotBlank(transportPath)
|
|
1377
|
+
};
|
|
1180
1378
|
} else {
|
|
1181
1379
|
const opts = {
|
|
1182
1380
|
path: getIfNotBlank(transportPath),
|
|
@@ -1192,6 +1390,8 @@ function URI_VMess() {
|
|
|
1192
1390
|
delete proxy.network;
|
|
1193
1391
|
}
|
|
1194
1392
|
}
|
|
1393
|
+
proxy["client-fingerprint"] = params.fp;
|
|
1394
|
+
proxy.alpn = params.alpn ? params.alpn.split(",") : void 0;
|
|
1195
1395
|
return proxy;
|
|
1196
1396
|
}
|
|
1197
1397
|
};
|
|
@@ -1212,12 +1412,12 @@ function URI_VLESS() {
|
|
|
1212
1412
|
parsed = /^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
1213
1413
|
isShadowrocket = true;
|
|
1214
1414
|
}
|
|
1215
|
-
let [__,
|
|
1415
|
+
let [__, uuid2, server, port, ___, addons = "", name2] = parsed;
|
|
1216
1416
|
if (isShadowrocket) {
|
|
1217
|
-
|
|
1417
|
+
uuid2 = uuid2.replace(/^.*?:/g, "");
|
|
1218
1418
|
}
|
|
1219
1419
|
port = parseInt(`${port}`, 10);
|
|
1220
|
-
|
|
1420
|
+
uuid2 = decodeURIComponent(uuid2);
|
|
1221
1421
|
if (name2 != null) {
|
|
1222
1422
|
name2 = decodeURIComponent(name2);
|
|
1223
1423
|
}
|
|
@@ -1226,14 +1426,16 @@ function URI_VLESS() {
|
|
|
1226
1426
|
name: name2,
|
|
1227
1427
|
server,
|
|
1228
1428
|
port,
|
|
1229
|
-
uuid
|
|
1429
|
+
uuid: uuid2
|
|
1230
1430
|
};
|
|
1231
1431
|
const params = {};
|
|
1232
1432
|
for (const addon of addons.split("&")) {
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1433
|
+
if (addon) {
|
|
1434
|
+
const [key, valueRaw] = addon.split("=");
|
|
1435
|
+
let value = valueRaw;
|
|
1436
|
+
value = decodeURIComponent(valueRaw);
|
|
1437
|
+
params[key] = value;
|
|
1438
|
+
}
|
|
1237
1439
|
}
|
|
1238
1440
|
proxy.name = name2 ?? params.remarks ?? params.remark ?? `VLESS ${server}:${port}`;
|
|
1239
1441
|
proxy.tls = params.security && params.security !== "none";
|
|
@@ -1260,6 +1462,9 @@ function URI_VLESS() {
|
|
|
1260
1462
|
if (params.sid) {
|
|
1261
1463
|
opts["short-id"] = params.sid;
|
|
1262
1464
|
}
|
|
1465
|
+
if (params.spx) {
|
|
1466
|
+
opts["_spider-x"] = params.spx;
|
|
1467
|
+
}
|
|
1263
1468
|
if (Object.keys(opts).length > 0) {
|
|
1264
1469
|
proxy[`${params.security}-opts`] = opts;
|
|
1265
1470
|
}
|
|
@@ -1274,6 +1479,9 @@ function URI_VLESS() {
|
|
|
1274
1479
|
}
|
|
1275
1480
|
if (!proxy.network && isShadowrocket && params.obfs) {
|
|
1276
1481
|
proxy.network = params.obfs;
|
|
1482
|
+
if (["none"].includes(proxy.network)) {
|
|
1483
|
+
proxy.network = "tcp";
|
|
1484
|
+
}
|
|
1277
1485
|
}
|
|
1278
1486
|
if (["websocket"].includes(proxy.network)) {
|
|
1279
1487
|
proxy.network = "ws";
|
|
@@ -1323,6 +1531,70 @@ function URI_VLESS() {
|
|
|
1323
1531
|
}
|
|
1324
1532
|
proxy.headerType = params.headerType || "none";
|
|
1325
1533
|
}
|
|
1534
|
+
if (params.mode) {
|
|
1535
|
+
proxy._mode = params.mode;
|
|
1536
|
+
}
|
|
1537
|
+
if (params.extra) {
|
|
1538
|
+
proxy._extra = params.extra;
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
if (params.encryption) {
|
|
1542
|
+
proxy.encryption = params.encryption;
|
|
1543
|
+
}
|
|
1544
|
+
if (params.pqv) {
|
|
1545
|
+
proxy._pqv = params.pqv;
|
|
1546
|
+
}
|
|
1547
|
+
return proxy;
|
|
1548
|
+
};
|
|
1549
|
+
return { name, test, parse };
|
|
1550
|
+
}
|
|
1551
|
+
function URI_AnyTLS() {
|
|
1552
|
+
const name = "URI AnyTLS Parser";
|
|
1553
|
+
const test = (line) => {
|
|
1554
|
+
return /^anytls:\/\//.test(line);
|
|
1555
|
+
};
|
|
1556
|
+
const parse = (line) => {
|
|
1557
|
+
const parsed = URI_VLESS().parse(line.replace("anytls", "vless"));
|
|
1558
|
+
line = line.split(/anytls:\/\//)[1];
|
|
1559
|
+
let [__, password, server, port, addons = "", name2] = /^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
1560
|
+
password = decodeURIComponent(password);
|
|
1561
|
+
port = parseInt(`${port}`, 10);
|
|
1562
|
+
if (isNaN(port)) {
|
|
1563
|
+
port = 443;
|
|
1564
|
+
}
|
|
1565
|
+
password = decodeURIComponent(password);
|
|
1566
|
+
if (name2 != null) {
|
|
1567
|
+
name2 = decodeURIComponent(name2);
|
|
1568
|
+
}
|
|
1569
|
+
name2 = name2 ?? `AnyTLS ${server}:${port}`;
|
|
1570
|
+
const proxy = {
|
|
1571
|
+
...parsed,
|
|
1572
|
+
uuid: void 0,
|
|
1573
|
+
type: "anytls",
|
|
1574
|
+
name: name2,
|
|
1575
|
+
server,
|
|
1576
|
+
port,
|
|
1577
|
+
password
|
|
1578
|
+
};
|
|
1579
|
+
for (const addon of addons.split("&")) {
|
|
1580
|
+
if (addon) {
|
|
1581
|
+
let [key, value] = addon.split("=");
|
|
1582
|
+
key = key.replace(/_/g, "-");
|
|
1583
|
+
value = decodeURIComponent(value);
|
|
1584
|
+
if (["alpn"].includes(key)) {
|
|
1585
|
+
proxy[key] = value ? value.split(",") : void 0;
|
|
1586
|
+
} else if (["insecure"].includes(key)) {
|
|
1587
|
+
proxy["skip-cert-verify"] = /(TRUE)|1/i.test(value);
|
|
1588
|
+
} else if (["udp"].includes(key)) {
|
|
1589
|
+
proxy[key] = /(TRUE)|1/i.test(value);
|
|
1590
|
+
} else if (!Object.keys(proxy).includes(key)) {
|
|
1591
|
+
proxy[key] = value;
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
if (["tcp"].includes(proxy.network) && !proxy["reality-opts"]) {
|
|
1596
|
+
delete proxy.network;
|
|
1597
|
+
delete proxy.security;
|
|
1326
1598
|
}
|
|
1327
1599
|
return proxy;
|
|
1328
1600
|
};
|
|
@@ -1378,10 +1650,12 @@ function URI_Hysteria2() {
|
|
|
1378
1650
|
};
|
|
1379
1651
|
const params = {};
|
|
1380
1652
|
for (const addon of addons.split("&")) {
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1653
|
+
if (addon) {
|
|
1654
|
+
const [key, valueRaw] = addon.split("=");
|
|
1655
|
+
let value = valueRaw;
|
|
1656
|
+
value = decodeURIComponent(valueRaw);
|
|
1657
|
+
params[key] = value;
|
|
1658
|
+
}
|
|
1385
1659
|
}
|
|
1386
1660
|
proxy.sni = params.sni;
|
|
1387
1661
|
if (!proxy.sni && params.peer) {
|
|
@@ -1390,11 +1664,21 @@ function URI_Hysteria2() {
|
|
|
1390
1664
|
if (params.obfs && params.obfs !== "none") {
|
|
1391
1665
|
proxy.obfs = params.obfs;
|
|
1392
1666
|
}
|
|
1393
|
-
|
|
1667
|
+
if (params.mport) {
|
|
1668
|
+
proxy.ports = params.mport;
|
|
1669
|
+
}
|
|
1394
1670
|
proxy["obfs-password"] = params["obfs-password"];
|
|
1395
1671
|
proxy["skip-cert-verify"] = /(TRUE)|1/i.test(params.insecure);
|
|
1396
1672
|
proxy.tfo = /(TRUE)|1/i.test(params.fastopen);
|
|
1397
1673
|
proxy["tls-fingerprint"] = params.pinSHA256;
|
|
1674
|
+
let hop_interval = params["hop-interval"] || params["hop_interval"];
|
|
1675
|
+
if (/^\d+$/.test(hop_interval)) {
|
|
1676
|
+
proxy["hop-interval"] = parseInt(`${hop_interval}`, 10);
|
|
1677
|
+
}
|
|
1678
|
+
let keepalive = params["keepalive"];
|
|
1679
|
+
if (/^\d+$/.test(keepalive)) {
|
|
1680
|
+
proxy["keepalive"] = parseInt(`${keepalive}`, 10);
|
|
1681
|
+
}
|
|
1398
1682
|
return proxy;
|
|
1399
1683
|
};
|
|
1400
1684
|
return { name, test, parse };
|
|
@@ -1423,29 +1707,31 @@ function URI_Hysteria() {
|
|
|
1423
1707
|
};
|
|
1424
1708
|
const params = {};
|
|
1425
1709
|
for (const addon of addons.split("&")) {
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
proxy
|
|
1710
|
+
if (addon) {
|
|
1711
|
+
let [key, value] = addon.split("=");
|
|
1712
|
+
key = key.replace(/_/, "-");
|
|
1713
|
+
value = decodeURIComponent(value);
|
|
1714
|
+
if (["alpn"].includes(key)) {
|
|
1715
|
+
proxy[key] = value ? value.split(",") : void 0;
|
|
1716
|
+
} else if (["insecure"].includes(key)) {
|
|
1717
|
+
proxy["skip-cert-verify"] = /(TRUE)|1/i.test(value);
|
|
1718
|
+
} else if (["auth"].includes(key)) {
|
|
1719
|
+
proxy["auth-str"] = value;
|
|
1720
|
+
} else if (["mport"].includes(key)) {
|
|
1721
|
+
proxy["ports"] = value;
|
|
1722
|
+
} else if (["obfsParam"].includes(key)) {
|
|
1723
|
+
proxy["obfs"] = value;
|
|
1724
|
+
} else if (["upmbps"].includes(key)) {
|
|
1725
|
+
proxy["up"] = value;
|
|
1726
|
+
} else if (["downmbps"].includes(key)) {
|
|
1727
|
+
proxy["down"] = value;
|
|
1728
|
+
} else if (["obfs"].includes(key)) {
|
|
1729
|
+
proxy["_obfs"] = value || "";
|
|
1730
|
+
} else if (["fast-open", "peer"].includes(key)) {
|
|
1731
|
+
params[key] = value;
|
|
1732
|
+
} else if (!Object.keys(proxy).includes(key)) {
|
|
1733
|
+
proxy[key] = value;
|
|
1734
|
+
}
|
|
1449
1735
|
}
|
|
1450
1736
|
}
|
|
1451
1737
|
if (!proxy.sni && params.peer) {
|
|
@@ -1468,7 +1754,10 @@ function URI_TUIC() {
|
|
|
1468
1754
|
};
|
|
1469
1755
|
const parse = (line) => {
|
|
1470
1756
|
line = line.split(/tuic:\/\//)[1];
|
|
1471
|
-
let [__,
|
|
1757
|
+
let [__, auth, server, port, addons = "", name2] = /^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
1758
|
+
auth = decodeURIComponent(auth);
|
|
1759
|
+
let [uuid2, ...passwordParts] = auth.split(":");
|
|
1760
|
+
let password = passwordParts.join(":");
|
|
1472
1761
|
port = parseInt(`${port}`, 10);
|
|
1473
1762
|
if (isNaN(port)) {
|
|
1474
1763
|
port = 443;
|
|
@@ -1484,20 +1773,27 @@ function URI_TUIC() {
|
|
|
1484
1773
|
server,
|
|
1485
1774
|
port,
|
|
1486
1775
|
password,
|
|
1487
|
-
uuid
|
|
1776
|
+
uuid: uuid2
|
|
1488
1777
|
};
|
|
1489
1778
|
for (const addon of addons.split("&")) {
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1779
|
+
if (addon) {
|
|
1780
|
+
let [key, value] = addon.split("=");
|
|
1781
|
+
key = key.replace(/_/g, "-");
|
|
1782
|
+
value = decodeURIComponent(value);
|
|
1783
|
+
if (["alpn"].includes(key)) {
|
|
1784
|
+
proxy[key] = value ? value.split(",") : void 0;
|
|
1785
|
+
} else if (["allow-insecure", "insecure"].includes(key)) {
|
|
1786
|
+
proxy["skip-cert-verify"] = /(TRUE)|1/i.test(value);
|
|
1787
|
+
} else if (["fast-open"].includes(key)) {
|
|
1788
|
+
proxy.tfo = true;
|
|
1789
|
+
} else if (["disable-sni", "reduce-rtt"].includes(key)) {
|
|
1790
|
+
proxy[key] = /(TRUE)|1/i.test(value);
|
|
1791
|
+
} else if (key === "congestion-control") {
|
|
1792
|
+
proxy["congestion-controller"] = value;
|
|
1793
|
+
delete proxy[key];
|
|
1794
|
+
} else if (!Object.keys(proxy).includes(key)) {
|
|
1795
|
+
proxy[key] = value;
|
|
1796
|
+
}
|
|
1501
1797
|
}
|
|
1502
1798
|
}
|
|
1503
1799
|
return proxy;
|
|
@@ -1540,36 +1836,38 @@ function URI_WireGuard() {
|
|
|
1540
1836
|
udp: true
|
|
1541
1837
|
};
|
|
1542
1838
|
for (const addon of addons.split("&")) {
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
} else if (["address", "ip"].includes(key)) {
|
|
1552
|
-
value.split(",").map((i) => {
|
|
1553
|
-
const ip = i.trim().replace(/\/\d+$/, "").replace(/^\[/, "").replace(/\]$/, "");
|
|
1554
|
-
if (isIPv4(ip)) {
|
|
1555
|
-
proxy.ip = ip;
|
|
1556
|
-
} else if (isIPv6(ip)) {
|
|
1557
|
-
proxy.ipv6 = ip;
|
|
1839
|
+
if (addon) {
|
|
1840
|
+
let [key, value] = addon.split("=");
|
|
1841
|
+
key = key.replace(/_/, "-");
|
|
1842
|
+
value = decodeURIComponent(value);
|
|
1843
|
+
if (["reserved"].includes(key)) {
|
|
1844
|
+
const parsed = value.split(",").map((i) => parseInt(i.trim(), 10)).filter((i) => Number.isInteger(i));
|
|
1845
|
+
if (parsed.length === 3) {
|
|
1846
|
+
proxy[key] = parsed;
|
|
1558
1847
|
}
|
|
1559
|
-
})
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1848
|
+
} else if (["address", "ip"].includes(key)) {
|
|
1849
|
+
value.split(",").map((i) => {
|
|
1850
|
+
const ip = i.trim().replace(/\/\d+$/, "").replace(/^\[/, "").replace(/\]$/, "");
|
|
1851
|
+
if (isIPv4(ip)) {
|
|
1852
|
+
proxy.ip = ip;
|
|
1853
|
+
} else if (isIPv6(ip)) {
|
|
1854
|
+
proxy.ipv6 = ip;
|
|
1855
|
+
}
|
|
1856
|
+
});
|
|
1857
|
+
} else if (["mtu"].includes(key)) {
|
|
1858
|
+
const parsed = parseInt(value.trim(), 10);
|
|
1859
|
+
if (Number.isInteger(parsed)) {
|
|
1860
|
+
proxy[key] = parsed;
|
|
1861
|
+
}
|
|
1862
|
+
} else if (/publickey/i.test(key)) {
|
|
1863
|
+
proxy["public-key"] = value;
|
|
1864
|
+
} else if (/privatekey/i.test(key)) {
|
|
1865
|
+
proxy["private-key"] = value;
|
|
1866
|
+
} else if (["udp"].includes(key)) {
|
|
1867
|
+
proxy[key] = /(TRUE)|1/i.test(value);
|
|
1868
|
+
} else if (![...Object.keys(proxy), "flag"].includes(key)) {
|
|
1869
|
+
proxy[key] = value;
|
|
1564
1870
|
}
|
|
1565
|
-
} else if (/publickey/i.test(key)) {
|
|
1566
|
-
proxy["public-key"] = value;
|
|
1567
|
-
} else if (/privatekey/i.test(key)) {
|
|
1568
|
-
proxy["private-key"] = value;
|
|
1569
|
-
} else if (["udp"].includes(key)) {
|
|
1570
|
-
proxy[key] = /(TRUE)|1/i.test(value);
|
|
1571
|
-
} else if (!["flag"].includes(key)) {
|
|
1572
|
-
proxy[key] = value;
|
|
1573
1871
|
}
|
|
1574
1872
|
}
|
|
1575
1873
|
return proxy;
|
|
@@ -1604,16 +1902,23 @@ function URI_Trojan() {
|
|
|
1604
1902
|
function Clash_All() {
|
|
1605
1903
|
const name = "Clash Parser";
|
|
1606
1904
|
const test = (line) => {
|
|
1905
|
+
let proxy;
|
|
1607
1906
|
try {
|
|
1608
|
-
|
|
1907
|
+
proxy = JSON5.parse(line);
|
|
1609
1908
|
} catch (e) {
|
|
1610
|
-
|
|
1909
|
+
proxy = yaml_default.parse(line);
|
|
1611
1910
|
}
|
|
1612
|
-
return
|
|
1911
|
+
return !!proxy?.type;
|
|
1613
1912
|
};
|
|
1614
1913
|
const parse = (line) => {
|
|
1615
|
-
|
|
1914
|
+
let proxy;
|
|
1915
|
+
try {
|
|
1916
|
+
proxy = JSON5.parse(line);
|
|
1917
|
+
} catch (e) {
|
|
1918
|
+
proxy = yaml_default.parse(line);
|
|
1919
|
+
}
|
|
1616
1920
|
if (![
|
|
1921
|
+
"anytls",
|
|
1617
1922
|
"mieru",
|
|
1618
1923
|
"juicity",
|
|
1619
1924
|
"ss",
|
|
@@ -2044,6 +2349,7 @@ function isIP(ip) {
|
|
|
2044
2349
|
}
|
|
2045
2350
|
var parsers_default = [
|
|
2046
2351
|
URI_PROXY(),
|
|
2352
|
+
URI_SOCKS(),
|
|
2047
2353
|
URI_SS(),
|
|
2048
2354
|
URI_SSR(),
|
|
2049
2355
|
URI_VMess(),
|
|
@@ -2053,6 +2359,7 @@ var parsers_default = [
|
|
|
2053
2359
|
URI_Hysteria(),
|
|
2054
2360
|
URI_Hysteria2(),
|
|
2055
2361
|
URI_Trojan(),
|
|
2362
|
+
URI_AnyTLS(),
|
|
2056
2363
|
Clash_All(),
|
|
2057
2364
|
Surge_Direct(),
|
|
2058
2365
|
Surge_SSH(),
|
|
@@ -2111,18 +2418,6 @@ function isPresent2(obj, attr) {
|
|
|
2111
2418
|
return typeof data !== "undefined" && data !== null;
|
|
2112
2419
|
}
|
|
2113
2420
|
|
|
2114
|
-
// src/core/app/index.js
|
|
2115
|
-
var app_default = new Proxy(console, {
|
|
2116
|
-
get: function(target, prop) {
|
|
2117
|
-
if (prop in target) {
|
|
2118
|
-
return target[prop];
|
|
2119
|
-
}
|
|
2120
|
-
return function() {
|
|
2121
|
-
return void 0;
|
|
2122
|
-
};
|
|
2123
|
-
}
|
|
2124
|
-
});
|
|
2125
|
-
|
|
2126
2421
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/surge.js
|
|
2127
2422
|
var targetPlatform = "Surge";
|
|
2128
2423
|
var ipVersions = {
|
|
@@ -2171,7 +2466,7 @@ function Surge_Producer() {
|
|
|
2171
2466
|
};
|
|
2172
2467
|
return { produce: produce2 };
|
|
2173
2468
|
}
|
|
2174
|
-
function shadowsocks(proxy
|
|
2469
|
+
function shadowsocks(proxy) {
|
|
2175
2470
|
const result = new Result(proxy);
|
|
2176
2471
|
result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`);
|
|
2177
2472
|
if (!proxy.cipher) {
|
|
@@ -2204,7 +2499,8 @@ function shadowsocks(proxy, includeUnsupportedProxy) {
|
|
|
2204
2499
|
"chacha20",
|
|
2205
2500
|
"chacha20-ietf",
|
|
2206
2501
|
"none",
|
|
2207
|
-
|
|
2502
|
+
"2022-blake3-aes-128-gcm",
|
|
2503
|
+
"2022-blake3-aes-256-gcm"
|
|
2208
2504
|
].includes(proxy.cipher)) {
|
|
2209
2505
|
throw new Error(`cipher ${proxy.cipher} is not supported`);
|
|
2210
2506
|
}
|
|
@@ -2233,7 +2529,6 @@ function shadowsocks(proxy, includeUnsupportedProxy) {
|
|
|
2233
2529
|
}
|
|
2234
2530
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
2235
2531
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
2236
|
-
result.appendIfPresent(`,udp-port=${proxy["udp-port"]}`, "udp-port");
|
|
2237
2532
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
2238
2533
|
result.appendIfPresent(
|
|
2239
2534
|
`,test-timeout=${proxy["test-timeout"]}`,
|
|
@@ -2260,6 +2555,7 @@ function shadowsocks(proxy, includeUnsupportedProxy) {
|
|
|
2260
2555
|
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
2261
2556
|
"shadow-tls-sni"
|
|
2262
2557
|
);
|
|
2558
|
+
result.appendIfPresent(`,udp-port=${proxy["udp-port"]}`, "udp-port");
|
|
2263
2559
|
} else if (["shadow-tls"].includes(proxy.plugin) && proxy["plugin-opts"]) {
|
|
2264
2560
|
const password = proxy["plugin-opts"].password;
|
|
2265
2561
|
const host = proxy["plugin-opts"].host;
|
|
@@ -2277,6 +2573,10 @@ function shadowsocks(proxy, includeUnsupportedProxy) {
|
|
|
2277
2573
|
}
|
|
2278
2574
|
result.append(`,shadow-tls-version=${version}`);
|
|
2279
2575
|
}
|
|
2576
|
+
result.appendIfPresent(
|
|
2577
|
+
`,udp-port=${proxy["udp-port"]}`,
|
|
2578
|
+
"udp-port"
|
|
2579
|
+
);
|
|
2280
2580
|
}
|
|
2281
2581
|
}
|
|
2282
2582
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
@@ -2408,8 +2708,8 @@ function vmess(proxy, includeUnsupportedProxy) {
|
|
|
2408
2708
|
function ssh(proxy) {
|
|
2409
2709
|
const result = new Result(proxy);
|
|
2410
2710
|
result.append(`${proxy.name}=ssh,${proxy.server},${proxy.port}`);
|
|
2411
|
-
result.appendIfPresent(
|
|
2412
|
-
result.appendIfPresent(`,"${proxy.password}"`, "password");
|
|
2711
|
+
result.appendIfPresent(`,username="${proxy.username}"`, "username");
|
|
2712
|
+
result.appendIfPresent(`,password="${proxy.password}"`, "password");
|
|
2413
2713
|
result.appendIfPresent(
|
|
2414
2714
|
`,private-key=${proxy["keystore-private-key"]}`,
|
|
2415
2715
|
"keystore-private-key"
|
|
@@ -2454,11 +2754,14 @@ function ssh(proxy) {
|
|
|
2454
2754
|
return result.toString();
|
|
2455
2755
|
}
|
|
2456
2756
|
function http(proxy) {
|
|
2757
|
+
if (proxy.headers && Object.keys(proxy.headers).length > 0) {
|
|
2758
|
+
throw new Error(`headers is unsupported`);
|
|
2759
|
+
}
|
|
2457
2760
|
const result = new Result(proxy);
|
|
2458
2761
|
const type = proxy.tls ? "https" : "http";
|
|
2459
2762
|
result.append(`${proxy.name}=${type},${proxy.server},${proxy.port}`);
|
|
2460
|
-
result.appendIfPresent(
|
|
2461
|
-
result.appendIfPresent(`,"${proxy.password}"`, "password");
|
|
2763
|
+
result.appendIfPresent(`,username="${proxy.username}"`, "username");
|
|
2764
|
+
result.appendIfPresent(`,password="${proxy.password}"`, "password");
|
|
2462
2765
|
const ip_version = ipVersions[proxy["ip-version"]] || proxy["ip-version"];
|
|
2463
2766
|
result.appendIfPresent(`,ip-version=${ip_version}`, "ip-version");
|
|
2464
2767
|
result.appendIfPresent(
|
|
@@ -2549,8 +2852,8 @@ function socks5(proxy) {
|
|
|
2549
2852
|
const result = new Result(proxy);
|
|
2550
2853
|
const type = proxy.tls ? "socks5-tls" : "socks5";
|
|
2551
2854
|
result.append(`${proxy.name}=${type},${proxy.server},${proxy.port}`);
|
|
2552
|
-
result.appendIfPresent(
|
|
2553
|
-
result.appendIfPresent(`,"${proxy.password}"`, "password");
|
|
2855
|
+
result.appendIfPresent(`,username="${proxy.username}"`, "username");
|
|
2856
|
+
result.appendIfPresent(`,password="${proxy.password}"`, "password");
|
|
2554
2857
|
const ip_version = ipVersions[proxy["ip-version"]] || proxy["ip-version"];
|
|
2555
2858
|
result.appendIfPresent(`,ip-version=${ip_version}`, "ip-version");
|
|
2556
2859
|
result.appendIfPresent(
|
|
@@ -2821,9 +3124,6 @@ prefer-ipv6 = true`);
|
|
|
2821
3124
|
const allowedIps = Array.isArray(proxy["allowed-ips"]) ? proxy["allowed-ips"].join(",") : proxy["allowed-ips"];
|
|
2822
3125
|
let reserved = Array.isArray(proxy.reserved) ? proxy.reserved.join("/") : proxy.reserved;
|
|
2823
3126
|
let presharedKey = proxy["preshared-key"] ?? proxy["pre-shared-key"];
|
|
2824
|
-
if (presharedKey) {
|
|
2825
|
-
presharedKey = `,preshared-key="${presharedKey}"`;
|
|
2826
|
-
}
|
|
2827
3127
|
const peer = {
|
|
2828
3128
|
"public-key": proxy["public-key"],
|
|
2829
3129
|
"allowed-ips": allowedIps ? `"${allowedIps}"` : void 0,
|
|
@@ -2971,9 +3271,7 @@ function handleTransport(result, proxy, includeUnsupportedProxy) {
|
|
|
2971
3271
|
const headers = proxy["ws-opts"].headers;
|
|
2972
3272
|
const value = Object.keys(headers).map((k) => {
|
|
2973
3273
|
let v = headers[k];
|
|
2974
|
-
|
|
2975
|
-
v = `"${v}"`;
|
|
2976
|
-
}
|
|
3274
|
+
v = `"${v}"`;
|
|
2977
3275
|
return `${k}:${v}`;
|
|
2978
3276
|
}).join("|");
|
|
2979
3277
|
if (isNotBlank(value)) {
|
|
@@ -2997,15 +3295,61 @@ function handleTransport(result, proxy, includeUnsupportedProxy) {
|
|
|
2997
3295
|
import { Base64 as Base642 } from "js-base64";
|
|
2998
3296
|
|
|
2999
3297
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/clashmeta.js
|
|
3298
|
+
var ipVersions2 = {
|
|
3299
|
+
dual: "dual",
|
|
3300
|
+
"v4-only": "ipv4",
|
|
3301
|
+
"v6-only": "ipv6",
|
|
3302
|
+
"prefer-v4": "ipv4-prefer",
|
|
3303
|
+
"prefer-v6": "ipv6-prefer"
|
|
3304
|
+
};
|
|
3000
3305
|
function ClashMeta_Producer() {
|
|
3001
3306
|
const type = "ALL";
|
|
3002
3307
|
const produce2 = (proxies, type2, opts = {}) => {
|
|
3003
3308
|
const list = proxies.filter((proxy) => {
|
|
3004
3309
|
if (opts["include-unsupported-proxy"]) return true;
|
|
3005
|
-
if (proxy.type === "snell" &&
|
|
3310
|
+
if (proxy.type === "snell" && proxy.version >= 4) {
|
|
3006
3311
|
return false;
|
|
3007
3312
|
} else if (["juicity"].includes(proxy.type)) {
|
|
3008
3313
|
return false;
|
|
3314
|
+
} else if (["ss"].includes(proxy.type) && ![
|
|
3315
|
+
"aes-128-ctr",
|
|
3316
|
+
"aes-192-ctr",
|
|
3317
|
+
"aes-256-ctr",
|
|
3318
|
+
"aes-128-cfb",
|
|
3319
|
+
"aes-192-cfb",
|
|
3320
|
+
"aes-256-cfb",
|
|
3321
|
+
"aes-128-gcm",
|
|
3322
|
+
"aes-192-gcm",
|
|
3323
|
+
"aes-256-gcm",
|
|
3324
|
+
"aes-128-ccm",
|
|
3325
|
+
"aes-192-ccm",
|
|
3326
|
+
"aes-256-ccm",
|
|
3327
|
+
"aes-128-gcm-siv",
|
|
3328
|
+
"aes-256-gcm-siv",
|
|
3329
|
+
"chacha20-ietf",
|
|
3330
|
+
"chacha20",
|
|
3331
|
+
"xchacha20",
|
|
3332
|
+
"chacha20-ietf-poly1305",
|
|
3333
|
+
"xchacha20-ietf-poly1305",
|
|
3334
|
+
"chacha8-ietf-poly1305",
|
|
3335
|
+
"xchacha8-ietf-poly1305",
|
|
3336
|
+
"2022-blake3-aes-128-gcm",
|
|
3337
|
+
"2022-blake3-aes-256-gcm",
|
|
3338
|
+
"2022-blake3-chacha20-poly1305",
|
|
3339
|
+
"lea-128-gcm",
|
|
3340
|
+
"lea-192-gcm",
|
|
3341
|
+
"lea-256-gcm",
|
|
3342
|
+
"rabbit128-poly1305",
|
|
3343
|
+
"aegis-128l",
|
|
3344
|
+
"aegis-256",
|
|
3345
|
+
"aez-384",
|
|
3346
|
+
"deoxys-ii-256-128",
|
|
3347
|
+
"rc4-md5",
|
|
3348
|
+
"none"
|
|
3349
|
+
].includes(proxy.cipher)) {
|
|
3350
|
+
return false;
|
|
3351
|
+
} else if (["anytls"].includes(proxy.type) && proxy.network && (!["tcp"].includes(proxy.network) || ["tcp"].includes(proxy.network) && proxy["reality-opts"])) {
|
|
3352
|
+
return false;
|
|
3009
3353
|
}
|
|
3010
3354
|
return true;
|
|
3011
3355
|
}).map((proxy) => {
|
|
@@ -3022,17 +3366,16 @@ function ClashMeta_Producer() {
|
|
|
3022
3366
|
}
|
|
3023
3367
|
if (isPresent2(proxy, "cipher") && ![
|
|
3024
3368
|
"auto",
|
|
3369
|
+
"none",
|
|
3370
|
+
"zero",
|
|
3025
3371
|
"aes-128-gcm",
|
|
3026
|
-
"chacha20-poly1305"
|
|
3027
|
-
"none"
|
|
3372
|
+
"chacha20-poly1305"
|
|
3028
3373
|
].includes(proxy.cipher)) {
|
|
3029
3374
|
proxy.cipher = "auto";
|
|
3030
3375
|
}
|
|
3031
3376
|
} else if (proxy.type === "tuic") {
|
|
3032
3377
|
if (isPresent2(proxy, "alpn")) {
|
|
3033
3378
|
proxy.alpn = Array.isArray(proxy.alpn) ? proxy.alpn : [proxy.alpn];
|
|
3034
|
-
} else {
|
|
3035
|
-
proxy.alpn = ["h3"];
|
|
3036
3379
|
}
|
|
3037
3380
|
if (isPresent2(proxy, "tfo") && !isPresent2(proxy, "fast-open")) {
|
|
3038
3381
|
proxy["fast-open"] = proxy.tfo;
|
|
@@ -3055,6 +3398,8 @@ function ClashMeta_Producer() {
|
|
|
3055
3398
|
proxy["persistent-keepalive"] = proxy.keepalive;
|
|
3056
3399
|
proxy["preshared-key"] = proxy["preshared-key"] ?? proxy["pre-shared-key"];
|
|
3057
3400
|
proxy["pre-shared-key"] = proxy["preshared-key"];
|
|
3401
|
+
} else if (proxy.type === "snell" && proxy.version < 3) {
|
|
3402
|
+
delete proxy.udp;
|
|
3058
3403
|
} else if (proxy.type === "vless") {
|
|
3059
3404
|
if (isPresent2(proxy, "sni")) {
|
|
3060
3405
|
proxy.servername = proxy.sni;
|
|
@@ -3068,6 +3413,9 @@ function ClashMeta_Producer() {
|
|
|
3068
3413
|
password: proxy["shadow-tls-password"],
|
|
3069
3414
|
version: proxy["shadow-tls-version"]
|
|
3070
3415
|
};
|
|
3416
|
+
delete proxy["shadow-tls-password"];
|
|
3417
|
+
delete proxy["shadow-tls-sni"];
|
|
3418
|
+
delete proxy["shadow-tls-version"];
|
|
3071
3419
|
}
|
|
3072
3420
|
}
|
|
3073
3421
|
if (["vmess", "vless"].includes(proxy.type) && proxy.network === "http") {
|
|
@@ -3090,6 +3438,24 @@ function ClashMeta_Producer() {
|
|
|
3090
3438
|
proxy["h2-opts"].headers.host = [host];
|
|
3091
3439
|
}
|
|
3092
3440
|
}
|
|
3441
|
+
if (["ws"].includes(proxy.network)) {
|
|
3442
|
+
const networkPath = proxy[`${proxy.network}-opts`]?.path;
|
|
3443
|
+
if (networkPath) {
|
|
3444
|
+
const reg = /^(.*?)(?:\?ed=(\d+))?$/;
|
|
3445
|
+
const [_2, path = "", ed = ""] = reg.exec(networkPath);
|
|
3446
|
+
proxy[`${proxy.network}-opts`].path = path;
|
|
3447
|
+
if (ed !== "") {
|
|
3448
|
+
proxy["ws-opts"]["early-data-header-name"] = "Sec-WebSocket-Protocol";
|
|
3449
|
+
proxy["ws-opts"]["max-early-data"] = parseInt(
|
|
3450
|
+
ed,
|
|
3451
|
+
10
|
|
3452
|
+
);
|
|
3453
|
+
}
|
|
3454
|
+
} else {
|
|
3455
|
+
proxy[`${proxy.network}-opts`] = proxy[`${proxy.network}-opts`] || {};
|
|
3456
|
+
proxy[`${proxy.network}-opts`].path = "/";
|
|
3457
|
+
}
|
|
3458
|
+
}
|
|
3093
3459
|
if (proxy["plugin-opts"]?.tls) {
|
|
3094
3460
|
if (isPresent2(proxy, "skip-cert-verify")) {
|
|
3095
3461
|
proxy["plugin-opts"]["skip-cert-verify"] = proxy["skip-cert-verify"];
|
|
@@ -3100,7 +3466,8 @@ function ClashMeta_Producer() {
|
|
|
3100
3466
|
"tuic",
|
|
3101
3467
|
"hysteria",
|
|
3102
3468
|
"hysteria2",
|
|
3103
|
-
"juicity"
|
|
3469
|
+
"juicity",
|
|
3470
|
+
"anytls"
|
|
3104
3471
|
].includes(proxy.type)) {
|
|
3105
3472
|
delete proxy.tls;
|
|
3106
3473
|
}
|
|
@@ -3120,7 +3487,7 @@ function ClashMeta_Producer() {
|
|
|
3120
3487
|
delete proxy.id;
|
|
3121
3488
|
delete proxy.resolved;
|
|
3122
3489
|
delete proxy["no-resolve"];
|
|
3123
|
-
if (type2 !== "internal") {
|
|
3490
|
+
if (type2 !== "internal" || opts["delete-underscore-fields"]) {
|
|
3124
3491
|
for (const key in proxy) {
|
|
3125
3492
|
if (proxy[key] == null || /^_/i.test(key)) {
|
|
3126
3493
|
delete proxy[key];
|
|
@@ -3131,6 +3498,9 @@ function ClashMeta_Producer() {
|
|
|
3131
3498
|
delete proxy[`${proxy.network}-opts`]["_grpc-type"];
|
|
3132
3499
|
delete proxy[`${proxy.network}-opts`]["_grpc-authority"];
|
|
3133
3500
|
}
|
|
3501
|
+
if (proxy["ip-version"]) {
|
|
3502
|
+
proxy["ip-version"] = ipVersions2[proxy["ip-version"]] || proxy["ip-version"];
|
|
3503
|
+
}
|
|
3134
3504
|
return proxy;
|
|
3135
3505
|
});
|
|
3136
3506
|
return type2 === "internal" ? list : "proxies:\n" + list.map((proxy) => " - " + JSON.stringify(proxy) + "\n").join("");
|
|
@@ -3219,9 +3589,16 @@ function mihomo(proxy, type, opts) {
|
|
|
3219
3589
|
dns: {
|
|
3220
3590
|
enable: true,
|
|
3221
3591
|
ipv6,
|
|
3222
|
-
nameserver: [
|
|
3223
|
-
"
|
|
3224
|
-
"
|
|
3592
|
+
"default-nameserver": opts?.defaultNameserver || proxy._defaultNameserver || [
|
|
3593
|
+
"180.76.76.76",
|
|
3594
|
+
"52.80.52.52",
|
|
3595
|
+
"119.28.28.28",
|
|
3596
|
+
"223.6.6.6"
|
|
3597
|
+
],
|
|
3598
|
+
nameserver: opts?.nameserver || proxy._nameserver || [
|
|
3599
|
+
"https://doh.pub/dns-query",
|
|
3600
|
+
"https://dns.alidns.com/dns-query",
|
|
3601
|
+
"https://doh-pure.onedns.net/dns-query"
|
|
3225
3602
|
]
|
|
3226
3603
|
},
|
|
3227
3604
|
proxies: [
|
|
@@ -3288,7 +3665,12 @@ function Clash_Producer() {
|
|
|
3288
3665
|
"xchacha20",
|
|
3289
3666
|
"chacha20-ietf-poly1305",
|
|
3290
3667
|
"xchacha20-ietf-poly1305"
|
|
3291
|
-
].includes(proxy.cipher) || proxy.type === "snell" &&
|
|
3668
|
+
].includes(proxy.cipher) || proxy.type === "snell" && proxy.version >= 4 || proxy.type === "vless" && (typeof proxy.flow !== "undefined" || proxy["reality-opts"])) {
|
|
3669
|
+
return false;
|
|
3670
|
+
} else if (proxy["underlying-proxy"] || proxy["dialer-proxy"]) {
|
|
3671
|
+
app_default.error(
|
|
3672
|
+
`Clash \u4E0D\u652F\u6301\u524D\u7F6E\u4EE3\u7406\u5B57\u6BB5. \u5DF2\u8FC7\u6EE4\u8282\u70B9 ${proxy.name}`
|
|
3673
|
+
);
|
|
3292
3674
|
return false;
|
|
3293
3675
|
}
|
|
3294
3676
|
return true;
|
|
@@ -3317,6 +3699,8 @@ function Clash_Producer() {
|
|
|
3317
3699
|
proxy["persistent-keepalive"] = proxy.keepalive;
|
|
3318
3700
|
proxy["preshared-key"] = proxy["preshared-key"] ?? proxy["pre-shared-key"];
|
|
3319
3701
|
proxy["pre-shared-key"] = proxy["preshared-key"];
|
|
3702
|
+
} else if (proxy.type === "snell" && proxy.version < 3) {
|
|
3703
|
+
delete proxy.udp;
|
|
3320
3704
|
} else if (proxy.type === "vless") {
|
|
3321
3705
|
if (isPresent2(proxy, "sni")) {
|
|
3322
3706
|
proxy.servername = proxy.sni;
|
|
@@ -3343,6 +3727,24 @@ function Clash_Producer() {
|
|
|
3343
3727
|
proxy["h2-opts"].headers.host = [host];
|
|
3344
3728
|
}
|
|
3345
3729
|
}
|
|
3730
|
+
if (["ws"].includes(proxy.network)) {
|
|
3731
|
+
const networkPath = proxy[`${proxy.network}-opts`]?.path;
|
|
3732
|
+
if (networkPath) {
|
|
3733
|
+
const reg = /^(.*?)(?:\?ed=(\d+))?$/;
|
|
3734
|
+
const [_2, path = "", ed = ""] = reg.exec(networkPath);
|
|
3735
|
+
proxy[`${proxy.network}-opts`].path = path;
|
|
3736
|
+
if (ed !== "") {
|
|
3737
|
+
proxy["ws-opts"]["early-data-header-name"] = "Sec-WebSocket-Protocol";
|
|
3738
|
+
proxy["ws-opts"]["max-early-data"] = parseInt(
|
|
3739
|
+
ed,
|
|
3740
|
+
10
|
|
3741
|
+
);
|
|
3742
|
+
}
|
|
3743
|
+
} else {
|
|
3744
|
+
proxy[`${proxy.network}-opts`] = proxy[`${proxy.network}-opts`] || {};
|
|
3745
|
+
proxy[`${proxy.network}-opts`].path = "/";
|
|
3746
|
+
}
|
|
3747
|
+
}
|
|
3346
3748
|
if (proxy["plugin-opts"]?.tls) {
|
|
3347
3749
|
if (isPresent2(proxy, "skip-cert-verify")) {
|
|
3348
3750
|
proxy["plugin-opts"]["skip-cert-verify"] = proxy["skip-cert-verify"];
|
|
@@ -3353,7 +3755,8 @@ function Clash_Producer() {
|
|
|
3353
3755
|
"tuic",
|
|
3354
3756
|
"hysteria",
|
|
3355
3757
|
"hysteria2",
|
|
3356
|
-
"juicity"
|
|
3758
|
+
"juicity",
|
|
3759
|
+
"anytls"
|
|
3357
3760
|
].includes(proxy.type)) {
|
|
3358
3761
|
delete proxy.tls;
|
|
3359
3762
|
}
|
|
@@ -3361,10 +3764,6 @@ function Clash_Producer() {
|
|
|
3361
3764
|
proxy.fingerprint = proxy["tls-fingerprint"];
|
|
3362
3765
|
}
|
|
3363
3766
|
delete proxy["tls-fingerprint"];
|
|
3364
|
-
if (proxy["underlying-proxy"]) {
|
|
3365
|
-
proxy["dialer-proxy"] = proxy["underlying-proxy"];
|
|
3366
|
-
}
|
|
3367
|
-
delete proxy["underlying-proxy"];
|
|
3368
3767
|
if (isPresent2(proxy, "tls") && typeof proxy.tls !== "boolean") {
|
|
3369
3768
|
delete proxy.tls;
|
|
3370
3769
|
}
|
|
@@ -3426,11 +3825,14 @@ function Stash_Producer() {
|
|
|
3426
3825
|
"xchacha20",
|
|
3427
3826
|
"chacha20-ietf-poly1305",
|
|
3428
3827
|
"xchacha20-ietf-poly1305",
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3828
|
+
"2022-blake3-aes-128-gcm",
|
|
3829
|
+
"2022-blake3-aes-256-gcm"
|
|
3830
|
+
].includes(proxy.cipher) || proxy.type === "snell" && proxy.version >= 4 || proxy.type === "vless" && proxy["reality-opts"] && !["xtls-rprx-vision"].includes(proxy.flow)) {
|
|
3831
|
+
return false;
|
|
3832
|
+
} else if (proxy["underlying-proxy"] || proxy["dialer-proxy"]) {
|
|
3833
|
+
app_default.error(
|
|
3834
|
+
`Stash \u6682\u4E0D\u652F\u6301\u524D\u7F6E\u4EE3\u7406\u5B57\u6BB5. \u5DF2\u8FC7\u6EE4\u8282\u70B9 ${proxy.name}. \u8BF7\u4F7F\u7528 \u4EE3\u7406\u7684\u8F6C\u53D1\u94FE https://stash.wiki/proxy-protocols/proxy-groups#relay`
|
|
3835
|
+
);
|
|
3434
3836
|
return false;
|
|
3435
3837
|
}
|
|
3436
3838
|
return true;
|
|
@@ -3520,6 +3922,8 @@ function Stash_Producer() {
|
|
|
3520
3922
|
proxy["persistent-keepalive"] = proxy.keepalive;
|
|
3521
3923
|
proxy["preshared-key"] = proxy["preshared-key"] ?? proxy["pre-shared-key"];
|
|
3522
3924
|
proxy["pre-shared-key"] = proxy["preshared-key"];
|
|
3925
|
+
} else if (proxy.type === "snell" && proxy.version < 3) {
|
|
3926
|
+
delete proxy.udp;
|
|
3523
3927
|
} else if (proxy.type === "vless") {
|
|
3524
3928
|
if (isPresent2(proxy, "sni")) {
|
|
3525
3929
|
proxy.servername = proxy.sni;
|
|
@@ -3546,6 +3950,24 @@ function Stash_Producer() {
|
|
|
3546
3950
|
proxy["h2-opts"].headers.host = [host];
|
|
3547
3951
|
}
|
|
3548
3952
|
}
|
|
3953
|
+
if (["ws"].includes(proxy.network)) {
|
|
3954
|
+
const networkPath = proxy[`${proxy.network}-opts`]?.path;
|
|
3955
|
+
if (networkPath) {
|
|
3956
|
+
const reg = /^(.*?)(?:\?ed=(\d+))?$/;
|
|
3957
|
+
const [_2, path = "", ed = ""] = reg.exec(networkPath);
|
|
3958
|
+
proxy[`${proxy.network}-opts`].path = path;
|
|
3959
|
+
if (ed !== "") {
|
|
3960
|
+
proxy["ws-opts"]["early-data-header-name"] = "Sec-WebSocket-Protocol";
|
|
3961
|
+
proxy["ws-opts"]["max-early-data"] = parseInt(
|
|
3962
|
+
ed,
|
|
3963
|
+
10
|
|
3964
|
+
);
|
|
3965
|
+
}
|
|
3966
|
+
} else {
|
|
3967
|
+
proxy[`${proxy.network}-opts`] = proxy[`${proxy.network}-opts`] || {};
|
|
3968
|
+
proxy[`${proxy.network}-opts`].path = "/";
|
|
3969
|
+
}
|
|
3970
|
+
}
|
|
3549
3971
|
if (proxy["plugin-opts"]?.tls) {
|
|
3550
3972
|
if (isPresent2(proxy, "skip-cert-verify")) {
|
|
3551
3973
|
proxy["plugin-opts"]["skip-cert-verify"] = proxy["skip-cert-verify"];
|
|
@@ -3556,7 +3978,8 @@ function Stash_Producer() {
|
|
|
3556
3978
|
"tuic",
|
|
3557
3979
|
"hysteria",
|
|
3558
3980
|
"hysteria2",
|
|
3559
|
-
"juicity"
|
|
3981
|
+
"juicity",
|
|
3982
|
+
"anytls"
|
|
3560
3983
|
].includes(proxy.type)) {
|
|
3561
3984
|
delete proxy.tls;
|
|
3562
3985
|
}
|
|
@@ -3564,10 +3987,6 @@ function Stash_Producer() {
|
|
|
3564
3987
|
proxy["server-cert-fingerprint"] = proxy["tls-fingerprint"];
|
|
3565
3988
|
}
|
|
3566
3989
|
delete proxy["tls-fingerprint"];
|
|
3567
|
-
if (proxy["underlying-proxy"]) {
|
|
3568
|
-
proxy["dialer-proxy"] = proxy["underlying-proxy"];
|
|
3569
|
-
}
|
|
3570
|
-
delete proxy["underlying-proxy"];
|
|
3571
3990
|
if (isPresent2(proxy, "tls") && typeof proxy.tls !== "boolean") {
|
|
3572
3991
|
delete proxy.tls;
|
|
3573
3992
|
}
|
|
@@ -3604,19 +4023,26 @@ function Stash_Producer() {
|
|
|
3604
4023
|
|
|
3605
4024
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/loon.js
|
|
3606
4025
|
var targetPlatform3 = "Loon";
|
|
4026
|
+
var ipVersions3 = {
|
|
4027
|
+
dual: "dual",
|
|
4028
|
+
ipv4: "v4-only",
|
|
4029
|
+
ipv6: "v6-only",
|
|
4030
|
+
"ipv4-prefer": "prefer-v4",
|
|
4031
|
+
"ipv6-prefer": "prefer-v6"
|
|
4032
|
+
};
|
|
3607
4033
|
function Loon_Producer() {
|
|
3608
4034
|
const produce2 = (proxy, type, opts = {}) => {
|
|
3609
4035
|
switch (proxy.type) {
|
|
3610
4036
|
case "ss":
|
|
3611
|
-
return shadowsocks2(proxy
|
|
4037
|
+
return shadowsocks2(proxy);
|
|
3612
4038
|
case "ssr":
|
|
3613
4039
|
return shadowsocksr(proxy);
|
|
3614
4040
|
case "trojan":
|
|
3615
4041
|
return trojan2(proxy);
|
|
3616
4042
|
case "vmess":
|
|
3617
|
-
return vmess2(proxy);
|
|
4043
|
+
return vmess2(proxy, opts["include-unsupported-proxy"]);
|
|
3618
4044
|
case "vless":
|
|
3619
|
-
return vless(proxy);
|
|
4045
|
+
return vless(proxy, opts["include-unsupported-proxy"]);
|
|
3620
4046
|
case "http":
|
|
3621
4047
|
return http2(proxy);
|
|
3622
4048
|
case "socks5":
|
|
@@ -3632,7 +4058,7 @@ function Loon_Producer() {
|
|
|
3632
4058
|
};
|
|
3633
4059
|
return { produce: produce2 };
|
|
3634
4060
|
}
|
|
3635
|
-
function shadowsocks2(proxy
|
|
4061
|
+
function shadowsocks2(proxy) {
|
|
3636
4062
|
const result = new Result(proxy);
|
|
3637
4063
|
if (![
|
|
3638
4064
|
"rc4",
|
|
@@ -3655,7 +4081,8 @@ function shadowsocks2(proxy, includeUnsupportedProxy) {
|
|
|
3655
4081
|
"aes-256-gcm",
|
|
3656
4082
|
"chacha20-ietf-poly1305",
|
|
3657
4083
|
"xchacha20-ietf-poly1305",
|
|
3658
|
-
|
|
4084
|
+
"2022-blake3-aes-128-gcm",
|
|
4085
|
+
"2022-blake3-aes-256-gcm"
|
|
3659
4086
|
].includes(proxy.cipher)) {
|
|
3660
4087
|
throw new Error(`cipher ${proxy.cipher} is not supported`);
|
|
3661
4088
|
}
|
|
@@ -3664,6 +4091,11 @@ function shadowsocks2(proxy, includeUnsupportedProxy) {
|
|
|
3664
4091
|
);
|
|
3665
4092
|
if (isPresent2(proxy, "plugin")) {
|
|
3666
4093
|
if (proxy.plugin === "obfs") {
|
|
4094
|
+
if (proxy["plugin-opts"]?.mode && proxy.cipher.startsWith("2022-")) {
|
|
4095
|
+
throw new Error(
|
|
4096
|
+
`${proxy.cipher} ${proxy.plugin} is not supported`
|
|
4097
|
+
);
|
|
4098
|
+
}
|
|
3667
4099
|
result.append(`,obfs-name=${proxy["plugin-opts"].mode}`);
|
|
3668
4100
|
result.appendIfPresent(
|
|
3669
4101
|
`,obfs-host=${proxy["plugin-opts"].host}`,
|
|
@@ -3673,32 +4105,114 @@ function shadowsocks2(proxy, includeUnsupportedProxy) {
|
|
|
3673
4105
|
`,obfs-uri=${proxy["plugin-opts"].path}`,
|
|
3674
4106
|
"plugin-opts.path"
|
|
3675
4107
|
);
|
|
3676
|
-
} else {
|
|
4108
|
+
} else if (!["shadow-tls"].includes(proxy.plugin)) {
|
|
3677
4109
|
throw new Error(`plugin ${proxy.plugin} is not supported`);
|
|
3678
4110
|
}
|
|
3679
4111
|
}
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
result.
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
4112
|
+
if (isPresent2(proxy, "shadow-tls-password")) {
|
|
4113
|
+
result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
|
|
4114
|
+
result.appendIfPresent(
|
|
4115
|
+
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
4116
|
+
"shadow-tls-version"
|
|
4117
|
+
);
|
|
4118
|
+
result.appendIfPresent(
|
|
4119
|
+
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
4120
|
+
"shadow-tls-sni"
|
|
4121
|
+
);
|
|
4122
|
+
result.appendIfPresent(`,udp-port=${proxy["udp-port"]}`, "udp-port");
|
|
4123
|
+
} else if (["shadow-tls"].includes(proxy.plugin) && proxy["plugin-opts"]) {
|
|
4124
|
+
const password = proxy["plugin-opts"].password;
|
|
4125
|
+
const host = proxy["plugin-opts"].host;
|
|
4126
|
+
const version = proxy["plugin-opts"].version;
|
|
4127
|
+
if (password) {
|
|
4128
|
+
result.append(`,shadow-tls-password=${password}`);
|
|
4129
|
+
if (host) {
|
|
4130
|
+
result.append(`,shadow-tls-sni=${host}`);
|
|
4131
|
+
}
|
|
4132
|
+
if (version) {
|
|
4133
|
+
if (version < 2) {
|
|
4134
|
+
throw new Error(
|
|
4135
|
+
`shadow-tls version ${version} is not supported`
|
|
4136
|
+
);
|
|
4137
|
+
}
|
|
4138
|
+
result.append(`,shadow-tls-version=${version}`);
|
|
4139
|
+
}
|
|
4140
|
+
result.appendIfPresent(
|
|
4141
|
+
`,udp-port=${proxy["udp-port"]}`,
|
|
4142
|
+
"udp-port"
|
|
4143
|
+
);
|
|
4144
|
+
}
|
|
4145
|
+
}
|
|
4146
|
+
result.appendIfPresent(`,fast-open=${proxy.tfo}`, "tfo");
|
|
4147
|
+
if (proxy["block-quic"] === "on") {
|
|
4148
|
+
result.append(",block-quic=true");
|
|
4149
|
+
} else if (proxy["block-quic"] === "off") {
|
|
4150
|
+
result.append(",block-quic=false");
|
|
4151
|
+
}
|
|
4152
|
+
if (proxy.udp) {
|
|
4153
|
+
result.append(`,udp=true`);
|
|
4154
|
+
}
|
|
4155
|
+
const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
4156
|
+
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
4157
|
+
return result.toString();
|
|
4158
|
+
}
|
|
4159
|
+
function shadowsocksr(proxy) {
|
|
4160
|
+
const result = new Result(proxy);
|
|
4161
|
+
result.append(
|
|
4162
|
+
`${proxy.name}=shadowsocksr,${proxy.server},${proxy.port},${proxy.cipher},"${proxy.password}"`
|
|
4163
|
+
);
|
|
4164
|
+
result.append(`,protocol=${proxy.protocol}`);
|
|
4165
|
+
result.appendIfPresent(
|
|
4166
|
+
`,protocol-param=${proxy["protocol-param"]}`,
|
|
3694
4167
|
"protocol-param"
|
|
3695
4168
|
);
|
|
3696
4169
|
result.appendIfPresent(`,obfs=${proxy.obfs}`, "obfs");
|
|
3697
4170
|
result.appendIfPresent(`,obfs-param=${proxy["obfs-param"]}`, "obfs-param");
|
|
4171
|
+
if (isPresent2(proxy, "shadow-tls-password")) {
|
|
4172
|
+
result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
|
|
4173
|
+
result.appendIfPresent(
|
|
4174
|
+
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
4175
|
+
"shadow-tls-version"
|
|
4176
|
+
);
|
|
4177
|
+
result.appendIfPresent(
|
|
4178
|
+
`,shadow-tls-sni=${proxy["shadow-tls-sni"]}`,
|
|
4179
|
+
"shadow-tls-sni"
|
|
4180
|
+
);
|
|
4181
|
+
result.appendIfPresent(`,udp-port=${proxy["udp-port"]}`, "udp-port");
|
|
4182
|
+
} else if (["shadow-tls"].includes(proxy.plugin) && proxy["plugin-opts"]) {
|
|
4183
|
+
const password = proxy["plugin-opts"].password;
|
|
4184
|
+
const host = proxy["plugin-opts"].host;
|
|
4185
|
+
const version = proxy["plugin-opts"].version;
|
|
4186
|
+
if (password) {
|
|
4187
|
+
result.append(`,shadow-tls-password=${password}`);
|
|
4188
|
+
if (host) {
|
|
4189
|
+
result.append(`,shadow-tls-sni=${host}`);
|
|
4190
|
+
}
|
|
4191
|
+
if (version) {
|
|
4192
|
+
if (version < 2) {
|
|
4193
|
+
throw new Error(
|
|
4194
|
+
`shadow-tls version ${version} is not supported`
|
|
4195
|
+
);
|
|
4196
|
+
}
|
|
4197
|
+
result.append(`,shadow-tls-version=${version}`);
|
|
4198
|
+
}
|
|
4199
|
+
result.appendIfPresent(
|
|
4200
|
+
`,udp-port=${proxy["udp-port"]}`,
|
|
4201
|
+
"udp-port"
|
|
4202
|
+
);
|
|
4203
|
+
}
|
|
4204
|
+
}
|
|
3698
4205
|
result.appendIfPresent(`,fast-open=${proxy.tfo}`, "tfo");
|
|
4206
|
+
if (proxy["block-quic"] === "on") {
|
|
4207
|
+
result.append(",block-quic=true");
|
|
4208
|
+
} else if (proxy["block-quic"] === "off") {
|
|
4209
|
+
result.append(",block-quic=false");
|
|
4210
|
+
}
|
|
3699
4211
|
if (proxy.udp) {
|
|
3700
4212
|
result.append(`,udp=true`);
|
|
3701
4213
|
}
|
|
4214
|
+
const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
4215
|
+
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
3702
4216
|
return result.toString();
|
|
3703
4217
|
}
|
|
3704
4218
|
function trojan2(proxy) {
|
|
@@ -3738,12 +4252,20 @@ function trojan2(proxy) {
|
|
|
3738
4252
|
"tls-pubkey-sha256"
|
|
3739
4253
|
);
|
|
3740
4254
|
result.appendIfPresent(`,fast-open=${proxy.tfo}`, "tfo");
|
|
4255
|
+
if (proxy["block-quic"] === "on") {
|
|
4256
|
+
result.append(",block-quic=true");
|
|
4257
|
+
} else if (proxy["block-quic"] === "off") {
|
|
4258
|
+
result.append(",block-quic=false");
|
|
4259
|
+
}
|
|
3741
4260
|
if (proxy.udp) {
|
|
3742
4261
|
result.append(`,udp=true`);
|
|
3743
4262
|
}
|
|
4263
|
+
const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
4264
|
+
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
3744
4265
|
return result.toString();
|
|
3745
4266
|
}
|
|
3746
4267
|
function vmess2(proxy) {
|
|
4268
|
+
const isReality = !!proxy["reality-opts"];
|
|
3747
4269
|
const result = new Result(proxy);
|
|
3748
4270
|
result.append(
|
|
3749
4271
|
`${proxy.name}=vmess,${proxy.server},${proxy.port},${proxy.cipher},"${proxy.uuid}"`
|
|
@@ -3785,29 +4307,54 @@ function vmess2(proxy) {
|
|
|
3785
4307
|
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
3786
4308
|
"skip-cert-verify"
|
|
3787
4309
|
);
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
4310
|
+
if (isReality) {
|
|
4311
|
+
result.appendIfPresent(`,sni=${proxy.sni}`, "sni");
|
|
4312
|
+
result.appendIfPresent(
|
|
4313
|
+
`,public-key="${proxy["reality-opts"]["public-key"]}"`,
|
|
4314
|
+
"reality-opts.public-key"
|
|
4315
|
+
);
|
|
4316
|
+
result.appendIfPresent(
|
|
4317
|
+
`,short-id=${proxy["reality-opts"]["short-id"]}`,
|
|
4318
|
+
"reality-opts.short-id"
|
|
4319
|
+
);
|
|
4320
|
+
} else {
|
|
4321
|
+
result.appendIfPresent(`,tls-name=${proxy.sni}`, "sni");
|
|
4322
|
+
result.appendIfPresent(
|
|
4323
|
+
`,tls-cert-sha256=${proxy["tls-fingerprint"]}`,
|
|
4324
|
+
"tls-fingerprint"
|
|
4325
|
+
);
|
|
4326
|
+
result.appendIfPresent(
|
|
4327
|
+
`,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
|
|
4328
|
+
"tls-pubkey-sha256"
|
|
4329
|
+
);
|
|
4330
|
+
}
|
|
3797
4331
|
if (isPresent2(proxy, "aead")) {
|
|
3798
|
-
result.append(`,alterId
|
|
4332
|
+
result.append(`,alterId=${proxy.aead ? 0 : 1}`);
|
|
3799
4333
|
} else {
|
|
3800
4334
|
result.append(`,alterId=${proxy.alterId}`);
|
|
3801
4335
|
}
|
|
3802
4336
|
result.appendIfPresent(`,fast-open=${proxy.tfo}`, "tfo");
|
|
4337
|
+
if (proxy["block-quic"] === "on") {
|
|
4338
|
+
result.append(",block-quic=true");
|
|
4339
|
+
} else if (proxy["block-quic"] === "off") {
|
|
4340
|
+
result.append(",block-quic=false");
|
|
4341
|
+
}
|
|
3803
4342
|
if (proxy.udp) {
|
|
3804
4343
|
result.append(`,udp=true`);
|
|
3805
4344
|
}
|
|
4345
|
+
const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
4346
|
+
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
3806
4347
|
return result.toString();
|
|
3807
4348
|
}
|
|
3808
4349
|
function vless(proxy) {
|
|
3809
|
-
|
|
3810
|
-
|
|
4350
|
+
let isXtls = false;
|
|
4351
|
+
const isReality = !!proxy["reality-opts"];
|
|
4352
|
+
if (typeof proxy.flow !== "undefined") {
|
|
4353
|
+
if (["xtls-rprx-vision"].includes(proxy.flow)) {
|
|
4354
|
+
isXtls = true;
|
|
4355
|
+
} else {
|
|
4356
|
+
throw new Error(`VLESS flow(${proxy.flow}) is not supported`);
|
|
4357
|
+
}
|
|
3811
4358
|
}
|
|
3812
4359
|
const result = new Result(proxy);
|
|
3813
4360
|
result.append(
|
|
@@ -3850,19 +4397,41 @@ function vless(proxy) {
|
|
|
3850
4397
|
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
3851
4398
|
"skip-cert-verify"
|
|
3852
4399
|
);
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
4400
|
+
if (isXtls) {
|
|
4401
|
+
result.appendIfPresent(`,flow=${proxy.flow}`, "flow");
|
|
4402
|
+
}
|
|
4403
|
+
if (isReality) {
|
|
4404
|
+
result.appendIfPresent(`,sni=${proxy.sni}`, "sni");
|
|
4405
|
+
result.appendIfPresent(
|
|
4406
|
+
`,public-key="${proxy["reality-opts"]["public-key"]}"`,
|
|
4407
|
+
"reality-opts.public-key"
|
|
4408
|
+
);
|
|
4409
|
+
result.appendIfPresent(
|
|
4410
|
+
`,short-id=${proxy["reality-opts"]["short-id"]}`,
|
|
4411
|
+
"reality-opts.short-id"
|
|
4412
|
+
);
|
|
4413
|
+
} else {
|
|
4414
|
+
result.appendIfPresent(`,tls-name=${proxy.sni}`, "sni");
|
|
4415
|
+
result.appendIfPresent(
|
|
4416
|
+
`,tls-cert-sha256=${proxy["tls-fingerprint"]}`,
|
|
4417
|
+
"tls-fingerprint"
|
|
4418
|
+
);
|
|
4419
|
+
result.appendIfPresent(
|
|
4420
|
+
`,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
|
|
4421
|
+
"tls-pubkey-sha256"
|
|
4422
|
+
);
|
|
4423
|
+
}
|
|
3862
4424
|
result.appendIfPresent(`,fast-open=${proxy.tfo}`, "tfo");
|
|
4425
|
+
if (proxy["block-quic"] === "on") {
|
|
4426
|
+
result.append(",block-quic=true");
|
|
4427
|
+
} else if (proxy["block-quic"] === "off") {
|
|
4428
|
+
result.append(",block-quic=false");
|
|
4429
|
+
}
|
|
3863
4430
|
if (proxy.udp) {
|
|
3864
4431
|
result.append(`,udp=true`);
|
|
3865
4432
|
}
|
|
4433
|
+
const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
4434
|
+
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
3866
4435
|
return result.toString();
|
|
3867
4436
|
}
|
|
3868
4437
|
function http2(proxy) {
|
|
@@ -3877,6 +4446,13 @@ function http2(proxy) {
|
|
|
3877
4446
|
"skip-cert-verify"
|
|
3878
4447
|
);
|
|
3879
4448
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
4449
|
+
if (proxy["block-quic"] === "on") {
|
|
4450
|
+
result.append(",block-quic=true");
|
|
4451
|
+
} else if (proxy["block-quic"] === "off") {
|
|
4452
|
+
result.append(",block-quic=false");
|
|
4453
|
+
}
|
|
4454
|
+
const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
4455
|
+
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
3880
4456
|
return result.toString();
|
|
3881
4457
|
}
|
|
3882
4458
|
function socks52(proxy) {
|
|
@@ -3891,9 +4467,16 @@ function socks52(proxy) {
|
|
|
3891
4467
|
"skip-cert-verify"
|
|
3892
4468
|
);
|
|
3893
4469
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
4470
|
+
if (proxy["block-quic"] === "on") {
|
|
4471
|
+
result.append(",block-quic=true");
|
|
4472
|
+
} else if (proxy["block-quic"] === "off") {
|
|
4473
|
+
result.append(",block-quic=false");
|
|
4474
|
+
}
|
|
3894
4475
|
if (proxy.udp) {
|
|
3895
4476
|
result.append(`,udp=true`);
|
|
3896
4477
|
}
|
|
4478
|
+
const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
4479
|
+
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
3897
4480
|
return result.toString();
|
|
3898
4481
|
}
|
|
3899
4482
|
function wireguard2(proxy) {
|
|
@@ -3945,6 +4528,13 @@ function wireguard2(proxy) {
|
|
|
3945
4528
|
result.append(
|
|
3946
4529
|
`,peers=[{public-key="${proxy["public-key"]}",allowed-ips="${allowedIps ?? "0.0.0.0/0,::/0"}",endpoint=${proxy.server}:${proxy.port}${reserved ?? ""}${presharedKey ?? ""}}]`
|
|
3947
4530
|
);
|
|
4531
|
+
const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
4532
|
+
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
4533
|
+
if (proxy["block-quic"] === "on") {
|
|
4534
|
+
result.append(",block-quic=true");
|
|
4535
|
+
} else if (proxy["block-quic"] === "off") {
|
|
4536
|
+
result.append(",block-quic=false");
|
|
4537
|
+
}
|
|
3948
4538
|
return result.toString();
|
|
3949
4539
|
}
|
|
3950
4540
|
function hysteria22(proxy) {
|
|
@@ -3971,6 +4561,11 @@ function hysteria22(proxy) {
|
|
|
3971
4561
|
result.append(`,salamander-password=${proxy["obfs-password"]}`);
|
|
3972
4562
|
}
|
|
3973
4563
|
result.appendIfPresent(`,fast-open=${proxy.tfo}`, "tfo");
|
|
4564
|
+
if (proxy["block-quic"] === "on") {
|
|
4565
|
+
result.append(",block-quic=true");
|
|
4566
|
+
} else if (proxy["block-quic"] === "off") {
|
|
4567
|
+
result.append(",block-quic=false");
|
|
4568
|
+
}
|
|
3974
4569
|
if (proxy.udp) {
|
|
3975
4570
|
result.append(`,udp=true`);
|
|
3976
4571
|
}
|
|
@@ -3979,11 +4574,123 @@ function hysteria22(proxy) {
|
|
|
3979
4574
|
"down"
|
|
3980
4575
|
);
|
|
3981
4576
|
result.appendIfPresent(`,ecn=${proxy.ecn}`, "ecn");
|
|
4577
|
+
const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
4578
|
+
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
3982
4579
|
return result.toString();
|
|
3983
4580
|
}
|
|
3984
4581
|
|
|
3985
4582
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/uri.js
|
|
3986
4583
|
import { Base64 as Base643 } from "js-base64";
|
|
4584
|
+
import { uuid } from "automerge";
|
|
4585
|
+
function vless2(proxy) {
|
|
4586
|
+
let security = "none";
|
|
4587
|
+
const isReality = proxy["reality-opts"];
|
|
4588
|
+
let sid = "";
|
|
4589
|
+
let pbk = "";
|
|
4590
|
+
let spx = "";
|
|
4591
|
+
if (isReality) {
|
|
4592
|
+
security = "reality";
|
|
4593
|
+
const publicKey = proxy["reality-opts"]?.["public-key"];
|
|
4594
|
+
if (publicKey) {
|
|
4595
|
+
pbk = `&pbk=${encodeURIComponent(publicKey)}`;
|
|
4596
|
+
}
|
|
4597
|
+
const shortId = proxy["reality-opts"]?.["short-id"];
|
|
4598
|
+
if (shortId) {
|
|
4599
|
+
sid = `&sid=${encodeURIComponent(shortId)}`;
|
|
4600
|
+
}
|
|
4601
|
+
const spiderX = proxy["reality-opts"]?.["_spider-x"];
|
|
4602
|
+
if (spiderX) {
|
|
4603
|
+
spx = `&spx=${encodeURIComponent(spiderX)}`;
|
|
4604
|
+
}
|
|
4605
|
+
} else if (proxy.tls) {
|
|
4606
|
+
security = "tls";
|
|
4607
|
+
}
|
|
4608
|
+
let alpn = "";
|
|
4609
|
+
if (proxy.alpn) {
|
|
4610
|
+
alpn = `&alpn=${encodeURIComponent(
|
|
4611
|
+
Array.isArray(proxy.alpn) ? proxy.alpn : proxy.alpn.join(",")
|
|
4612
|
+
)}`;
|
|
4613
|
+
}
|
|
4614
|
+
let allowInsecure = "";
|
|
4615
|
+
if (proxy["skip-cert-verify"]) {
|
|
4616
|
+
allowInsecure = `&allowInsecure=1`;
|
|
4617
|
+
}
|
|
4618
|
+
let sni = "";
|
|
4619
|
+
if (proxy.sni) {
|
|
4620
|
+
sni = `&sni=${encodeURIComponent(proxy.sni)}`;
|
|
4621
|
+
}
|
|
4622
|
+
let fp = "";
|
|
4623
|
+
if (proxy["client-fingerprint"]) {
|
|
4624
|
+
fp = `&fp=${encodeURIComponent(proxy["client-fingerprint"])}`;
|
|
4625
|
+
}
|
|
4626
|
+
let flow = "";
|
|
4627
|
+
if (proxy.flow) {
|
|
4628
|
+
flow = `&flow=${encodeURIComponent(proxy.flow)}`;
|
|
4629
|
+
}
|
|
4630
|
+
let extra = "";
|
|
4631
|
+
if (proxy._extra) {
|
|
4632
|
+
extra = `&extra=${encodeURIComponent(proxy._extra)}`;
|
|
4633
|
+
}
|
|
4634
|
+
let mode = "";
|
|
4635
|
+
if (proxy._mode) {
|
|
4636
|
+
mode = `&mode=${encodeURIComponent(proxy._mode)}`;
|
|
4637
|
+
}
|
|
4638
|
+
let pqv = "";
|
|
4639
|
+
if (proxy._pqv) {
|
|
4640
|
+
pqv = `&pqv=${encodeURIComponent(proxy._pqv)}`;
|
|
4641
|
+
}
|
|
4642
|
+
let encryption = "";
|
|
4643
|
+
if (proxy.encryption) {
|
|
4644
|
+
encryption = `&encryption=${encodeURIComponent(proxy.encryption)}`;
|
|
4645
|
+
}
|
|
4646
|
+
let vlessType = proxy.network;
|
|
4647
|
+
if (proxy.network === "ws" && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
4648
|
+
vlessType = "httpupgrade";
|
|
4649
|
+
}
|
|
4650
|
+
let vlessTransport = `&type=${encodeURIComponent(vlessType)}`;
|
|
4651
|
+
if (["grpc"].includes(proxy.network)) {
|
|
4652
|
+
vlessTransport += `&mode=${encodeURIComponent(
|
|
4653
|
+
proxy[`${proxy.network}-opts`]?.["_grpc-type"] || "gun"
|
|
4654
|
+
)}`;
|
|
4655
|
+
const authority = proxy[`${proxy.network}-opts`]?.["_grpc-authority"];
|
|
4656
|
+
if (authority) {
|
|
4657
|
+
vlessTransport += `&authority=${encodeURIComponent(authority)}`;
|
|
4658
|
+
}
|
|
4659
|
+
}
|
|
4660
|
+
let vlessTransportServiceName = proxy[`${proxy.network}-opts`]?.[`${proxy.network}-service-name`];
|
|
4661
|
+
let vlessTransportPath = proxy[`${proxy.network}-opts`]?.path;
|
|
4662
|
+
let vlessTransportHost = proxy[`${proxy.network}-opts`]?.headers?.Host;
|
|
4663
|
+
if (vlessTransportPath) {
|
|
4664
|
+
vlessTransport += `&path=${encodeURIComponent(
|
|
4665
|
+
Array.isArray(vlessTransportPath) ? vlessTransportPath[0] : vlessTransportPath
|
|
4666
|
+
)}`;
|
|
4667
|
+
}
|
|
4668
|
+
if (vlessTransportHost) {
|
|
4669
|
+
vlessTransport += `&host=${encodeURIComponent(
|
|
4670
|
+
Array.isArray(vlessTransportHost) ? vlessTransportHost[0] : vlessTransportHost
|
|
4671
|
+
)}`;
|
|
4672
|
+
}
|
|
4673
|
+
if (vlessTransportServiceName) {
|
|
4674
|
+
vlessTransport += `&serviceName=${encodeURIComponent(
|
|
4675
|
+
vlessTransportServiceName
|
|
4676
|
+
)}`;
|
|
4677
|
+
}
|
|
4678
|
+
if (proxy.network === "kcp") {
|
|
4679
|
+
if (proxy.seed) {
|
|
4680
|
+
vlessTransport += `&seed=${encodeURIComponent(proxy.seed)}`;
|
|
4681
|
+
}
|
|
4682
|
+
if (proxy.headerType) {
|
|
4683
|
+
vlessTransport += `&headerType=${encodeURIComponent(
|
|
4684
|
+
proxy.headerType
|
|
4685
|
+
)}`;
|
|
4686
|
+
}
|
|
4687
|
+
}
|
|
4688
|
+
return `vless://${proxy.uuid}@${proxy.server}:${proxy.port}?security=${encodeURIComponent(
|
|
4689
|
+
security
|
|
4690
|
+
)}${vlessTransport}${alpn}${allowInsecure}${sni}${fp}${flow}${sid}${spx}${pbk}${mode}${extra}${pqv}${encryption}#${encodeURIComponent(
|
|
4691
|
+
proxy.name
|
|
4692
|
+
)}`;
|
|
4693
|
+
}
|
|
3987
4694
|
function URI_Producer() {
|
|
3988
4695
|
const type = "SINGLE";
|
|
3989
4696
|
const produce2 = (proxy) => {
|
|
@@ -3994,7 +4701,7 @@ function URI_Producer() {
|
|
|
3994
4701
|
delete proxy.resolved;
|
|
3995
4702
|
delete proxy["no-resolve"];
|
|
3996
4703
|
for (const key in proxy) {
|
|
3997
|
-
if (proxy[key] == null
|
|
4704
|
+
if (proxy[key] == null) {
|
|
3998
4705
|
delete proxy[key];
|
|
3999
4706
|
}
|
|
4000
4707
|
}
|
|
@@ -4003,10 +4710,17 @@ function URI_Producer() {
|
|
|
4003
4710
|
)) {
|
|
4004
4711
|
delete proxy.tls;
|
|
4005
4712
|
}
|
|
4006
|
-
if (proxy.server && isIPv6(proxy.server)) {
|
|
4713
|
+
if (!["vmess"].includes(proxy.type) && proxy.server && isIPv6(proxy.server)) {
|
|
4007
4714
|
proxy.server = `[${proxy.server}]`;
|
|
4008
4715
|
}
|
|
4009
4716
|
switch (proxy.type) {
|
|
4717
|
+
case "socks5":
|
|
4718
|
+
result = `socks://${encodeURIComponent(
|
|
4719
|
+
Base643.encode(
|
|
4720
|
+
`${proxy.username ?? ""}:${proxy.password ?? ""}`
|
|
4721
|
+
)
|
|
4722
|
+
)}@${proxy.server}:${proxy.port}#${proxy.name}`;
|
|
4723
|
+
break;
|
|
4010
4724
|
case "ss":
|
|
4011
4725
|
const userinfo = `${proxy.cipher}:${proxy.password}`;
|
|
4012
4726
|
result = `ss://${proxy.cipher?.startsWith("2022-blake3-") ? `${encodeURIComponent(
|
|
@@ -4026,6 +4740,11 @@ function URI_Producer() {
|
|
|
4026
4740
|
`v2ray-plugin;obfs=${opts.mode}${opts.host ? ";obfs-host" + opts.host : ""}${opts.tls ? ";tls" : ""}`
|
|
4027
4741
|
);
|
|
4028
4742
|
break;
|
|
4743
|
+
case "shadow-tls":
|
|
4744
|
+
result += encodeURIComponent(
|
|
4745
|
+
`shadow-tls;host=${opts.host};password=${opts.password};version=${opts.version}`
|
|
4746
|
+
);
|
|
4747
|
+
break;
|
|
4029
4748
|
default:
|
|
4030
4749
|
throw new Error(
|
|
4031
4750
|
`Unsupported plugin option: ${proxy.plugin}`
|
|
@@ -4058,12 +4777,15 @@ function URI_Producer() {
|
|
|
4058
4777
|
v: "2",
|
|
4059
4778
|
ps: proxy.name,
|
|
4060
4779
|
add: proxy.server,
|
|
4061
|
-
port: proxy.port
|
|
4780
|
+
port: `${proxy.port}`,
|
|
4062
4781
|
id: proxy.uuid,
|
|
4063
|
-
|
|
4064
|
-
|
|
4782
|
+
aid: `${proxy.alterId || 0}`,
|
|
4783
|
+
scy: proxy.cipher,
|
|
4065
4784
|
net,
|
|
4066
|
-
|
|
4785
|
+
type: type2,
|
|
4786
|
+
tls: proxy.tls ? "tls" : "",
|
|
4787
|
+
alpn: Array.isArray(proxy.alpn) ? proxy.alpn.join(",") : proxy.alpn,
|
|
4788
|
+
fp: proxy["client-fingerprint"]
|
|
4067
4789
|
};
|
|
4068
4790
|
if (proxy.tls && proxy.sni) {
|
|
4069
4791
|
result.sni = proxy.sni;
|
|
@@ -4071,113 +4793,27 @@ function URI_Producer() {
|
|
|
4071
4793
|
if (proxy.network) {
|
|
4072
4794
|
let vmessTransportPath = proxy[`${proxy.network}-opts`]?.path;
|
|
4073
4795
|
let vmessTransportHost = proxy[`${proxy.network}-opts`]?.headers?.Host;
|
|
4074
|
-
if (vmessTransportPath) {
|
|
4075
|
-
result.path = Array.isArray(vmessTransportPath) ? vmessTransportPath[0] : vmessTransportPath;
|
|
4076
|
-
}
|
|
4077
|
-
if (vmessTransportHost) {
|
|
4078
|
-
result.host = Array.isArray(vmessTransportHost) ? vmessTransportHost[0] : vmessTransportHost;
|
|
4079
|
-
}
|
|
4080
4796
|
if (["grpc"].includes(proxy.network)) {
|
|
4081
4797
|
result.path = proxy[`${proxy.network}-opts`]?.["grpc-service-name"];
|
|
4082
4798
|
result.type = proxy[`${proxy.network}-opts`]?.["_grpc-type"] || "gun";
|
|
4083
4799
|
result.host = proxy[`${proxy.network}-opts`]?.["_grpc-authority"];
|
|
4800
|
+
} else if (["kcp", "quic"].includes(proxy.network)) {
|
|
4801
|
+
result.type = proxy[`${proxy.network}-opts`]?.[`_${proxy.network}-type`] || "none";
|
|
4802
|
+
result.host = proxy[`${proxy.network}-opts`]?.[`_${proxy.network}-host`];
|
|
4803
|
+
result.path = proxy[`${proxy.network}-opts`]?.[`_${proxy.network}-path`];
|
|
4804
|
+
} else {
|
|
4805
|
+
if (vmessTransportPath) {
|
|
4806
|
+
result.path = Array.isArray(vmessTransportPath) ? vmessTransportPath[0] : vmessTransportPath;
|
|
4807
|
+
}
|
|
4808
|
+
if (vmessTransportHost) {
|
|
4809
|
+
result.host = Array.isArray(vmessTransportHost) ? vmessTransportHost[0] : vmessTransportHost;
|
|
4810
|
+
}
|
|
4084
4811
|
}
|
|
4085
4812
|
}
|
|
4086
4813
|
result = "vmess://" + Base643.encode(JSON.stringify(result));
|
|
4087
4814
|
break;
|
|
4088
4815
|
case "vless":
|
|
4089
|
-
|
|
4090
|
-
const isReality = proxy["reality-opts"];
|
|
4091
|
-
let sid = "";
|
|
4092
|
-
let pbk = "";
|
|
4093
|
-
if (isReality) {
|
|
4094
|
-
security = "reality";
|
|
4095
|
-
const publicKey = proxy["reality-opts"]?.["public-key"];
|
|
4096
|
-
if (publicKey) {
|
|
4097
|
-
pbk = `&pbk=${encodeURIComponent(publicKey)}`;
|
|
4098
|
-
}
|
|
4099
|
-
const shortId = proxy["reality-opts"]?.["short-id"];
|
|
4100
|
-
if (shortId) {
|
|
4101
|
-
sid = `&sid=${encodeURIComponent(shortId)}`;
|
|
4102
|
-
}
|
|
4103
|
-
} else if (proxy.tls) {
|
|
4104
|
-
security = "tls";
|
|
4105
|
-
}
|
|
4106
|
-
let alpn = "";
|
|
4107
|
-
if (proxy.alpn) {
|
|
4108
|
-
alpn = `&alpn=${encodeURIComponent(
|
|
4109
|
-
Array.isArray(proxy.alpn) ? proxy.alpn : proxy.alpn.join(",")
|
|
4110
|
-
)}`;
|
|
4111
|
-
}
|
|
4112
|
-
let allowInsecure = "";
|
|
4113
|
-
if (proxy["skip-cert-verify"]) {
|
|
4114
|
-
allowInsecure = `&allowInsecure=1`;
|
|
4115
|
-
}
|
|
4116
|
-
let sni = "";
|
|
4117
|
-
if (proxy.sni) {
|
|
4118
|
-
sni = `&sni=${encodeURIComponent(proxy.sni)}`;
|
|
4119
|
-
}
|
|
4120
|
-
let fp = "";
|
|
4121
|
-
if (proxy["client-fingerprint"]) {
|
|
4122
|
-
fp = `&fp=${encodeURIComponent(
|
|
4123
|
-
proxy["client-fingerprint"]
|
|
4124
|
-
)}`;
|
|
4125
|
-
}
|
|
4126
|
-
let flow = "";
|
|
4127
|
-
if (proxy.flow) {
|
|
4128
|
-
flow = `&flow=${encodeURIComponent(proxy.flow)}`;
|
|
4129
|
-
}
|
|
4130
|
-
let vlessType = proxy.network;
|
|
4131
|
-
if (proxy.network === "ws" && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
4132
|
-
vlessType = "httpupgrade";
|
|
4133
|
-
}
|
|
4134
|
-
let vlessTransport = `&type=${encodeURIComponent(vlessType)}`;
|
|
4135
|
-
if (["grpc"].includes(proxy.network)) {
|
|
4136
|
-
vlessTransport += `&mode=${encodeURIComponent(
|
|
4137
|
-
proxy[`${proxy.network}-opts`]?.["_grpc-type"] || "gun"
|
|
4138
|
-
)}`;
|
|
4139
|
-
const authority = proxy[`${proxy.network}-opts`]?.["_grpc-authority"];
|
|
4140
|
-
if (authority) {
|
|
4141
|
-
vlessTransport += `&authority=${encodeURIComponent(
|
|
4142
|
-
authority
|
|
4143
|
-
)}`;
|
|
4144
|
-
}
|
|
4145
|
-
}
|
|
4146
|
-
let vlessTransportServiceName = proxy[`${proxy.network}-opts`]?.[`${proxy.network}-service-name`];
|
|
4147
|
-
let vlessTransportPath = proxy[`${proxy.network}-opts`]?.path;
|
|
4148
|
-
let vlessTransportHost = proxy[`${proxy.network}-opts`]?.headers?.Host;
|
|
4149
|
-
if (vlessTransportPath) {
|
|
4150
|
-
vlessTransport += `&path=${encodeURIComponent(
|
|
4151
|
-
Array.isArray(vlessTransportPath) ? vlessTransportPath[0] : vlessTransportPath
|
|
4152
|
-
)}`;
|
|
4153
|
-
}
|
|
4154
|
-
if (vlessTransportHost) {
|
|
4155
|
-
vlessTransport += `&host=${encodeURIComponent(
|
|
4156
|
-
Array.isArray(vlessTransportHost) ? vlessTransportHost[0] : vlessTransportHost
|
|
4157
|
-
)}`;
|
|
4158
|
-
}
|
|
4159
|
-
if (vlessTransportServiceName) {
|
|
4160
|
-
vlessTransport += `&serviceName=${encodeURIComponent(
|
|
4161
|
-
vlessTransportServiceName
|
|
4162
|
-
)}`;
|
|
4163
|
-
}
|
|
4164
|
-
if (proxy.network === "kcp") {
|
|
4165
|
-
if (proxy.seed) {
|
|
4166
|
-
vlessTransport += `&seed=${encodeURIComponent(
|
|
4167
|
-
proxy.seed
|
|
4168
|
-
)}`;
|
|
4169
|
-
}
|
|
4170
|
-
if (proxy.headerType) {
|
|
4171
|
-
vlessTransport += `&headerType=${encodeURIComponent(
|
|
4172
|
-
proxy.headerType
|
|
4173
|
-
)}`;
|
|
4174
|
-
}
|
|
4175
|
-
}
|
|
4176
|
-
result = `vless://${proxy.uuid}@${proxy.server}:${proxy.port}?security=${encodeURIComponent(
|
|
4177
|
-
security
|
|
4178
|
-
)}${vlessTransport}${alpn}${allowInsecure}${sni}${fp}${flow}${sid}${pbk}#${encodeURIComponent(
|
|
4179
|
-
proxy.name
|
|
4180
|
-
)}`;
|
|
4816
|
+
result = vless2(proxy);
|
|
4181
4817
|
break;
|
|
4182
4818
|
case "trojan":
|
|
4183
4819
|
let trojanTransport = "";
|
|
@@ -4229,12 +4865,50 @@ function URI_Producer() {
|
|
|
4229
4865
|
Array.isArray(proxy.alpn) ? proxy.alpn : proxy.alpn.join(",")
|
|
4230
4866
|
)}`;
|
|
4231
4867
|
}
|
|
4232
|
-
|
|
4868
|
+
const trojanIsReality = proxy["reality-opts"];
|
|
4869
|
+
let trojanSid = "";
|
|
4870
|
+
let trojanPbk = "";
|
|
4871
|
+
let trojanSpx = "";
|
|
4872
|
+
let trojanSecurity = "";
|
|
4873
|
+
let trojanMode = "";
|
|
4874
|
+
let trojanExtra = "";
|
|
4875
|
+
if (trojanIsReality) {
|
|
4876
|
+
trojanSecurity = `&security=reality`;
|
|
4877
|
+
const publicKey = proxy["reality-opts"]?.["public-key"];
|
|
4878
|
+
if (publicKey) {
|
|
4879
|
+
trojanPbk = `&pbk=${encodeURIComponent(publicKey)}`;
|
|
4880
|
+
}
|
|
4881
|
+
const shortId = proxy["reality-opts"]?.["short-id"];
|
|
4882
|
+
if (shortId) {
|
|
4883
|
+
trojanSid = `&sid=${encodeURIComponent(shortId)}`;
|
|
4884
|
+
}
|
|
4885
|
+
const spiderX = proxy["reality-opts"]?.["_spider-x"];
|
|
4886
|
+
if (spiderX) {
|
|
4887
|
+
trojanSpx = `&spx=${encodeURIComponent(spiderX)}`;
|
|
4888
|
+
}
|
|
4889
|
+
if (proxy._extra) {
|
|
4890
|
+
trojanExtra = `&extra=${encodeURIComponent(
|
|
4891
|
+
proxy._extra
|
|
4892
|
+
)}`;
|
|
4893
|
+
}
|
|
4894
|
+
if (proxy._mode) {
|
|
4895
|
+
trojanMode = `&mode=${encodeURIComponent(proxy._mode)}`;
|
|
4896
|
+
}
|
|
4897
|
+
}
|
|
4898
|
+
result = `trojan://${proxy.password}@${proxy.server}:${proxy.port}?sni=${encodeURIComponent(proxy.sni || proxy.server)}${proxy["skip-cert-verify"] ? "&allowInsecure=1" : ""}${trojanTransport}${trojanAlpn}${trojanFp}${trojanSecurity}${trojanSid}${trojanPbk}${trojanSpx}${trojanMode}${trojanExtra}#${encodeURIComponent(
|
|
4233
4899
|
proxy.name
|
|
4234
4900
|
)}`;
|
|
4235
4901
|
break;
|
|
4236
4902
|
case "hysteria2":
|
|
4237
4903
|
let hysteria2params = [];
|
|
4904
|
+
if (proxy["hop-interval"]) {
|
|
4905
|
+
hysteria2params.push(
|
|
4906
|
+
`hop-interval=${proxy["hop-interval"]}`
|
|
4907
|
+
);
|
|
4908
|
+
}
|
|
4909
|
+
if (proxy["keepalive"]) {
|
|
4910
|
+
hysteria2params.push(`keepalive=${proxy["keepalive"]}`);
|
|
4911
|
+
}
|
|
4238
4912
|
if (proxy["skip-cert-verify"]) {
|
|
4239
4913
|
hysteria2params.push(`insecure=1`);
|
|
4240
4914
|
}
|
|
@@ -4307,7 +4981,7 @@ function URI_Producer() {
|
|
|
4307
4981
|
hysteriaParams.push(`obfsParam=${proxy[key]}`);
|
|
4308
4982
|
} else if (["sni"].includes(key)) {
|
|
4309
4983
|
hysteriaParams.push(`peer=${proxy[key]}`);
|
|
4310
|
-
} else if (proxy[key]) {
|
|
4984
|
+
} else if (proxy[key] && !/^_/i.test(key)) {
|
|
4311
4985
|
hysteriaParams.push(
|
|
4312
4986
|
`${i}=${encodeURIComponent(proxy[key])}`
|
|
4313
4987
|
);
|
|
@@ -4328,7 +5002,8 @@ function URI_Producer() {
|
|
|
4328
5002
|
"uuid",
|
|
4329
5003
|
"password",
|
|
4330
5004
|
"server",
|
|
4331
|
-
"port"
|
|
5005
|
+
"port",
|
|
5006
|
+
"tls"
|
|
4332
5007
|
].includes(key)) {
|
|
4333
5008
|
const i = key.replace(/-/, "_");
|
|
4334
5009
|
if (["alpn"].includes(key)) {
|
|
@@ -4348,10 +5023,17 @@ function URI_Producer() {
|
|
|
4348
5023
|
tuicParams.push(`fast_open=1`);
|
|
4349
5024
|
}
|
|
4350
5025
|
} else if (["disable-sni", "reduce-rtt"].includes(key) && proxy[key]) {
|
|
4351
|
-
tuicParams.push(`${i}=1`);
|
|
4352
|
-
} else if (
|
|
5026
|
+
tuicParams.push(`${i.replace(/-/g, "_")}=1`);
|
|
5027
|
+
} else if (["congestion-controller"].includes(key)) {
|
|
5028
|
+
tuicParams.push(
|
|
5029
|
+
`congestion_control=${proxy[key]}`
|
|
5030
|
+
);
|
|
5031
|
+
} else if (proxy[key] && !/^_/i.test(key)) {
|
|
4353
5032
|
tuicParams.push(
|
|
4354
|
-
`${i
|
|
5033
|
+
`${i.replace(
|
|
5034
|
+
/-/g,
|
|
5035
|
+
"_"
|
|
5036
|
+
)}=${encodeURIComponent(proxy[key])}`
|
|
4355
5037
|
);
|
|
4356
5038
|
}
|
|
4357
5039
|
}
|
|
@@ -4363,6 +5045,74 @@ function URI_Producer() {
|
|
|
4363
5045
|
)}`;
|
|
4364
5046
|
}
|
|
4365
5047
|
break;
|
|
5048
|
+
case "anytls":
|
|
5049
|
+
result = vless2({
|
|
5050
|
+
...proxy,
|
|
5051
|
+
uuid: proxy.password,
|
|
5052
|
+
network: proxy.network || "tcp"
|
|
5053
|
+
}).replace("vless", "anytls");
|
|
5054
|
+
let anytlsParams = [];
|
|
5055
|
+
Object.keys(proxy).forEach((key) => {
|
|
5056
|
+
if (![
|
|
5057
|
+
"name",
|
|
5058
|
+
"type",
|
|
5059
|
+
"password",
|
|
5060
|
+
"server",
|
|
5061
|
+
"port",
|
|
5062
|
+
"tls"
|
|
5063
|
+
].includes(key)) {
|
|
5064
|
+
const i = key.replace(/-/, "_");
|
|
5065
|
+
if (["alpn"].includes(key)) {
|
|
5066
|
+
if (proxy[key]) {
|
|
5067
|
+
anytlsParams.push(
|
|
5068
|
+
`${i}=${encodeURIComponent(
|
|
5069
|
+
Array.isArray(proxy[key]) ? proxy[key][0] : proxy[key]
|
|
5070
|
+
)}`
|
|
5071
|
+
);
|
|
5072
|
+
}
|
|
5073
|
+
} else if (["skip-cert-verify"].includes(key)) {
|
|
5074
|
+
if (proxy[key]) {
|
|
5075
|
+
anytlsParams.push(`insecure=1`);
|
|
5076
|
+
}
|
|
5077
|
+
} else if (["udp"].includes(key)) {
|
|
5078
|
+
if (proxy[key]) {
|
|
5079
|
+
anytlsParams.push(`udp=1`);
|
|
5080
|
+
}
|
|
5081
|
+
} else if (proxy[key] && !/^_|client-fingerprint/i.test(key) && ["number", "string", "boolean"].includes(
|
|
5082
|
+
typeof proxy[key]
|
|
5083
|
+
)) {
|
|
5084
|
+
anytlsParams.push(
|
|
5085
|
+
`${i.replace(/-/g, "_")}=${encodeURIComponent(
|
|
5086
|
+
proxy[key]
|
|
5087
|
+
)}`
|
|
5088
|
+
);
|
|
5089
|
+
}
|
|
5090
|
+
}
|
|
5091
|
+
});
|
|
5092
|
+
const urlParts = result.split("?");
|
|
5093
|
+
let baseUrl = urlParts[0];
|
|
5094
|
+
let existingParams = {};
|
|
5095
|
+
if (urlParts.length > 1) {
|
|
5096
|
+
const queryString = urlParts[1].split("#")[0];
|
|
5097
|
+
const pairs = queryString.split("&");
|
|
5098
|
+
pairs.forEach((pair) => {
|
|
5099
|
+
const [key, value] = pair.split("=");
|
|
5100
|
+
if (key) {
|
|
5101
|
+
existingParams[key] = value;
|
|
5102
|
+
}
|
|
5103
|
+
});
|
|
5104
|
+
}
|
|
5105
|
+
anytlsParams.forEach((param) => {
|
|
5106
|
+
const [key, value] = param.split("=");
|
|
5107
|
+
if (key) {
|
|
5108
|
+
existingParams[key] = value;
|
|
5109
|
+
}
|
|
5110
|
+
});
|
|
5111
|
+
const newParams = Object.keys(existingParams).map((key) => `${key}=${existingParams[key]}`).join("&");
|
|
5112
|
+
const fragmentMatch = result.match(/#(.*)$/);
|
|
5113
|
+
const fragment = fragmentMatch ? `#${fragmentMatch[1]}` : "";
|
|
5114
|
+
result = `${baseUrl}?${newParams}${fragment}`;
|
|
5115
|
+
break;
|
|
4366
5116
|
case "wireguard":
|
|
4367
5117
|
let wireguardParams = [];
|
|
4368
5118
|
Object.keys(proxy).forEach((key) => {
|
|
@@ -4381,7 +5131,7 @@ function URI_Producer() {
|
|
|
4381
5131
|
if (proxy[key]) {
|
|
4382
5132
|
wireguardParams.push(`${key}=1`);
|
|
4383
5133
|
}
|
|
4384
|
-
} else if (proxy[key]) {
|
|
5134
|
+
} else if (proxy[key] && !/^_/i.test(key)) {
|
|
4385
5135
|
wireguardParams.push(
|
|
4386
5136
|
`${key}=${encodeURIComponent(proxy[key])}`
|
|
4387
5137
|
);
|
|
@@ -4453,7 +5203,7 @@ function QX_Producer() {
|
|
|
4453
5203
|
case "socks5":
|
|
4454
5204
|
return socks53(proxy);
|
|
4455
5205
|
case "vless":
|
|
4456
|
-
return
|
|
5206
|
+
return vless3(proxy);
|
|
4457
5207
|
}
|
|
4458
5208
|
throw new Error(
|
|
4459
5209
|
`Platform ${targetPlatform4} does not support proxy type: ${proxy.type}`
|
|
@@ -4489,7 +5239,9 @@ function shadowsocks3(proxy) {
|
|
|
4489
5239
|
"aes-192-gcm",
|
|
4490
5240
|
"aes-256-gcm",
|
|
4491
5241
|
"chacha20-ietf-poly1305",
|
|
4492
|
-
"xchacha20-ietf-poly1305"
|
|
5242
|
+
"xchacha20-ietf-poly1305",
|
|
5243
|
+
"2022-blake3-aes-128-gcm",
|
|
5244
|
+
"2022-blake3-aes-256-gcm"
|
|
4493
5245
|
].includes(proxy.cipher)) {
|
|
4494
5246
|
throw new Error(`cipher ${proxy.cipher} is not supported`);
|
|
4495
5247
|
}
|
|
@@ -4545,6 +5297,15 @@ function shadowsocks3(proxy) {
|
|
|
4545
5297
|
}
|
|
4546
5298
|
appendIfPresent(`,fast-open=${proxy.tfo}`, "tfo");
|
|
4547
5299
|
appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
5300
|
+
if (proxy["_ssr_python_uot"]) {
|
|
5301
|
+
append(`,udp-over-tcp=true`);
|
|
5302
|
+
} else if (proxy["udp-over-tcp"]) {
|
|
5303
|
+
if (!proxy["udp-over-tcp-version"] || proxy["udp-over-tcp-version"] === 1) {
|
|
5304
|
+
append(`,udp-over-tcp=sp.v1`);
|
|
5305
|
+
} else if (proxy["udp-over-tcp-version"] === 2) {
|
|
5306
|
+
append(`,udp-over-tcp=sp.v2`);
|
|
5307
|
+
}
|
|
5308
|
+
}
|
|
4548
5309
|
result.appendIfPresent(
|
|
4549
5310
|
`,server_check_url=${proxy["test-url"]}`,
|
|
4550
5311
|
"test-url"
|
|
@@ -4709,7 +5470,7 @@ function vmess3(proxy) {
|
|
|
4709
5470
|
append(`,tag=${proxy.name}`);
|
|
4710
5471
|
return result.toString();
|
|
4711
5472
|
}
|
|
4712
|
-
function
|
|
5473
|
+
function vless3(proxy) {
|
|
4713
5474
|
if (typeof proxy.flow !== "undefined" || proxy["reality-opts"]) {
|
|
4714
5475
|
throw new Error(`VLESS XTLS/REALITY is not supported`);
|
|
4715
5476
|
}
|
|
@@ -4729,6 +5490,8 @@ function vless2(proxy) {
|
|
|
4729
5490
|
else append(`,obfs=ws`);
|
|
4730
5491
|
} else if (proxy.network === "http") {
|
|
4731
5492
|
append(`,obfs=http`);
|
|
5493
|
+
} else if (["tcp"].includes(proxy.network)) {
|
|
5494
|
+
if (proxy.tls) append(`,obfs=over-tls`);
|
|
4732
5495
|
} else if (!["tcp"].includes(proxy.network)) {
|
|
4733
5496
|
throw new Error(`network ${proxy.network} is unsupported`);
|
|
4734
5497
|
}
|
|
@@ -4871,12 +5634,12 @@ function needTls(proxy) {
|
|
|
4871
5634
|
}
|
|
4872
5635
|
|
|
4873
5636
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/shadowrocket.js
|
|
4874
|
-
function
|
|
5637
|
+
function Shadowrocket_Producer() {
|
|
4875
5638
|
const type = "ALL";
|
|
4876
5639
|
const produce2 = (proxies, type2, opts = {}) => {
|
|
4877
5640
|
const list = proxies.filter((proxy) => {
|
|
4878
5641
|
if (opts["include-unsupported-proxy"]) return true;
|
|
4879
|
-
if (proxy.type === "snell" &&
|
|
5642
|
+
if (proxy.type === "snell" && proxy.version >= 4) {
|
|
4880
5643
|
return false;
|
|
4881
5644
|
} else if (["mieru"].includes(proxy.type)) {
|
|
4882
5645
|
return false;
|
|
@@ -4896,17 +5659,16 @@ function ShadowRocket_Producer() {
|
|
|
4896
5659
|
}
|
|
4897
5660
|
if (isPresent2(proxy, "cipher") && ![
|
|
4898
5661
|
"auto",
|
|
5662
|
+
"none",
|
|
5663
|
+
"zero",
|
|
4899
5664
|
"aes-128-gcm",
|
|
4900
|
-
"chacha20-poly1305"
|
|
4901
|
-
"none"
|
|
5665
|
+
"chacha20-poly1305"
|
|
4902
5666
|
].includes(proxy.cipher)) {
|
|
4903
5667
|
proxy.cipher = "auto";
|
|
4904
5668
|
}
|
|
4905
5669
|
} else if (proxy.type === "tuic") {
|
|
4906
5670
|
if (isPresent2(proxy, "alpn")) {
|
|
4907
5671
|
proxy.alpn = Array.isArray(proxy.alpn) ? proxy.alpn : [proxy.alpn];
|
|
4908
|
-
} else {
|
|
4909
|
-
proxy.alpn = ["h3"];
|
|
4910
5672
|
}
|
|
4911
5673
|
if (isPresent2(proxy, "tfo") && !isPresent2(proxy, "fast-open")) {
|
|
4912
5674
|
proxy["fast-open"] = proxy.tfo;
|
|
@@ -4925,10 +5687,6 @@ function ShadowRocket_Producer() {
|
|
|
4925
5687
|
proxy["fast-open"] = proxy.tfo;
|
|
4926
5688
|
}
|
|
4927
5689
|
} else if (proxy.type === "hysteria2") {
|
|
4928
|
-
if (proxy["obfs-password"] && proxy.obfs == "salamander") {
|
|
4929
|
-
proxy.obfs = proxy["obfs-password"];
|
|
4930
|
-
delete proxy["obfs-password"];
|
|
4931
|
-
}
|
|
4932
5690
|
if (isPresent2(proxy, "alpn")) {
|
|
4933
5691
|
proxy.alpn = Array.isArray(proxy.alpn) ? proxy.alpn : [proxy.alpn];
|
|
4934
5692
|
}
|
|
@@ -4940,11 +5698,27 @@ function ShadowRocket_Producer() {
|
|
|
4940
5698
|
proxy["persistent-keepalive"] = proxy.keepalive;
|
|
4941
5699
|
proxy["preshared-key"] = proxy["preshared-key"] ?? proxy["pre-shared-key"];
|
|
4942
5700
|
proxy["pre-shared-key"] = proxy["preshared-key"];
|
|
5701
|
+
} else if (proxy.type === "snell" && proxy.version < 3) {
|
|
5702
|
+
delete proxy.udp;
|
|
4943
5703
|
} else if (proxy.type === "vless") {
|
|
4944
5704
|
if (isPresent2(proxy, "sni")) {
|
|
4945
5705
|
proxy.servername = proxy.sni;
|
|
4946
5706
|
delete proxy.sni;
|
|
4947
5707
|
}
|
|
5708
|
+
} else if (proxy.type === "ss") {
|
|
5709
|
+
if (isPresent2(proxy, "shadow-tls-password") && !isPresent2(proxy, "plugin")) {
|
|
5710
|
+
proxy.plugin = "shadow-tls";
|
|
5711
|
+
proxy["plugin-opts"] = {
|
|
5712
|
+
host: proxy["shadow-tls-sni"],
|
|
5713
|
+
password: proxy["shadow-tls-password"],
|
|
5714
|
+
version: proxy["shadow-tls-version"]
|
|
5715
|
+
};
|
|
5716
|
+
delete proxy["shadow-tls-password"];
|
|
5717
|
+
delete proxy["shadow-tls-sni"];
|
|
5718
|
+
delete proxy["shadow-tls-version"];
|
|
5719
|
+
}
|
|
5720
|
+
} else if (["anytls"].includes(proxy.type) && proxy.network && (!["tcp"].includes(proxy.network) || ["tcp"].includes(proxy.network) && proxy["reality-opts"])) {
|
|
5721
|
+
return false;
|
|
4948
5722
|
}
|
|
4949
5723
|
if (["vmess", "vless"].includes(proxy.type) && proxy.network === "http") {
|
|
4950
5724
|
let httpPath = proxy["http-opts"]?.path;
|
|
@@ -4966,6 +5740,24 @@ function ShadowRocket_Producer() {
|
|
|
4966
5740
|
proxy["h2-opts"].headers.host = [host];
|
|
4967
5741
|
}
|
|
4968
5742
|
}
|
|
5743
|
+
if (["ws"].includes(proxy.network)) {
|
|
5744
|
+
const networkPath = proxy[`${proxy.network}-opts`]?.path;
|
|
5745
|
+
if (networkPath) {
|
|
5746
|
+
const reg = /^(.*?)(?:\?ed=(\d+))?$/;
|
|
5747
|
+
const [_2, path = "", ed = ""] = reg.exec(networkPath);
|
|
5748
|
+
proxy[`${proxy.network}-opts`].path = path;
|
|
5749
|
+
if (ed !== "") {
|
|
5750
|
+
proxy["ws-opts"]["early-data-header-name"] = "Sec-WebSocket-Protocol";
|
|
5751
|
+
proxy["ws-opts"]["max-early-data"] = parseInt(
|
|
5752
|
+
ed,
|
|
5753
|
+
10
|
|
5754
|
+
);
|
|
5755
|
+
}
|
|
5756
|
+
} else {
|
|
5757
|
+
proxy[`${proxy.network}-opts`] = proxy[`${proxy.network}-opts`] || {};
|
|
5758
|
+
proxy[`${proxy.network}-opts`].path = "/";
|
|
5759
|
+
}
|
|
5760
|
+
}
|
|
4969
5761
|
if (proxy["plugin-opts"]?.tls) {
|
|
4970
5762
|
if (isPresent2(proxy, "skip-cert-verify")) {
|
|
4971
5763
|
proxy["plugin-opts"]["skip-cert-verify"] = proxy["skip-cert-verify"];
|
|
@@ -4976,7 +5768,8 @@ function ShadowRocket_Producer() {
|
|
|
4976
5768
|
"tuic",
|
|
4977
5769
|
"hysteria",
|
|
4978
5770
|
"hysteria2",
|
|
4979
|
-
"juicity"
|
|
5771
|
+
"juicity",
|
|
5772
|
+
"anytls"
|
|
4980
5773
|
].includes(proxy.type)) {
|
|
4981
5774
|
delete proxy.tls;
|
|
4982
5775
|
}
|
|
@@ -5189,9 +5982,32 @@ function handleTransport2(result, proxy) {
|
|
|
5189
5982
|
}
|
|
5190
5983
|
|
|
5191
5984
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/sing-box.js
|
|
5985
|
+
var ipVersions4 = {
|
|
5986
|
+
ipv4: "ipv4_only",
|
|
5987
|
+
ipv6: "ipv6_only",
|
|
5988
|
+
"v4-only": "ipv4_only",
|
|
5989
|
+
"v6-only": "ipv6_only",
|
|
5990
|
+
"ipv4-prefer": "prefer_ipv4",
|
|
5991
|
+
"ipv6-prefer": "prefer_ipv6",
|
|
5992
|
+
"prefer-v4": "prefer_ipv4",
|
|
5993
|
+
"prefer-v6": "prefer_ipv6"
|
|
5994
|
+
};
|
|
5995
|
+
var ipVersionParser = (proxy, parsedProxy) => {
|
|
5996
|
+
const strategy = ipVersions4[proxy["ip-version"]];
|
|
5997
|
+
if (proxy._dns_server && strategy) {
|
|
5998
|
+
parsedProxy.domain_resolver = {
|
|
5999
|
+
server: proxy._dns_server,
|
|
6000
|
+
strategy
|
|
6001
|
+
};
|
|
6002
|
+
}
|
|
6003
|
+
};
|
|
5192
6004
|
var detourParser = (proxy, parsedProxy) => {
|
|
5193
6005
|
parsedProxy.detour = proxy["dialer-proxy"] || proxy.detour;
|
|
5194
6006
|
};
|
|
6007
|
+
var networkParser = (proxy, parsedProxy) => {
|
|
6008
|
+
if (["tcp", "udp"].includes(proxy._network))
|
|
6009
|
+
parsedProxy.network = proxy._network;
|
|
6010
|
+
};
|
|
5195
6011
|
var tfoParser = (proxy, parsedProxy) => {
|
|
5196
6012
|
parsedProxy.tcp_fast_open = false;
|
|
5197
6013
|
if (proxy.tfo) parsedProxy.tcp_fast_open = true;
|
|
@@ -5213,11 +6029,33 @@ var smuxParser = (smux, proxy) => {
|
|
|
5213
6029
|
if (smux["min-streams"])
|
|
5214
6030
|
proxy.multiplex.min_streams = parseInt(`${smux["min-streams"]}`, 10);
|
|
5215
6031
|
if (smux.padding) proxy.multiplex.padding = true;
|
|
6032
|
+
if (smux["brutal-opts"]?.up || smux["brutal-opts"]?.down) {
|
|
6033
|
+
proxy.multiplex.brutal = {
|
|
6034
|
+
enabled: true
|
|
6035
|
+
};
|
|
6036
|
+
if (smux["brutal-opts"]?.up)
|
|
6037
|
+
proxy.multiplex.brutal.up_mbps = parseInt(
|
|
6038
|
+
`${smux["brutal-opts"]?.up}`,
|
|
6039
|
+
10
|
|
6040
|
+
);
|
|
6041
|
+
if (smux["brutal-opts"]?.down)
|
|
6042
|
+
proxy.multiplex.brutal.down_mbps = parseInt(
|
|
6043
|
+
`${smux["brutal-opts"]?.down}`,
|
|
6044
|
+
10
|
|
6045
|
+
);
|
|
6046
|
+
}
|
|
5216
6047
|
};
|
|
5217
6048
|
var wsParser = (proxy, parsedProxy) => {
|
|
5218
6049
|
const transport = { type: "ws", headers: {} };
|
|
5219
6050
|
if (proxy["ws-opts"]) {
|
|
5220
|
-
const {
|
|
6051
|
+
const {
|
|
6052
|
+
path: wsPath = "",
|
|
6053
|
+
headers: wsHeaders = {},
|
|
6054
|
+
"max-early-data": max_early_data,
|
|
6055
|
+
"early-data-header-name": early_data_header_name
|
|
6056
|
+
} = proxy["ws-opts"];
|
|
6057
|
+
transport.early_data_header_name = early_data_header_name;
|
|
6058
|
+
transport.max_early_data = max_early_data ? parseInt(max_early_data, 10) : void 0;
|
|
5221
6059
|
if (wsPath !== "") transport.path = `${wsPath}`;
|
|
5222
6060
|
if (Object.keys(wsHeaders).length > 0) {
|
|
5223
6061
|
const headers = {};
|
|
@@ -5317,7 +6155,6 @@ var h1Parser = (proxy, parsedProxy) => {
|
|
|
5317
6155
|
host = `${host}`.split(",").map((i) => i.trim());
|
|
5318
6156
|
if (host.length > 0) transport.host = host;
|
|
5319
6157
|
}
|
|
5320
|
-
if (!transport.host) return;
|
|
5321
6158
|
if (proxy["http-path"] && proxy["http-path"] !== "") {
|
|
5322
6159
|
const path = proxy["http-path"];
|
|
5323
6160
|
if (Array.isArray(path)) {
|
|
@@ -5326,7 +6163,7 @@ var h1Parser = (proxy, parsedProxy) => {
|
|
|
5326
6163
|
}
|
|
5327
6164
|
if (parsedProxy.tls.insecure)
|
|
5328
6165
|
parsedProxy.tls.server_name = transport.host[0];
|
|
5329
|
-
if (transport.host
|
|
6166
|
+
if (transport.host?.length === 1) transport.host = transport.host[0];
|
|
5330
6167
|
for (const key of Object.keys(transport.headers)) {
|
|
5331
6168
|
const value = transport.headers[key];
|
|
5332
6169
|
if (value.length === 1) transport.headers[key] = value[0];
|
|
@@ -5396,6 +6233,11 @@ var tlsParser = (proxy, parsedProxy) => {
|
|
|
5396
6233
|
enabled: true,
|
|
5397
6234
|
fingerprint: proxy["client-fingerprint"]
|
|
5398
6235
|
};
|
|
6236
|
+
if (proxy["_fragment"]) parsedProxy.tls.fragment = !!proxy["_fragment"];
|
|
6237
|
+
if (proxy["_fragment_fallback_delay"])
|
|
6238
|
+
parsedProxy.tls.fragment_fallback_delay = proxy["_fragment_fallback_delay"];
|
|
6239
|
+
if (proxy["_record_fragment"])
|
|
6240
|
+
parsedProxy.tls.record_fragment = !!proxy["_record_fragment"];
|
|
5399
6241
|
if (!parsedProxy.tls.enabled) delete parsedProxy.tls;
|
|
5400
6242
|
};
|
|
5401
6243
|
var sshParser = (proxy = {}) => {
|
|
@@ -5426,6 +6268,7 @@ var sshParser = (proxy = {}) => {
|
|
|
5426
6268
|
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
5427
6269
|
tfoParser(proxy, parsedProxy);
|
|
5428
6270
|
detourParser(proxy, parsedProxy);
|
|
6271
|
+
ipVersionParser(proxy, parsedProxy);
|
|
5429
6272
|
return parsedProxy;
|
|
5430
6273
|
};
|
|
5431
6274
|
var httpParser = (proxy = {}) => {
|
|
@@ -5452,6 +6295,7 @@ var httpParser = (proxy = {}) => {
|
|
|
5452
6295
|
tfoParser(proxy, parsedProxy);
|
|
5453
6296
|
detourParser(proxy, parsedProxy);
|
|
5454
6297
|
tlsParser(proxy, parsedProxy);
|
|
6298
|
+
ipVersionParser(proxy, parsedProxy);
|
|
5455
6299
|
return parsedProxy;
|
|
5456
6300
|
};
|
|
5457
6301
|
var socks5Parser = (proxy = {}) => {
|
|
@@ -5470,8 +6314,10 @@ var socks5Parser = (proxy = {}) => {
|
|
|
5470
6314
|
if (proxy.uot) parsedProxy.udp_over_tcp = true;
|
|
5471
6315
|
if (proxy["udp-over-tcp"]) parsedProxy.udp_over_tcp = true;
|
|
5472
6316
|
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
6317
|
+
networkParser(proxy, parsedProxy);
|
|
5473
6318
|
tfoParser(proxy, parsedProxy);
|
|
5474
6319
|
detourParser(proxy, parsedProxy);
|
|
6320
|
+
ipVersionParser(proxy, parsedProxy);
|
|
5475
6321
|
return parsedProxy;
|
|
5476
6322
|
};
|
|
5477
6323
|
var shadowTLSParser = (proxy = {}) => {
|
|
@@ -5482,6 +6328,13 @@ var shadowTLSParser = (proxy = {}) => {
|
|
|
5482
6328
|
password: proxy.password,
|
|
5483
6329
|
detour: `${proxy.name}_shadowtls`
|
|
5484
6330
|
};
|
|
6331
|
+
if (proxy.uot) ssPart.udp_over_tcp = true;
|
|
6332
|
+
if (proxy["udp-over-tcp"]) {
|
|
6333
|
+
ssPart.udp_over_tcp = {
|
|
6334
|
+
enabled: true,
|
|
6335
|
+
version: !proxy["udp-over-tcp-version"] || proxy["udp-over-tcp-version"] === 1 ? 1 : 2
|
|
6336
|
+
};
|
|
6337
|
+
}
|
|
5485
6338
|
const stPart = {
|
|
5486
6339
|
tag: `${proxy.name}_shadowtls`,
|
|
5487
6340
|
type: "shadowtls",
|
|
@@ -5504,6 +6357,7 @@ var shadowTLSParser = (proxy = {}) => {
|
|
|
5504
6357
|
tfoParser(proxy, stPart);
|
|
5505
6358
|
detourParser(proxy, stPart);
|
|
5506
6359
|
smuxParser(proxy.smux, ssPart);
|
|
6360
|
+
ipVersionParser(proxy, stPart);
|
|
5507
6361
|
return { type: "ss-with-st", ssPart, stPart };
|
|
5508
6362
|
};
|
|
5509
6363
|
var ssParser = (proxy = {}) => {
|
|
@@ -5518,11 +6372,18 @@ var ssParser = (proxy = {}) => {
|
|
|
5518
6372
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
5519
6373
|
throw "invalid port";
|
|
5520
6374
|
if (proxy.uot) parsedProxy.udp_over_tcp = true;
|
|
5521
|
-
if (proxy["udp-over-tcp"])
|
|
6375
|
+
if (proxy["udp-over-tcp"]) {
|
|
6376
|
+
parsedProxy.udp_over_tcp = {
|
|
6377
|
+
enabled: true,
|
|
6378
|
+
version: !proxy["udp-over-tcp-version"] || proxy["udp-over-tcp-version"] === 1 ? 1 : 2
|
|
6379
|
+
};
|
|
6380
|
+
}
|
|
5522
6381
|
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
6382
|
+
networkParser(proxy, parsedProxy);
|
|
5523
6383
|
tfoParser(proxy, parsedProxy);
|
|
5524
6384
|
detourParser(proxy, parsedProxy);
|
|
5525
6385
|
smuxParser(proxy.smux, parsedProxy);
|
|
6386
|
+
ipVersionParser(proxy, parsedProxy);
|
|
5526
6387
|
if (proxy.plugin) {
|
|
5527
6388
|
const optArr = [];
|
|
5528
6389
|
if (proxy.plugin === "obfs") {
|
|
@@ -5599,6 +6460,7 @@ var ssrParser = (proxy = {}) => {
|
|
|
5599
6460
|
tfoParser(proxy, parsedProxy);
|
|
5600
6461
|
detourParser(proxy, parsedProxy);
|
|
5601
6462
|
smuxParser(proxy.smux, parsedProxy);
|
|
6463
|
+
ipVersionParser(proxy, parsedProxy);
|
|
5602
6464
|
return parsedProxy;
|
|
5603
6465
|
};
|
|
5604
6466
|
var vmessParser = (proxy = {}) => {
|
|
@@ -5629,10 +6491,12 @@ var vmessParser = (proxy = {}) => {
|
|
|
5629
6491
|
if (proxy.network === "h2") h2Parser(proxy, parsedProxy);
|
|
5630
6492
|
if (proxy.network === "http") h1Parser(proxy, parsedProxy);
|
|
5631
6493
|
if (proxy.network === "grpc") grpcParser(proxy, parsedProxy);
|
|
6494
|
+
networkParser(proxy, parsedProxy);
|
|
5632
6495
|
tfoParser(proxy, parsedProxy);
|
|
5633
6496
|
detourParser(proxy, parsedProxy);
|
|
5634
6497
|
tlsParser(proxy, parsedProxy);
|
|
5635
6498
|
smuxParser(proxy.smux, parsedProxy);
|
|
6499
|
+
ipVersionParser(proxy, parsedProxy);
|
|
5636
6500
|
return parsedProxy;
|
|
5637
6501
|
};
|
|
5638
6502
|
var vlessParser = (proxy = {}) => {
|
|
@@ -5646,14 +6510,19 @@ var vlessParser = (proxy = {}) => {
|
|
|
5646
6510
|
};
|
|
5647
6511
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
5648
6512
|
throw "invalid port";
|
|
6513
|
+
if (proxy.xudp) parsedProxy.packet_encoding = "xudp";
|
|
5649
6514
|
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
5650
|
-
if (proxy.flow
|
|
6515
|
+
if (proxy.flow != null) parsedProxy.flow = proxy.flow;
|
|
5651
6516
|
if (proxy.network === "ws") wsParser(proxy, parsedProxy);
|
|
6517
|
+
if (proxy.network === "h2") h2Parser(proxy, parsedProxy);
|
|
6518
|
+
if (proxy.network === "http") h1Parser(proxy, parsedProxy);
|
|
5652
6519
|
if (proxy.network === "grpc") grpcParser(proxy, parsedProxy);
|
|
6520
|
+
networkParser(proxy, parsedProxy);
|
|
5653
6521
|
tfoParser(proxy, parsedProxy);
|
|
5654
6522
|
detourParser(proxy, parsedProxy);
|
|
5655
6523
|
smuxParser(proxy.smux, parsedProxy);
|
|
5656
6524
|
tlsParser(proxy, parsedProxy);
|
|
6525
|
+
ipVersionParser(proxy, parsedProxy);
|
|
5657
6526
|
return parsedProxy;
|
|
5658
6527
|
};
|
|
5659
6528
|
var trojanParser = (proxy = {}) => {
|
|
@@ -5670,10 +6539,12 @@ var trojanParser = (proxy = {}) => {
|
|
|
5670
6539
|
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
5671
6540
|
if (proxy.network === "grpc") grpcParser(proxy, parsedProxy);
|
|
5672
6541
|
if (proxy.network === "ws") wsParser(proxy, parsedProxy);
|
|
6542
|
+
networkParser(proxy, parsedProxy);
|
|
5673
6543
|
tfoParser(proxy, parsedProxy);
|
|
5674
6544
|
detourParser(proxy, parsedProxy);
|
|
5675
6545
|
tlsParser(proxy, parsedProxy);
|
|
5676
6546
|
smuxParser(proxy.smux, parsedProxy);
|
|
6547
|
+
ipVersionParser(proxy, parsedProxy);
|
|
5677
6548
|
return parsedProxy;
|
|
5678
6549
|
};
|
|
5679
6550
|
var hysteriaParser = (proxy = {}) => {
|
|
@@ -5687,16 +6558,23 @@ var hysteriaParser = (proxy = {}) => {
|
|
|
5687
6558
|
};
|
|
5688
6559
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
5689
6560
|
throw "invalid port";
|
|
6561
|
+
if (proxy["hop-interval"])
|
|
6562
|
+
parsedProxy.hop_interval = /^\d+$/.test(proxy["hop-interval"]) ? `${proxy["hop-interval"]}s` : proxy["hop-interval"];
|
|
6563
|
+
if (proxy["ports"])
|
|
6564
|
+
parsedProxy.server_ports = proxy["ports"].split(/\s*,\s*/).map((p) => {
|
|
6565
|
+
const range = p.replace(/\s*-\s*/g, ":");
|
|
6566
|
+
return range.includes(":") ? range : `${range}:${range}`;
|
|
6567
|
+
});
|
|
5690
6568
|
if (proxy.auth_str) parsedProxy.auth_str = `${proxy.auth_str}`;
|
|
5691
6569
|
if (proxy["auth-str"]) parsedProxy.auth_str = `${proxy["auth-str"]}`;
|
|
5692
6570
|
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
5693
6571
|
const reg = new RegExp("^[0-9]+[ ]*[KMGT]*[Bb]ps$");
|
|
5694
|
-
if (reg.test(`${proxy.up}`)) {
|
|
6572
|
+
if (reg.test(`${proxy.up}`) && !`${proxy.up}`.endsWith("Mbps")) {
|
|
5695
6573
|
parsedProxy.up = `${proxy.up}`;
|
|
5696
6574
|
} else {
|
|
5697
6575
|
parsedProxy.up_mbps = parseInt(`${proxy.up}`, 10);
|
|
5698
6576
|
}
|
|
5699
|
-
if (reg.test(`${proxy.down}`)) {
|
|
6577
|
+
if (reg.test(`${proxy.down}`) && !`${proxy.down}`.endsWith("Mbps")) {
|
|
5700
6578
|
parsedProxy.down = `${proxy.down}`;
|
|
5701
6579
|
} else {
|
|
5702
6580
|
parsedProxy.down_mbps = parseInt(`${proxy.down}`, 10);
|
|
@@ -5716,13 +6594,15 @@ var hysteriaParser = (proxy = {}) => {
|
|
|
5716
6594
|
parsedProxy.disable_mtu_discovery = true;
|
|
5717
6595
|
}
|
|
5718
6596
|
}
|
|
6597
|
+
networkParser(proxy, parsedProxy);
|
|
5719
6598
|
tlsParser(proxy, parsedProxy);
|
|
5720
6599
|
detourParser(proxy, parsedProxy);
|
|
5721
6600
|
tfoParser(proxy, parsedProxy);
|
|
5722
6601
|
smuxParser(proxy.smux, parsedProxy);
|
|
6602
|
+
ipVersionParser(proxy, parsedProxy);
|
|
5723
6603
|
return parsedProxy;
|
|
5724
6604
|
};
|
|
5725
|
-
var hysteria2Parser = (proxy = {}
|
|
6605
|
+
var hysteria2Parser = (proxy = {}) => {
|
|
5726
6606
|
const parsedProxy = {
|
|
5727
6607
|
tag: proxy.name,
|
|
5728
6608
|
type: "hysteria2",
|
|
@@ -5734,22 +6614,25 @@ var hysteria2Parser = (proxy = {}, includeUnsupportedProxy) => {
|
|
|
5734
6614
|
};
|
|
5735
6615
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
5736
6616
|
throw "invalid port";
|
|
5737
|
-
if (
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
6617
|
+
if (proxy["hop-interval"])
|
|
6618
|
+
parsedProxy.hop_interval = /^\d+$/.test(proxy["hop-interval"]) ? `${proxy["hop-interval"]}s` : proxy["hop-interval"];
|
|
6619
|
+
if (proxy["ports"])
|
|
6620
|
+
parsedProxy.server_ports = proxy["ports"].split(/\s*,\s*/).map((p) => {
|
|
6621
|
+
const range = p.replace(/\s*-\s*/g, ":");
|
|
6622
|
+
return range.includes(":") ? range : `${range}:${range}`;
|
|
6623
|
+
});
|
|
5743
6624
|
if (proxy.up) parsedProxy.up_mbps = parseInt(`${proxy.up}`, 10);
|
|
5744
6625
|
if (proxy.down) parsedProxy.down_mbps = parseInt(`${proxy.down}`, 10);
|
|
5745
6626
|
if (proxy.obfs === "salamander") parsedProxy.obfs.type = "salamander";
|
|
5746
6627
|
if (proxy["obfs-password"])
|
|
5747
6628
|
parsedProxy.obfs.password = proxy["obfs-password"];
|
|
5748
6629
|
if (!parsedProxy.obfs.type) delete parsedProxy.obfs;
|
|
6630
|
+
networkParser(proxy, parsedProxy);
|
|
5749
6631
|
tlsParser(proxy, parsedProxy);
|
|
5750
6632
|
tfoParser(proxy, parsedProxy);
|
|
5751
6633
|
detourParser(proxy, parsedProxy);
|
|
5752
6634
|
smuxParser(proxy.smux, parsedProxy);
|
|
6635
|
+
ipVersionParser(proxy, parsedProxy);
|
|
5753
6636
|
return parsedProxy;
|
|
5754
6637
|
};
|
|
5755
6638
|
var tuic5Parser = (proxy = {}) => {
|
|
@@ -5773,10 +6656,36 @@ var tuic5Parser = (proxy = {}) => {
|
|
|
5773
6656
|
if (proxy["udp-over-stream"]) parsedProxy.udp_over_stream = true;
|
|
5774
6657
|
if (proxy["heartbeat-interval"])
|
|
5775
6658
|
parsedProxy.heartbeat = `${proxy["heartbeat-interval"]}ms`;
|
|
6659
|
+
networkParser(proxy, parsedProxy);
|
|
5776
6660
|
tfoParser(proxy, parsedProxy);
|
|
5777
6661
|
detourParser(proxy, parsedProxy);
|
|
5778
6662
|
tlsParser(proxy, parsedProxy);
|
|
5779
6663
|
smuxParser(proxy.smux, parsedProxy);
|
|
6664
|
+
ipVersionParser(proxy, parsedProxy);
|
|
6665
|
+
return parsedProxy;
|
|
6666
|
+
};
|
|
6667
|
+
var anytlsParser = (proxy = {}) => {
|
|
6668
|
+
const parsedProxy = {
|
|
6669
|
+
tag: proxy.name,
|
|
6670
|
+
type: "anytls",
|
|
6671
|
+
server: proxy.server,
|
|
6672
|
+
server_port: parseInt(`${proxy.port}`, 10),
|
|
6673
|
+
password: proxy.password,
|
|
6674
|
+
tls: { enabled: true, server_name: proxy.server, insecure: false }
|
|
6675
|
+
};
|
|
6676
|
+
if (/^\d+$/.test(proxy["idle-session-check-interval"]))
|
|
6677
|
+
parsedProxy.idle_session_check_interval = `${proxy["idle-session-check-interval"]}s`;
|
|
6678
|
+
if (/^\d+$/.test(proxy["idle-session-timeout"]))
|
|
6679
|
+
parsedProxy.idle_session_timeout = `${proxy["idle-session-timeout"]}s`;
|
|
6680
|
+
if (/^\d+$/.test(proxy["min-idle-session"]))
|
|
6681
|
+
parsedProxy.min_idle_session = parseInt(
|
|
6682
|
+
`${proxy["min-idle-session"]}`,
|
|
6683
|
+
10
|
|
6684
|
+
);
|
|
6685
|
+
networkParser(proxy, parsedProxy);
|
|
6686
|
+
detourParser(proxy, parsedProxy);
|
|
6687
|
+
tlsParser(proxy, parsedProxy);
|
|
6688
|
+
ipVersionParser(proxy, parsedProxy);
|
|
5780
6689
|
return parsedProxy;
|
|
5781
6690
|
};
|
|
5782
6691
|
var wireguardParser = (proxy = {}) => {
|
|
@@ -5826,9 +6735,11 @@ var wireguardParser = (proxy = {}) => {
|
|
|
5826
6735
|
parsedProxy.peers.push(peer);
|
|
5827
6736
|
}
|
|
5828
6737
|
}
|
|
6738
|
+
networkParser(proxy, parsedProxy);
|
|
5829
6739
|
tfoParser(proxy, parsedProxy);
|
|
5830
6740
|
detourParser(proxy, parsedProxy);
|
|
5831
6741
|
smuxParser(proxy.smux, parsedProxy);
|
|
6742
|
+
ipVersionParser(proxy, parsedProxy);
|
|
5832
6743
|
return parsedProxy;
|
|
5833
6744
|
};
|
|
5834
6745
|
function singbox_Producer() {
|
|
@@ -5923,6 +6834,9 @@ function singbox_Producer() {
|
|
|
5923
6834
|
case "wireguard":
|
|
5924
6835
|
list.push(wireguardParser(proxy));
|
|
5925
6836
|
break;
|
|
6837
|
+
case "anytls":
|
|
6838
|
+
list.push(anytlsParser(proxy));
|
|
6839
|
+
break;
|
|
5926
6840
|
default:
|
|
5927
6841
|
throw new Error(
|
|
5928
6842
|
`Platform sing-box does not support proxy type: ${proxy.type}`
|
|
@@ -5942,7 +6856,6 @@ function Egern_Producer() {
|
|
|
5942
6856
|
const type = "ALL";
|
|
5943
6857
|
const produce2 = (proxies, type2, opts = {}) => {
|
|
5944
6858
|
const list = proxies.filter((proxy) => {
|
|
5945
|
-
if (opts["include-unsupported-proxy"]) return true;
|
|
5946
6859
|
if (![
|
|
5947
6860
|
"http",
|
|
5948
6861
|
"socks5",
|
|
@@ -5950,7 +6863,8 @@ function Egern_Producer() {
|
|
|
5950
6863
|
"trojan",
|
|
5951
6864
|
"hysteria2",
|
|
5952
6865
|
"vless",
|
|
5953
|
-
"vmess"
|
|
6866
|
+
"vmess",
|
|
6867
|
+
"tuic"
|
|
5954
6868
|
].includes(proxy.type) || proxy.type === "ss" && (proxy.plugin === "obfs" && !["http", "tls"].includes(
|
|
5955
6869
|
proxy["plugin-opts"]?.mode
|
|
5956
6870
|
) || ![
|
|
@@ -5979,18 +6893,16 @@ function Egern_Producer() {
|
|
|
5979
6893
|
"seed-cfb",
|
|
5980
6894
|
"salsa20",
|
|
5981
6895
|
"chacha20",
|
|
5982
|
-
"chacha20-ietf"
|
|
5983
|
-
|
|
5984
|
-
"
|
|
5985
|
-
|
|
5986
|
-
"chacha20-poly1305",
|
|
5987
|
-
"none",
|
|
5988
|
-
"zero"
|
|
5989
|
-
].includes(proxy.cipher) || !["http", "ws", "tcp"].includes(proxy.network) && proxy.network) || proxy.type === "trojan" && !["http", "ws", "tcp"].includes(proxy.network) && proxy.network || proxy.type === "vless" && (typeof proxy.flow !== "undefined" || proxy["reality-opts"] || !["http", "ws", "tcp"].includes(proxy.network) && proxy.network)) {
|
|
6896
|
+
"chacha20-ietf",
|
|
6897
|
+
"2022-blake3-aes-128-gcm",
|
|
6898
|
+
"2022-blake3-aes-256-gcm"
|
|
6899
|
+
].includes(proxy.cipher)) || proxy.type === "vmess" && !["http", "ws", "tcp"].includes(proxy.network) && proxy.network || proxy.type === "trojan" && !["http", "ws", "tcp"].includes(proxy.network) && proxy.network || proxy.type === "vless" && (!opts["include-unsupported-proxy"] && (typeof proxy.flow !== "undefined" || proxy["reality-opts"]) || opts["include-unsupported-proxy"] && typeof proxy.flow !== "undefined" && proxy.flow !== "xtls-rprx-vision" || !["http", "ws", "tcp"].includes(proxy.network) && proxy.network) || proxy.type === "tuic" && proxy.token && proxy.token.length !== 0) {
|
|
5990
6900
|
return false;
|
|
5991
6901
|
}
|
|
5992
6902
|
return true;
|
|
5993
6903
|
}).map((proxy) => {
|
|
6904
|
+
const original = { ...proxy };
|
|
6905
|
+
let flow;
|
|
5994
6906
|
if (proxy.tls && !proxy.sni) {
|
|
5995
6907
|
proxy.sni = proxy.server;
|
|
5996
6908
|
}
|
|
@@ -6030,10 +6942,10 @@ function Egern_Producer() {
|
|
|
6030
6942
|
udp_relay: proxy.udp || proxy.udp_relay || proxy.udp_relay,
|
|
6031
6943
|
next_hop: proxy.next_hop
|
|
6032
6944
|
};
|
|
6033
|
-
if (
|
|
6034
|
-
proxy.obfs =
|
|
6035
|
-
proxy.obfs_host =
|
|
6036
|
-
proxy.obfs_uri =
|
|
6945
|
+
if (original.plugin === "obfs") {
|
|
6946
|
+
proxy.obfs = original["plugin-opts"].mode;
|
|
6947
|
+
proxy.obfs_host = original["plugin-opts"].host;
|
|
6948
|
+
proxy.obfs_uri = original["plugin-opts"].path;
|
|
6037
6949
|
}
|
|
6038
6950
|
} else if (proxy.type === "hysteria2") {
|
|
6039
6951
|
proxy = {
|
|
@@ -6050,10 +6962,25 @@ function Egern_Producer() {
|
|
|
6050
6962
|
port_hopping: proxy.ports,
|
|
6051
6963
|
port_hopping_interval: proxy["hop-interval"]
|
|
6052
6964
|
};
|
|
6053
|
-
if (
|
|
6965
|
+
if (original["obfs-password"] && original.obfs == "salamander") {
|
|
6054
6966
|
proxy.obfs = "salamander";
|
|
6055
|
-
proxy.obfs_password =
|
|
6967
|
+
proxy.obfs_password = original["obfs-password"];
|
|
6056
6968
|
}
|
|
6969
|
+
} else if (proxy.type === "tuic") {
|
|
6970
|
+
proxy = {
|
|
6971
|
+
type: "tuic",
|
|
6972
|
+
name: proxy.name,
|
|
6973
|
+
server: proxy.server,
|
|
6974
|
+
port: proxy.port,
|
|
6975
|
+
uuid: proxy.uuid,
|
|
6976
|
+
password: proxy.password,
|
|
6977
|
+
next_hop: proxy.next_hop,
|
|
6978
|
+
sni: proxy.sni,
|
|
6979
|
+
alpn: Array.isArray(proxy.alpn) ? proxy.alpn : [proxy.alpn || "h3"],
|
|
6980
|
+
skip_tls_verify: proxy["skip-cert-verify"],
|
|
6981
|
+
port_hopping: proxy.ports,
|
|
6982
|
+
port_hopping_interval: proxy["hop-interval"]
|
|
6983
|
+
};
|
|
6057
6984
|
} else if (proxy.type === "trojan") {
|
|
6058
6985
|
if (proxy.network === "ws") {
|
|
6059
6986
|
proxy.websocket = {
|
|
@@ -6075,6 +7002,16 @@ function Egern_Producer() {
|
|
|
6075
7002
|
websocket: proxy.websocket
|
|
6076
7003
|
};
|
|
6077
7004
|
} else if (proxy.type === "vmess") {
|
|
7005
|
+
let security = proxy.cipher;
|
|
7006
|
+
if (security && ![
|
|
7007
|
+
"auto",
|
|
7008
|
+
"none",
|
|
7009
|
+
"zero",
|
|
7010
|
+
"aes-128-gcm",
|
|
7011
|
+
"chacha20-poly1305"
|
|
7012
|
+
].includes(security)) {
|
|
7013
|
+
security = "auto";
|
|
7014
|
+
}
|
|
6078
7015
|
if (proxy.network === "ws") {
|
|
6079
7016
|
proxy.transport = {
|
|
6080
7017
|
[proxy.tls ? "wss" : "ws"]: {
|
|
@@ -6088,9 +7025,9 @@ function Egern_Producer() {
|
|
|
6088
7025
|
};
|
|
6089
7026
|
} else if (proxy.network === "http") {
|
|
6090
7027
|
proxy.transport = {
|
|
6091
|
-
|
|
7028
|
+
http1: {
|
|
6092
7029
|
method: proxy["http-opts"]?.method,
|
|
6093
|
-
path: proxy["http-opts"]?.path,
|
|
7030
|
+
path: Array.isArray(proxy["http-opts"]?.path) ? proxy["http-opts"]?.path[0] : proxy["http-opts"]?.path,
|
|
6094
7031
|
headers: {
|
|
6095
7032
|
Host: Array.isArray(
|
|
6096
7033
|
proxy["http-opts"]?.headers?.Host
|
|
@@ -6099,23 +7036,42 @@ function Egern_Producer() {
|
|
|
6099
7036
|
skip_tls_verify: proxy["skip-cert-verify"]
|
|
6100
7037
|
}
|
|
6101
7038
|
};
|
|
6102
|
-
} else if (proxy.network === "
|
|
7039
|
+
} else if (proxy.network === "h2") {
|
|
6103
7040
|
proxy.transport = {
|
|
6104
|
-
|
|
7041
|
+
http2: {
|
|
7042
|
+
method: proxy["h2-opts"]?.method,
|
|
7043
|
+
path: Array.isArray(proxy["h2-opts"]?.path) ? proxy["h2-opts"]?.path[0] : proxy["h2-opts"]?.path,
|
|
7044
|
+
headers: {
|
|
7045
|
+
Host: Array.isArray(
|
|
7046
|
+
proxy["h2-opts"]?.headers?.Host
|
|
7047
|
+
) ? proxy["h2-opts"]?.headers?.Host[0] : proxy["h2-opts"]?.headers?.Host
|
|
7048
|
+
},
|
|
7049
|
+
skip_tls_verify: proxy["skip-cert-verify"]
|
|
7050
|
+
}
|
|
7051
|
+
};
|
|
7052
|
+
} else if ((proxy.network === "tcp" || !proxy.network) && proxy.tls) {
|
|
7053
|
+
proxy.transport = {
|
|
7054
|
+
tls: {
|
|
6105
7055
|
sni: proxy.tls ? proxy.sni : void 0,
|
|
6106
7056
|
skip_tls_verify: proxy.tls ? proxy["skip-cert-verify"] : void 0
|
|
6107
7057
|
}
|
|
6108
7058
|
};
|
|
6109
7059
|
}
|
|
7060
|
+
let legacy;
|
|
7061
|
+
if (isPresent2(proxy, "aead") && !proxy.aead) {
|
|
7062
|
+
legacy = true;
|
|
7063
|
+
} else if (proxy.alterId !== 0) {
|
|
7064
|
+
legacy = true;
|
|
7065
|
+
}
|
|
6110
7066
|
proxy = {
|
|
6111
7067
|
type: "vmess",
|
|
6112
7068
|
name: proxy.name,
|
|
6113
7069
|
server: proxy.server,
|
|
6114
7070
|
port: proxy.port,
|
|
6115
7071
|
user_id: proxy.uuid,
|
|
6116
|
-
security
|
|
7072
|
+
security,
|
|
6117
7073
|
tfo: proxy.tfo || proxy["fast-open"],
|
|
6118
|
-
legacy
|
|
7074
|
+
legacy,
|
|
6119
7075
|
udp_relay: proxy.udp || proxy.udp_relay || proxy.udp_relay,
|
|
6120
7076
|
next_hop: proxy.next_hop,
|
|
6121
7077
|
transport: proxy.transport
|
|
@@ -6138,7 +7094,7 @@ function Egern_Producer() {
|
|
|
6138
7094
|
proxy.transport = {
|
|
6139
7095
|
http: {
|
|
6140
7096
|
method: proxy["http-opts"]?.method,
|
|
6141
|
-
path: proxy["http-opts"]?.path,
|
|
7097
|
+
path: Array.isArray(proxy["http-opts"]?.path) ? proxy["http-opts"]?.path[0] : proxy["http-opts"]?.path,
|
|
6142
7098
|
headers: {
|
|
6143
7099
|
Host: Array.isArray(
|
|
6144
7100
|
proxy["http-opts"]?.headers?.Host
|
|
@@ -6148,12 +7104,21 @@ function Egern_Producer() {
|
|
|
6148
7104
|
}
|
|
6149
7105
|
};
|
|
6150
7106
|
} else if (proxy.network === "tcp" || !proxy.network) {
|
|
7107
|
+
let reality;
|
|
7108
|
+
if (proxy["reality-opts"]?.["short-id"] || proxy["reality-opts"]?.["public-key"]) {
|
|
7109
|
+
reality = {
|
|
7110
|
+
short_id: proxy["reality-opts"]["short-id"],
|
|
7111
|
+
public_key: proxy["reality-opts"]["public-key"]
|
|
7112
|
+
};
|
|
7113
|
+
}
|
|
6151
7114
|
proxy.transport = {
|
|
6152
7115
|
[proxy.tls ? "tls" : "tcp"]: {
|
|
6153
7116
|
sni: proxy.tls ? proxy.sni : void 0,
|
|
6154
|
-
skip_tls_verify: proxy.tls ? proxy["skip-cert-verify"] : void 0
|
|
7117
|
+
skip_tls_verify: proxy.tls ? proxy["skip-cert-verify"] : void 0,
|
|
7118
|
+
reality
|
|
6155
7119
|
}
|
|
6156
7120
|
};
|
|
7121
|
+
flow = proxy.flow;
|
|
6157
7122
|
}
|
|
6158
7123
|
proxy = {
|
|
6159
7124
|
type: "vless",
|
|
@@ -6163,19 +7128,62 @@ function Egern_Producer() {
|
|
|
6163
7128
|
user_id: proxy.uuid,
|
|
6164
7129
|
security: proxy.cipher,
|
|
6165
7130
|
tfo: proxy.tfo || proxy["fast-open"],
|
|
6166
|
-
legacy: proxy.legacy,
|
|
6167
7131
|
udp_relay: proxy.udp || proxy.udp_relay || proxy.udp_relay,
|
|
6168
7132
|
next_hop: proxy.next_hop,
|
|
6169
|
-
transport: proxy.transport
|
|
7133
|
+
transport: proxy.transport,
|
|
7134
|
+
flow
|
|
6170
7135
|
// sni: proxy.sni,
|
|
6171
7136
|
// skip_tls_verify: proxy['skip-cert-verify'],
|
|
6172
7137
|
};
|
|
6173
7138
|
}
|
|
7139
|
+
if ([
|
|
7140
|
+
"http",
|
|
7141
|
+
"socks5",
|
|
7142
|
+
"ss",
|
|
7143
|
+
"trojan",
|
|
7144
|
+
"vless",
|
|
7145
|
+
"vmess"
|
|
7146
|
+
].includes(original.type)) {
|
|
7147
|
+
if (isPresent2(original, "shadow-tls-password")) {
|
|
7148
|
+
if (original["shadow-tls-version"] != 3)
|
|
7149
|
+
throw new Error(
|
|
7150
|
+
`shadow-tls version ${original["shadow-tls-version"]} is not supported`
|
|
7151
|
+
);
|
|
7152
|
+
proxy.shadow_tls = {
|
|
7153
|
+
password: original["shadow-tls-password"],
|
|
7154
|
+
sni: original["shadow-tls-sni"]
|
|
7155
|
+
};
|
|
7156
|
+
} else if (["shadow-tls"].includes(original.plugin) && original["plugin-opts"]) {
|
|
7157
|
+
if (original["plugin-opts"].version != 3)
|
|
7158
|
+
throw new Error(
|
|
7159
|
+
`shadow-tls version ${original["plugin-opts"].version} is not supported`
|
|
7160
|
+
);
|
|
7161
|
+
proxy.shadow_tls = {
|
|
7162
|
+
password: original["plugin-opts"].password,
|
|
7163
|
+
sni: original["plugin-opts"].host
|
|
7164
|
+
};
|
|
7165
|
+
}
|
|
7166
|
+
}
|
|
7167
|
+
if (["ss"].includes(original.type) && proxy.shadow_tls && original["udp-port"] > 0 && original["udp-port"] <= 65535) {
|
|
7168
|
+
proxy["udp_port"] = original["udp-port"];
|
|
7169
|
+
}
|
|
6174
7170
|
delete proxy.subName;
|
|
6175
7171
|
delete proxy.collectionName;
|
|
6176
7172
|
delete proxy.id;
|
|
6177
7173
|
delete proxy.resolved;
|
|
6178
7174
|
delete proxy["no-resolve"];
|
|
7175
|
+
if (proxy.transport) {
|
|
7176
|
+
for (const key in proxy.transport) {
|
|
7177
|
+
if (Object.keys(proxy.transport[key]).length === 0 || Object.values(proxy.transport[key]).every(
|
|
7178
|
+
(v) => v == null
|
|
7179
|
+
)) {
|
|
7180
|
+
delete proxy.transport[key];
|
|
7181
|
+
}
|
|
7182
|
+
}
|
|
7183
|
+
if (Object.keys(proxy.transport).length === 0) {
|
|
7184
|
+
delete proxy.transport;
|
|
7185
|
+
}
|
|
7186
|
+
}
|
|
6179
7187
|
if (type2 !== "internal") {
|
|
6180
7188
|
for (const key in proxy) {
|
|
6181
7189
|
if (proxy[key] == null || /^_/i.test(key)) {
|
|
@@ -6203,21 +7211,38 @@ function JSON_Producer() {
|
|
|
6203
7211
|
return { type, produce: produce2 };
|
|
6204
7212
|
}
|
|
6205
7213
|
var producers_default = {
|
|
7214
|
+
qx: QX_Producer(),
|
|
6206
7215
|
QX: QX_Producer(),
|
|
6207
7216
|
QuantumultX: QX_Producer(),
|
|
7217
|
+
surge: Surge_Producer(),
|
|
6208
7218
|
Surge: Surge_Producer(),
|
|
6209
7219
|
SurgeMac: SurgeMac_Producer(),
|
|
6210
7220
|
Loon: Loon_Producer(),
|
|
6211
7221
|
Clash: Clash_Producer(),
|
|
7222
|
+
meta: ClashMeta_Producer(),
|
|
7223
|
+
clashmeta: ClashMeta_Producer(),
|
|
7224
|
+
"clash.meta": ClashMeta_Producer(),
|
|
7225
|
+
"Clash.Meta": ClashMeta_Producer(),
|
|
6212
7226
|
ClashMeta: ClashMeta_Producer(),
|
|
7227
|
+
mihomo: ClashMeta_Producer(),
|
|
7228
|
+
Mihomo: ClashMeta_Producer(),
|
|
7229
|
+
uri: URI_Producer(),
|
|
6213
7230
|
URI: URI_Producer(),
|
|
7231
|
+
v2: V2Ray_Producer(),
|
|
7232
|
+
v2ray: V2Ray_Producer(),
|
|
6214
7233
|
V2Ray: V2Ray_Producer(),
|
|
7234
|
+
json: JSON_Producer(),
|
|
6215
7235
|
JSON: JSON_Producer(),
|
|
7236
|
+
stash: Stash_Producer(),
|
|
6216
7237
|
Stash: Stash_Producer(),
|
|
6217
|
-
|
|
6218
|
-
|
|
7238
|
+
shadowrocket: Shadowrocket_Producer(),
|
|
7239
|
+
Shadowrocket: Shadowrocket_Producer(),
|
|
7240
|
+
ShadowRocket: Shadowrocket_Producer(),
|
|
7241
|
+
surfboard: Surfboard_Producer(),
|
|
6219
7242
|
Surfboard: Surfboard_Producer(),
|
|
7243
|
+
singbox: singbox_Producer(),
|
|
6220
7244
|
"sing-box": singbox_Producer(),
|
|
7245
|
+
egern: Egern_Producer(),
|
|
6221
7246
|
Egern: Egern_Producer()
|
|
6222
7247
|
};
|
|
6223
7248
|
|