sub-store-convert 2.19.36 → 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 -17
- package/{build → packages/core/build}/index.js +611 -299
|
@@ -94,10 +94,11 @@ shadowsocks = tag equals "ss" address (method/passwordk/obfs/obfs_host/obfs_uri/
|
|
|
94
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();
|
|
@@ -143,11 +144,11 @@ wireguard = tag equals "wireguard" (section_name/no_error_alert/ip_version/under
|
|
|
143
144
|
proxy.type = "wireguard-surge";
|
|
144
145
|
handleShadowTLS();
|
|
145
146
|
}
|
|
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/
|
|
147
|
+
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
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/tfo/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
|
}
|
|
@@ -159,7 +160,6 @@ socks5_tls = tag equals "socks5-tls" address (username password)? (usernamek pas
|
|
|
159
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; };
|
|
@@ -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
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
|
|
|
@@ -483,7 +483,8 @@ shadow_tls_sni = comma "shadow-tls-sni" equals match:[^,]+ { proxy["shadow-tls-s
|
|
|
483
483
|
shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { proxy["shadow-tls-password"] = match.join(""); }
|
|
484
484
|
|
|
485
485
|
over_tls = comma "over-tls" equals flag:bool { proxy.tls = flag; }
|
|
486
|
-
|
|
486
|
+
tls_name = comma sni:("tls-name") equals host:domain { proxy.sni = host; }
|
|
487
|
+
sni = comma sni:("sni") equals host:domain { proxy.sni = host; }
|
|
487
488
|
tls_verification = comma "skip-cert-verify" equals flag:bool { proxy["skip-cert-verify"] = flag; }
|
|
488
489
|
tls_cert_sha256 = comma "tls-cert-sha256" equals match:[^,]+ { proxy["tls-fingerprint"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
|
489
490
|
tls_pubkey_sha256 = comma "tls-pubkey-sha256" equals match:[^,]+ { proxy["tls-pubkey-sha256"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
|
@@ -606,10 +607,10 @@ vmess = "vmess" equals address
|
|
|
606
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)* {
|
|
607
608
|
proxy.type = "vmess";
|
|
608
609
|
proxy.cipher = proxy.cipher || "none";
|
|
609
|
-
if (proxy.aead) {
|
|
610
|
-
proxy.alterId =
|
|
610
|
+
if (proxy.aead === false) {
|
|
611
|
+
proxy.alterId = 1;
|
|
611
612
|
} else {
|
|
612
|
-
proxy.alterId =
|
|
613
|
+
proxy.alterId = 0;
|
|
613
614
|
}
|
|
614
615
|
handleObfs();
|
|
615
616
|
}
|
|
@@ -907,6 +908,47 @@ var app_default = new Proxy(console, {
|
|
|
907
908
|
}
|
|
908
909
|
});
|
|
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
|
+
|
|
910
952
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/parsers/index.js
|
|
911
953
|
import { Base64 } from "js-base64";
|
|
912
954
|
function surge_port_hopping(raw) {
|
|
@@ -925,7 +967,7 @@ function URI_PROXY() {
|
|
|
925
967
|
};
|
|
926
968
|
const parse = (line) => {
|
|
927
969
|
let [__, type, tls, username, password, server, port, query, name2] = line.match(
|
|
928
|
-
/^(socks5|http|http)(\+tls|s)?:\/\/(?:(.*?):(.*?)@)?(.*?)(?::(\d+?))
|
|
970
|
+
/^(socks5|http|http)(\+tls|s)?:\/\/(?:(.*?):(.*?)@)?(.*?)(?::(\d+?))?\/?(\?.*?)?(?:#(.*?))?$/
|
|
929
971
|
);
|
|
930
972
|
if (port) {
|
|
931
973
|
port = parseInt(port, 10);
|
|
@@ -1237,9 +1279,9 @@ function URI_VMess() {
|
|
|
1237
1279
|
params[key] = value.split(",");
|
|
1238
1280
|
}
|
|
1239
1281
|
}
|
|
1240
|
-
let [___, cipher,
|
|
1282
|
+
let [___, cipher, uuid2, server2, port2] = /(^[^:]+?):([^:]+?)@(.*):(\d+)$/.exec(content);
|
|
1241
1283
|
params.scy = cipher;
|
|
1242
|
-
params.id =
|
|
1284
|
+
params.id = uuid2;
|
|
1243
1285
|
params.port = port2;
|
|
1244
1286
|
params.add = server2;
|
|
1245
1287
|
}
|
|
@@ -1250,7 +1292,14 @@ function URI_VMess() {
|
|
|
1250
1292
|
type: "vmess",
|
|
1251
1293
|
server,
|
|
1252
1294
|
port,
|
|
1253
|
-
|
|
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",
|
|
1254
1303
|
uuid: params.id,
|
|
1255
1304
|
alterId: parseInt(
|
|
1256
1305
|
getIfPresent(params.aid ?? params.alterId, 0),
|
|
@@ -1276,8 +1325,8 @@ function URI_VMess() {
|
|
|
1276
1325
|
proxy.network = "ws";
|
|
1277
1326
|
} else if (["http"].includes(params.net) || ["http"].includes(params.obfs) || ["http"].includes(params.type)) {
|
|
1278
1327
|
proxy.network = "http";
|
|
1279
|
-
} else if (["grpc"].includes(params.net)) {
|
|
1280
|
-
proxy.network =
|
|
1328
|
+
} else if (["grpc", "kcp", "quic"].includes(params.net)) {
|
|
1329
|
+
proxy.network = params.net;
|
|
1281
1330
|
} else if (params.net === "httpupgrade" || proxy.network === "httpupgrade") {
|
|
1282
1331
|
proxy.network = "ws";
|
|
1283
1332
|
httpupgrade = true;
|
|
@@ -1309,13 +1358,23 @@ function URI_VMess() {
|
|
|
1309
1358
|
transportPath = "/";
|
|
1310
1359
|
}
|
|
1311
1360
|
}
|
|
1312
|
-
if (transportPath || transportHost) {
|
|
1361
|
+
if (transportPath || transportHost || ["kcp", "quic"].includes(proxy.network)) {
|
|
1313
1362
|
if (["grpc"].includes(proxy.network)) {
|
|
1314
1363
|
proxy[`${proxy.network}-opts`] = {
|
|
1315
1364
|
"grpc-service-name": getIfNotBlank(transportPath),
|
|
1316
1365
|
"_grpc-type": getIfNotBlank(params.type),
|
|
1317
1366
|
"_grpc-authority": getIfNotBlank(params.authority)
|
|
1318
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
|
+
};
|
|
1319
1378
|
} else {
|
|
1320
1379
|
const opts = {
|
|
1321
1380
|
path: getIfNotBlank(transportPath),
|
|
@@ -1331,6 +1390,8 @@ function URI_VMess() {
|
|
|
1331
1390
|
delete proxy.network;
|
|
1332
1391
|
}
|
|
1333
1392
|
}
|
|
1393
|
+
proxy["client-fingerprint"] = params.fp;
|
|
1394
|
+
proxy.alpn = params.alpn ? params.alpn.split(",") : void 0;
|
|
1334
1395
|
return proxy;
|
|
1335
1396
|
}
|
|
1336
1397
|
};
|
|
@@ -1351,12 +1412,12 @@ function URI_VLESS() {
|
|
|
1351
1412
|
parsed = /^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
1352
1413
|
isShadowrocket = true;
|
|
1353
1414
|
}
|
|
1354
|
-
let [__,
|
|
1415
|
+
let [__, uuid2, server, port, ___, addons = "", name2] = parsed;
|
|
1355
1416
|
if (isShadowrocket) {
|
|
1356
|
-
|
|
1417
|
+
uuid2 = uuid2.replace(/^.*?:/g, "");
|
|
1357
1418
|
}
|
|
1358
1419
|
port = parseInt(`${port}`, 10);
|
|
1359
|
-
|
|
1420
|
+
uuid2 = decodeURIComponent(uuid2);
|
|
1360
1421
|
if (name2 != null) {
|
|
1361
1422
|
name2 = decodeURIComponent(name2);
|
|
1362
1423
|
}
|
|
@@ -1365,14 +1426,16 @@ function URI_VLESS() {
|
|
|
1365
1426
|
name: name2,
|
|
1366
1427
|
server,
|
|
1367
1428
|
port,
|
|
1368
|
-
uuid
|
|
1429
|
+
uuid: uuid2
|
|
1369
1430
|
};
|
|
1370
1431
|
const params = {};
|
|
1371
1432
|
for (const addon of addons.split("&")) {
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1433
|
+
if (addon) {
|
|
1434
|
+
const [key, valueRaw] = addon.split("=");
|
|
1435
|
+
let value = valueRaw;
|
|
1436
|
+
value = decodeURIComponent(valueRaw);
|
|
1437
|
+
params[key] = value;
|
|
1438
|
+
}
|
|
1376
1439
|
}
|
|
1377
1440
|
proxy.name = name2 ?? params.remarks ?? params.remark ?? `VLESS ${server}:${port}`;
|
|
1378
1441
|
proxy.tls = params.security && params.security !== "none";
|
|
@@ -1475,6 +1538,12 @@ function URI_VLESS() {
|
|
|
1475
1538
|
proxy._extra = params.extra;
|
|
1476
1539
|
}
|
|
1477
1540
|
}
|
|
1541
|
+
if (params.encryption) {
|
|
1542
|
+
proxy.encryption = params.encryption;
|
|
1543
|
+
}
|
|
1544
|
+
if (params.pqv) {
|
|
1545
|
+
proxy._pqv = params.pqv;
|
|
1546
|
+
}
|
|
1478
1547
|
return proxy;
|
|
1479
1548
|
};
|
|
1480
1549
|
return { name, test, parse };
|
|
@@ -1485,6 +1554,7 @@ function URI_AnyTLS() {
|
|
|
1485
1554
|
return /^anytls:\/\//.test(line);
|
|
1486
1555
|
};
|
|
1487
1556
|
const parse = (line) => {
|
|
1557
|
+
const parsed = URI_VLESS().parse(line.replace("anytls", "vless"));
|
|
1488
1558
|
line = line.split(/anytls:\/\//)[1];
|
|
1489
1559
|
let [__, password, server, port, addons = "", name2] = /^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
1490
1560
|
password = decodeURIComponent(password);
|
|
@@ -1498,6 +1568,8 @@ function URI_AnyTLS() {
|
|
|
1498
1568
|
}
|
|
1499
1569
|
name2 = name2 ?? `AnyTLS ${server}:${port}`;
|
|
1500
1570
|
const proxy = {
|
|
1571
|
+
...parsed,
|
|
1572
|
+
uuid: void 0,
|
|
1501
1573
|
type: "anytls",
|
|
1502
1574
|
name: name2,
|
|
1503
1575
|
server,
|
|
@@ -1505,19 +1577,25 @@ function URI_AnyTLS() {
|
|
|
1505
1577
|
password
|
|
1506
1578
|
};
|
|
1507
1579
|
for (const addon of addons.split("&")) {
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
proxy
|
|
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
|
+
}
|
|
1519
1593
|
}
|
|
1520
1594
|
}
|
|
1595
|
+
if (["tcp"].includes(proxy.network) && !proxy["reality-opts"]) {
|
|
1596
|
+
delete proxy.network;
|
|
1597
|
+
delete proxy.security;
|
|
1598
|
+
}
|
|
1521
1599
|
return proxy;
|
|
1522
1600
|
};
|
|
1523
1601
|
return { name, test, parse };
|
|
@@ -1572,10 +1650,12 @@ function URI_Hysteria2() {
|
|
|
1572
1650
|
};
|
|
1573
1651
|
const params = {};
|
|
1574
1652
|
for (const addon of addons.split("&")) {
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1653
|
+
if (addon) {
|
|
1654
|
+
const [key, valueRaw] = addon.split("=");
|
|
1655
|
+
let value = valueRaw;
|
|
1656
|
+
value = decodeURIComponent(valueRaw);
|
|
1657
|
+
params[key] = value;
|
|
1658
|
+
}
|
|
1579
1659
|
}
|
|
1580
1660
|
proxy.sni = params.sni;
|
|
1581
1661
|
if (!proxy.sni && params.peer) {
|
|
@@ -1627,29 +1707,31 @@ function URI_Hysteria() {
|
|
|
1627
1707
|
};
|
|
1628
1708
|
const params = {};
|
|
1629
1709
|
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
|
|
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
|
+
}
|
|
1653
1735
|
}
|
|
1654
1736
|
}
|
|
1655
1737
|
if (!proxy.sni && params.peer) {
|
|
@@ -1674,7 +1756,7 @@ function URI_TUIC() {
|
|
|
1674
1756
|
line = line.split(/tuic:\/\//)[1];
|
|
1675
1757
|
let [__, auth, server, port, addons = "", name2] = /^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
1676
1758
|
auth = decodeURIComponent(auth);
|
|
1677
|
-
let [
|
|
1759
|
+
let [uuid2, ...passwordParts] = auth.split(":");
|
|
1678
1760
|
let password = passwordParts.join(":");
|
|
1679
1761
|
port = parseInt(`${port}`, 10);
|
|
1680
1762
|
if (isNaN(port)) {
|
|
@@ -1691,25 +1773,27 @@ function URI_TUIC() {
|
|
|
1691
1773
|
server,
|
|
1692
1774
|
port,
|
|
1693
1775
|
password,
|
|
1694
|
-
uuid
|
|
1776
|
+
uuid: uuid2
|
|
1695
1777
|
};
|
|
1696
1778
|
for (const addon of addons.split("&")) {
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
proxy
|
|
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
|
+
}
|
|
1713
1797
|
}
|
|
1714
1798
|
}
|
|
1715
1799
|
return proxy;
|
|
@@ -1752,36 +1836,38 @@ function URI_WireGuard() {
|
|
|
1752
1836
|
udp: true
|
|
1753
1837
|
};
|
|
1754
1838
|
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;
|
|
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;
|
|
1770
1847
|
}
|
|
1771
|
-
})
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
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;
|
|
1776
1870
|
}
|
|
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
1871
|
}
|
|
1786
1872
|
}
|
|
1787
1873
|
return proxy;
|
|
@@ -1816,15 +1902,21 @@ function URI_Trojan() {
|
|
|
1816
1902
|
function Clash_All() {
|
|
1817
1903
|
const name = "Clash Parser";
|
|
1818
1904
|
const test = (line) => {
|
|
1905
|
+
let proxy;
|
|
1819
1906
|
try {
|
|
1820
|
-
|
|
1907
|
+
proxy = JSON5.parse(line);
|
|
1821
1908
|
} catch (e) {
|
|
1822
|
-
|
|
1909
|
+
proxy = yaml_default.parse(line);
|
|
1823
1910
|
}
|
|
1824
|
-
return
|
|
1911
|
+
return !!proxy?.type;
|
|
1825
1912
|
};
|
|
1826
1913
|
const parse = (line) => {
|
|
1827
|
-
|
|
1914
|
+
let proxy;
|
|
1915
|
+
try {
|
|
1916
|
+
proxy = JSON5.parse(line);
|
|
1917
|
+
} catch (e) {
|
|
1918
|
+
proxy = yaml_default.parse(line);
|
|
1919
|
+
}
|
|
1828
1920
|
if (![
|
|
1829
1921
|
"anytls",
|
|
1830
1922
|
"mieru",
|
|
@@ -2616,8 +2708,8 @@ function vmess(proxy, includeUnsupportedProxy) {
|
|
|
2616
2708
|
function ssh(proxy) {
|
|
2617
2709
|
const result = new Result(proxy);
|
|
2618
2710
|
result.append(`${proxy.name}=ssh,${proxy.server},${proxy.port}`);
|
|
2619
|
-
result.appendIfPresent(
|
|
2620
|
-
result.appendIfPresent(`,"${proxy.password}"`, "password");
|
|
2711
|
+
result.appendIfPresent(`,username="${proxy.username}"`, "username");
|
|
2712
|
+
result.appendIfPresent(`,password="${proxy.password}"`, "password");
|
|
2621
2713
|
result.appendIfPresent(
|
|
2622
2714
|
`,private-key=${proxy["keystore-private-key"]}`,
|
|
2623
2715
|
"keystore-private-key"
|
|
@@ -2668,8 +2760,8 @@ function http(proxy) {
|
|
|
2668
2760
|
const result = new Result(proxy);
|
|
2669
2761
|
const type = proxy.tls ? "https" : "http";
|
|
2670
2762
|
result.append(`${proxy.name}=${type},${proxy.server},${proxy.port}`);
|
|
2671
|
-
result.appendIfPresent(
|
|
2672
|
-
result.appendIfPresent(`,"${proxy.password}"`, "password");
|
|
2763
|
+
result.appendIfPresent(`,username="${proxy.username}"`, "username");
|
|
2764
|
+
result.appendIfPresent(`,password="${proxy.password}"`, "password");
|
|
2673
2765
|
const ip_version = ipVersions[proxy["ip-version"]] || proxy["ip-version"];
|
|
2674
2766
|
result.appendIfPresent(`,ip-version=${ip_version}`, "ip-version");
|
|
2675
2767
|
result.appendIfPresent(
|
|
@@ -2760,8 +2852,8 @@ function socks5(proxy) {
|
|
|
2760
2852
|
const result = new Result(proxy);
|
|
2761
2853
|
const type = proxy.tls ? "socks5-tls" : "socks5";
|
|
2762
2854
|
result.append(`${proxy.name}=${type},${proxy.server},${proxy.port}`);
|
|
2763
|
-
result.appendIfPresent(
|
|
2764
|
-
result.appendIfPresent(`,"${proxy.password}"`, "password");
|
|
2855
|
+
result.appendIfPresent(`,username="${proxy.username}"`, "username");
|
|
2856
|
+
result.appendIfPresent(`,password="${proxy.password}"`, "password");
|
|
2765
2857
|
const ip_version = ipVersions[proxy["ip-version"]] || proxy["ip-version"];
|
|
2766
2858
|
result.appendIfPresent(`,ip-version=${ip_version}`, "ip-version");
|
|
2767
2859
|
result.appendIfPresent(
|
|
@@ -3032,9 +3124,6 @@ prefer-ipv6 = true`);
|
|
|
3032
3124
|
const allowedIps = Array.isArray(proxy["allowed-ips"]) ? proxy["allowed-ips"].join(",") : proxy["allowed-ips"];
|
|
3033
3125
|
let reserved = Array.isArray(proxy.reserved) ? proxy.reserved.join("/") : proxy.reserved;
|
|
3034
3126
|
let presharedKey = proxy["preshared-key"] ?? proxy["pre-shared-key"];
|
|
3035
|
-
if (presharedKey) {
|
|
3036
|
-
presharedKey = `,preshared-key="${presharedKey}"`;
|
|
3037
|
-
}
|
|
3038
3127
|
const peer = {
|
|
3039
3128
|
"public-key": proxy["public-key"],
|
|
3040
3129
|
"allowed-ips": allowedIps ? `"${allowedIps}"` : void 0,
|
|
@@ -3182,9 +3271,7 @@ function handleTransport(result, proxy, includeUnsupportedProxy) {
|
|
|
3182
3271
|
const headers = proxy["ws-opts"].headers;
|
|
3183
3272
|
const value = Object.keys(headers).map((k) => {
|
|
3184
3273
|
let v = headers[k];
|
|
3185
|
-
|
|
3186
|
-
v = `"${v}"`;
|
|
3187
|
-
}
|
|
3274
|
+
v = `"${v}"`;
|
|
3188
3275
|
return `${k}:${v}`;
|
|
3189
3276
|
}).join("|");
|
|
3190
3277
|
if (isNotBlank(value)) {
|
|
@@ -3208,12 +3295,19 @@ function handleTransport(result, proxy, includeUnsupportedProxy) {
|
|
|
3208
3295
|
import { Base64 as Base642 } from "js-base64";
|
|
3209
3296
|
|
|
3210
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
|
+
};
|
|
3211
3305
|
function ClashMeta_Producer() {
|
|
3212
3306
|
const type = "ALL";
|
|
3213
3307
|
const produce2 = (proxies, type2, opts = {}) => {
|
|
3214
3308
|
const list = proxies.filter((proxy) => {
|
|
3215
3309
|
if (opts["include-unsupported-proxy"]) return true;
|
|
3216
|
-
if (proxy.type === "snell" &&
|
|
3310
|
+
if (proxy.type === "snell" && proxy.version >= 4) {
|
|
3217
3311
|
return false;
|
|
3218
3312
|
} else if (["juicity"].includes(proxy.type)) {
|
|
3219
3313
|
return false;
|
|
@@ -3254,6 +3348,8 @@ function ClashMeta_Producer() {
|
|
|
3254
3348
|
"none"
|
|
3255
3349
|
].includes(proxy.cipher)) {
|
|
3256
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;
|
|
3257
3353
|
}
|
|
3258
3354
|
return true;
|
|
3259
3355
|
}).map((proxy) => {
|
|
@@ -3280,8 +3376,6 @@ function ClashMeta_Producer() {
|
|
|
3280
3376
|
} else if (proxy.type === "tuic") {
|
|
3281
3377
|
if (isPresent2(proxy, "alpn")) {
|
|
3282
3378
|
proxy.alpn = Array.isArray(proxy.alpn) ? proxy.alpn : [proxy.alpn];
|
|
3283
|
-
} else {
|
|
3284
|
-
proxy.alpn = ["h3"];
|
|
3285
3379
|
}
|
|
3286
3380
|
if (isPresent2(proxy, "tfo") && !isPresent2(proxy, "fast-open")) {
|
|
3287
3381
|
proxy["fast-open"] = proxy.tfo;
|
|
@@ -3344,6 +3438,24 @@ function ClashMeta_Producer() {
|
|
|
3344
3438
|
proxy["h2-opts"].headers.host = [host];
|
|
3345
3439
|
}
|
|
3346
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
|
+
}
|
|
3347
3459
|
if (proxy["plugin-opts"]?.tls) {
|
|
3348
3460
|
if (isPresent2(proxy, "skip-cert-verify")) {
|
|
3349
3461
|
proxy["plugin-opts"]["skip-cert-verify"] = proxy["skip-cert-verify"];
|
|
@@ -3386,6 +3498,9 @@ function ClashMeta_Producer() {
|
|
|
3386
3498
|
delete proxy[`${proxy.network}-opts`]["_grpc-type"];
|
|
3387
3499
|
delete proxy[`${proxy.network}-opts`]["_grpc-authority"];
|
|
3388
3500
|
}
|
|
3501
|
+
if (proxy["ip-version"]) {
|
|
3502
|
+
proxy["ip-version"] = ipVersions2[proxy["ip-version"]] || proxy["ip-version"];
|
|
3503
|
+
}
|
|
3389
3504
|
return proxy;
|
|
3390
3505
|
});
|
|
3391
3506
|
return type2 === "internal" ? list : "proxies:\n" + list.map((proxy) => " - " + JSON.stringify(proxy) + "\n").join("");
|
|
@@ -3550,7 +3665,7 @@ function Clash_Producer() {
|
|
|
3550
3665
|
"xchacha20",
|
|
3551
3666
|
"chacha20-ietf-poly1305",
|
|
3552
3667
|
"xchacha20-ietf-poly1305"
|
|
3553
|
-
].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"])) {
|
|
3554
3669
|
return false;
|
|
3555
3670
|
} else if (proxy["underlying-proxy"] || proxy["dialer-proxy"]) {
|
|
3556
3671
|
app_default.error(
|
|
@@ -3612,6 +3727,24 @@ function Clash_Producer() {
|
|
|
3612
3727
|
proxy["h2-opts"].headers.host = [host];
|
|
3613
3728
|
}
|
|
3614
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
|
+
}
|
|
3615
3748
|
if (proxy["plugin-opts"]?.tls) {
|
|
3616
3749
|
if (isPresent2(proxy, "skip-cert-verify")) {
|
|
3617
3750
|
proxy["plugin-opts"]["skip-cert-verify"] = proxy["skip-cert-verify"];
|
|
@@ -3694,7 +3827,7 @@ function Stash_Producer() {
|
|
|
3694
3827
|
"xchacha20-ietf-poly1305",
|
|
3695
3828
|
"2022-blake3-aes-128-gcm",
|
|
3696
3829
|
"2022-blake3-aes-256-gcm"
|
|
3697
|
-
].includes(proxy.cipher) || proxy.type === "snell" &&
|
|
3830
|
+
].includes(proxy.cipher) || proxy.type === "snell" && proxy.version >= 4 || proxy.type === "vless" && proxy["reality-opts"] && !["xtls-rprx-vision"].includes(proxy.flow)) {
|
|
3698
3831
|
return false;
|
|
3699
3832
|
} else if (proxy["underlying-proxy"] || proxy["dialer-proxy"]) {
|
|
3700
3833
|
app_default.error(
|
|
@@ -3817,6 +3950,24 @@ function Stash_Producer() {
|
|
|
3817
3950
|
proxy["h2-opts"].headers.host = [host];
|
|
3818
3951
|
}
|
|
3819
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
|
+
}
|
|
3820
3971
|
if (proxy["plugin-opts"]?.tls) {
|
|
3821
3972
|
if (isPresent2(proxy, "skip-cert-verify")) {
|
|
3822
3973
|
proxy["plugin-opts"]["skip-cert-verify"] = proxy["skip-cert-verify"];
|
|
@@ -3872,7 +4023,7 @@ function Stash_Producer() {
|
|
|
3872
4023
|
|
|
3873
4024
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/loon.js
|
|
3874
4025
|
var targetPlatform3 = "Loon";
|
|
3875
|
-
var
|
|
4026
|
+
var ipVersions3 = {
|
|
3876
4027
|
dual: "dual",
|
|
3877
4028
|
ipv4: "v4-only",
|
|
3878
4029
|
ipv6: "v6-only",
|
|
@@ -3940,6 +4091,11 @@ function shadowsocks2(proxy) {
|
|
|
3940
4091
|
);
|
|
3941
4092
|
if (isPresent2(proxy, "plugin")) {
|
|
3942
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
|
+
}
|
|
3943
4099
|
result.append(`,obfs-name=${proxy["plugin-opts"].mode}`);
|
|
3944
4100
|
result.appendIfPresent(
|
|
3945
4101
|
`,obfs-host=${proxy["plugin-opts"].host}`,
|
|
@@ -3996,7 +4152,7 @@ function shadowsocks2(proxy) {
|
|
|
3996
4152
|
if (proxy.udp) {
|
|
3997
4153
|
result.append(`,udp=true`);
|
|
3998
4154
|
}
|
|
3999
|
-
const ip_version =
|
|
4155
|
+
const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
4000
4156
|
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
4001
4157
|
return result.toString();
|
|
4002
4158
|
}
|
|
@@ -4055,7 +4211,7 @@ function shadowsocksr(proxy) {
|
|
|
4055
4211
|
if (proxy.udp) {
|
|
4056
4212
|
result.append(`,udp=true`);
|
|
4057
4213
|
}
|
|
4058
|
-
const ip_version =
|
|
4214
|
+
const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
4059
4215
|
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
4060
4216
|
return result.toString();
|
|
4061
4217
|
}
|
|
@@ -4104,7 +4260,7 @@ function trojan2(proxy) {
|
|
|
4104
4260
|
if (proxy.udp) {
|
|
4105
4261
|
result.append(`,udp=true`);
|
|
4106
4262
|
}
|
|
4107
|
-
const ip_version =
|
|
4263
|
+
const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
4108
4264
|
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
4109
4265
|
return result.toString();
|
|
4110
4266
|
}
|
|
@@ -4173,7 +4329,7 @@ function vmess2(proxy) {
|
|
|
4173
4329
|
);
|
|
4174
4330
|
}
|
|
4175
4331
|
if (isPresent2(proxy, "aead")) {
|
|
4176
|
-
result.append(`,alterId
|
|
4332
|
+
result.append(`,alterId=${proxy.aead ? 0 : 1}`);
|
|
4177
4333
|
} else {
|
|
4178
4334
|
result.append(`,alterId=${proxy.alterId}`);
|
|
4179
4335
|
}
|
|
@@ -4186,7 +4342,7 @@ function vmess2(proxy) {
|
|
|
4186
4342
|
if (proxy.udp) {
|
|
4187
4343
|
result.append(`,udp=true`);
|
|
4188
4344
|
}
|
|
4189
|
-
const ip_version =
|
|
4345
|
+
const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
4190
4346
|
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
4191
4347
|
return result.toString();
|
|
4192
4348
|
}
|
|
@@ -4274,7 +4430,7 @@ function vless(proxy) {
|
|
|
4274
4430
|
if (proxy.udp) {
|
|
4275
4431
|
result.append(`,udp=true`);
|
|
4276
4432
|
}
|
|
4277
|
-
const ip_version =
|
|
4433
|
+
const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
4278
4434
|
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
4279
4435
|
return result.toString();
|
|
4280
4436
|
}
|
|
@@ -4295,7 +4451,7 @@ function http2(proxy) {
|
|
|
4295
4451
|
} else if (proxy["block-quic"] === "off") {
|
|
4296
4452
|
result.append(",block-quic=false");
|
|
4297
4453
|
}
|
|
4298
|
-
const ip_version =
|
|
4454
|
+
const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
4299
4455
|
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
4300
4456
|
return result.toString();
|
|
4301
4457
|
}
|
|
@@ -4319,7 +4475,7 @@ function socks52(proxy) {
|
|
|
4319
4475
|
if (proxy.udp) {
|
|
4320
4476
|
result.append(`,udp=true`);
|
|
4321
4477
|
}
|
|
4322
|
-
const ip_version =
|
|
4478
|
+
const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
4323
4479
|
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
4324
4480
|
return result.toString();
|
|
4325
4481
|
}
|
|
@@ -4372,7 +4528,7 @@ function wireguard2(proxy) {
|
|
|
4372
4528
|
result.append(
|
|
4373
4529
|
`,peers=[{public-key="${proxy["public-key"]}",allowed-ips="${allowedIps ?? "0.0.0.0/0,::/0"}",endpoint=${proxy.server}:${proxy.port}${reserved ?? ""}${presharedKey ?? ""}}]`
|
|
4374
4530
|
);
|
|
4375
|
-
const ip_version =
|
|
4531
|
+
const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
4376
4532
|
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
4377
4533
|
if (proxy["block-quic"] === "on") {
|
|
4378
4534
|
result.append(",block-quic=true");
|
|
@@ -4418,13 +4574,123 @@ function hysteria22(proxy) {
|
|
|
4418
4574
|
"down"
|
|
4419
4575
|
);
|
|
4420
4576
|
result.appendIfPresent(`,ecn=${proxy.ecn}`, "ecn");
|
|
4421
|
-
const ip_version =
|
|
4577
|
+
const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
4422
4578
|
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
4423
4579
|
return result.toString();
|
|
4424
4580
|
}
|
|
4425
4581
|
|
|
4426
4582
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/uri.js
|
|
4427
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
|
+
}
|
|
4428
4694
|
function URI_Producer() {
|
|
4429
4695
|
const type = "SINGLE";
|
|
4430
4696
|
const produce2 = (proxy) => {
|
|
@@ -4450,7 +4716,9 @@ function URI_Producer() {
|
|
|
4450
4716
|
switch (proxy.type) {
|
|
4451
4717
|
case "socks5":
|
|
4452
4718
|
result = `socks://${encodeURIComponent(
|
|
4453
|
-
Base643.encode(
|
|
4719
|
+
Base643.encode(
|
|
4720
|
+
`${proxy.username ?? ""}:${proxy.password ?? ""}`
|
|
4721
|
+
)
|
|
4454
4722
|
)}@${proxy.server}:${proxy.port}#${proxy.name}`;
|
|
4455
4723
|
break;
|
|
4456
4724
|
case "ss":
|
|
@@ -4509,12 +4777,15 @@ function URI_Producer() {
|
|
|
4509
4777
|
v: "2",
|
|
4510
4778
|
ps: proxy.name,
|
|
4511
4779
|
add: proxy.server,
|
|
4512
|
-
port: proxy.port
|
|
4780
|
+
port: `${proxy.port}`,
|
|
4513
4781
|
id: proxy.uuid,
|
|
4514
|
-
|
|
4515
|
-
|
|
4782
|
+
aid: `${proxy.alterId || 0}`,
|
|
4783
|
+
scy: proxy.cipher,
|
|
4516
4784
|
net,
|
|
4517
|
-
|
|
4785
|
+
type: type2,
|
|
4786
|
+
tls: proxy.tls ? "tls" : "",
|
|
4787
|
+
alpn: Array.isArray(proxy.alpn) ? proxy.alpn.join(",") : proxy.alpn,
|
|
4788
|
+
fp: proxy["client-fingerprint"]
|
|
4518
4789
|
};
|
|
4519
4790
|
if (proxy.tls && proxy.sni) {
|
|
4520
4791
|
result.sni = proxy.sni;
|
|
@@ -4522,126 +4793,27 @@ function URI_Producer() {
|
|
|
4522
4793
|
if (proxy.network) {
|
|
4523
4794
|
let vmessTransportPath = proxy[`${proxy.network}-opts`]?.path;
|
|
4524
4795
|
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
4796
|
if (["grpc"].includes(proxy.network)) {
|
|
4532
4797
|
result.path = proxy[`${proxy.network}-opts`]?.["grpc-service-name"];
|
|
4533
4798
|
result.type = proxy[`${proxy.network}-opts`]?.["_grpc-type"] || "gun";
|
|
4534
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
|
+
}
|
|
4535
4811
|
}
|
|
4536
4812
|
}
|
|
4537
4813
|
result = "vmess://" + Base643.encode(JSON.stringify(result));
|
|
4538
4814
|
break;
|
|
4539
4815
|
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
|
-
)}`;
|
|
4816
|
+
result = vless2(proxy);
|
|
4645
4817
|
break;
|
|
4646
4818
|
case "trojan":
|
|
4647
4819
|
let trojanTransport = "";
|
|
@@ -4874,6 +5046,11 @@ function URI_Producer() {
|
|
|
4874
5046
|
}
|
|
4875
5047
|
break;
|
|
4876
5048
|
case "anytls":
|
|
5049
|
+
result = vless2({
|
|
5050
|
+
...proxy,
|
|
5051
|
+
uuid: proxy.password,
|
|
5052
|
+
network: proxy.network || "tcp"
|
|
5053
|
+
}).replace("vless", "anytls");
|
|
4877
5054
|
let anytlsParams = [];
|
|
4878
5055
|
Object.keys(proxy).forEach((key) => {
|
|
4879
5056
|
if (![
|
|
@@ -4901,7 +5078,9 @@ function URI_Producer() {
|
|
|
4901
5078
|
if (proxy[key]) {
|
|
4902
5079
|
anytlsParams.push(`udp=1`);
|
|
4903
5080
|
}
|
|
4904
|
-
} else if (proxy[key] && !/^_/i.test(key)
|
|
5081
|
+
} else if (proxy[key] && !/^_|client-fingerprint/i.test(key) && ["number", "string", "boolean"].includes(
|
|
5082
|
+
typeof proxy[key]
|
|
5083
|
+
)) {
|
|
4905
5084
|
anytlsParams.push(
|
|
4906
5085
|
`${i.replace(/-/g, "_")}=${encodeURIComponent(
|
|
4907
5086
|
proxy[key]
|
|
@@ -4910,9 +5089,29 @@ function URI_Producer() {
|
|
|
4910
5089
|
}
|
|
4911
5090
|
}
|
|
4912
5091
|
});
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
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}`;
|
|
4916
5115
|
break;
|
|
4917
5116
|
case "wireguard":
|
|
4918
5117
|
let wireguardParams = [];
|
|
@@ -4992,7 +5191,7 @@ function QX_Producer() {
|
|
|
4992
5191
|
const produce2 = (proxy, type, opts = {}) => {
|
|
4993
5192
|
switch (proxy.type) {
|
|
4994
5193
|
case "ss":
|
|
4995
|
-
return shadowsocks3(proxy
|
|
5194
|
+
return shadowsocks3(proxy);
|
|
4996
5195
|
case "ssr":
|
|
4997
5196
|
return shadowsocksr2(proxy);
|
|
4998
5197
|
case "trojan":
|
|
@@ -5004,7 +5203,7 @@ function QX_Producer() {
|
|
|
5004
5203
|
case "socks5":
|
|
5005
5204
|
return socks53(proxy);
|
|
5006
5205
|
case "vless":
|
|
5007
|
-
return
|
|
5206
|
+
return vless3(proxy);
|
|
5008
5207
|
}
|
|
5009
5208
|
throw new Error(
|
|
5010
5209
|
`Platform ${targetPlatform4} does not support proxy type: ${proxy.type}`
|
|
@@ -5012,7 +5211,7 @@ function QX_Producer() {
|
|
|
5012
5211
|
};
|
|
5013
5212
|
return { produce: produce2 };
|
|
5014
5213
|
}
|
|
5015
|
-
function shadowsocks3(proxy
|
|
5214
|
+
function shadowsocks3(proxy) {
|
|
5016
5215
|
const result = new Result(proxy);
|
|
5017
5216
|
const append = result.append.bind(result);
|
|
5018
5217
|
const appendIfPresent = result.appendIfPresent.bind(result);
|
|
@@ -5041,7 +5240,8 @@ function shadowsocks3(proxy, includeUnsupportedProxy) {
|
|
|
5041
5240
|
"aes-256-gcm",
|
|
5042
5241
|
"chacha20-ietf-poly1305",
|
|
5043
5242
|
"xchacha20-ietf-poly1305",
|
|
5044
|
-
|
|
5243
|
+
"2022-blake3-aes-128-gcm",
|
|
5244
|
+
"2022-blake3-aes-256-gcm"
|
|
5045
5245
|
].includes(proxy.cipher)) {
|
|
5046
5246
|
throw new Error(`cipher ${proxy.cipher} is not supported`);
|
|
5047
5247
|
}
|
|
@@ -5270,7 +5470,7 @@ function vmess3(proxy) {
|
|
|
5270
5470
|
append(`,tag=${proxy.name}`);
|
|
5271
5471
|
return result.toString();
|
|
5272
5472
|
}
|
|
5273
|
-
function
|
|
5473
|
+
function vless3(proxy) {
|
|
5274
5474
|
if (typeof proxy.flow !== "undefined" || proxy["reality-opts"]) {
|
|
5275
5475
|
throw new Error(`VLESS XTLS/REALITY is not supported`);
|
|
5276
5476
|
}
|
|
@@ -5290,6 +5490,8 @@ function vless2(proxy) {
|
|
|
5290
5490
|
else append(`,obfs=ws`);
|
|
5291
5491
|
} else if (proxy.network === "http") {
|
|
5292
5492
|
append(`,obfs=http`);
|
|
5493
|
+
} else if (["tcp"].includes(proxy.network)) {
|
|
5494
|
+
if (proxy.tls) append(`,obfs=over-tls`);
|
|
5293
5495
|
} else if (!["tcp"].includes(proxy.network)) {
|
|
5294
5496
|
throw new Error(`network ${proxy.network} is unsupported`);
|
|
5295
5497
|
}
|
|
@@ -5437,14 +5639,9 @@ function Shadowrocket_Producer() {
|
|
|
5437
5639
|
const produce2 = (proxies, type2, opts = {}) => {
|
|
5438
5640
|
const list = proxies.filter((proxy) => {
|
|
5439
5641
|
if (opts["include-unsupported-proxy"]) return true;
|
|
5440
|
-
if (proxy.type === "snell" &&
|
|
5441
|
-
return false;
|
|
5442
|
-
} else if (["mieru", "anytls"].includes(proxy.type)) {
|
|
5642
|
+
if (proxy.type === "snell" && proxy.version >= 4) {
|
|
5443
5643
|
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
|
-
);
|
|
5644
|
+
} else if (["mieru"].includes(proxy.type)) {
|
|
5448
5645
|
return false;
|
|
5449
5646
|
}
|
|
5450
5647
|
return true;
|
|
@@ -5472,8 +5669,6 @@ function Shadowrocket_Producer() {
|
|
|
5472
5669
|
} else if (proxy.type === "tuic") {
|
|
5473
5670
|
if (isPresent2(proxy, "alpn")) {
|
|
5474
5671
|
proxy.alpn = Array.isArray(proxy.alpn) ? proxy.alpn : [proxy.alpn];
|
|
5475
|
-
} else {
|
|
5476
|
-
proxy.alpn = ["h3"];
|
|
5477
5672
|
}
|
|
5478
5673
|
if (isPresent2(proxy, "tfo") && !isPresent2(proxy, "fast-open")) {
|
|
5479
5674
|
proxy["fast-open"] = proxy.tfo;
|
|
@@ -5492,10 +5687,6 @@ function Shadowrocket_Producer() {
|
|
|
5492
5687
|
proxy["fast-open"] = proxy.tfo;
|
|
5493
5688
|
}
|
|
5494
5689
|
} 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
5690
|
if (isPresent2(proxy, "alpn")) {
|
|
5500
5691
|
proxy.alpn = Array.isArray(proxy.alpn) ? proxy.alpn : [proxy.alpn];
|
|
5501
5692
|
}
|
|
@@ -5526,6 +5717,8 @@ function Shadowrocket_Producer() {
|
|
|
5526
5717
|
delete proxy["shadow-tls-sni"];
|
|
5527
5718
|
delete proxy["shadow-tls-version"];
|
|
5528
5719
|
}
|
|
5720
|
+
} else if (["anytls"].includes(proxy.type) && proxy.network && (!["tcp"].includes(proxy.network) || ["tcp"].includes(proxy.network) && proxy["reality-opts"])) {
|
|
5721
|
+
return false;
|
|
5529
5722
|
}
|
|
5530
5723
|
if (["vmess", "vless"].includes(proxy.type) && proxy.network === "http") {
|
|
5531
5724
|
let httpPath = proxy["http-opts"]?.path;
|
|
@@ -5547,6 +5740,24 @@ function Shadowrocket_Producer() {
|
|
|
5547
5740
|
proxy["h2-opts"].headers.host = [host];
|
|
5548
5741
|
}
|
|
5549
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
|
+
}
|
|
5550
5761
|
if (proxy["plugin-opts"]?.tls) {
|
|
5551
5762
|
if (isPresent2(proxy, "skip-cert-verify")) {
|
|
5552
5763
|
proxy["plugin-opts"]["skip-cert-verify"] = proxy["skip-cert-verify"];
|
|
@@ -5771,6 +5982,25 @@ function handleTransport2(result, proxy) {
|
|
|
5771
5982
|
}
|
|
5772
5983
|
|
|
5773
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
|
+
};
|
|
5774
6004
|
var detourParser = (proxy, parsedProxy) => {
|
|
5775
6005
|
parsedProxy.detour = proxy["dialer-proxy"] || proxy.detour;
|
|
5776
6006
|
};
|
|
@@ -5818,7 +6048,14 @@ var smuxParser = (smux, proxy) => {
|
|
|
5818
6048
|
var wsParser = (proxy, parsedProxy) => {
|
|
5819
6049
|
const transport = { type: "ws", headers: {} };
|
|
5820
6050
|
if (proxy["ws-opts"]) {
|
|
5821
|
-
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;
|
|
5822
6059
|
if (wsPath !== "") transport.path = `${wsPath}`;
|
|
5823
6060
|
if (Object.keys(wsHeaders).length > 0) {
|
|
5824
6061
|
const headers = {};
|
|
@@ -5918,7 +6155,6 @@ var h1Parser = (proxy, parsedProxy) => {
|
|
|
5918
6155
|
host = `${host}`.split(",").map((i) => i.trim());
|
|
5919
6156
|
if (host.length > 0) transport.host = host;
|
|
5920
6157
|
}
|
|
5921
|
-
if (!transport.host) return;
|
|
5922
6158
|
if (proxy["http-path"] && proxy["http-path"] !== "") {
|
|
5923
6159
|
const path = proxy["http-path"];
|
|
5924
6160
|
if (Array.isArray(path)) {
|
|
@@ -5927,7 +6163,7 @@ var h1Parser = (proxy, parsedProxy) => {
|
|
|
5927
6163
|
}
|
|
5928
6164
|
if (parsedProxy.tls.insecure)
|
|
5929
6165
|
parsedProxy.tls.server_name = transport.host[0];
|
|
5930
|
-
if (transport.host
|
|
6166
|
+
if (transport.host?.length === 1) transport.host = transport.host[0];
|
|
5931
6167
|
for (const key of Object.keys(transport.headers)) {
|
|
5932
6168
|
const value = transport.headers[key];
|
|
5933
6169
|
if (value.length === 1) transport.headers[key] = value[0];
|
|
@@ -5997,6 +6233,11 @@ var tlsParser = (proxy, parsedProxy) => {
|
|
|
5997
6233
|
enabled: true,
|
|
5998
6234
|
fingerprint: proxy["client-fingerprint"]
|
|
5999
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"];
|
|
6000
6241
|
if (!parsedProxy.tls.enabled) delete parsedProxy.tls;
|
|
6001
6242
|
};
|
|
6002
6243
|
var sshParser = (proxy = {}) => {
|
|
@@ -6027,6 +6268,7 @@ var sshParser = (proxy = {}) => {
|
|
|
6027
6268
|
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
6028
6269
|
tfoParser(proxy, parsedProxy);
|
|
6029
6270
|
detourParser(proxy, parsedProxy);
|
|
6271
|
+
ipVersionParser(proxy, parsedProxy);
|
|
6030
6272
|
return parsedProxy;
|
|
6031
6273
|
};
|
|
6032
6274
|
var httpParser = (proxy = {}) => {
|
|
@@ -6053,6 +6295,7 @@ var httpParser = (proxy = {}) => {
|
|
|
6053
6295
|
tfoParser(proxy, parsedProxy);
|
|
6054
6296
|
detourParser(proxy, parsedProxy);
|
|
6055
6297
|
tlsParser(proxy, parsedProxy);
|
|
6298
|
+
ipVersionParser(proxy, parsedProxy);
|
|
6056
6299
|
return parsedProxy;
|
|
6057
6300
|
};
|
|
6058
6301
|
var socks5Parser = (proxy = {}) => {
|
|
@@ -6074,6 +6317,7 @@ var socks5Parser = (proxy = {}) => {
|
|
|
6074
6317
|
networkParser(proxy, parsedProxy);
|
|
6075
6318
|
tfoParser(proxy, parsedProxy);
|
|
6076
6319
|
detourParser(proxy, parsedProxy);
|
|
6320
|
+
ipVersionParser(proxy, parsedProxy);
|
|
6077
6321
|
return parsedProxy;
|
|
6078
6322
|
};
|
|
6079
6323
|
var shadowTLSParser = (proxy = {}) => {
|
|
@@ -6084,6 +6328,13 @@ var shadowTLSParser = (proxy = {}) => {
|
|
|
6084
6328
|
password: proxy.password,
|
|
6085
6329
|
detour: `${proxy.name}_shadowtls`
|
|
6086
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
|
+
}
|
|
6087
6338
|
const stPart = {
|
|
6088
6339
|
tag: `${proxy.name}_shadowtls`,
|
|
6089
6340
|
type: "shadowtls",
|
|
@@ -6106,6 +6357,7 @@ var shadowTLSParser = (proxy = {}) => {
|
|
|
6106
6357
|
tfoParser(proxy, stPart);
|
|
6107
6358
|
detourParser(proxy, stPart);
|
|
6108
6359
|
smuxParser(proxy.smux, ssPart);
|
|
6360
|
+
ipVersionParser(proxy, stPart);
|
|
6109
6361
|
return { type: "ss-with-st", ssPart, stPart };
|
|
6110
6362
|
};
|
|
6111
6363
|
var ssParser = (proxy = {}) => {
|
|
@@ -6131,6 +6383,7 @@ var ssParser = (proxy = {}) => {
|
|
|
6131
6383
|
tfoParser(proxy, parsedProxy);
|
|
6132
6384
|
detourParser(proxy, parsedProxy);
|
|
6133
6385
|
smuxParser(proxy.smux, parsedProxy);
|
|
6386
|
+
ipVersionParser(proxy, parsedProxy);
|
|
6134
6387
|
if (proxy.plugin) {
|
|
6135
6388
|
const optArr = [];
|
|
6136
6389
|
if (proxy.plugin === "obfs") {
|
|
@@ -6207,6 +6460,7 @@ var ssrParser = (proxy = {}) => {
|
|
|
6207
6460
|
tfoParser(proxy, parsedProxy);
|
|
6208
6461
|
detourParser(proxy, parsedProxy);
|
|
6209
6462
|
smuxParser(proxy.smux, parsedProxy);
|
|
6463
|
+
ipVersionParser(proxy, parsedProxy);
|
|
6210
6464
|
return parsedProxy;
|
|
6211
6465
|
};
|
|
6212
6466
|
var vmessParser = (proxy = {}) => {
|
|
@@ -6242,6 +6496,7 @@ var vmessParser = (proxy = {}) => {
|
|
|
6242
6496
|
detourParser(proxy, parsedProxy);
|
|
6243
6497
|
tlsParser(proxy, parsedProxy);
|
|
6244
6498
|
smuxParser(proxy.smux, parsedProxy);
|
|
6499
|
+
ipVersionParser(proxy, parsedProxy);
|
|
6245
6500
|
return parsedProxy;
|
|
6246
6501
|
};
|
|
6247
6502
|
var vlessParser = (proxy = {}) => {
|
|
@@ -6255,15 +6510,19 @@ var vlessParser = (proxy = {}) => {
|
|
|
6255
6510
|
};
|
|
6256
6511
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
6257
6512
|
throw "invalid port";
|
|
6513
|
+
if (proxy.xudp) parsedProxy.packet_encoding = "xudp";
|
|
6258
6514
|
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
6259
|
-
if (proxy.flow
|
|
6515
|
+
if (proxy.flow != null) parsedProxy.flow = proxy.flow;
|
|
6260
6516
|
if (proxy.network === "ws") wsParser(proxy, parsedProxy);
|
|
6517
|
+
if (proxy.network === "h2") h2Parser(proxy, parsedProxy);
|
|
6518
|
+
if (proxy.network === "http") h1Parser(proxy, parsedProxy);
|
|
6261
6519
|
if (proxy.network === "grpc") grpcParser(proxy, parsedProxy);
|
|
6262
6520
|
networkParser(proxy, parsedProxy);
|
|
6263
6521
|
tfoParser(proxy, parsedProxy);
|
|
6264
6522
|
detourParser(proxy, parsedProxy);
|
|
6265
6523
|
smuxParser(proxy.smux, parsedProxy);
|
|
6266
6524
|
tlsParser(proxy, parsedProxy);
|
|
6525
|
+
ipVersionParser(proxy, parsedProxy);
|
|
6267
6526
|
return parsedProxy;
|
|
6268
6527
|
};
|
|
6269
6528
|
var trojanParser = (proxy = {}) => {
|
|
@@ -6285,6 +6544,7 @@ var trojanParser = (proxy = {}) => {
|
|
|
6285
6544
|
detourParser(proxy, parsedProxy);
|
|
6286
6545
|
tlsParser(proxy, parsedProxy);
|
|
6287
6546
|
smuxParser(proxy.smux, parsedProxy);
|
|
6547
|
+
ipVersionParser(proxy, parsedProxy);
|
|
6288
6548
|
return parsedProxy;
|
|
6289
6549
|
};
|
|
6290
6550
|
var hysteriaParser = (proxy = {}) => {
|
|
@@ -6298,6 +6558,13 @@ var hysteriaParser = (proxy = {}) => {
|
|
|
6298
6558
|
};
|
|
6299
6559
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
6300
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
|
+
});
|
|
6301
6568
|
if (proxy.auth_str) parsedProxy.auth_str = `${proxy.auth_str}`;
|
|
6302
6569
|
if (proxy["auth-str"]) parsedProxy.auth_str = `${proxy["auth-str"]}`;
|
|
6303
6570
|
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
@@ -6332,6 +6599,7 @@ var hysteriaParser = (proxy = {}) => {
|
|
|
6332
6599
|
detourParser(proxy, parsedProxy);
|
|
6333
6600
|
tfoParser(proxy, parsedProxy);
|
|
6334
6601
|
smuxParser(proxy.smux, parsedProxy);
|
|
6602
|
+
ipVersionParser(proxy, parsedProxy);
|
|
6335
6603
|
return parsedProxy;
|
|
6336
6604
|
};
|
|
6337
6605
|
var hysteria2Parser = (proxy = {}) => {
|
|
@@ -6349,7 +6617,10 @@ var hysteria2Parser = (proxy = {}) => {
|
|
|
6349
6617
|
if (proxy["hop-interval"])
|
|
6350
6618
|
parsedProxy.hop_interval = /^\d+$/.test(proxy["hop-interval"]) ? `${proxy["hop-interval"]}s` : proxy["hop-interval"];
|
|
6351
6619
|
if (proxy["ports"])
|
|
6352
|
-
parsedProxy.server_ports = proxy["ports"].split(/\s*,\s*/).map((p) =>
|
|
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
|
+
});
|
|
6353
6624
|
if (proxy.up) parsedProxy.up_mbps = parseInt(`${proxy.up}`, 10);
|
|
6354
6625
|
if (proxy.down) parsedProxy.down_mbps = parseInt(`${proxy.down}`, 10);
|
|
6355
6626
|
if (proxy.obfs === "salamander") parsedProxy.obfs.type = "salamander";
|
|
@@ -6361,6 +6632,7 @@ var hysteria2Parser = (proxy = {}) => {
|
|
|
6361
6632
|
tfoParser(proxy, parsedProxy);
|
|
6362
6633
|
detourParser(proxy, parsedProxy);
|
|
6363
6634
|
smuxParser(proxy.smux, parsedProxy);
|
|
6635
|
+
ipVersionParser(proxy, parsedProxy);
|
|
6364
6636
|
return parsedProxy;
|
|
6365
6637
|
};
|
|
6366
6638
|
var tuic5Parser = (proxy = {}) => {
|
|
@@ -6389,6 +6661,7 @@ var tuic5Parser = (proxy = {}) => {
|
|
|
6389
6661
|
detourParser(proxy, parsedProxy);
|
|
6390
6662
|
tlsParser(proxy, parsedProxy);
|
|
6391
6663
|
smuxParser(proxy.smux, parsedProxy);
|
|
6664
|
+
ipVersionParser(proxy, parsedProxy);
|
|
6392
6665
|
return parsedProxy;
|
|
6393
6666
|
};
|
|
6394
6667
|
var anytlsParser = (proxy = {}) => {
|
|
@@ -6404,8 +6677,15 @@ var anytlsParser = (proxy = {}) => {
|
|
|
6404
6677
|
parsedProxy.idle_session_check_interval = `${proxy["idle-session-check-interval"]}s`;
|
|
6405
6678
|
if (/^\d+$/.test(proxy["idle-session-timeout"]))
|
|
6406
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);
|
|
6407
6686
|
detourParser(proxy, parsedProxy);
|
|
6408
6687
|
tlsParser(proxy, parsedProxy);
|
|
6688
|
+
ipVersionParser(proxy, parsedProxy);
|
|
6409
6689
|
return parsedProxy;
|
|
6410
6690
|
};
|
|
6411
6691
|
var wireguardParser = (proxy = {}) => {
|
|
@@ -6459,6 +6739,7 @@ var wireguardParser = (proxy = {}) => {
|
|
|
6459
6739
|
tfoParser(proxy, parsedProxy);
|
|
6460
6740
|
detourParser(proxy, parsedProxy);
|
|
6461
6741
|
smuxParser(proxy.smux, parsedProxy);
|
|
6742
|
+
ipVersionParser(proxy, parsedProxy);
|
|
6462
6743
|
return parsedProxy;
|
|
6463
6744
|
};
|
|
6464
6745
|
function singbox_Producer() {
|
|
@@ -6573,7 +6854,7 @@ function singbox_Producer() {
|
|
|
6573
6854
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/egern.js
|
|
6574
6855
|
function Egern_Producer() {
|
|
6575
6856
|
const type = "ALL";
|
|
6576
|
-
const produce2 = (proxies, type2) => {
|
|
6857
|
+
const produce2 = (proxies, type2, opts = {}) => {
|
|
6577
6858
|
const list = proxies.filter((proxy) => {
|
|
6578
6859
|
if (![
|
|
6579
6860
|
"http",
|
|
@@ -6615,12 +6896,13 @@ function Egern_Producer() {
|
|
|
6615
6896
|
"chacha20-ietf",
|
|
6616
6897
|
"2022-blake3-aes-128-gcm",
|
|
6617
6898
|
"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) {
|
|
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) {
|
|
6619
6900
|
return false;
|
|
6620
6901
|
}
|
|
6621
6902
|
return true;
|
|
6622
6903
|
}).map((proxy) => {
|
|
6623
6904
|
const original = { ...proxy };
|
|
6905
|
+
let flow;
|
|
6624
6906
|
if (proxy.tls && !proxy.sni) {
|
|
6625
6907
|
proxy.sni = proxy.server;
|
|
6626
6908
|
}
|
|
@@ -6775,6 +7057,12 @@ function Egern_Producer() {
|
|
|
6775
7057
|
}
|
|
6776
7058
|
};
|
|
6777
7059
|
}
|
|
7060
|
+
let legacy;
|
|
7061
|
+
if (isPresent2(proxy, "aead") && !proxy.aead) {
|
|
7062
|
+
legacy = true;
|
|
7063
|
+
} else if (proxy.alterId !== 0) {
|
|
7064
|
+
legacy = true;
|
|
7065
|
+
}
|
|
6778
7066
|
proxy = {
|
|
6779
7067
|
type: "vmess",
|
|
6780
7068
|
name: proxy.name,
|
|
@@ -6783,7 +7071,7 @@ function Egern_Producer() {
|
|
|
6783
7071
|
user_id: proxy.uuid,
|
|
6784
7072
|
security,
|
|
6785
7073
|
tfo: proxy.tfo || proxy["fast-open"],
|
|
6786
|
-
legacy
|
|
7074
|
+
legacy,
|
|
6787
7075
|
udp_relay: proxy.udp || proxy.udp_relay || proxy.udp_relay,
|
|
6788
7076
|
next_hop: proxy.next_hop,
|
|
6789
7077
|
transport: proxy.transport
|
|
@@ -6816,12 +7104,21 @@ function Egern_Producer() {
|
|
|
6816
7104
|
}
|
|
6817
7105
|
};
|
|
6818
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
|
+
}
|
|
6819
7114
|
proxy.transport = {
|
|
6820
7115
|
[proxy.tls ? "tls" : "tcp"]: {
|
|
6821
7116
|
sni: proxy.tls ? proxy.sni : void 0,
|
|
6822
|
-
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
|
|
6823
7119
|
}
|
|
6824
7120
|
};
|
|
7121
|
+
flow = proxy.flow;
|
|
6825
7122
|
}
|
|
6826
7123
|
proxy = {
|
|
6827
7124
|
type: "vless",
|
|
@@ -6831,10 +7128,10 @@ function Egern_Producer() {
|
|
|
6831
7128
|
user_id: proxy.uuid,
|
|
6832
7129
|
security: proxy.cipher,
|
|
6833
7130
|
tfo: proxy.tfo || proxy["fast-open"],
|
|
6834
|
-
legacy: proxy.legacy,
|
|
6835
7131
|
udp_relay: proxy.udp || proxy.udp_relay || proxy.udp_relay,
|
|
6836
7132
|
next_hop: proxy.next_hop,
|
|
6837
|
-
transport: proxy.transport
|
|
7133
|
+
transport: proxy.transport,
|
|
7134
|
+
flow
|
|
6838
7135
|
// sni: proxy.sni,
|
|
6839
7136
|
// skip_tls_verify: proxy['skip-cert-verify'],
|
|
6840
7137
|
};
|
|
@@ -6867,11 +7164,26 @@ function Egern_Producer() {
|
|
|
6867
7164
|
};
|
|
6868
7165
|
}
|
|
6869
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
|
+
}
|
|
6870
7170
|
delete proxy.subName;
|
|
6871
7171
|
delete proxy.collectionName;
|
|
6872
7172
|
delete proxy.id;
|
|
6873
7173
|
delete proxy.resolved;
|
|
6874
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
|
+
}
|
|
6875
7187
|
if (type2 !== "internal") {
|
|
6876
7188
|
for (const key in proxy) {
|
|
6877
7189
|
if (proxy[key] == null || /^_/i.test(key)) {
|