sub-store-convert 2.19.36 → 2.20.30-b
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/{build/index.js → index.js} +610 -300
- package/package.json +10 -13
- package/LICENSE +0 -21
- package/README.md +0 -12
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// src/vendors/Sub-Store/backend/src/utils/index.js
|
|
2
|
-
import * as ipAddress from "ip-address";
|
|
3
2
|
var IPV4_REGEX = /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)(\.(?!$)|$)){4}$/;
|
|
4
3
|
var IPV6_REGEX = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
|
|
5
4
|
function isIPv4(ip) {
|
|
@@ -94,10 +93,11 @@ shadowsocks = tag equals "ss" address (method/passwordk/obfs/obfs_host/obfs_uri/
|
|
|
94
93
|
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
94
|
proxy.type = "vmess";
|
|
96
95
|
proxy.cipher = proxy.cipher || "none";
|
|
96
|
+
// Surfboard 与 Surge 默认不一致, 不管 Surfboard https://getsurfboard.com/docs/profile-format/proxy/external-proxy/vmess
|
|
97
97
|
if (proxy.aead) {
|
|
98
98
|
proxy.alterId = 0;
|
|
99
99
|
} else {
|
|
100
|
-
proxy.alterId =
|
|
100
|
+
proxy.alterId = 1;
|
|
101
101
|
}
|
|
102
102
|
handleWebsocket();
|
|
103
103
|
handleShadowTLS();
|
|
@@ -143,11 +143,11 @@ wireguard = tag equals "wireguard" (section_name/no_error_alert/ip_version/under
|
|
|
143
143
|
proxy.type = "wireguard-surge";
|
|
144
144
|
handleShadowTLS();
|
|
145
145
|
}
|
|
146
|
-
hysteria2 = tag equals "hysteria2" address (no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/sni/
|
|
146
|
+
hysteria2 = tag equals "hysteria2" address (no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/sni/tls_verification/passwordk/tls_fingerprint/download_bandwidth/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* {
|
|
147
147
|
proxy.type = "hysteria2";
|
|
148
148
|
handleShadowTLS();
|
|
149
149
|
}
|
|
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/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
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/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
151
151
|
proxy.type = "socks5";
|
|
152
152
|
handleShadowTLS();
|
|
153
153
|
}
|
|
@@ -159,7 +159,6 @@ socks5_tls = tag equals "socks5-tls" address (username password)? (usernamek pas
|
|
|
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/tfo/block_quic/others)* {
|
|
160
160
|
proxy.type = "direct";
|
|
161
161
|
}
|
|
162
|
-
|
|
163
162
|
address = comma server:server comma port:port {
|
|
164
163
|
proxy.server = server;
|
|
165
164
|
proxy.port = port;
|
|
@@ -217,8 +216,8 @@ username = & {
|
|
|
217
216
|
peg$currPos = end;
|
|
218
217
|
return true;
|
|
219
218
|
}
|
|
220
|
-
} { proxy.username = $.username; }
|
|
221
|
-
password = comma match:[^,]+ { proxy.password = match.join(""); }
|
|
219
|
+
} { proxy.username = $.username.trim().replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
|
220
|
+
password = comma match:[^,]+ { proxy.password = match.join("").replace(/^"(.*)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
|
222
221
|
|
|
223
222
|
tls = comma "tls" equals flag:bool { proxy.tls = flag; }
|
|
224
223
|
sni = comma "sni" equals sni:("off"/domain) {
|
|
@@ -234,7 +233,7 @@ tls_fingerprint = comma "server-cert-fingerprint-sha256" equals tls_fingerprint:
|
|
|
234
233
|
snell_psk = comma "psk" equals match:[^,]+ { proxy.psk = match.join(""); }
|
|
235
234
|
snell_version = comma "version" equals match:$[0-9]+ { proxy.version = parseInt(match.trim()); }
|
|
236
235
|
|
|
237
|
-
usernamek = comma "username" equals match:[^,]+ { proxy.username = match.join(""); }
|
|
236
|
+
usernamek = comma "username" equals match:[^,]+ { proxy.username = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
|
238
237
|
passwordk = comma "password" equals match:[^,]+ { proxy.password = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
|
239
238
|
vmess_uuid = comma "username" equals match:[^,]+ { proxy.uuid = match.join(""); }
|
|
240
239
|
vmess_aead = comma "vmess-aead" equals flag:bool { proxy.aead = flag; }
|
|
@@ -250,11 +249,11 @@ ws_headers = comma "ws-headers" equals headers:$[^,]+ {
|
|
|
250
249
|
const result = {};
|
|
251
250
|
pairs.forEach(pair => {
|
|
252
251
|
const [key, value] = pair.trim().split(":");
|
|
253
|
-
result[key.trim()] = value.trim();
|
|
252
|
+
result[key.trim()] = value.trim().replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1');
|
|
254
253
|
})
|
|
255
254
|
obfs["ws-headers"] = result;
|
|
256
255
|
}
|
|
257
|
-
ws_path = comma "ws-path" equals path:uri { obfs.path = path; }
|
|
256
|
+
ws_path = comma "ws-path" equals path:uri { obfs.path = path.trim().replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
|
258
257
|
|
|
259
258
|
obfs = comma "obfs" equals type:("http"/"tls") { obfs.type = type; }
|
|
260
259
|
obfs_host = comma "obfs-host" equals host:domain { obfs.host = host; };
|
|
@@ -362,31 +361,31 @@ shadowsocks = tag equals "shadowsocks"i address method password (obfs_typev obfs
|
|
|
362
361
|
$set(proxy, "plugin-opts.path", obfs.path);
|
|
363
362
|
}
|
|
364
363
|
}
|
|
365
|
-
vmess = tag equals "vmess"i address method uuid (transport/transport_host/transport_path/over_tls/
|
|
364
|
+
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
365
|
proxy.type = "vmess";
|
|
367
366
|
proxy.cipher = proxy.cipher || "none";
|
|
368
367
|
proxy.alterId = proxy.alterId || 0;
|
|
369
368
|
handleTransport();
|
|
370
369
|
}
|
|
371
|
-
vless = tag equals "vless"i address uuid (transport/transport_host/transport_path/over_tls/
|
|
370
|
+
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
371
|
proxy.type = "vless";
|
|
373
372
|
handleTransport();
|
|
374
373
|
}
|
|
375
|
-
trojan = tag equals "trojan"i address password (transport/transport_host/transport_path/over_tls/
|
|
374
|
+
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
375
|
proxy.type = "trojan";
|
|
377
376
|
handleTransport();
|
|
378
377
|
}
|
|
379
|
-
hysteria2 = tag equals "hysteria2"i address password (
|
|
378
|
+
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
379
|
proxy.type = "hysteria2";
|
|
381
380
|
}
|
|
382
|
-
https = tag equals "https"i address (username password)? (
|
|
381
|
+
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
382
|
proxy.type = "http";
|
|
384
383
|
proxy.tls = true;
|
|
385
384
|
}
|
|
386
385
|
http = tag equals "http"i address (username password)? (fast_open/udp_relay/ip_mode/block_quic/others)* {
|
|
387
386
|
proxy.type = "http";
|
|
388
387
|
}
|
|
389
|
-
socks5 = tag equals "socks5"i address (username password)? (over_tls/
|
|
388
|
+
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
389
|
proxy.type = "socks5";
|
|
391
390
|
}
|
|
392
391
|
|
|
@@ -483,7 +482,8 @@ shadow_tls_sni = comma "shadow-tls-sni" equals match:[^,]+ { proxy["shadow-tls-s
|
|
|
483
482
|
shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { proxy["shadow-tls-password"] = match.join(""); }
|
|
484
483
|
|
|
485
484
|
over_tls = comma "over-tls" equals flag:bool { proxy.tls = flag; }
|
|
486
|
-
|
|
485
|
+
tls_name = comma sni:("tls-name") equals host:domain { proxy.sni = host; }
|
|
486
|
+
sni = comma sni:("sni") equals host:domain { proxy.sni = host; }
|
|
487
487
|
tls_verification = comma "skip-cert-verify" equals flag:bool { proxy["skip-cert-verify"] = flag; }
|
|
488
488
|
tls_cert_sha256 = comma "tls-cert-sha256" equals match:[^,]+ { proxy["tls-fingerprint"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
|
489
489
|
tls_pubkey_sha256 = comma "tls-pubkey-sha256" equals match:[^,]+ { proxy["tls-pubkey-sha256"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
|
@@ -606,10 +606,10 @@ vmess = "vmess" equals address
|
|
|
606
606
|
(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)* {
|
|
607
607
|
proxy.type = "vmess";
|
|
608
608
|
proxy.cipher = proxy.cipher || "none";
|
|
609
|
-
if (proxy.aead) {
|
|
610
|
-
proxy.alterId =
|
|
609
|
+
if (proxy.aead === false) {
|
|
610
|
+
proxy.alterId = 1;
|
|
611
611
|
} else {
|
|
612
|
-
proxy.alterId =
|
|
612
|
+
proxy.alterId = 0;
|
|
613
613
|
}
|
|
614
614
|
handleObfs();
|
|
615
615
|
}
|
|
@@ -907,6 +907,47 @@ var app_default = new Proxy(console, {
|
|
|
907
907
|
}
|
|
908
908
|
});
|
|
909
909
|
|
|
910
|
+
// src/vendors/Sub-Store/backend/src/core/proxy-utils/parsers/index.js
|
|
911
|
+
import JSON5 from "json5";
|
|
912
|
+
|
|
913
|
+
// src/vendors/Sub-Store/backend/src/utils/yaml.js
|
|
914
|
+
import YAML from "static-js-yaml";
|
|
915
|
+
function retry(fn, content, ...args) {
|
|
916
|
+
try {
|
|
917
|
+
return fn(content, ...args);
|
|
918
|
+
} catch (e) {
|
|
919
|
+
return fn(
|
|
920
|
+
dump(
|
|
921
|
+
fn(
|
|
922
|
+
content.replace(/!<str>\s*/g, "__SubStoreJSYAMLString__"),
|
|
923
|
+
...args
|
|
924
|
+
)
|
|
925
|
+
).replace(/__SubStoreJSYAMLString__/g, ""),
|
|
926
|
+
...args
|
|
927
|
+
);
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
function safeLoad(content, ...args) {
|
|
931
|
+
return retry(YAML.safeLoad, JSON.parse(JSON.stringify(content)), ...args);
|
|
932
|
+
}
|
|
933
|
+
function load(content, ...args) {
|
|
934
|
+
return retry(YAML.load, JSON.parse(JSON.stringify(content)), ...args);
|
|
935
|
+
}
|
|
936
|
+
function safeDump(content, ...args) {
|
|
937
|
+
return YAML.safeDump(JSON.parse(JSON.stringify(content)), ...args);
|
|
938
|
+
}
|
|
939
|
+
function dump(content, ...args) {
|
|
940
|
+
return YAML.dump(JSON.parse(JSON.stringify(content)), ...args);
|
|
941
|
+
}
|
|
942
|
+
var yaml_default = {
|
|
943
|
+
safeLoad,
|
|
944
|
+
load,
|
|
945
|
+
safeDump,
|
|
946
|
+
dump,
|
|
947
|
+
parse: safeLoad,
|
|
948
|
+
stringify: safeDump
|
|
949
|
+
};
|
|
950
|
+
|
|
910
951
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/parsers/index.js
|
|
911
952
|
import { Base64 } from "js-base64";
|
|
912
953
|
function surge_port_hopping(raw) {
|
|
@@ -925,7 +966,7 @@ function URI_PROXY() {
|
|
|
925
966
|
};
|
|
926
967
|
const parse = (line) => {
|
|
927
968
|
let [__, type, tls, username, password, server, port, query, name2] = line.match(
|
|
928
|
-
/^(socks5|http|http)(\+tls|s)?:\/\/(?:(.*?):(.*?)@)?(.*?)(?::(\d+?))
|
|
969
|
+
/^(socks5|http|http)(\+tls|s)?:\/\/(?:(.*?):(.*?)@)?(.*?)(?::(\d+?))?\/?(\?.*?)?(?:#(.*?))?$/
|
|
929
970
|
);
|
|
930
971
|
if (port) {
|
|
931
972
|
port = parseInt(port, 10);
|
|
@@ -1237,9 +1278,9 @@ function URI_VMess() {
|
|
|
1237
1278
|
params[key] = value.split(",");
|
|
1238
1279
|
}
|
|
1239
1280
|
}
|
|
1240
|
-
let [___, cipher,
|
|
1281
|
+
let [___, cipher, uuid2, server2, port2] = /(^[^:]+?):([^:]+?)@(.*):(\d+)$/.exec(content);
|
|
1241
1282
|
params.scy = cipher;
|
|
1242
|
-
params.id =
|
|
1283
|
+
params.id = uuid2;
|
|
1243
1284
|
params.port = port2;
|
|
1244
1285
|
params.add = server2;
|
|
1245
1286
|
}
|
|
@@ -1250,7 +1291,14 @@ function URI_VMess() {
|
|
|
1250
1291
|
type: "vmess",
|
|
1251
1292
|
server,
|
|
1252
1293
|
port,
|
|
1253
|
-
|
|
1294
|
+
// https://github.com/2dust/v2rayN/wiki/Description-of-VMess-share-link
|
|
1295
|
+
// https://github.com/XTLS/Xray-core/issues/91
|
|
1296
|
+
cipher: [
|
|
1297
|
+
"auto",
|
|
1298
|
+
"aes-128-gcm",
|
|
1299
|
+
"chacha20-poly1305",
|
|
1300
|
+
"none"
|
|
1301
|
+
].includes(params.scy) ? params.scy : "auto",
|
|
1254
1302
|
uuid: params.id,
|
|
1255
1303
|
alterId: parseInt(
|
|
1256
1304
|
getIfPresent(params.aid ?? params.alterId, 0),
|
|
@@ -1276,8 +1324,8 @@ function URI_VMess() {
|
|
|
1276
1324
|
proxy.network = "ws";
|
|
1277
1325
|
} else if (["http"].includes(params.net) || ["http"].includes(params.obfs) || ["http"].includes(params.type)) {
|
|
1278
1326
|
proxy.network = "http";
|
|
1279
|
-
} else if (["grpc"].includes(params.net)) {
|
|
1280
|
-
proxy.network =
|
|
1327
|
+
} else if (["grpc", "kcp", "quic"].includes(params.net)) {
|
|
1328
|
+
proxy.network = params.net;
|
|
1281
1329
|
} else if (params.net === "httpupgrade" || proxy.network === "httpupgrade") {
|
|
1282
1330
|
proxy.network = "ws";
|
|
1283
1331
|
httpupgrade = true;
|
|
@@ -1309,13 +1357,23 @@ function URI_VMess() {
|
|
|
1309
1357
|
transportPath = "/";
|
|
1310
1358
|
}
|
|
1311
1359
|
}
|
|
1312
|
-
if (transportPath || transportHost) {
|
|
1360
|
+
if (transportPath || transportHost || ["kcp", "quic"].includes(proxy.network)) {
|
|
1313
1361
|
if (["grpc"].includes(proxy.network)) {
|
|
1314
1362
|
proxy[`${proxy.network}-opts`] = {
|
|
1315
1363
|
"grpc-service-name": getIfNotBlank(transportPath),
|
|
1316
1364
|
"_grpc-type": getIfNotBlank(params.type),
|
|
1317
1365
|
"_grpc-authority": getIfNotBlank(params.authority)
|
|
1318
1366
|
};
|
|
1367
|
+
} else if (["kcp", "quic"].includes(proxy.network)) {
|
|
1368
|
+
proxy[`${proxy.network}-opts`] = {
|
|
1369
|
+
[`_${proxy.network}-type`]: getIfNotBlank(
|
|
1370
|
+
params.type
|
|
1371
|
+
),
|
|
1372
|
+
[`_${proxy.network}-host`]: getIfNotBlank(
|
|
1373
|
+
getIfNotBlank(transportHost)
|
|
1374
|
+
),
|
|
1375
|
+
[`_${proxy.network}-path`]: getIfNotBlank(transportPath)
|
|
1376
|
+
};
|
|
1319
1377
|
} else {
|
|
1320
1378
|
const opts = {
|
|
1321
1379
|
path: getIfNotBlank(transportPath),
|
|
@@ -1331,6 +1389,8 @@ function URI_VMess() {
|
|
|
1331
1389
|
delete proxy.network;
|
|
1332
1390
|
}
|
|
1333
1391
|
}
|
|
1392
|
+
proxy["client-fingerprint"] = params.fp;
|
|
1393
|
+
proxy.alpn = params.alpn ? params.alpn.split(",") : void 0;
|
|
1334
1394
|
return proxy;
|
|
1335
1395
|
}
|
|
1336
1396
|
};
|
|
@@ -1351,12 +1411,12 @@ function URI_VLESS() {
|
|
|
1351
1411
|
parsed = /^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
1352
1412
|
isShadowrocket = true;
|
|
1353
1413
|
}
|
|
1354
|
-
let [__,
|
|
1414
|
+
let [__, uuid2, server, port, ___, addons = "", name2] = parsed;
|
|
1355
1415
|
if (isShadowrocket) {
|
|
1356
|
-
|
|
1416
|
+
uuid2 = uuid2.replace(/^.*?:/g, "");
|
|
1357
1417
|
}
|
|
1358
1418
|
port = parseInt(`${port}`, 10);
|
|
1359
|
-
|
|
1419
|
+
uuid2 = decodeURIComponent(uuid2);
|
|
1360
1420
|
if (name2 != null) {
|
|
1361
1421
|
name2 = decodeURIComponent(name2);
|
|
1362
1422
|
}
|
|
@@ -1365,14 +1425,16 @@ function URI_VLESS() {
|
|
|
1365
1425
|
name: name2,
|
|
1366
1426
|
server,
|
|
1367
1427
|
port,
|
|
1368
|
-
uuid
|
|
1428
|
+
uuid: uuid2
|
|
1369
1429
|
};
|
|
1370
1430
|
const params = {};
|
|
1371
1431
|
for (const addon of addons.split("&")) {
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1432
|
+
if (addon) {
|
|
1433
|
+
const [key, valueRaw] = addon.split("=");
|
|
1434
|
+
let value = valueRaw;
|
|
1435
|
+
value = decodeURIComponent(valueRaw);
|
|
1436
|
+
params[key] = value;
|
|
1437
|
+
}
|
|
1376
1438
|
}
|
|
1377
1439
|
proxy.name = name2 ?? params.remarks ?? params.remark ?? `VLESS ${server}:${port}`;
|
|
1378
1440
|
proxy.tls = params.security && params.security !== "none";
|
|
@@ -1475,6 +1537,12 @@ function URI_VLESS() {
|
|
|
1475
1537
|
proxy._extra = params.extra;
|
|
1476
1538
|
}
|
|
1477
1539
|
}
|
|
1540
|
+
if (params.encryption) {
|
|
1541
|
+
proxy.encryption = params.encryption;
|
|
1542
|
+
}
|
|
1543
|
+
if (params.pqv) {
|
|
1544
|
+
proxy._pqv = params.pqv;
|
|
1545
|
+
}
|
|
1478
1546
|
return proxy;
|
|
1479
1547
|
};
|
|
1480
1548
|
return { name, test, parse };
|
|
@@ -1485,6 +1553,7 @@ function URI_AnyTLS() {
|
|
|
1485
1553
|
return /^anytls:\/\//.test(line);
|
|
1486
1554
|
};
|
|
1487
1555
|
const parse = (line) => {
|
|
1556
|
+
const parsed = URI_VLESS().parse(line.replace("anytls", "vless"));
|
|
1488
1557
|
line = line.split(/anytls:\/\//)[1];
|
|
1489
1558
|
let [__, password, server, port, addons = "", name2] = /^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
1490
1559
|
password = decodeURIComponent(password);
|
|
@@ -1498,6 +1567,8 @@ function URI_AnyTLS() {
|
|
|
1498
1567
|
}
|
|
1499
1568
|
name2 = name2 ?? `AnyTLS ${server}:${port}`;
|
|
1500
1569
|
const proxy = {
|
|
1570
|
+
...parsed,
|
|
1571
|
+
uuid: void 0,
|
|
1501
1572
|
type: "anytls",
|
|
1502
1573
|
name: name2,
|
|
1503
1574
|
server,
|
|
@@ -1505,19 +1576,25 @@ function URI_AnyTLS() {
|
|
|
1505
1576
|
password
|
|
1506
1577
|
};
|
|
1507
1578
|
for (const addon of addons.split("&")) {
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
proxy
|
|
1579
|
+
if (addon) {
|
|
1580
|
+
let [key, value] = addon.split("=");
|
|
1581
|
+
key = key.replace(/_/g, "-");
|
|
1582
|
+
value = decodeURIComponent(value);
|
|
1583
|
+
if (["alpn"].includes(key)) {
|
|
1584
|
+
proxy[key] = value ? value.split(",") : void 0;
|
|
1585
|
+
} else if (["insecure"].includes(key)) {
|
|
1586
|
+
proxy["skip-cert-verify"] = /(TRUE)|1/i.test(value);
|
|
1587
|
+
} else if (["udp"].includes(key)) {
|
|
1588
|
+
proxy[key] = /(TRUE)|1/i.test(value);
|
|
1589
|
+
} else if (!Object.keys(proxy).includes(key)) {
|
|
1590
|
+
proxy[key] = value;
|
|
1591
|
+
}
|
|
1519
1592
|
}
|
|
1520
1593
|
}
|
|
1594
|
+
if (["tcp"].includes(proxy.network) && !proxy["reality-opts"]) {
|
|
1595
|
+
delete proxy.network;
|
|
1596
|
+
delete proxy.security;
|
|
1597
|
+
}
|
|
1521
1598
|
return proxy;
|
|
1522
1599
|
};
|
|
1523
1600
|
return { name, test, parse };
|
|
@@ -1572,10 +1649,12 @@ function URI_Hysteria2() {
|
|
|
1572
1649
|
};
|
|
1573
1650
|
const params = {};
|
|
1574
1651
|
for (const addon of addons.split("&")) {
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1652
|
+
if (addon) {
|
|
1653
|
+
const [key, valueRaw] = addon.split("=");
|
|
1654
|
+
let value = valueRaw;
|
|
1655
|
+
value = decodeURIComponent(valueRaw);
|
|
1656
|
+
params[key] = value;
|
|
1657
|
+
}
|
|
1579
1658
|
}
|
|
1580
1659
|
proxy.sni = params.sni;
|
|
1581
1660
|
if (!proxy.sni && params.peer) {
|
|
@@ -1627,29 +1706,31 @@ function URI_Hysteria() {
|
|
|
1627
1706
|
};
|
|
1628
1707
|
const params = {};
|
|
1629
1708
|
for (const addon of addons.split("&")) {
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
proxy
|
|
1709
|
+
if (addon) {
|
|
1710
|
+
let [key, value] = addon.split("=");
|
|
1711
|
+
key = key.replace(/_/, "-");
|
|
1712
|
+
value = decodeURIComponent(value);
|
|
1713
|
+
if (["alpn"].includes(key)) {
|
|
1714
|
+
proxy[key] = value ? value.split(",") : void 0;
|
|
1715
|
+
} else if (["insecure"].includes(key)) {
|
|
1716
|
+
proxy["skip-cert-verify"] = /(TRUE)|1/i.test(value);
|
|
1717
|
+
} else if (["auth"].includes(key)) {
|
|
1718
|
+
proxy["auth-str"] = value;
|
|
1719
|
+
} else if (["mport"].includes(key)) {
|
|
1720
|
+
proxy["ports"] = value;
|
|
1721
|
+
} else if (["obfsParam"].includes(key)) {
|
|
1722
|
+
proxy["obfs"] = value;
|
|
1723
|
+
} else if (["upmbps"].includes(key)) {
|
|
1724
|
+
proxy["up"] = value;
|
|
1725
|
+
} else if (["downmbps"].includes(key)) {
|
|
1726
|
+
proxy["down"] = value;
|
|
1727
|
+
} else if (["obfs"].includes(key)) {
|
|
1728
|
+
proxy["_obfs"] = value || "";
|
|
1729
|
+
} else if (["fast-open", "peer"].includes(key)) {
|
|
1730
|
+
params[key] = value;
|
|
1731
|
+
} else if (!Object.keys(proxy).includes(key)) {
|
|
1732
|
+
proxy[key] = value;
|
|
1733
|
+
}
|
|
1653
1734
|
}
|
|
1654
1735
|
}
|
|
1655
1736
|
if (!proxy.sni && params.peer) {
|
|
@@ -1674,7 +1755,7 @@ function URI_TUIC() {
|
|
|
1674
1755
|
line = line.split(/tuic:\/\//)[1];
|
|
1675
1756
|
let [__, auth, server, port, addons = "", name2] = /^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
1676
1757
|
auth = decodeURIComponent(auth);
|
|
1677
|
-
let [
|
|
1758
|
+
let [uuid2, ...passwordParts] = auth.split(":");
|
|
1678
1759
|
let password = passwordParts.join(":");
|
|
1679
1760
|
port = parseInt(`${port}`, 10);
|
|
1680
1761
|
if (isNaN(port)) {
|
|
@@ -1691,25 +1772,27 @@ function URI_TUIC() {
|
|
|
1691
1772
|
server,
|
|
1692
1773
|
port,
|
|
1693
1774
|
password,
|
|
1694
|
-
uuid
|
|
1775
|
+
uuid: uuid2
|
|
1695
1776
|
};
|
|
1696
1777
|
for (const addon of addons.split("&")) {
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
proxy
|
|
1778
|
+
if (addon) {
|
|
1779
|
+
let [key, value] = addon.split("=");
|
|
1780
|
+
key = key.replace(/_/g, "-");
|
|
1781
|
+
value = decodeURIComponent(value);
|
|
1782
|
+
if (["alpn"].includes(key)) {
|
|
1783
|
+
proxy[key] = value ? value.split(",") : void 0;
|
|
1784
|
+
} else if (["allow-insecure", "insecure"].includes(key)) {
|
|
1785
|
+
proxy["skip-cert-verify"] = /(TRUE)|1/i.test(value);
|
|
1786
|
+
} else if (["fast-open"].includes(key)) {
|
|
1787
|
+
proxy.tfo = true;
|
|
1788
|
+
} else if (["disable-sni", "reduce-rtt"].includes(key)) {
|
|
1789
|
+
proxy[key] = /(TRUE)|1/i.test(value);
|
|
1790
|
+
} else if (key === "congestion-control") {
|
|
1791
|
+
proxy["congestion-controller"] = value;
|
|
1792
|
+
delete proxy[key];
|
|
1793
|
+
} else if (!Object.keys(proxy).includes(key)) {
|
|
1794
|
+
proxy[key] = value;
|
|
1795
|
+
}
|
|
1713
1796
|
}
|
|
1714
1797
|
}
|
|
1715
1798
|
return proxy;
|
|
@@ -1752,36 +1835,38 @@ function URI_WireGuard() {
|
|
|
1752
1835
|
udp: true
|
|
1753
1836
|
};
|
|
1754
1837
|
for (const addon of addons.split("&")) {
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
} else if (["address", "ip"].includes(key)) {
|
|
1764
|
-
value.split(",").map((i) => {
|
|
1765
|
-
const ip = i.trim().replace(/\/\d+$/, "").replace(/^\[/, "").replace(/\]$/, "");
|
|
1766
|
-
if (isIPv4(ip)) {
|
|
1767
|
-
proxy.ip = ip;
|
|
1768
|
-
} else if (isIPv6(ip)) {
|
|
1769
|
-
proxy.ipv6 = ip;
|
|
1838
|
+
if (addon) {
|
|
1839
|
+
let [key, value] = addon.split("=");
|
|
1840
|
+
key = key.replace(/_/, "-");
|
|
1841
|
+
value = decodeURIComponent(value);
|
|
1842
|
+
if (["reserved"].includes(key)) {
|
|
1843
|
+
const parsed = value.split(",").map((i) => parseInt(i.trim(), 10)).filter((i) => Number.isInteger(i));
|
|
1844
|
+
if (parsed.length === 3) {
|
|
1845
|
+
proxy[key] = parsed;
|
|
1770
1846
|
}
|
|
1771
|
-
})
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1847
|
+
} else if (["address", "ip"].includes(key)) {
|
|
1848
|
+
value.split(",").map((i) => {
|
|
1849
|
+
const ip = i.trim().replace(/\/\d+$/, "").replace(/^\[/, "").replace(/\]$/, "");
|
|
1850
|
+
if (isIPv4(ip)) {
|
|
1851
|
+
proxy.ip = ip;
|
|
1852
|
+
} else if (isIPv6(ip)) {
|
|
1853
|
+
proxy.ipv6 = ip;
|
|
1854
|
+
}
|
|
1855
|
+
});
|
|
1856
|
+
} else if (["mtu"].includes(key)) {
|
|
1857
|
+
const parsed = parseInt(value.trim(), 10);
|
|
1858
|
+
if (Number.isInteger(parsed)) {
|
|
1859
|
+
proxy[key] = parsed;
|
|
1860
|
+
}
|
|
1861
|
+
} else if (/publickey/i.test(key)) {
|
|
1862
|
+
proxy["public-key"] = value;
|
|
1863
|
+
} else if (/privatekey/i.test(key)) {
|
|
1864
|
+
proxy["private-key"] = value;
|
|
1865
|
+
} else if (["udp"].includes(key)) {
|
|
1866
|
+
proxy[key] = /(TRUE)|1/i.test(value);
|
|
1867
|
+
} else if (![...Object.keys(proxy), "flag"].includes(key)) {
|
|
1868
|
+
proxy[key] = value;
|
|
1776
1869
|
}
|
|
1777
|
-
} else if (/publickey/i.test(key)) {
|
|
1778
|
-
proxy["public-key"] = value;
|
|
1779
|
-
} else if (/privatekey/i.test(key)) {
|
|
1780
|
-
proxy["private-key"] = value;
|
|
1781
|
-
} else if (["udp"].includes(key)) {
|
|
1782
|
-
proxy[key] = /(TRUE)|1/i.test(value);
|
|
1783
|
-
} else if (!["flag"].includes(key)) {
|
|
1784
|
-
proxy[key] = value;
|
|
1785
1870
|
}
|
|
1786
1871
|
}
|
|
1787
1872
|
return proxy;
|
|
@@ -1816,15 +1901,21 @@ function URI_Trojan() {
|
|
|
1816
1901
|
function Clash_All() {
|
|
1817
1902
|
const name = "Clash Parser";
|
|
1818
1903
|
const test = (line) => {
|
|
1904
|
+
let proxy;
|
|
1819
1905
|
try {
|
|
1820
|
-
|
|
1906
|
+
proxy = JSON5.parse(line);
|
|
1821
1907
|
} catch (e) {
|
|
1822
|
-
|
|
1908
|
+
proxy = yaml_default.parse(line);
|
|
1823
1909
|
}
|
|
1824
|
-
return
|
|
1910
|
+
return !!proxy?.type;
|
|
1825
1911
|
};
|
|
1826
1912
|
const parse = (line) => {
|
|
1827
|
-
|
|
1913
|
+
let proxy;
|
|
1914
|
+
try {
|
|
1915
|
+
proxy = JSON5.parse(line);
|
|
1916
|
+
} catch (e) {
|
|
1917
|
+
proxy = yaml_default.parse(line);
|
|
1918
|
+
}
|
|
1828
1919
|
if (![
|
|
1829
1920
|
"anytls",
|
|
1830
1921
|
"mieru",
|
|
@@ -2616,8 +2707,8 @@ function vmess(proxy, includeUnsupportedProxy) {
|
|
|
2616
2707
|
function ssh(proxy) {
|
|
2617
2708
|
const result = new Result(proxy);
|
|
2618
2709
|
result.append(`${proxy.name}=ssh,${proxy.server},${proxy.port}`);
|
|
2619
|
-
result.appendIfPresent(
|
|
2620
|
-
result.appendIfPresent(`,"${proxy.password}"`, "password");
|
|
2710
|
+
result.appendIfPresent(`,username="${proxy.username}"`, "username");
|
|
2711
|
+
result.appendIfPresent(`,password="${proxy.password}"`, "password");
|
|
2621
2712
|
result.appendIfPresent(
|
|
2622
2713
|
`,private-key=${proxy["keystore-private-key"]}`,
|
|
2623
2714
|
"keystore-private-key"
|
|
@@ -2668,8 +2759,8 @@ function http(proxy) {
|
|
|
2668
2759
|
const result = new Result(proxy);
|
|
2669
2760
|
const type = proxy.tls ? "https" : "http";
|
|
2670
2761
|
result.append(`${proxy.name}=${type},${proxy.server},${proxy.port}`);
|
|
2671
|
-
result.appendIfPresent(
|
|
2672
|
-
result.appendIfPresent(`,"${proxy.password}"`, "password");
|
|
2762
|
+
result.appendIfPresent(`,username="${proxy.username}"`, "username");
|
|
2763
|
+
result.appendIfPresent(`,password="${proxy.password}"`, "password");
|
|
2673
2764
|
const ip_version = ipVersions[proxy["ip-version"]] || proxy["ip-version"];
|
|
2674
2765
|
result.appendIfPresent(`,ip-version=${ip_version}`, "ip-version");
|
|
2675
2766
|
result.appendIfPresent(
|
|
@@ -2760,8 +2851,8 @@ function socks5(proxy) {
|
|
|
2760
2851
|
const result = new Result(proxy);
|
|
2761
2852
|
const type = proxy.tls ? "socks5-tls" : "socks5";
|
|
2762
2853
|
result.append(`${proxy.name}=${type},${proxy.server},${proxy.port}`);
|
|
2763
|
-
result.appendIfPresent(
|
|
2764
|
-
result.appendIfPresent(`,"${proxy.password}"`, "password");
|
|
2854
|
+
result.appendIfPresent(`,username="${proxy.username}"`, "username");
|
|
2855
|
+
result.appendIfPresent(`,password="${proxy.password}"`, "password");
|
|
2765
2856
|
const ip_version = ipVersions[proxy["ip-version"]] || proxy["ip-version"];
|
|
2766
2857
|
result.appendIfPresent(`,ip-version=${ip_version}`, "ip-version");
|
|
2767
2858
|
result.appendIfPresent(
|
|
@@ -3032,9 +3123,6 @@ prefer-ipv6 = true`);
|
|
|
3032
3123
|
const allowedIps = Array.isArray(proxy["allowed-ips"]) ? proxy["allowed-ips"].join(",") : proxy["allowed-ips"];
|
|
3033
3124
|
let reserved = Array.isArray(proxy.reserved) ? proxy.reserved.join("/") : proxy.reserved;
|
|
3034
3125
|
let presharedKey = proxy["preshared-key"] ?? proxy["pre-shared-key"];
|
|
3035
|
-
if (presharedKey) {
|
|
3036
|
-
presharedKey = `,preshared-key="${presharedKey}"`;
|
|
3037
|
-
}
|
|
3038
3126
|
const peer = {
|
|
3039
3127
|
"public-key": proxy["public-key"],
|
|
3040
3128
|
"allowed-ips": allowedIps ? `"${allowedIps}"` : void 0,
|
|
@@ -3182,9 +3270,7 @@ function handleTransport(result, proxy, includeUnsupportedProxy) {
|
|
|
3182
3270
|
const headers = proxy["ws-opts"].headers;
|
|
3183
3271
|
const value = Object.keys(headers).map((k) => {
|
|
3184
3272
|
let v = headers[k];
|
|
3185
|
-
|
|
3186
|
-
v = `"${v}"`;
|
|
3187
|
-
}
|
|
3273
|
+
v = `"${v}"`;
|
|
3188
3274
|
return `${k}:${v}`;
|
|
3189
3275
|
}).join("|");
|
|
3190
3276
|
if (isNotBlank(value)) {
|
|
@@ -3208,12 +3294,19 @@ function handleTransport(result, proxy, includeUnsupportedProxy) {
|
|
|
3208
3294
|
import { Base64 as Base642 } from "js-base64";
|
|
3209
3295
|
|
|
3210
3296
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/clashmeta.js
|
|
3297
|
+
var ipVersions2 = {
|
|
3298
|
+
dual: "dual",
|
|
3299
|
+
"v4-only": "ipv4",
|
|
3300
|
+
"v6-only": "ipv6",
|
|
3301
|
+
"prefer-v4": "ipv4-prefer",
|
|
3302
|
+
"prefer-v6": "ipv6-prefer"
|
|
3303
|
+
};
|
|
3211
3304
|
function ClashMeta_Producer() {
|
|
3212
3305
|
const type = "ALL";
|
|
3213
3306
|
const produce2 = (proxies, type2, opts = {}) => {
|
|
3214
3307
|
const list = proxies.filter((proxy) => {
|
|
3215
3308
|
if (opts["include-unsupported-proxy"]) return true;
|
|
3216
|
-
if (proxy.type === "snell" &&
|
|
3309
|
+
if (proxy.type === "snell" && proxy.version >= 4) {
|
|
3217
3310
|
return false;
|
|
3218
3311
|
} else if (["juicity"].includes(proxy.type)) {
|
|
3219
3312
|
return false;
|
|
@@ -3254,6 +3347,8 @@ function ClashMeta_Producer() {
|
|
|
3254
3347
|
"none"
|
|
3255
3348
|
].includes(proxy.cipher)) {
|
|
3256
3349
|
return false;
|
|
3350
|
+
} else if (["anytls"].includes(proxy.type) && proxy.network && (!["tcp"].includes(proxy.network) || ["tcp"].includes(proxy.network) && proxy["reality-opts"])) {
|
|
3351
|
+
return false;
|
|
3257
3352
|
}
|
|
3258
3353
|
return true;
|
|
3259
3354
|
}).map((proxy) => {
|
|
@@ -3280,8 +3375,6 @@ function ClashMeta_Producer() {
|
|
|
3280
3375
|
} else if (proxy.type === "tuic") {
|
|
3281
3376
|
if (isPresent2(proxy, "alpn")) {
|
|
3282
3377
|
proxy.alpn = Array.isArray(proxy.alpn) ? proxy.alpn : [proxy.alpn];
|
|
3283
|
-
} else {
|
|
3284
|
-
proxy.alpn = ["h3"];
|
|
3285
3378
|
}
|
|
3286
3379
|
if (isPresent2(proxy, "tfo") && !isPresent2(proxy, "fast-open")) {
|
|
3287
3380
|
proxy["fast-open"] = proxy.tfo;
|
|
@@ -3344,6 +3437,24 @@ function ClashMeta_Producer() {
|
|
|
3344
3437
|
proxy["h2-opts"].headers.host = [host];
|
|
3345
3438
|
}
|
|
3346
3439
|
}
|
|
3440
|
+
if (["ws"].includes(proxy.network)) {
|
|
3441
|
+
const networkPath = proxy[`${proxy.network}-opts`]?.path;
|
|
3442
|
+
if (networkPath) {
|
|
3443
|
+
const reg = /^(.*?)(?:\?ed=(\d+))?$/;
|
|
3444
|
+
const [_2, path = "", ed = ""] = reg.exec(networkPath);
|
|
3445
|
+
proxy[`${proxy.network}-opts`].path = path;
|
|
3446
|
+
if (ed !== "") {
|
|
3447
|
+
proxy["ws-opts"]["early-data-header-name"] = "Sec-WebSocket-Protocol";
|
|
3448
|
+
proxy["ws-opts"]["max-early-data"] = parseInt(
|
|
3449
|
+
ed,
|
|
3450
|
+
10
|
|
3451
|
+
);
|
|
3452
|
+
}
|
|
3453
|
+
} else {
|
|
3454
|
+
proxy[`${proxy.network}-opts`] = proxy[`${proxy.network}-opts`] || {};
|
|
3455
|
+
proxy[`${proxy.network}-opts`].path = "/";
|
|
3456
|
+
}
|
|
3457
|
+
}
|
|
3347
3458
|
if (proxy["plugin-opts"]?.tls) {
|
|
3348
3459
|
if (isPresent2(proxy, "skip-cert-verify")) {
|
|
3349
3460
|
proxy["plugin-opts"]["skip-cert-verify"] = proxy["skip-cert-verify"];
|
|
@@ -3386,6 +3497,9 @@ function ClashMeta_Producer() {
|
|
|
3386
3497
|
delete proxy[`${proxy.network}-opts`]["_grpc-type"];
|
|
3387
3498
|
delete proxy[`${proxy.network}-opts`]["_grpc-authority"];
|
|
3388
3499
|
}
|
|
3500
|
+
if (proxy["ip-version"]) {
|
|
3501
|
+
proxy["ip-version"] = ipVersions2[proxy["ip-version"]] || proxy["ip-version"];
|
|
3502
|
+
}
|
|
3389
3503
|
return proxy;
|
|
3390
3504
|
});
|
|
3391
3505
|
return type2 === "internal" ? list : "proxies:\n" + list.map((proxy) => " - " + JSON.stringify(proxy) + "\n").join("");
|
|
@@ -3550,7 +3664,7 @@ function Clash_Producer() {
|
|
|
3550
3664
|
"xchacha20",
|
|
3551
3665
|
"chacha20-ietf-poly1305",
|
|
3552
3666
|
"xchacha20-ietf-poly1305"
|
|
3553
|
-
].includes(proxy.cipher) || proxy.type === "snell" &&
|
|
3667
|
+
].includes(proxy.cipher) || proxy.type === "snell" && proxy.version >= 4 || proxy.type === "vless" && (typeof proxy.flow !== "undefined" || proxy["reality-opts"])) {
|
|
3554
3668
|
return false;
|
|
3555
3669
|
} else if (proxy["underlying-proxy"] || proxy["dialer-proxy"]) {
|
|
3556
3670
|
app_default.error(
|
|
@@ -3612,6 +3726,24 @@ function Clash_Producer() {
|
|
|
3612
3726
|
proxy["h2-opts"].headers.host = [host];
|
|
3613
3727
|
}
|
|
3614
3728
|
}
|
|
3729
|
+
if (["ws"].includes(proxy.network)) {
|
|
3730
|
+
const networkPath = proxy[`${proxy.network}-opts`]?.path;
|
|
3731
|
+
if (networkPath) {
|
|
3732
|
+
const reg = /^(.*?)(?:\?ed=(\d+))?$/;
|
|
3733
|
+
const [_2, path = "", ed = ""] = reg.exec(networkPath);
|
|
3734
|
+
proxy[`${proxy.network}-opts`].path = path;
|
|
3735
|
+
if (ed !== "") {
|
|
3736
|
+
proxy["ws-opts"]["early-data-header-name"] = "Sec-WebSocket-Protocol";
|
|
3737
|
+
proxy["ws-opts"]["max-early-data"] = parseInt(
|
|
3738
|
+
ed,
|
|
3739
|
+
10
|
|
3740
|
+
);
|
|
3741
|
+
}
|
|
3742
|
+
} else {
|
|
3743
|
+
proxy[`${proxy.network}-opts`] = proxy[`${proxy.network}-opts`] || {};
|
|
3744
|
+
proxy[`${proxy.network}-opts`].path = "/";
|
|
3745
|
+
}
|
|
3746
|
+
}
|
|
3615
3747
|
if (proxy["plugin-opts"]?.tls) {
|
|
3616
3748
|
if (isPresent2(proxy, "skip-cert-verify")) {
|
|
3617
3749
|
proxy["plugin-opts"]["skip-cert-verify"] = proxy["skip-cert-verify"];
|
|
@@ -3694,7 +3826,7 @@ function Stash_Producer() {
|
|
|
3694
3826
|
"xchacha20-ietf-poly1305",
|
|
3695
3827
|
"2022-blake3-aes-128-gcm",
|
|
3696
3828
|
"2022-blake3-aes-256-gcm"
|
|
3697
|
-
].includes(proxy.cipher) || proxy.type === "snell" &&
|
|
3829
|
+
].includes(proxy.cipher) || proxy.type === "snell" && proxy.version >= 4 || proxy.type === "vless" && proxy["reality-opts"] && !["xtls-rprx-vision"].includes(proxy.flow)) {
|
|
3698
3830
|
return false;
|
|
3699
3831
|
} else if (proxy["underlying-proxy"] || proxy["dialer-proxy"]) {
|
|
3700
3832
|
app_default.error(
|
|
@@ -3817,6 +3949,24 @@ function Stash_Producer() {
|
|
|
3817
3949
|
proxy["h2-opts"].headers.host = [host];
|
|
3818
3950
|
}
|
|
3819
3951
|
}
|
|
3952
|
+
if (["ws"].includes(proxy.network)) {
|
|
3953
|
+
const networkPath = proxy[`${proxy.network}-opts`]?.path;
|
|
3954
|
+
if (networkPath) {
|
|
3955
|
+
const reg = /^(.*?)(?:\?ed=(\d+))?$/;
|
|
3956
|
+
const [_2, path = "", ed = ""] = reg.exec(networkPath);
|
|
3957
|
+
proxy[`${proxy.network}-opts`].path = path;
|
|
3958
|
+
if (ed !== "") {
|
|
3959
|
+
proxy["ws-opts"]["early-data-header-name"] = "Sec-WebSocket-Protocol";
|
|
3960
|
+
proxy["ws-opts"]["max-early-data"] = parseInt(
|
|
3961
|
+
ed,
|
|
3962
|
+
10
|
|
3963
|
+
);
|
|
3964
|
+
}
|
|
3965
|
+
} else {
|
|
3966
|
+
proxy[`${proxy.network}-opts`] = proxy[`${proxy.network}-opts`] || {};
|
|
3967
|
+
proxy[`${proxy.network}-opts`].path = "/";
|
|
3968
|
+
}
|
|
3969
|
+
}
|
|
3820
3970
|
if (proxy["plugin-opts"]?.tls) {
|
|
3821
3971
|
if (isPresent2(proxy, "skip-cert-verify")) {
|
|
3822
3972
|
proxy["plugin-opts"]["skip-cert-verify"] = proxy["skip-cert-verify"];
|
|
@@ -3872,7 +4022,7 @@ function Stash_Producer() {
|
|
|
3872
4022
|
|
|
3873
4023
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/loon.js
|
|
3874
4024
|
var targetPlatform3 = "Loon";
|
|
3875
|
-
var
|
|
4025
|
+
var ipVersions3 = {
|
|
3876
4026
|
dual: "dual",
|
|
3877
4027
|
ipv4: "v4-only",
|
|
3878
4028
|
ipv6: "v6-only",
|
|
@@ -3940,6 +4090,11 @@ function shadowsocks2(proxy) {
|
|
|
3940
4090
|
);
|
|
3941
4091
|
if (isPresent2(proxy, "plugin")) {
|
|
3942
4092
|
if (proxy.plugin === "obfs") {
|
|
4093
|
+
if (proxy["plugin-opts"]?.mode && proxy.cipher.startsWith("2022-")) {
|
|
4094
|
+
throw new Error(
|
|
4095
|
+
`${proxy.cipher} ${proxy.plugin} is not supported`
|
|
4096
|
+
);
|
|
4097
|
+
}
|
|
3943
4098
|
result.append(`,obfs-name=${proxy["plugin-opts"].mode}`);
|
|
3944
4099
|
result.appendIfPresent(
|
|
3945
4100
|
`,obfs-host=${proxy["plugin-opts"].host}`,
|
|
@@ -3996,7 +4151,7 @@ function shadowsocks2(proxy) {
|
|
|
3996
4151
|
if (proxy.udp) {
|
|
3997
4152
|
result.append(`,udp=true`);
|
|
3998
4153
|
}
|
|
3999
|
-
const ip_version =
|
|
4154
|
+
const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
4000
4155
|
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
4001
4156
|
return result.toString();
|
|
4002
4157
|
}
|
|
@@ -4055,7 +4210,7 @@ function shadowsocksr(proxy) {
|
|
|
4055
4210
|
if (proxy.udp) {
|
|
4056
4211
|
result.append(`,udp=true`);
|
|
4057
4212
|
}
|
|
4058
|
-
const ip_version =
|
|
4213
|
+
const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
4059
4214
|
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
4060
4215
|
return result.toString();
|
|
4061
4216
|
}
|
|
@@ -4104,7 +4259,7 @@ function trojan2(proxy) {
|
|
|
4104
4259
|
if (proxy.udp) {
|
|
4105
4260
|
result.append(`,udp=true`);
|
|
4106
4261
|
}
|
|
4107
|
-
const ip_version =
|
|
4262
|
+
const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
4108
4263
|
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
4109
4264
|
return result.toString();
|
|
4110
4265
|
}
|
|
@@ -4173,7 +4328,7 @@ function vmess2(proxy) {
|
|
|
4173
4328
|
);
|
|
4174
4329
|
}
|
|
4175
4330
|
if (isPresent2(proxy, "aead")) {
|
|
4176
|
-
result.append(`,alterId
|
|
4331
|
+
result.append(`,alterId=${proxy.aead ? 0 : 1}`);
|
|
4177
4332
|
} else {
|
|
4178
4333
|
result.append(`,alterId=${proxy.alterId}`);
|
|
4179
4334
|
}
|
|
@@ -4186,7 +4341,7 @@ function vmess2(proxy) {
|
|
|
4186
4341
|
if (proxy.udp) {
|
|
4187
4342
|
result.append(`,udp=true`);
|
|
4188
4343
|
}
|
|
4189
|
-
const ip_version =
|
|
4344
|
+
const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
4190
4345
|
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
4191
4346
|
return result.toString();
|
|
4192
4347
|
}
|
|
@@ -4274,7 +4429,7 @@ function vless(proxy) {
|
|
|
4274
4429
|
if (proxy.udp) {
|
|
4275
4430
|
result.append(`,udp=true`);
|
|
4276
4431
|
}
|
|
4277
|
-
const ip_version =
|
|
4432
|
+
const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
4278
4433
|
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
4279
4434
|
return result.toString();
|
|
4280
4435
|
}
|
|
@@ -4295,7 +4450,7 @@ function http2(proxy) {
|
|
|
4295
4450
|
} else if (proxy["block-quic"] === "off") {
|
|
4296
4451
|
result.append(",block-quic=false");
|
|
4297
4452
|
}
|
|
4298
|
-
const ip_version =
|
|
4453
|
+
const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
4299
4454
|
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
4300
4455
|
return result.toString();
|
|
4301
4456
|
}
|
|
@@ -4319,7 +4474,7 @@ function socks52(proxy) {
|
|
|
4319
4474
|
if (proxy.udp) {
|
|
4320
4475
|
result.append(`,udp=true`);
|
|
4321
4476
|
}
|
|
4322
|
-
const ip_version =
|
|
4477
|
+
const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
4323
4478
|
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
4324
4479
|
return result.toString();
|
|
4325
4480
|
}
|
|
@@ -4372,7 +4527,7 @@ function wireguard2(proxy) {
|
|
|
4372
4527
|
result.append(
|
|
4373
4528
|
`,peers=[{public-key="${proxy["public-key"]}",allowed-ips="${allowedIps ?? "0.0.0.0/0,::/0"}",endpoint=${proxy.server}:${proxy.port}${reserved ?? ""}${presharedKey ?? ""}}]`
|
|
4374
4529
|
);
|
|
4375
|
-
const ip_version =
|
|
4530
|
+
const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
4376
4531
|
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
4377
4532
|
if (proxy["block-quic"] === "on") {
|
|
4378
4533
|
result.append(",block-quic=true");
|
|
@@ -4418,13 +4573,122 @@ function hysteria22(proxy) {
|
|
|
4418
4573
|
"down"
|
|
4419
4574
|
);
|
|
4420
4575
|
result.appendIfPresent(`,ecn=${proxy.ecn}`, "ecn");
|
|
4421
|
-
const ip_version =
|
|
4576
|
+
const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
4422
4577
|
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
4423
4578
|
return result.toString();
|
|
4424
4579
|
}
|
|
4425
4580
|
|
|
4426
4581
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/uri.js
|
|
4427
4582
|
import { Base64 as Base643 } from "js-base64";
|
|
4583
|
+
function vless2(proxy) {
|
|
4584
|
+
let security = "none";
|
|
4585
|
+
const isReality = proxy["reality-opts"];
|
|
4586
|
+
let sid = "";
|
|
4587
|
+
let pbk = "";
|
|
4588
|
+
let spx = "";
|
|
4589
|
+
if (isReality) {
|
|
4590
|
+
security = "reality";
|
|
4591
|
+
const publicKey = proxy["reality-opts"]?.["public-key"];
|
|
4592
|
+
if (publicKey) {
|
|
4593
|
+
pbk = `&pbk=${encodeURIComponent(publicKey)}`;
|
|
4594
|
+
}
|
|
4595
|
+
const shortId = proxy["reality-opts"]?.["short-id"];
|
|
4596
|
+
if (shortId) {
|
|
4597
|
+
sid = `&sid=${encodeURIComponent(shortId)}`;
|
|
4598
|
+
}
|
|
4599
|
+
const spiderX = proxy["reality-opts"]?.["_spider-x"];
|
|
4600
|
+
if (spiderX) {
|
|
4601
|
+
spx = `&spx=${encodeURIComponent(spiderX)}`;
|
|
4602
|
+
}
|
|
4603
|
+
} else if (proxy.tls) {
|
|
4604
|
+
security = "tls";
|
|
4605
|
+
}
|
|
4606
|
+
let alpn = "";
|
|
4607
|
+
if (proxy.alpn) {
|
|
4608
|
+
alpn = `&alpn=${encodeURIComponent(
|
|
4609
|
+
Array.isArray(proxy.alpn) ? proxy.alpn : proxy.alpn.join(",")
|
|
4610
|
+
)}`;
|
|
4611
|
+
}
|
|
4612
|
+
let allowInsecure = "";
|
|
4613
|
+
if (proxy["skip-cert-verify"]) {
|
|
4614
|
+
allowInsecure = `&allowInsecure=1`;
|
|
4615
|
+
}
|
|
4616
|
+
let sni = "";
|
|
4617
|
+
if (proxy.sni) {
|
|
4618
|
+
sni = `&sni=${encodeURIComponent(proxy.sni)}`;
|
|
4619
|
+
}
|
|
4620
|
+
let fp = "";
|
|
4621
|
+
if (proxy["client-fingerprint"]) {
|
|
4622
|
+
fp = `&fp=${encodeURIComponent(proxy["client-fingerprint"])}`;
|
|
4623
|
+
}
|
|
4624
|
+
let flow = "";
|
|
4625
|
+
if (proxy.flow) {
|
|
4626
|
+
flow = `&flow=${encodeURIComponent(proxy.flow)}`;
|
|
4627
|
+
}
|
|
4628
|
+
let extra = "";
|
|
4629
|
+
if (proxy._extra) {
|
|
4630
|
+
extra = `&extra=${encodeURIComponent(proxy._extra)}`;
|
|
4631
|
+
}
|
|
4632
|
+
let mode = "";
|
|
4633
|
+
if (proxy._mode) {
|
|
4634
|
+
mode = `&mode=${encodeURIComponent(proxy._mode)}`;
|
|
4635
|
+
}
|
|
4636
|
+
let pqv = "";
|
|
4637
|
+
if (proxy._pqv) {
|
|
4638
|
+
pqv = `&pqv=${encodeURIComponent(proxy._pqv)}`;
|
|
4639
|
+
}
|
|
4640
|
+
let encryption = "";
|
|
4641
|
+
if (proxy.encryption) {
|
|
4642
|
+
encryption = `&encryption=${encodeURIComponent(proxy.encryption)}`;
|
|
4643
|
+
}
|
|
4644
|
+
let vlessType = proxy.network;
|
|
4645
|
+
if (proxy.network === "ws" && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
4646
|
+
vlessType = "httpupgrade";
|
|
4647
|
+
}
|
|
4648
|
+
let vlessTransport = `&type=${encodeURIComponent(vlessType)}`;
|
|
4649
|
+
if (["grpc"].includes(proxy.network)) {
|
|
4650
|
+
vlessTransport += `&mode=${encodeURIComponent(
|
|
4651
|
+
proxy[`${proxy.network}-opts`]?.["_grpc-type"] || "gun"
|
|
4652
|
+
)}`;
|
|
4653
|
+
const authority = proxy[`${proxy.network}-opts`]?.["_grpc-authority"];
|
|
4654
|
+
if (authority) {
|
|
4655
|
+
vlessTransport += `&authority=${encodeURIComponent(authority)}`;
|
|
4656
|
+
}
|
|
4657
|
+
}
|
|
4658
|
+
let vlessTransportServiceName = proxy[`${proxy.network}-opts`]?.[`${proxy.network}-service-name`];
|
|
4659
|
+
let vlessTransportPath = proxy[`${proxy.network}-opts`]?.path;
|
|
4660
|
+
let vlessTransportHost = proxy[`${proxy.network}-opts`]?.headers?.Host;
|
|
4661
|
+
if (vlessTransportPath) {
|
|
4662
|
+
vlessTransport += `&path=${encodeURIComponent(
|
|
4663
|
+
Array.isArray(vlessTransportPath) ? vlessTransportPath[0] : vlessTransportPath
|
|
4664
|
+
)}`;
|
|
4665
|
+
}
|
|
4666
|
+
if (vlessTransportHost) {
|
|
4667
|
+
vlessTransport += `&host=${encodeURIComponent(
|
|
4668
|
+
Array.isArray(vlessTransportHost) ? vlessTransportHost[0] : vlessTransportHost
|
|
4669
|
+
)}`;
|
|
4670
|
+
}
|
|
4671
|
+
if (vlessTransportServiceName) {
|
|
4672
|
+
vlessTransport += `&serviceName=${encodeURIComponent(
|
|
4673
|
+
vlessTransportServiceName
|
|
4674
|
+
)}`;
|
|
4675
|
+
}
|
|
4676
|
+
if (proxy.network === "kcp") {
|
|
4677
|
+
if (proxy.seed) {
|
|
4678
|
+
vlessTransport += `&seed=${encodeURIComponent(proxy.seed)}`;
|
|
4679
|
+
}
|
|
4680
|
+
if (proxy.headerType) {
|
|
4681
|
+
vlessTransport += `&headerType=${encodeURIComponent(
|
|
4682
|
+
proxy.headerType
|
|
4683
|
+
)}`;
|
|
4684
|
+
}
|
|
4685
|
+
}
|
|
4686
|
+
return `vless://${proxy.uuid}@${proxy.server}:${proxy.port}?security=${encodeURIComponent(
|
|
4687
|
+
security
|
|
4688
|
+
)}${vlessTransport}${alpn}${allowInsecure}${sni}${fp}${flow}${sid}${spx}${pbk}${mode}${extra}${pqv}${encryption}#${encodeURIComponent(
|
|
4689
|
+
proxy.name
|
|
4690
|
+
)}`;
|
|
4691
|
+
}
|
|
4428
4692
|
function URI_Producer() {
|
|
4429
4693
|
const type = "SINGLE";
|
|
4430
4694
|
const produce2 = (proxy) => {
|
|
@@ -4450,7 +4714,9 @@ function URI_Producer() {
|
|
|
4450
4714
|
switch (proxy.type) {
|
|
4451
4715
|
case "socks5":
|
|
4452
4716
|
result = `socks://${encodeURIComponent(
|
|
4453
|
-
Base643.encode(
|
|
4717
|
+
Base643.encode(
|
|
4718
|
+
`${proxy.username ?? ""}:${proxy.password ?? ""}`
|
|
4719
|
+
)
|
|
4454
4720
|
)}@${proxy.server}:${proxy.port}#${proxy.name}`;
|
|
4455
4721
|
break;
|
|
4456
4722
|
case "ss":
|
|
@@ -4509,12 +4775,15 @@ function URI_Producer() {
|
|
|
4509
4775
|
v: "2",
|
|
4510
4776
|
ps: proxy.name,
|
|
4511
4777
|
add: proxy.server,
|
|
4512
|
-
port: proxy.port
|
|
4778
|
+
port: `${proxy.port}`,
|
|
4513
4779
|
id: proxy.uuid,
|
|
4514
|
-
|
|
4515
|
-
|
|
4780
|
+
aid: `${proxy.alterId || 0}`,
|
|
4781
|
+
scy: proxy.cipher,
|
|
4516
4782
|
net,
|
|
4517
|
-
|
|
4783
|
+
type: type2,
|
|
4784
|
+
tls: proxy.tls ? "tls" : "",
|
|
4785
|
+
alpn: Array.isArray(proxy.alpn) ? proxy.alpn.join(",") : proxy.alpn,
|
|
4786
|
+
fp: proxy["client-fingerprint"]
|
|
4518
4787
|
};
|
|
4519
4788
|
if (proxy.tls && proxy.sni) {
|
|
4520
4789
|
result.sni = proxy.sni;
|
|
@@ -4522,126 +4791,27 @@ function URI_Producer() {
|
|
|
4522
4791
|
if (proxy.network) {
|
|
4523
4792
|
let vmessTransportPath = proxy[`${proxy.network}-opts`]?.path;
|
|
4524
4793
|
let vmessTransportHost = proxy[`${proxy.network}-opts`]?.headers?.Host;
|
|
4525
|
-
if (vmessTransportPath) {
|
|
4526
|
-
result.path = Array.isArray(vmessTransportPath) ? vmessTransportPath[0] : vmessTransportPath;
|
|
4527
|
-
}
|
|
4528
|
-
if (vmessTransportHost) {
|
|
4529
|
-
result.host = Array.isArray(vmessTransportHost) ? vmessTransportHost[0] : vmessTransportHost;
|
|
4530
|
-
}
|
|
4531
4794
|
if (["grpc"].includes(proxy.network)) {
|
|
4532
4795
|
result.path = proxy[`${proxy.network}-opts`]?.["grpc-service-name"];
|
|
4533
4796
|
result.type = proxy[`${proxy.network}-opts`]?.["_grpc-type"] || "gun";
|
|
4534
4797
|
result.host = proxy[`${proxy.network}-opts`]?.["_grpc-authority"];
|
|
4798
|
+
} else if (["kcp", "quic"].includes(proxy.network)) {
|
|
4799
|
+
result.type = proxy[`${proxy.network}-opts`]?.[`_${proxy.network}-type`] || "none";
|
|
4800
|
+
result.host = proxy[`${proxy.network}-opts`]?.[`_${proxy.network}-host`];
|
|
4801
|
+
result.path = proxy[`${proxy.network}-opts`]?.[`_${proxy.network}-path`];
|
|
4802
|
+
} else {
|
|
4803
|
+
if (vmessTransportPath) {
|
|
4804
|
+
result.path = Array.isArray(vmessTransportPath) ? vmessTransportPath[0] : vmessTransportPath;
|
|
4805
|
+
}
|
|
4806
|
+
if (vmessTransportHost) {
|
|
4807
|
+
result.host = Array.isArray(vmessTransportHost) ? vmessTransportHost[0] : vmessTransportHost;
|
|
4808
|
+
}
|
|
4535
4809
|
}
|
|
4536
4810
|
}
|
|
4537
4811
|
result = "vmess://" + Base643.encode(JSON.stringify(result));
|
|
4538
4812
|
break;
|
|
4539
4813
|
case "vless":
|
|
4540
|
-
|
|
4541
|
-
const isReality = proxy["reality-opts"];
|
|
4542
|
-
let sid = "";
|
|
4543
|
-
let pbk = "";
|
|
4544
|
-
let spx = "";
|
|
4545
|
-
if (isReality) {
|
|
4546
|
-
security = "reality";
|
|
4547
|
-
const publicKey = proxy["reality-opts"]?.["public-key"];
|
|
4548
|
-
if (publicKey) {
|
|
4549
|
-
pbk = `&pbk=${encodeURIComponent(publicKey)}`;
|
|
4550
|
-
}
|
|
4551
|
-
const shortId = proxy["reality-opts"]?.["short-id"];
|
|
4552
|
-
if (shortId) {
|
|
4553
|
-
sid = `&sid=${encodeURIComponent(shortId)}`;
|
|
4554
|
-
}
|
|
4555
|
-
const spiderX = proxy["reality-opts"]?.["_spider-x"];
|
|
4556
|
-
if (spiderX) {
|
|
4557
|
-
spx = `&spx=${encodeURIComponent(spiderX)}`;
|
|
4558
|
-
}
|
|
4559
|
-
} else if (proxy.tls) {
|
|
4560
|
-
security = "tls";
|
|
4561
|
-
}
|
|
4562
|
-
let alpn = "";
|
|
4563
|
-
if (proxy.alpn) {
|
|
4564
|
-
alpn = `&alpn=${encodeURIComponent(
|
|
4565
|
-
Array.isArray(proxy.alpn) ? proxy.alpn : proxy.alpn.join(",")
|
|
4566
|
-
)}`;
|
|
4567
|
-
}
|
|
4568
|
-
let allowInsecure = "";
|
|
4569
|
-
if (proxy["skip-cert-verify"]) {
|
|
4570
|
-
allowInsecure = `&allowInsecure=1`;
|
|
4571
|
-
}
|
|
4572
|
-
let sni = "";
|
|
4573
|
-
if (proxy.sni) {
|
|
4574
|
-
sni = `&sni=${encodeURIComponent(proxy.sni)}`;
|
|
4575
|
-
}
|
|
4576
|
-
let fp = "";
|
|
4577
|
-
if (proxy["client-fingerprint"]) {
|
|
4578
|
-
fp = `&fp=${encodeURIComponent(
|
|
4579
|
-
proxy["client-fingerprint"]
|
|
4580
|
-
)}`;
|
|
4581
|
-
}
|
|
4582
|
-
let flow = "";
|
|
4583
|
-
if (proxy.flow) {
|
|
4584
|
-
flow = `&flow=${encodeURIComponent(proxy.flow)}`;
|
|
4585
|
-
}
|
|
4586
|
-
let extra = "";
|
|
4587
|
-
if (proxy._extra) {
|
|
4588
|
-
extra = `&extra=${encodeURIComponent(proxy._extra)}`;
|
|
4589
|
-
}
|
|
4590
|
-
let mode = "";
|
|
4591
|
-
if (proxy._mode) {
|
|
4592
|
-
mode = `&mode=${encodeURIComponent(proxy._mode)}`;
|
|
4593
|
-
}
|
|
4594
|
-
let vlessType = proxy.network;
|
|
4595
|
-
if (proxy.network === "ws" && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
4596
|
-
vlessType = "httpupgrade";
|
|
4597
|
-
}
|
|
4598
|
-
let vlessTransport = `&type=${encodeURIComponent(vlessType)}`;
|
|
4599
|
-
if (["grpc"].includes(proxy.network)) {
|
|
4600
|
-
vlessTransport += `&mode=${encodeURIComponent(
|
|
4601
|
-
proxy[`${proxy.network}-opts`]?.["_grpc-type"] || "gun"
|
|
4602
|
-
)}`;
|
|
4603
|
-
const authority = proxy[`${proxy.network}-opts`]?.["_grpc-authority"];
|
|
4604
|
-
if (authority) {
|
|
4605
|
-
vlessTransport += `&authority=${encodeURIComponent(
|
|
4606
|
-
authority
|
|
4607
|
-
)}`;
|
|
4608
|
-
}
|
|
4609
|
-
}
|
|
4610
|
-
let vlessTransportServiceName = proxy[`${proxy.network}-opts`]?.[`${proxy.network}-service-name`];
|
|
4611
|
-
let vlessTransportPath = proxy[`${proxy.network}-opts`]?.path;
|
|
4612
|
-
let vlessTransportHost = proxy[`${proxy.network}-opts`]?.headers?.Host;
|
|
4613
|
-
if (vlessTransportPath) {
|
|
4614
|
-
vlessTransport += `&path=${encodeURIComponent(
|
|
4615
|
-
Array.isArray(vlessTransportPath) ? vlessTransportPath[0] : vlessTransportPath
|
|
4616
|
-
)}`;
|
|
4617
|
-
}
|
|
4618
|
-
if (vlessTransportHost) {
|
|
4619
|
-
vlessTransport += `&host=${encodeURIComponent(
|
|
4620
|
-
Array.isArray(vlessTransportHost) ? vlessTransportHost[0] : vlessTransportHost
|
|
4621
|
-
)}`;
|
|
4622
|
-
}
|
|
4623
|
-
if (vlessTransportServiceName) {
|
|
4624
|
-
vlessTransport += `&serviceName=${encodeURIComponent(
|
|
4625
|
-
vlessTransportServiceName
|
|
4626
|
-
)}`;
|
|
4627
|
-
}
|
|
4628
|
-
if (proxy.network === "kcp") {
|
|
4629
|
-
if (proxy.seed) {
|
|
4630
|
-
vlessTransport += `&seed=${encodeURIComponent(
|
|
4631
|
-
proxy.seed
|
|
4632
|
-
)}`;
|
|
4633
|
-
}
|
|
4634
|
-
if (proxy.headerType) {
|
|
4635
|
-
vlessTransport += `&headerType=${encodeURIComponent(
|
|
4636
|
-
proxy.headerType
|
|
4637
|
-
)}`;
|
|
4638
|
-
}
|
|
4639
|
-
}
|
|
4640
|
-
result = `vless://${proxy.uuid}@${proxy.server}:${proxy.port}?security=${encodeURIComponent(
|
|
4641
|
-
security
|
|
4642
|
-
)}${vlessTransport}${alpn}${allowInsecure}${sni}${fp}${flow}${sid}${spx}${pbk}${mode}${extra}#${encodeURIComponent(
|
|
4643
|
-
proxy.name
|
|
4644
|
-
)}`;
|
|
4814
|
+
result = vless2(proxy);
|
|
4645
4815
|
break;
|
|
4646
4816
|
case "trojan":
|
|
4647
4817
|
let trojanTransport = "";
|
|
@@ -4874,6 +5044,11 @@ function URI_Producer() {
|
|
|
4874
5044
|
}
|
|
4875
5045
|
break;
|
|
4876
5046
|
case "anytls":
|
|
5047
|
+
result = vless2({
|
|
5048
|
+
...proxy,
|
|
5049
|
+
uuid: proxy.password,
|
|
5050
|
+
network: proxy.network || "tcp"
|
|
5051
|
+
}).replace("vless", "anytls");
|
|
4877
5052
|
let anytlsParams = [];
|
|
4878
5053
|
Object.keys(proxy).forEach((key) => {
|
|
4879
5054
|
if (![
|
|
@@ -4901,7 +5076,9 @@ function URI_Producer() {
|
|
|
4901
5076
|
if (proxy[key]) {
|
|
4902
5077
|
anytlsParams.push(`udp=1`);
|
|
4903
5078
|
}
|
|
4904
|
-
} else if (proxy[key] && !/^_/i.test(key)
|
|
5079
|
+
} else if (proxy[key] && !/^_|client-fingerprint/i.test(key) && ["number", "string", "boolean"].includes(
|
|
5080
|
+
typeof proxy[key]
|
|
5081
|
+
)) {
|
|
4905
5082
|
anytlsParams.push(
|
|
4906
5083
|
`${i.replace(/-/g, "_")}=${encodeURIComponent(
|
|
4907
5084
|
proxy[key]
|
|
@@ -4910,9 +5087,29 @@ function URI_Producer() {
|
|
|
4910
5087
|
}
|
|
4911
5088
|
}
|
|
4912
5089
|
});
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
5090
|
+
const urlParts = result.split("?");
|
|
5091
|
+
let baseUrl = urlParts[0];
|
|
5092
|
+
let existingParams = {};
|
|
5093
|
+
if (urlParts.length > 1) {
|
|
5094
|
+
const queryString = urlParts[1].split("#")[0];
|
|
5095
|
+
const pairs = queryString.split("&");
|
|
5096
|
+
pairs.forEach((pair) => {
|
|
5097
|
+
const [key, value] = pair.split("=");
|
|
5098
|
+
if (key) {
|
|
5099
|
+
existingParams[key] = value;
|
|
5100
|
+
}
|
|
5101
|
+
});
|
|
5102
|
+
}
|
|
5103
|
+
anytlsParams.forEach((param) => {
|
|
5104
|
+
const [key, value] = param.split("=");
|
|
5105
|
+
if (key) {
|
|
5106
|
+
existingParams[key] = value;
|
|
5107
|
+
}
|
|
5108
|
+
});
|
|
5109
|
+
const newParams = Object.keys(existingParams).map((key) => `${key}=${existingParams[key]}`).join("&");
|
|
5110
|
+
const fragmentMatch = result.match(/#(.*)$/);
|
|
5111
|
+
const fragment = fragmentMatch ? `#${fragmentMatch[1]}` : "";
|
|
5112
|
+
result = `${baseUrl}?${newParams}${fragment}`;
|
|
4916
5113
|
break;
|
|
4917
5114
|
case "wireguard":
|
|
4918
5115
|
let wireguardParams = [];
|
|
@@ -4992,7 +5189,7 @@ function QX_Producer() {
|
|
|
4992
5189
|
const produce2 = (proxy, type, opts = {}) => {
|
|
4993
5190
|
switch (proxy.type) {
|
|
4994
5191
|
case "ss":
|
|
4995
|
-
return shadowsocks3(proxy
|
|
5192
|
+
return shadowsocks3(proxy);
|
|
4996
5193
|
case "ssr":
|
|
4997
5194
|
return shadowsocksr2(proxy);
|
|
4998
5195
|
case "trojan":
|
|
@@ -5004,7 +5201,7 @@ function QX_Producer() {
|
|
|
5004
5201
|
case "socks5":
|
|
5005
5202
|
return socks53(proxy);
|
|
5006
5203
|
case "vless":
|
|
5007
|
-
return
|
|
5204
|
+
return vless3(proxy);
|
|
5008
5205
|
}
|
|
5009
5206
|
throw new Error(
|
|
5010
5207
|
`Platform ${targetPlatform4} does not support proxy type: ${proxy.type}`
|
|
@@ -5012,7 +5209,7 @@ function QX_Producer() {
|
|
|
5012
5209
|
};
|
|
5013
5210
|
return { produce: produce2 };
|
|
5014
5211
|
}
|
|
5015
|
-
function shadowsocks3(proxy
|
|
5212
|
+
function shadowsocks3(proxy) {
|
|
5016
5213
|
const result = new Result(proxy);
|
|
5017
5214
|
const append = result.append.bind(result);
|
|
5018
5215
|
const appendIfPresent = result.appendIfPresent.bind(result);
|
|
@@ -5041,7 +5238,8 @@ function shadowsocks3(proxy, includeUnsupportedProxy) {
|
|
|
5041
5238
|
"aes-256-gcm",
|
|
5042
5239
|
"chacha20-ietf-poly1305",
|
|
5043
5240
|
"xchacha20-ietf-poly1305",
|
|
5044
|
-
|
|
5241
|
+
"2022-blake3-aes-128-gcm",
|
|
5242
|
+
"2022-blake3-aes-256-gcm"
|
|
5045
5243
|
].includes(proxy.cipher)) {
|
|
5046
5244
|
throw new Error(`cipher ${proxy.cipher} is not supported`);
|
|
5047
5245
|
}
|
|
@@ -5270,7 +5468,7 @@ function vmess3(proxy) {
|
|
|
5270
5468
|
append(`,tag=${proxy.name}`);
|
|
5271
5469
|
return result.toString();
|
|
5272
5470
|
}
|
|
5273
|
-
function
|
|
5471
|
+
function vless3(proxy) {
|
|
5274
5472
|
if (typeof proxy.flow !== "undefined" || proxy["reality-opts"]) {
|
|
5275
5473
|
throw new Error(`VLESS XTLS/REALITY is not supported`);
|
|
5276
5474
|
}
|
|
@@ -5290,6 +5488,8 @@ function vless2(proxy) {
|
|
|
5290
5488
|
else append(`,obfs=ws`);
|
|
5291
5489
|
} else if (proxy.network === "http") {
|
|
5292
5490
|
append(`,obfs=http`);
|
|
5491
|
+
} else if (["tcp"].includes(proxy.network)) {
|
|
5492
|
+
if (proxy.tls) append(`,obfs=over-tls`);
|
|
5293
5493
|
} else if (!["tcp"].includes(proxy.network)) {
|
|
5294
5494
|
throw new Error(`network ${proxy.network} is unsupported`);
|
|
5295
5495
|
}
|
|
@@ -5437,14 +5637,9 @@ function Shadowrocket_Producer() {
|
|
|
5437
5637
|
const produce2 = (proxies, type2, opts = {}) => {
|
|
5438
5638
|
const list = proxies.filter((proxy) => {
|
|
5439
5639
|
if (opts["include-unsupported-proxy"]) return true;
|
|
5440
|
-
if (proxy.type === "snell" &&
|
|
5441
|
-
return false;
|
|
5442
|
-
} else if (["mieru", "anytls"].includes(proxy.type)) {
|
|
5640
|
+
if (proxy.type === "snell" && proxy.version >= 4) {
|
|
5443
5641
|
return false;
|
|
5444
|
-
} else if (
|
|
5445
|
-
app_default.error(
|
|
5446
|
-
`Shadowrocket \u4E0D\u652F\u6301\u524D\u7F6E\u4EE3\u7406\u5B57\u6BB5. \u5DF2\u8FC7\u6EE4\u8282\u70B9 ${proxy.name}. \u8BF7\u4F7F\u7528 App \u5185\u7684 "\u4EE3\u7406\u901A\u8FC7" \u529F\u80FD`
|
|
5447
|
-
);
|
|
5642
|
+
} else if (["mieru"].includes(proxy.type)) {
|
|
5448
5643
|
return false;
|
|
5449
5644
|
}
|
|
5450
5645
|
return true;
|
|
@@ -5472,8 +5667,6 @@ function Shadowrocket_Producer() {
|
|
|
5472
5667
|
} else if (proxy.type === "tuic") {
|
|
5473
5668
|
if (isPresent2(proxy, "alpn")) {
|
|
5474
5669
|
proxy.alpn = Array.isArray(proxy.alpn) ? proxy.alpn : [proxy.alpn];
|
|
5475
|
-
} else {
|
|
5476
|
-
proxy.alpn = ["h3"];
|
|
5477
5670
|
}
|
|
5478
5671
|
if (isPresent2(proxy, "tfo") && !isPresent2(proxy, "fast-open")) {
|
|
5479
5672
|
proxy["fast-open"] = proxy.tfo;
|
|
@@ -5492,10 +5685,6 @@ function Shadowrocket_Producer() {
|
|
|
5492
5685
|
proxy["fast-open"] = proxy.tfo;
|
|
5493
5686
|
}
|
|
5494
5687
|
} else if (proxy.type === "hysteria2") {
|
|
5495
|
-
if (proxy["obfs-password"] && proxy.obfs == "salamander") {
|
|
5496
|
-
proxy.obfs = proxy["obfs-password"];
|
|
5497
|
-
delete proxy["obfs-password"];
|
|
5498
|
-
}
|
|
5499
5688
|
if (isPresent2(proxy, "alpn")) {
|
|
5500
5689
|
proxy.alpn = Array.isArray(proxy.alpn) ? proxy.alpn : [proxy.alpn];
|
|
5501
5690
|
}
|
|
@@ -5526,6 +5715,8 @@ function Shadowrocket_Producer() {
|
|
|
5526
5715
|
delete proxy["shadow-tls-sni"];
|
|
5527
5716
|
delete proxy["shadow-tls-version"];
|
|
5528
5717
|
}
|
|
5718
|
+
} else if (["anytls"].includes(proxy.type) && proxy.network && (!["tcp"].includes(proxy.network) || ["tcp"].includes(proxy.network) && proxy["reality-opts"])) {
|
|
5719
|
+
return false;
|
|
5529
5720
|
}
|
|
5530
5721
|
if (["vmess", "vless"].includes(proxy.type) && proxy.network === "http") {
|
|
5531
5722
|
let httpPath = proxy["http-opts"]?.path;
|
|
@@ -5547,6 +5738,24 @@ function Shadowrocket_Producer() {
|
|
|
5547
5738
|
proxy["h2-opts"].headers.host = [host];
|
|
5548
5739
|
}
|
|
5549
5740
|
}
|
|
5741
|
+
if (["ws"].includes(proxy.network)) {
|
|
5742
|
+
const networkPath = proxy[`${proxy.network}-opts`]?.path;
|
|
5743
|
+
if (networkPath) {
|
|
5744
|
+
const reg = /^(.*?)(?:\?ed=(\d+))?$/;
|
|
5745
|
+
const [_2, path = "", ed = ""] = reg.exec(networkPath);
|
|
5746
|
+
proxy[`${proxy.network}-opts`].path = path;
|
|
5747
|
+
if (ed !== "") {
|
|
5748
|
+
proxy["ws-opts"]["early-data-header-name"] = "Sec-WebSocket-Protocol";
|
|
5749
|
+
proxy["ws-opts"]["max-early-data"] = parseInt(
|
|
5750
|
+
ed,
|
|
5751
|
+
10
|
|
5752
|
+
);
|
|
5753
|
+
}
|
|
5754
|
+
} else {
|
|
5755
|
+
proxy[`${proxy.network}-opts`] = proxy[`${proxy.network}-opts`] || {};
|
|
5756
|
+
proxy[`${proxy.network}-opts`].path = "/";
|
|
5757
|
+
}
|
|
5758
|
+
}
|
|
5550
5759
|
if (proxy["plugin-opts"]?.tls) {
|
|
5551
5760
|
if (isPresent2(proxy, "skip-cert-verify")) {
|
|
5552
5761
|
proxy["plugin-opts"]["skip-cert-verify"] = proxy["skip-cert-verify"];
|
|
@@ -5771,6 +5980,25 @@ function handleTransport2(result, proxy) {
|
|
|
5771
5980
|
}
|
|
5772
5981
|
|
|
5773
5982
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/sing-box.js
|
|
5983
|
+
var ipVersions4 = {
|
|
5984
|
+
ipv4: "ipv4_only",
|
|
5985
|
+
ipv6: "ipv6_only",
|
|
5986
|
+
"v4-only": "ipv4_only",
|
|
5987
|
+
"v6-only": "ipv6_only",
|
|
5988
|
+
"ipv4-prefer": "prefer_ipv4",
|
|
5989
|
+
"ipv6-prefer": "prefer_ipv6",
|
|
5990
|
+
"prefer-v4": "prefer_ipv4",
|
|
5991
|
+
"prefer-v6": "prefer_ipv6"
|
|
5992
|
+
};
|
|
5993
|
+
var ipVersionParser = (proxy, parsedProxy) => {
|
|
5994
|
+
const strategy = ipVersions4[proxy["ip-version"]];
|
|
5995
|
+
if (proxy._dns_server && strategy) {
|
|
5996
|
+
parsedProxy.domain_resolver = {
|
|
5997
|
+
server: proxy._dns_server,
|
|
5998
|
+
strategy
|
|
5999
|
+
};
|
|
6000
|
+
}
|
|
6001
|
+
};
|
|
5774
6002
|
var detourParser = (proxy, parsedProxy) => {
|
|
5775
6003
|
parsedProxy.detour = proxy["dialer-proxy"] || proxy.detour;
|
|
5776
6004
|
};
|
|
@@ -5818,7 +6046,14 @@ var smuxParser = (smux, proxy) => {
|
|
|
5818
6046
|
var wsParser = (proxy, parsedProxy) => {
|
|
5819
6047
|
const transport = { type: "ws", headers: {} };
|
|
5820
6048
|
if (proxy["ws-opts"]) {
|
|
5821
|
-
const {
|
|
6049
|
+
const {
|
|
6050
|
+
path: wsPath = "",
|
|
6051
|
+
headers: wsHeaders = {},
|
|
6052
|
+
"max-early-data": max_early_data,
|
|
6053
|
+
"early-data-header-name": early_data_header_name
|
|
6054
|
+
} = proxy["ws-opts"];
|
|
6055
|
+
transport.early_data_header_name = early_data_header_name;
|
|
6056
|
+
transport.max_early_data = max_early_data ? parseInt(max_early_data, 10) : void 0;
|
|
5822
6057
|
if (wsPath !== "") transport.path = `${wsPath}`;
|
|
5823
6058
|
if (Object.keys(wsHeaders).length > 0) {
|
|
5824
6059
|
const headers = {};
|
|
@@ -5918,7 +6153,6 @@ var h1Parser = (proxy, parsedProxy) => {
|
|
|
5918
6153
|
host = `${host}`.split(",").map((i) => i.trim());
|
|
5919
6154
|
if (host.length > 0) transport.host = host;
|
|
5920
6155
|
}
|
|
5921
|
-
if (!transport.host) return;
|
|
5922
6156
|
if (proxy["http-path"] && proxy["http-path"] !== "") {
|
|
5923
6157
|
const path = proxy["http-path"];
|
|
5924
6158
|
if (Array.isArray(path)) {
|
|
@@ -5927,7 +6161,7 @@ var h1Parser = (proxy, parsedProxy) => {
|
|
|
5927
6161
|
}
|
|
5928
6162
|
if (parsedProxy.tls.insecure)
|
|
5929
6163
|
parsedProxy.tls.server_name = transport.host[0];
|
|
5930
|
-
if (transport.host
|
|
6164
|
+
if (transport.host?.length === 1) transport.host = transport.host[0];
|
|
5931
6165
|
for (const key of Object.keys(transport.headers)) {
|
|
5932
6166
|
const value = transport.headers[key];
|
|
5933
6167
|
if (value.length === 1) transport.headers[key] = value[0];
|
|
@@ -5997,6 +6231,11 @@ var tlsParser = (proxy, parsedProxy) => {
|
|
|
5997
6231
|
enabled: true,
|
|
5998
6232
|
fingerprint: proxy["client-fingerprint"]
|
|
5999
6233
|
};
|
|
6234
|
+
if (proxy["_fragment"]) parsedProxy.tls.fragment = !!proxy["_fragment"];
|
|
6235
|
+
if (proxy["_fragment_fallback_delay"])
|
|
6236
|
+
parsedProxy.tls.fragment_fallback_delay = proxy["_fragment_fallback_delay"];
|
|
6237
|
+
if (proxy["_record_fragment"])
|
|
6238
|
+
parsedProxy.tls.record_fragment = !!proxy["_record_fragment"];
|
|
6000
6239
|
if (!parsedProxy.tls.enabled) delete parsedProxy.tls;
|
|
6001
6240
|
};
|
|
6002
6241
|
var sshParser = (proxy = {}) => {
|
|
@@ -6027,6 +6266,7 @@ var sshParser = (proxy = {}) => {
|
|
|
6027
6266
|
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
6028
6267
|
tfoParser(proxy, parsedProxy);
|
|
6029
6268
|
detourParser(proxy, parsedProxy);
|
|
6269
|
+
ipVersionParser(proxy, parsedProxy);
|
|
6030
6270
|
return parsedProxy;
|
|
6031
6271
|
};
|
|
6032
6272
|
var httpParser = (proxy = {}) => {
|
|
@@ -6053,6 +6293,7 @@ var httpParser = (proxy = {}) => {
|
|
|
6053
6293
|
tfoParser(proxy, parsedProxy);
|
|
6054
6294
|
detourParser(proxy, parsedProxy);
|
|
6055
6295
|
tlsParser(proxy, parsedProxy);
|
|
6296
|
+
ipVersionParser(proxy, parsedProxy);
|
|
6056
6297
|
return parsedProxy;
|
|
6057
6298
|
};
|
|
6058
6299
|
var socks5Parser = (proxy = {}) => {
|
|
@@ -6074,6 +6315,7 @@ var socks5Parser = (proxy = {}) => {
|
|
|
6074
6315
|
networkParser(proxy, parsedProxy);
|
|
6075
6316
|
tfoParser(proxy, parsedProxy);
|
|
6076
6317
|
detourParser(proxy, parsedProxy);
|
|
6318
|
+
ipVersionParser(proxy, parsedProxy);
|
|
6077
6319
|
return parsedProxy;
|
|
6078
6320
|
};
|
|
6079
6321
|
var shadowTLSParser = (proxy = {}) => {
|
|
@@ -6084,6 +6326,13 @@ var shadowTLSParser = (proxy = {}) => {
|
|
|
6084
6326
|
password: proxy.password,
|
|
6085
6327
|
detour: `${proxy.name}_shadowtls`
|
|
6086
6328
|
};
|
|
6329
|
+
if (proxy.uot) ssPart.udp_over_tcp = true;
|
|
6330
|
+
if (proxy["udp-over-tcp"]) {
|
|
6331
|
+
ssPart.udp_over_tcp = {
|
|
6332
|
+
enabled: true,
|
|
6333
|
+
version: !proxy["udp-over-tcp-version"] || proxy["udp-over-tcp-version"] === 1 ? 1 : 2
|
|
6334
|
+
};
|
|
6335
|
+
}
|
|
6087
6336
|
const stPart = {
|
|
6088
6337
|
tag: `${proxy.name}_shadowtls`,
|
|
6089
6338
|
type: "shadowtls",
|
|
@@ -6106,6 +6355,7 @@ var shadowTLSParser = (proxy = {}) => {
|
|
|
6106
6355
|
tfoParser(proxy, stPart);
|
|
6107
6356
|
detourParser(proxy, stPart);
|
|
6108
6357
|
smuxParser(proxy.smux, ssPart);
|
|
6358
|
+
ipVersionParser(proxy, stPart);
|
|
6109
6359
|
return { type: "ss-with-st", ssPart, stPart };
|
|
6110
6360
|
};
|
|
6111
6361
|
var ssParser = (proxy = {}) => {
|
|
@@ -6131,6 +6381,7 @@ var ssParser = (proxy = {}) => {
|
|
|
6131
6381
|
tfoParser(proxy, parsedProxy);
|
|
6132
6382
|
detourParser(proxy, parsedProxy);
|
|
6133
6383
|
smuxParser(proxy.smux, parsedProxy);
|
|
6384
|
+
ipVersionParser(proxy, parsedProxy);
|
|
6134
6385
|
if (proxy.plugin) {
|
|
6135
6386
|
const optArr = [];
|
|
6136
6387
|
if (proxy.plugin === "obfs") {
|
|
@@ -6207,6 +6458,7 @@ var ssrParser = (proxy = {}) => {
|
|
|
6207
6458
|
tfoParser(proxy, parsedProxy);
|
|
6208
6459
|
detourParser(proxy, parsedProxy);
|
|
6209
6460
|
smuxParser(proxy.smux, parsedProxy);
|
|
6461
|
+
ipVersionParser(proxy, parsedProxy);
|
|
6210
6462
|
return parsedProxy;
|
|
6211
6463
|
};
|
|
6212
6464
|
var vmessParser = (proxy = {}) => {
|
|
@@ -6242,6 +6494,7 @@ var vmessParser = (proxy = {}) => {
|
|
|
6242
6494
|
detourParser(proxy, parsedProxy);
|
|
6243
6495
|
tlsParser(proxy, parsedProxy);
|
|
6244
6496
|
smuxParser(proxy.smux, parsedProxy);
|
|
6497
|
+
ipVersionParser(proxy, parsedProxy);
|
|
6245
6498
|
return parsedProxy;
|
|
6246
6499
|
};
|
|
6247
6500
|
var vlessParser = (proxy = {}) => {
|
|
@@ -6255,15 +6508,19 @@ var vlessParser = (proxy = {}) => {
|
|
|
6255
6508
|
};
|
|
6256
6509
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
6257
6510
|
throw "invalid port";
|
|
6511
|
+
if (proxy.xudp) parsedProxy.packet_encoding = "xudp";
|
|
6258
6512
|
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
6259
|
-
if (proxy.flow
|
|
6513
|
+
if (proxy.flow != null) parsedProxy.flow = proxy.flow;
|
|
6260
6514
|
if (proxy.network === "ws") wsParser(proxy, parsedProxy);
|
|
6515
|
+
if (proxy.network === "h2") h2Parser(proxy, parsedProxy);
|
|
6516
|
+
if (proxy.network === "http") h1Parser(proxy, parsedProxy);
|
|
6261
6517
|
if (proxy.network === "grpc") grpcParser(proxy, parsedProxy);
|
|
6262
6518
|
networkParser(proxy, parsedProxy);
|
|
6263
6519
|
tfoParser(proxy, parsedProxy);
|
|
6264
6520
|
detourParser(proxy, parsedProxy);
|
|
6265
6521
|
smuxParser(proxy.smux, parsedProxy);
|
|
6266
6522
|
tlsParser(proxy, parsedProxy);
|
|
6523
|
+
ipVersionParser(proxy, parsedProxy);
|
|
6267
6524
|
return parsedProxy;
|
|
6268
6525
|
};
|
|
6269
6526
|
var trojanParser = (proxy = {}) => {
|
|
@@ -6285,6 +6542,7 @@ var trojanParser = (proxy = {}) => {
|
|
|
6285
6542
|
detourParser(proxy, parsedProxy);
|
|
6286
6543
|
tlsParser(proxy, parsedProxy);
|
|
6287
6544
|
smuxParser(proxy.smux, parsedProxy);
|
|
6545
|
+
ipVersionParser(proxy, parsedProxy);
|
|
6288
6546
|
return parsedProxy;
|
|
6289
6547
|
};
|
|
6290
6548
|
var hysteriaParser = (proxy = {}) => {
|
|
@@ -6298,6 +6556,13 @@ var hysteriaParser = (proxy = {}) => {
|
|
|
6298
6556
|
};
|
|
6299
6557
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
6300
6558
|
throw "invalid port";
|
|
6559
|
+
if (proxy["hop-interval"])
|
|
6560
|
+
parsedProxy.hop_interval = /^\d+$/.test(proxy["hop-interval"]) ? `${proxy["hop-interval"]}s` : proxy["hop-interval"];
|
|
6561
|
+
if (proxy["ports"])
|
|
6562
|
+
parsedProxy.server_ports = proxy["ports"].split(/\s*,\s*/).map((p) => {
|
|
6563
|
+
const range = p.replace(/\s*-\s*/g, ":");
|
|
6564
|
+
return range.includes(":") ? range : `${range}:${range}`;
|
|
6565
|
+
});
|
|
6301
6566
|
if (proxy.auth_str) parsedProxy.auth_str = `${proxy.auth_str}`;
|
|
6302
6567
|
if (proxy["auth-str"]) parsedProxy.auth_str = `${proxy["auth-str"]}`;
|
|
6303
6568
|
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
@@ -6332,6 +6597,7 @@ var hysteriaParser = (proxy = {}) => {
|
|
|
6332
6597
|
detourParser(proxy, parsedProxy);
|
|
6333
6598
|
tfoParser(proxy, parsedProxy);
|
|
6334
6599
|
smuxParser(proxy.smux, parsedProxy);
|
|
6600
|
+
ipVersionParser(proxy, parsedProxy);
|
|
6335
6601
|
return parsedProxy;
|
|
6336
6602
|
};
|
|
6337
6603
|
var hysteria2Parser = (proxy = {}) => {
|
|
@@ -6349,7 +6615,10 @@ var hysteria2Parser = (proxy = {}) => {
|
|
|
6349
6615
|
if (proxy["hop-interval"])
|
|
6350
6616
|
parsedProxy.hop_interval = /^\d+$/.test(proxy["hop-interval"]) ? `${proxy["hop-interval"]}s` : proxy["hop-interval"];
|
|
6351
6617
|
if (proxy["ports"])
|
|
6352
|
-
parsedProxy.server_ports = proxy["ports"].split(/\s*,\s*/).map((p) =>
|
|
6618
|
+
parsedProxy.server_ports = proxy["ports"].split(/\s*,\s*/).map((p) => {
|
|
6619
|
+
const range = p.replace(/\s*-\s*/g, ":");
|
|
6620
|
+
return range.includes(":") ? range : `${range}:${range}`;
|
|
6621
|
+
});
|
|
6353
6622
|
if (proxy.up) parsedProxy.up_mbps = parseInt(`${proxy.up}`, 10);
|
|
6354
6623
|
if (proxy.down) parsedProxy.down_mbps = parseInt(`${proxy.down}`, 10);
|
|
6355
6624
|
if (proxy.obfs === "salamander") parsedProxy.obfs.type = "salamander";
|
|
@@ -6361,6 +6630,7 @@ var hysteria2Parser = (proxy = {}) => {
|
|
|
6361
6630
|
tfoParser(proxy, parsedProxy);
|
|
6362
6631
|
detourParser(proxy, parsedProxy);
|
|
6363
6632
|
smuxParser(proxy.smux, parsedProxy);
|
|
6633
|
+
ipVersionParser(proxy, parsedProxy);
|
|
6364
6634
|
return parsedProxy;
|
|
6365
6635
|
};
|
|
6366
6636
|
var tuic5Parser = (proxy = {}) => {
|
|
@@ -6389,6 +6659,7 @@ var tuic5Parser = (proxy = {}) => {
|
|
|
6389
6659
|
detourParser(proxy, parsedProxy);
|
|
6390
6660
|
tlsParser(proxy, parsedProxy);
|
|
6391
6661
|
smuxParser(proxy.smux, parsedProxy);
|
|
6662
|
+
ipVersionParser(proxy, parsedProxy);
|
|
6392
6663
|
return parsedProxy;
|
|
6393
6664
|
};
|
|
6394
6665
|
var anytlsParser = (proxy = {}) => {
|
|
@@ -6404,8 +6675,15 @@ var anytlsParser = (proxy = {}) => {
|
|
|
6404
6675
|
parsedProxy.idle_session_check_interval = `${proxy["idle-session-check-interval"]}s`;
|
|
6405
6676
|
if (/^\d+$/.test(proxy["idle-session-timeout"]))
|
|
6406
6677
|
parsedProxy.idle_session_timeout = `${proxy["idle-session-timeout"]}s`;
|
|
6678
|
+
if (/^\d+$/.test(proxy["min-idle-session"]))
|
|
6679
|
+
parsedProxy.min_idle_session = parseInt(
|
|
6680
|
+
`${proxy["min-idle-session"]}`,
|
|
6681
|
+
10
|
|
6682
|
+
);
|
|
6683
|
+
networkParser(proxy, parsedProxy);
|
|
6407
6684
|
detourParser(proxy, parsedProxy);
|
|
6408
6685
|
tlsParser(proxy, parsedProxy);
|
|
6686
|
+
ipVersionParser(proxy, parsedProxy);
|
|
6409
6687
|
return parsedProxy;
|
|
6410
6688
|
};
|
|
6411
6689
|
var wireguardParser = (proxy = {}) => {
|
|
@@ -6459,6 +6737,7 @@ var wireguardParser = (proxy = {}) => {
|
|
|
6459
6737
|
tfoParser(proxy, parsedProxy);
|
|
6460
6738
|
detourParser(proxy, parsedProxy);
|
|
6461
6739
|
smuxParser(proxy.smux, parsedProxy);
|
|
6740
|
+
ipVersionParser(proxy, parsedProxy);
|
|
6462
6741
|
return parsedProxy;
|
|
6463
6742
|
};
|
|
6464
6743
|
function singbox_Producer() {
|
|
@@ -6573,7 +6852,7 @@ function singbox_Producer() {
|
|
|
6573
6852
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/egern.js
|
|
6574
6853
|
function Egern_Producer() {
|
|
6575
6854
|
const type = "ALL";
|
|
6576
|
-
const produce2 = (proxies, type2) => {
|
|
6855
|
+
const produce2 = (proxies, type2, opts = {}) => {
|
|
6577
6856
|
const list = proxies.filter((proxy) => {
|
|
6578
6857
|
if (![
|
|
6579
6858
|
"http",
|
|
@@ -6615,12 +6894,13 @@ function Egern_Producer() {
|
|
|
6615
6894
|
"chacha20-ietf",
|
|
6616
6895
|
"2022-blake3-aes-128-gcm",
|
|
6617
6896
|
"2022-blake3-aes-256-gcm"
|
|
6618
|
-
].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" && (typeof proxy.flow !== "undefined" || proxy["reality-opts"] || !["http", "ws", "tcp"].includes(proxy.network) && proxy.network) || proxy.type === "tuic" && proxy.token && proxy.token.length !== 0) {
|
|
6897
|
+
].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) {
|
|
6619
6898
|
return false;
|
|
6620
6899
|
}
|
|
6621
6900
|
return true;
|
|
6622
6901
|
}).map((proxy) => {
|
|
6623
6902
|
const original = { ...proxy };
|
|
6903
|
+
let flow;
|
|
6624
6904
|
if (proxy.tls && !proxy.sni) {
|
|
6625
6905
|
proxy.sni = proxy.server;
|
|
6626
6906
|
}
|
|
@@ -6775,6 +7055,12 @@ function Egern_Producer() {
|
|
|
6775
7055
|
}
|
|
6776
7056
|
};
|
|
6777
7057
|
}
|
|
7058
|
+
let legacy;
|
|
7059
|
+
if (isPresent2(proxy, "aead") && !proxy.aead) {
|
|
7060
|
+
legacy = true;
|
|
7061
|
+
} else if (proxy.alterId !== 0) {
|
|
7062
|
+
legacy = true;
|
|
7063
|
+
}
|
|
6778
7064
|
proxy = {
|
|
6779
7065
|
type: "vmess",
|
|
6780
7066
|
name: proxy.name,
|
|
@@ -6783,7 +7069,7 @@ function Egern_Producer() {
|
|
|
6783
7069
|
user_id: proxy.uuid,
|
|
6784
7070
|
security,
|
|
6785
7071
|
tfo: proxy.tfo || proxy["fast-open"],
|
|
6786
|
-
legacy
|
|
7072
|
+
legacy,
|
|
6787
7073
|
udp_relay: proxy.udp || proxy.udp_relay || proxy.udp_relay,
|
|
6788
7074
|
next_hop: proxy.next_hop,
|
|
6789
7075
|
transport: proxy.transport
|
|
@@ -6816,12 +7102,21 @@ function Egern_Producer() {
|
|
|
6816
7102
|
}
|
|
6817
7103
|
};
|
|
6818
7104
|
} else if (proxy.network === "tcp" || !proxy.network) {
|
|
7105
|
+
let reality;
|
|
7106
|
+
if (proxy["reality-opts"]?.["short-id"] || proxy["reality-opts"]?.["public-key"]) {
|
|
7107
|
+
reality = {
|
|
7108
|
+
short_id: proxy["reality-opts"]["short-id"],
|
|
7109
|
+
public_key: proxy["reality-opts"]["public-key"]
|
|
7110
|
+
};
|
|
7111
|
+
}
|
|
6819
7112
|
proxy.transport = {
|
|
6820
7113
|
[proxy.tls ? "tls" : "tcp"]: {
|
|
6821
7114
|
sni: proxy.tls ? proxy.sni : void 0,
|
|
6822
|
-
skip_tls_verify: proxy.tls ? proxy["skip-cert-verify"] : void 0
|
|
7115
|
+
skip_tls_verify: proxy.tls ? proxy["skip-cert-verify"] : void 0,
|
|
7116
|
+
reality
|
|
6823
7117
|
}
|
|
6824
7118
|
};
|
|
7119
|
+
flow = proxy.flow;
|
|
6825
7120
|
}
|
|
6826
7121
|
proxy = {
|
|
6827
7122
|
type: "vless",
|
|
@@ -6831,10 +7126,10 @@ function Egern_Producer() {
|
|
|
6831
7126
|
user_id: proxy.uuid,
|
|
6832
7127
|
security: proxy.cipher,
|
|
6833
7128
|
tfo: proxy.tfo || proxy["fast-open"],
|
|
6834
|
-
legacy: proxy.legacy,
|
|
6835
7129
|
udp_relay: proxy.udp || proxy.udp_relay || proxy.udp_relay,
|
|
6836
7130
|
next_hop: proxy.next_hop,
|
|
6837
|
-
transport: proxy.transport
|
|
7131
|
+
transport: proxy.transport,
|
|
7132
|
+
flow
|
|
6838
7133
|
// sni: proxy.sni,
|
|
6839
7134
|
// skip_tls_verify: proxy['skip-cert-verify'],
|
|
6840
7135
|
};
|
|
@@ -6867,11 +7162,26 @@ function Egern_Producer() {
|
|
|
6867
7162
|
};
|
|
6868
7163
|
}
|
|
6869
7164
|
}
|
|
7165
|
+
if (["ss"].includes(original.type) && proxy.shadow_tls && original["udp-port"] > 0 && original["udp-port"] <= 65535) {
|
|
7166
|
+
proxy["udp_port"] = original["udp-port"];
|
|
7167
|
+
}
|
|
6870
7168
|
delete proxy.subName;
|
|
6871
7169
|
delete proxy.collectionName;
|
|
6872
7170
|
delete proxy.id;
|
|
6873
7171
|
delete proxy.resolved;
|
|
6874
7172
|
delete proxy["no-resolve"];
|
|
7173
|
+
if (proxy.transport) {
|
|
7174
|
+
for (const key in proxy.transport) {
|
|
7175
|
+
if (Object.keys(proxy.transport[key]).length === 0 || Object.values(proxy.transport[key]).every(
|
|
7176
|
+
(v) => v == null
|
|
7177
|
+
)) {
|
|
7178
|
+
delete proxy.transport[key];
|
|
7179
|
+
}
|
|
7180
|
+
}
|
|
7181
|
+
if (Object.keys(proxy.transport).length === 0) {
|
|
7182
|
+
delete proxy.transport;
|
|
7183
|
+
}
|
|
7184
|
+
}
|
|
6875
7185
|
if (type2 !== "internal") {
|
|
6876
7186
|
for (const key in proxy) {
|
|
6877
7187
|
if (proxy[key] == null || /^_/i.test(key)) {
|