sub-store-convert 2.20.32 → 2.21.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +583 -86
- package/package.json +3 -8
package/index.js
CHANGED
|
@@ -34,6 +34,9 @@ function getRandomPort(portString) {
|
|
|
34
34
|
return Number(randomPart);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
+
function isPlainObject(obj) {
|
|
38
|
+
return obj !== null && typeof obj === "object" && [null, Object.prototype].includes(Object.getPrototypeOf(obj));
|
|
39
|
+
}
|
|
37
40
|
|
|
38
41
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/parsers/peggy/surge.js
|
|
39
42
|
import * as peggy from "peggy";
|
|
@@ -75,7 +78,7 @@ var grammars = String.raw`
|
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
80
|
|
|
78
|
-
start = (shadowsocks/vmess/trojan/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2/ssh/direct) {
|
|
81
|
+
start = (anytls/shadowsocks/vmess/trojan/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2/ssh/direct) {
|
|
79
82
|
return proxy;
|
|
80
83
|
}
|
|
81
84
|
|
|
@@ -143,7 +146,7 @@ wireguard = tag equals "wireguard" (section_name/no_error_alert/ip_version/under
|
|
|
143
146
|
proxy.type = "wireguard-surge";
|
|
144
147
|
handleShadowTLS();
|
|
145
148
|
}
|
|
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)* {
|
|
149
|
+
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/salamander_password/others)* {
|
|
147
150
|
proxy.type = "hysteria2";
|
|
148
151
|
handleShadowTLS();
|
|
149
152
|
}
|
|
@@ -156,6 +159,10 @@ socks5_tls = tag equals "socks5-tls" address (username password)? (usernamek pas
|
|
|
156
159
|
proxy.tls = true;
|
|
157
160
|
handleShadowTLS();
|
|
158
161
|
}
|
|
162
|
+
anytls = tag equals "anytls" address (passwordk/reuse/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/sni/fast_open/tfo/block_quic/others)* {
|
|
163
|
+
proxy.type = "anytls";
|
|
164
|
+
proxy.tls = true;
|
|
165
|
+
}
|
|
159
166
|
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
167
|
proxy.type = "direct";
|
|
161
168
|
}
|
|
@@ -288,6 +295,7 @@ shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { proxy["sh
|
|
|
288
295
|
token = comma "token" equals match:[^,]+ { proxy.token = match.join(""); }
|
|
289
296
|
alpn = comma "alpn" equals match:[^,]+ { proxy.alpn = match.join(""); }
|
|
290
297
|
uuidk = comma "uuid" equals match:[^,]+ { proxy.uuid = match.join(""); }
|
|
298
|
+
salamander_password = comma "salamander-password" equals match:[^,]+ { proxy['obfs-password'] = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); proxy.obfs = 'salamander'; }
|
|
291
299
|
|
|
292
300
|
tag = match:[^=,]* { proxy.name = match.join("").trim(); }
|
|
293
301
|
comma = _ "," _
|
|
@@ -563,13 +571,13 @@ start = (trojan/shadowsocks/vmess/vless/http/socks5) {
|
|
|
563
571
|
}
|
|
564
572
|
|
|
565
573
|
trojan = "trojan" equals address
|
|
566
|
-
(password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/obfs/obfs_host/obfs_uri/tag/udp_relay/udp_over_tcp/fast_open/server_check_url/others)* {
|
|
574
|
+
(password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/obfs/obfs_host/obfs_uri/tag/udp_relay/udp_over_tcp/fast_open/server_check_url/reality_base64_pubkey/reality_hex_shortid/others)* {
|
|
567
575
|
proxy.type = "trojan";
|
|
568
576
|
handleObfs();
|
|
569
577
|
}
|
|
570
578
|
|
|
571
579
|
shadowsocks = "shadowsocks" equals address
|
|
572
|
-
(password/method/obfs_ssr/obfs_ss/obfs_host/obfs_uri/ssr_protocol/ssr_protocol_param/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/udp_relay/udp_over_tcp_new/fast_open/tag/server_check_url/others)* {
|
|
580
|
+
(password/method/obfs_ssr/obfs_ss/obfs_host/obfs_uri/ssr_protocol/ssr_protocol_param/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/udp_relay/udp_over_tcp_new/fast_open/tag/server_check_url/reality_base64_pubkey/reality_hex_shortid/others)* {
|
|
573
581
|
if (proxy.protocol || proxy.type === "ssr") {
|
|
574
582
|
proxy.type = "ssr";
|
|
575
583
|
if (!proxy.protocol) {
|
|
@@ -603,7 +611,7 @@ shadowsocks = "shadowsocks" equals address
|
|
|
603
611
|
}
|
|
604
612
|
|
|
605
613
|
vmess = "vmess" equals address
|
|
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)* {
|
|
614
|
+
(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/reality_base64_pubkey/reality_hex_shortid/others)* {
|
|
607
615
|
proxy.type = "vmess";
|
|
608
616
|
proxy.cipher = proxy.cipher || "none";
|
|
609
617
|
if (proxy.aead === false) {
|
|
@@ -615,19 +623,19 @@ vmess = "vmess" equals address
|
|
|
615
623
|
}
|
|
616
624
|
|
|
617
625
|
vless = "vless" equals address
|
|
618
|
-
(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)* {
|
|
626
|
+
(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/reality_base64_pubkey/reality_hex_shortid/vless_flow/others)* {
|
|
619
627
|
proxy.type = "vless";
|
|
620
628
|
proxy.cipher = proxy.cipher || "none";
|
|
621
629
|
handleObfs();
|
|
622
630
|
}
|
|
623
631
|
|
|
624
632
|
http = "http" equals address
|
|
625
|
-
(username/password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/fast_open/udp_relay/udp_over_tcp/server_check_url/others)*{
|
|
633
|
+
(username/password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/fast_open/udp_relay/udp_over_tcp/server_check_url/reality_base64_pubkey/reality_hex_shortid/others)*{
|
|
626
634
|
proxy.type = "http";
|
|
627
635
|
}
|
|
628
636
|
|
|
629
637
|
socks5 = "socks5" equals address
|
|
630
|
-
(username/password/password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/fast_open/udp_relay/udp_over_tcp/server_check_url/others)* {
|
|
638
|
+
(username/password/password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/fast_open/udp_relay/udp_over_tcp/server_check_url/reality_base64_pubkey/reality_hex_shortid/others)* {
|
|
631
639
|
proxy.type = "socks5";
|
|
632
640
|
}
|
|
633
641
|
|
|
@@ -706,6 +714,14 @@ obfs_uri = comma "obfs-uri" equals uri:uri { obfs.path = uri; }
|
|
|
706
714
|
ssr_protocol = comma "ssr-protocol" equals protocol:("origin"/"auth_sha1_v4"/"auth_aes128_md5"/"auth_aes128_sha1"/"auth_chain_a"/"auth_chain_b") { proxy.protocol = protocol; return protocol; }
|
|
707
715
|
ssr_protocol_param = comma "ssr-protocol-param" equals param:$[^=,]+ { proxy["protocol-param"] = param; }
|
|
708
716
|
|
|
717
|
+
reality_base64_pubkey = comma "reality-base64-pubkey" equals param:$[^=,]+ {
|
|
718
|
+
$set(proxy, "reality-opts.public-key", param);
|
|
719
|
+
}
|
|
720
|
+
reality_hex_shortid = comma "reality-hex-shortid" equals param:$[^=,]+ {
|
|
721
|
+
$set(proxy, "reality-opts.short-id", param);
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
vless_flow = comma "vless-flow" equals param:$[^=,]+ { proxy["flow"] = param; }
|
|
709
725
|
server_check_url = comma "server_check_url" equals param:$[^=,]+ { proxy["test-url"] = param; }
|
|
710
726
|
|
|
711
727
|
uri = $[^,]+
|
|
@@ -949,6 +965,7 @@ var yaml_default = {
|
|
|
949
965
|
};
|
|
950
966
|
|
|
951
967
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/parsers/index.js
|
|
968
|
+
import _ from "lodash";
|
|
952
969
|
import { Base64 } from "js-base64";
|
|
953
970
|
function surge_port_hopping(raw) {
|
|
954
971
|
const [parts, port_hopping] = raw.match(
|
|
@@ -1074,6 +1091,88 @@ function URI_SS() {
|
|
|
1074
1091
|
const parsed = content.match(/(\?.*)$/);
|
|
1075
1092
|
query = parsed[1];
|
|
1076
1093
|
}
|
|
1094
|
+
const params = {};
|
|
1095
|
+
for (const addon of query.replace(/^\?/, "").split("&")) {
|
|
1096
|
+
if (addon) {
|
|
1097
|
+
const [key, valueRaw] = addon.split("=");
|
|
1098
|
+
let value = valueRaw;
|
|
1099
|
+
value = decodeURIComponent(valueRaw);
|
|
1100
|
+
params[key] = value;
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
proxy.tls = params.security && params.security !== "none";
|
|
1104
|
+
proxy["skip-cert-verify"] = !!params["allowInsecure"];
|
|
1105
|
+
proxy.sni = params["sni"] || params["peer"];
|
|
1106
|
+
proxy["client-fingerprint"] = params.fp;
|
|
1107
|
+
proxy.alpn = params.alpn ? decodeURIComponent(params.alpn).split(",") : void 0;
|
|
1108
|
+
if (params["ws"]) {
|
|
1109
|
+
proxy.network = "ws";
|
|
1110
|
+
_.set(proxy, "ws-opts.path", params["wspath"]);
|
|
1111
|
+
}
|
|
1112
|
+
if (params["type"]) {
|
|
1113
|
+
let httpupgrade;
|
|
1114
|
+
proxy.network = params["type"];
|
|
1115
|
+
if (proxy.network === "httpupgrade") {
|
|
1116
|
+
proxy.network = "ws";
|
|
1117
|
+
httpupgrade = true;
|
|
1118
|
+
}
|
|
1119
|
+
if (["grpc"].includes(proxy.network)) {
|
|
1120
|
+
proxy[proxy.network + "-opts"] = {
|
|
1121
|
+
"grpc-service-name": params["serviceName"],
|
|
1122
|
+
"_grpc-type": params["mode"],
|
|
1123
|
+
"_grpc-authority": params["authority"]
|
|
1124
|
+
};
|
|
1125
|
+
} else {
|
|
1126
|
+
if (params["path"]) {
|
|
1127
|
+
_.set(
|
|
1128
|
+
proxy,
|
|
1129
|
+
proxy.network + "-opts.path",
|
|
1130
|
+
decodeURIComponent(params["path"])
|
|
1131
|
+
);
|
|
1132
|
+
}
|
|
1133
|
+
if (params["host"]) {
|
|
1134
|
+
_.set(
|
|
1135
|
+
proxy,
|
|
1136
|
+
proxy.network + "-opts.headers.Host",
|
|
1137
|
+
decodeURIComponent(params["host"])
|
|
1138
|
+
);
|
|
1139
|
+
}
|
|
1140
|
+
if (httpupgrade) {
|
|
1141
|
+
_.set(
|
|
1142
|
+
proxy,
|
|
1143
|
+
proxy.network + "-opts.v2ray-http-upgrade",
|
|
1144
|
+
true
|
|
1145
|
+
);
|
|
1146
|
+
_.set(
|
|
1147
|
+
proxy,
|
|
1148
|
+
proxy.network + "-opts.v2ray-http-upgrade-fast-open",
|
|
1149
|
+
true
|
|
1150
|
+
);
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
if (["reality"].includes(params.security)) {
|
|
1154
|
+
const opts = {};
|
|
1155
|
+
if (params.pbk) {
|
|
1156
|
+
opts["public-key"] = params.pbk;
|
|
1157
|
+
}
|
|
1158
|
+
if (params.sid) {
|
|
1159
|
+
opts["short-id"] = params.sid;
|
|
1160
|
+
}
|
|
1161
|
+
if (params.spx) {
|
|
1162
|
+
opts["_spider-x"] = params.spx;
|
|
1163
|
+
}
|
|
1164
|
+
if (params.mode) {
|
|
1165
|
+
proxy._mode = params.mode;
|
|
1166
|
+
}
|
|
1167
|
+
if (params.extra) {
|
|
1168
|
+
proxy._extra = params.extra;
|
|
1169
|
+
}
|
|
1170
|
+
if (Object.keys(opts).length > 0) {
|
|
1171
|
+
_.set(proxy, params.security + "-opts", opts);
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
proxy.udp = !!params["udp"];
|
|
1077
1176
|
const serverAndPort = serverAndPortArray[1];
|
|
1078
1177
|
const portIdx = serverAndPort.lastIndexOf(":");
|
|
1079
1178
|
proxy.server = serverAndPort.substring(0, portIdx);
|
|
@@ -1087,54 +1186,54 @@ function URI_SS() {
|
|
|
1087
1186
|
const shadowTlsMatch = content.match(/[?&]shadow-tls=([^&]+)/);
|
|
1088
1187
|
if (pluginMatch) {
|
|
1089
1188
|
const pluginInfo = ("plugin=" + decodeURIComponent(pluginMatch[1])).split(";");
|
|
1090
|
-
const
|
|
1189
|
+
const params2 = {};
|
|
1091
1190
|
for (const item of pluginInfo) {
|
|
1092
1191
|
const [key, val] = item.split("=");
|
|
1093
|
-
if (key)
|
|
1192
|
+
if (key) params2[key] = val || true;
|
|
1094
1193
|
}
|
|
1095
|
-
switch (
|
|
1194
|
+
switch (params2.plugin) {
|
|
1096
1195
|
case "obfs-local":
|
|
1097
1196
|
case "simple-obfs":
|
|
1098
1197
|
proxy.plugin = "obfs";
|
|
1099
1198
|
proxy["plugin-opts"] = {
|
|
1100
|
-
mode:
|
|
1101
|
-
host: getIfNotBlank(
|
|
1199
|
+
mode: params2.obfs,
|
|
1200
|
+
host: getIfNotBlank(params2["obfs-host"])
|
|
1102
1201
|
};
|
|
1103
1202
|
break;
|
|
1104
1203
|
case "v2ray-plugin":
|
|
1105
1204
|
proxy.plugin = "v2ray-plugin";
|
|
1106
1205
|
proxy["plugin-opts"] = {
|
|
1107
1206
|
mode: "websocket",
|
|
1108
|
-
host: getIfNotBlank(
|
|
1109
|
-
path: getIfNotBlank(
|
|
1110
|
-
tls: getIfPresent(
|
|
1207
|
+
host: getIfNotBlank(params2["obfs-host"]),
|
|
1208
|
+
path: getIfNotBlank(params2.path),
|
|
1209
|
+
tls: getIfPresent(params2.tls)
|
|
1111
1210
|
};
|
|
1112
1211
|
break;
|
|
1113
1212
|
case "shadow-tls": {
|
|
1114
1213
|
proxy.plugin = "shadow-tls";
|
|
1115
|
-
const version = getIfNotBlank(
|
|
1214
|
+
const version = getIfNotBlank(params2["version"]);
|
|
1116
1215
|
proxy["plugin-opts"] = {
|
|
1117
|
-
host: getIfNotBlank(
|
|
1118
|
-
password: getIfNotBlank(
|
|
1216
|
+
host: getIfNotBlank(params2["host"]),
|
|
1217
|
+
password: getIfNotBlank(params2["password"]),
|
|
1119
1218
|
version: version ? parseInt(version, 10) : void 0
|
|
1120
1219
|
};
|
|
1121
1220
|
break;
|
|
1122
1221
|
}
|
|
1123
1222
|
default:
|
|
1124
1223
|
throw new Error(
|
|
1125
|
-
`Unsupported plugin option: ${
|
|
1224
|
+
`Unsupported plugin option: ${params2.plugin}`
|
|
1126
1225
|
);
|
|
1127
1226
|
}
|
|
1128
1227
|
}
|
|
1129
1228
|
if (shadowTlsMatch) {
|
|
1130
|
-
const
|
|
1131
|
-
const version = getIfNotBlank(
|
|
1132
|
-
const address = getIfNotBlank(
|
|
1133
|
-
const port = getIfNotBlank(
|
|
1229
|
+
const params2 = JSON.parse(Base64.decode(shadowTlsMatch[1]));
|
|
1230
|
+
const version = getIfNotBlank(params2["version"]);
|
|
1231
|
+
const address = getIfNotBlank(params2["address"]);
|
|
1232
|
+
const port = getIfNotBlank(params2["port"]);
|
|
1134
1233
|
proxy.plugin = "shadow-tls";
|
|
1135
1234
|
proxy["plugin-opts"] = {
|
|
1136
|
-
host: getIfNotBlank(
|
|
1137
|
-
password: getIfNotBlank(
|
|
1235
|
+
host: getIfNotBlank(params2["host"]),
|
|
1236
|
+
password: getIfNotBlank(params2["password"]),
|
|
1138
1237
|
version: version ? parseInt(version, 10) : void 0
|
|
1139
1238
|
};
|
|
1140
1239
|
if (address) {
|
|
@@ -1278,9 +1377,9 @@ function URI_VMess() {
|
|
|
1278
1377
|
params[key] = value.split(",");
|
|
1279
1378
|
}
|
|
1280
1379
|
}
|
|
1281
|
-
let [___, cipher,
|
|
1380
|
+
let [___, cipher, uuid, server2, port2] = /(^[^:]+?):([^:]+?)@(.*):(\d+)$/.exec(content);
|
|
1282
1381
|
params.scy = cipher;
|
|
1283
|
-
params.id =
|
|
1382
|
+
params.id = uuid;
|
|
1284
1383
|
params.port = port2;
|
|
1285
1384
|
params.add = server2;
|
|
1286
1385
|
}
|
|
@@ -1406,17 +1505,17 @@ function URI_VLESS() {
|
|
|
1406
1505
|
let isShadowrocket;
|
|
1407
1506
|
let parsed = /^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
1408
1507
|
if (!parsed) {
|
|
1409
|
-
let [
|
|
1508
|
+
let [_3, base64, other] = /^(.*?)(\?.*?$)/.exec(line);
|
|
1410
1509
|
line = `${Base64.decode(base64)}${other}`;
|
|
1411
1510
|
parsed = /^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
1412
1511
|
isShadowrocket = true;
|
|
1413
1512
|
}
|
|
1414
|
-
let [__,
|
|
1513
|
+
let [__, uuid, server, port, ___, addons = "", name2] = parsed;
|
|
1415
1514
|
if (isShadowrocket) {
|
|
1416
|
-
|
|
1515
|
+
uuid = uuid.replace(/^.*?:/g, "");
|
|
1417
1516
|
}
|
|
1418
1517
|
port = parseInt(`${port}`, 10);
|
|
1419
|
-
|
|
1518
|
+
uuid = decodeURIComponent(uuid);
|
|
1420
1519
|
if (name2 != null) {
|
|
1421
1520
|
name2 = decodeURIComponent(name2);
|
|
1422
1521
|
}
|
|
@@ -1425,7 +1524,7 @@ function URI_VLESS() {
|
|
|
1425
1524
|
name: name2,
|
|
1426
1525
|
server,
|
|
1427
1526
|
port,
|
|
1428
|
-
uuid
|
|
1527
|
+
uuid
|
|
1429
1528
|
};
|
|
1430
1529
|
const params = {};
|
|
1431
1530
|
for (const addon of addons.split("&")) {
|
|
@@ -1453,6 +1552,9 @@ function URI_VLESS() {
|
|
|
1453
1552
|
proxy["client-fingerprint"] = params.fp;
|
|
1454
1553
|
proxy.alpn = params.alpn ? params.alpn.split(",") : void 0;
|
|
1455
1554
|
proxy["skip-cert-verify"] = /(TRUE)|1/i.test(params.allowInsecure);
|
|
1555
|
+
proxy._echConfigList = getIfPresent(params.ech);
|
|
1556
|
+
proxy._pcs = getIfPresent(params.pcs);
|
|
1557
|
+
proxy._h2 = /(TRUE)|1/i.test(params.h2);
|
|
1456
1558
|
if (["reality"].includes(params.security)) {
|
|
1457
1559
|
const opts = {};
|
|
1458
1560
|
if (params.pbk) {
|
|
@@ -1755,7 +1857,7 @@ function URI_TUIC() {
|
|
|
1755
1857
|
line = line.split(/tuic:\/\//)[1];
|
|
1756
1858
|
let [__, auth, server, port, addons = "", name2] = /^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
1757
1859
|
auth = decodeURIComponent(auth);
|
|
1758
|
-
let [
|
|
1860
|
+
let [uuid, ...passwordParts] = auth.split(":");
|
|
1759
1861
|
let password = passwordParts.join(":");
|
|
1760
1862
|
port = parseInt(`${port}`, 10);
|
|
1761
1863
|
if (isNaN(port)) {
|
|
@@ -1772,7 +1874,7 @@ function URI_TUIC() {
|
|
|
1772
1874
|
server,
|
|
1773
1875
|
port,
|
|
1774
1876
|
password,
|
|
1775
|
-
uuid
|
|
1877
|
+
uuid
|
|
1776
1878
|
};
|
|
1777
1879
|
for (const addon of addons.split("&")) {
|
|
1778
1880
|
if (addon) {
|
|
@@ -1917,8 +2019,10 @@ function Clash_All() {
|
|
|
1917
2019
|
proxy = yaml_default.parse(line);
|
|
1918
2020
|
}
|
|
1919
2021
|
if (![
|
|
2022
|
+
"naive",
|
|
1920
2023
|
"anytls",
|
|
1921
2024
|
"mieru",
|
|
2025
|
+
"sudoku",
|
|
1922
2026
|
"juicity",
|
|
1923
2027
|
"ss",
|
|
1924
2028
|
"ssr",
|
|
@@ -2193,6 +2297,14 @@ function Surge_Direct() {
|
|
|
2193
2297
|
const parse = (line) => getParser().parse(line);
|
|
2194
2298
|
return { name, test, parse };
|
|
2195
2299
|
}
|
|
2300
|
+
function Surge_Anytls() {
|
|
2301
|
+
const name = "Surge Anytls Parser";
|
|
2302
|
+
const test = (line) => {
|
|
2303
|
+
return /^.*=\s*anytls/.test(line.split(",")[0]);
|
|
2304
|
+
};
|
|
2305
|
+
const parse = (line) => getParser().parse(line);
|
|
2306
|
+
return { name, test, parse };
|
|
2307
|
+
}
|
|
2196
2308
|
function Surge_SSH() {
|
|
2197
2309
|
const name = "Surge SSH Parser";
|
|
2198
2310
|
const test = (line) => {
|
|
@@ -2248,7 +2360,7 @@ function Surge_External() {
|
|
|
2248
2360
|
};
|
|
2249
2361
|
const parse = (line) => {
|
|
2250
2362
|
let parsed = /^\s*(.*?)\s*?=\s*?external\s*?,\s*(.*?)\s*$/.exec(line);
|
|
2251
|
-
let [
|
|
2363
|
+
let [_3, name2, other] = parsed;
|
|
2252
2364
|
line = other;
|
|
2253
2365
|
let exec = /(,|^)\s*?exec\s*?=\s*"(.*?)"\s*?(,|$)/.exec(line)?.[2];
|
|
2254
2366
|
if (!exec) {
|
|
@@ -2361,6 +2473,7 @@ var parsers_default = [
|
|
|
2361
2473
|
URI_AnyTLS(),
|
|
2362
2474
|
Clash_All(),
|
|
2363
2475
|
Surge_Direct(),
|
|
2476
|
+
Surge_Anytls(),
|
|
2364
2477
|
Surge_SSH(),
|
|
2365
2478
|
Surge_SS(),
|
|
2366
2479
|
Surge_VMess(),
|
|
@@ -2391,7 +2504,7 @@ var parsers_default = [
|
|
|
2391
2504
|
];
|
|
2392
2505
|
|
|
2393
2506
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/utils.js
|
|
2394
|
-
import
|
|
2507
|
+
import _2 from "lodash";
|
|
2395
2508
|
var Result = class {
|
|
2396
2509
|
constructor(proxy) {
|
|
2397
2510
|
this.proxy = proxy;
|
|
@@ -2413,7 +2526,7 @@ var Result = class {
|
|
|
2413
2526
|
}
|
|
2414
2527
|
};
|
|
2415
2528
|
function isPresent2(obj, attr) {
|
|
2416
|
-
const data =
|
|
2529
|
+
const data = _2.get(obj, attr);
|
|
2417
2530
|
return typeof data !== "undefined" && data !== null;
|
|
2418
2531
|
}
|
|
2419
2532
|
|
|
@@ -2428,13 +2541,18 @@ var ipVersions = {
|
|
|
2428
2541
|
};
|
|
2429
2542
|
function Surge_Producer() {
|
|
2430
2543
|
const produce2 = (proxy, type, opts = {}) => {
|
|
2544
|
+
if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
2545
|
+
throw new Error(
|
|
2546
|
+
`Platform ${targetPlatform} does not support network ${proxy.network} with http upgrade`
|
|
2547
|
+
);
|
|
2548
|
+
}
|
|
2431
2549
|
proxy.name = proxy.name.replace(/=|,/g, "");
|
|
2432
2550
|
if (proxy.ports) {
|
|
2433
2551
|
proxy.ports = String(proxy.ports);
|
|
2434
2552
|
}
|
|
2435
2553
|
switch (proxy.type) {
|
|
2436
2554
|
case "ss":
|
|
2437
|
-
return shadowsocks(proxy
|
|
2555
|
+
return shadowsocks(proxy);
|
|
2438
2556
|
case "trojan":
|
|
2439
2557
|
return trojan(proxy);
|
|
2440
2558
|
case "vmess":
|
|
@@ -2452,13 +2570,21 @@ function Surge_Producer() {
|
|
|
2452
2570
|
case "wireguard-surge":
|
|
2453
2571
|
return wireguard_surge(proxy);
|
|
2454
2572
|
case "hysteria2":
|
|
2455
|
-
return hysteria2(proxy);
|
|
2573
|
+
return hysteria2(proxy, opts["include-unsupported-proxy"]);
|
|
2456
2574
|
case "ssh":
|
|
2457
2575
|
return ssh(proxy);
|
|
2458
2576
|
}
|
|
2459
2577
|
if (opts["include-unsupported-proxy"] && proxy.type === "wireguard") {
|
|
2460
2578
|
return wireguard(proxy);
|
|
2461
2579
|
}
|
|
2580
|
+
if (opts["include-unsupported-proxy"] && proxy.type === "anytls") {
|
|
2581
|
+
if (proxy.network && (!["tcp"].includes(proxy.network) || ["tcp"].includes(proxy.network) && proxy["reality-opts"])) {
|
|
2582
|
+
throw new Error(
|
|
2583
|
+
`Platform ${targetPlatform} does not support proxy type ${proxy.type} with network or reality`
|
|
2584
|
+
);
|
|
2585
|
+
}
|
|
2586
|
+
return anytls(proxy);
|
|
2587
|
+
}
|
|
2462
2588
|
throw new Error(
|
|
2463
2589
|
`Platform ${targetPlatform} does not support proxy type: ${proxy.type}`
|
|
2464
2590
|
);
|
|
@@ -2544,6 +2670,7 @@ function shadowsocks(proxy) {
|
|
|
2544
2670
|
`,interface=${proxy["interface-name"]}`,
|
|
2545
2671
|
"interface-name"
|
|
2546
2672
|
);
|
|
2673
|
+
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
2547
2674
|
if (isPresent2(proxy, "shadow-tls-password")) {
|
|
2548
2675
|
result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
|
|
2549
2676
|
result.appendIfPresent(
|
|
@@ -2624,6 +2751,7 @@ function trojan(proxy) {
|
|
|
2624
2751
|
`,interface=${proxy["interface-name"]}`,
|
|
2625
2752
|
"interface-name"
|
|
2626
2753
|
);
|
|
2754
|
+
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
2627
2755
|
if (isPresent2(proxy, "shadow-tls-password")) {
|
|
2628
2756
|
result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
|
|
2629
2757
|
result.appendIfPresent(
|
|
@@ -2642,6 +2770,52 @@ function trojan(proxy) {
|
|
|
2642
2770
|
);
|
|
2643
2771
|
return result.toString();
|
|
2644
2772
|
}
|
|
2773
|
+
function anytls(proxy) {
|
|
2774
|
+
const result = new Result(proxy);
|
|
2775
|
+
result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`);
|
|
2776
|
+
result.appendIfPresent(`,password="${proxy.password}"`, "password");
|
|
2777
|
+
const ip_version = ipVersions[proxy["ip-version"]] || proxy["ip-version"];
|
|
2778
|
+
result.appendIfPresent(`,ip-version=${ip_version}`, "ip-version");
|
|
2779
|
+
result.appendIfPresent(
|
|
2780
|
+
`,no-error-alert=${proxy["no-error-alert"]}`,
|
|
2781
|
+
"no-error-alert"
|
|
2782
|
+
);
|
|
2783
|
+
result.appendIfPresent(
|
|
2784
|
+
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
2785
|
+
"tls-fingerprint"
|
|
2786
|
+
);
|
|
2787
|
+
result.appendIfPresent(`,sni=${proxy.sni}`, "sni");
|
|
2788
|
+
result.appendIfPresent(
|
|
2789
|
+
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
2790
|
+
"skip-cert-verify"
|
|
2791
|
+
);
|
|
2792
|
+
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
2793
|
+
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
2794
|
+
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
2795
|
+
result.appendIfPresent(
|
|
2796
|
+
`,test-timeout=${proxy["test-timeout"]}`,
|
|
2797
|
+
"test-timeout"
|
|
2798
|
+
);
|
|
2799
|
+
result.appendIfPresent(`,test-udp=${proxy["test-udp"]}`, "test-udp");
|
|
2800
|
+
result.appendIfPresent(`,hybrid=${proxy["hybrid"]}`, "hybrid");
|
|
2801
|
+
result.appendIfPresent(`,tos=${proxy["tos"]}`, "tos");
|
|
2802
|
+
result.appendIfPresent(
|
|
2803
|
+
`,allow-other-interface=${proxy["allow-other-interface"]}`,
|
|
2804
|
+
"allow-other-interface"
|
|
2805
|
+
);
|
|
2806
|
+
result.appendIfPresent(
|
|
2807
|
+
`,interface=${proxy["interface-name"]}`,
|
|
2808
|
+
"interface-name"
|
|
2809
|
+
);
|
|
2810
|
+
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
2811
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
2812
|
+
result.appendIfPresent(
|
|
2813
|
+
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
2814
|
+
"underlying-proxy"
|
|
2815
|
+
);
|
|
2816
|
+
result.appendIfPresent(`,reuse=${proxy["reuse"]}`, "reuse");
|
|
2817
|
+
return result.toString();
|
|
2818
|
+
}
|
|
2645
2819
|
function vmess(proxy, includeUnsupportedProxy) {
|
|
2646
2820
|
const result = new Result(proxy);
|
|
2647
2821
|
result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`);
|
|
@@ -2686,6 +2860,7 @@ function vmess(proxy, includeUnsupportedProxy) {
|
|
|
2686
2860
|
`,interface=${proxy["interface-name"]}`,
|
|
2687
2861
|
"interface-name"
|
|
2688
2862
|
);
|
|
2863
|
+
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
2689
2864
|
if (isPresent2(proxy, "shadow-tls-password")) {
|
|
2690
2865
|
result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
|
|
2691
2866
|
result.appendIfPresent(
|
|
@@ -2745,6 +2920,7 @@ function ssh(proxy) {
|
|
|
2745
2920
|
`,interface=${proxy["interface-name"]}`,
|
|
2746
2921
|
"interface-name"
|
|
2747
2922
|
);
|
|
2923
|
+
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
2748
2924
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
2749
2925
|
result.appendIfPresent(
|
|
2750
2926
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -2794,6 +2970,7 @@ function http(proxy) {
|
|
|
2794
2970
|
`,interface=${proxy["interface-name"]}`,
|
|
2795
2971
|
"interface-name"
|
|
2796
2972
|
);
|
|
2973
|
+
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
2797
2974
|
if (isPresent2(proxy, "shadow-tls-password")) {
|
|
2798
2975
|
result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
|
|
2799
2976
|
result.appendIfPresent(
|
|
@@ -2840,6 +3017,7 @@ function direct(proxy) {
|
|
|
2840
3017
|
`,interface=${proxy["interface-name"]}`,
|
|
2841
3018
|
"interface-name"
|
|
2842
3019
|
);
|
|
3020
|
+
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
2843
3021
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
2844
3022
|
result.appendIfPresent(
|
|
2845
3023
|
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
@@ -2888,6 +3066,7 @@ function socks5(proxy) {
|
|
|
2888
3066
|
`,interface=${proxy["interface-name"]}`,
|
|
2889
3067
|
"interface-name"
|
|
2890
3068
|
);
|
|
3069
|
+
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
2891
3070
|
if (isPresent2(proxy, "shadow-tls-password")) {
|
|
2892
3071
|
result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
|
|
2893
3072
|
result.appendIfPresent(
|
|
@@ -2947,6 +3126,7 @@ function snell(proxy) {
|
|
|
2947
3126
|
`,interface=${proxy["interface-name"]}`,
|
|
2948
3127
|
"interface-name"
|
|
2949
3128
|
);
|
|
3129
|
+
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
2950
3130
|
if (isPresent2(proxy, "shadow-tls-password")) {
|
|
2951
3131
|
result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
|
|
2952
3132
|
result.appendIfPresent(
|
|
@@ -3023,6 +3203,7 @@ function tuic(proxy) {
|
|
|
3023
3203
|
`,interface=${proxy["interface-name"]}`,
|
|
3024
3204
|
"interface-name"
|
|
3025
3205
|
);
|
|
3206
|
+
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
3026
3207
|
if (isPresent2(proxy, "shadow-tls-password")) {
|
|
3027
3208
|
result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
|
|
3028
3209
|
result.appendIfPresent(
|
|
@@ -3083,6 +3264,7 @@ function wireguard(proxy) {
|
|
|
3083
3264
|
`,interface=${proxy["interface-name"]}`,
|
|
3084
3265
|
"interface-name"
|
|
3085
3266
|
);
|
|
3267
|
+
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
3086
3268
|
if (isPresent2(proxy, "shadow-tls-password")) {
|
|
3087
3269
|
result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
|
|
3088
3270
|
result.appendIfPresent(
|
|
@@ -3166,6 +3348,7 @@ function wireguard_surge(proxy) {
|
|
|
3166
3348
|
`,interface=${proxy["interface-name"]}`,
|
|
3167
3349
|
"interface-name"
|
|
3168
3350
|
);
|
|
3351
|
+
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
3169
3352
|
if (isPresent2(proxy, "shadow-tls-password")) {
|
|
3170
3353
|
result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
|
|
3171
3354
|
result.appendIfPresent(
|
|
@@ -3184,9 +3367,15 @@ function wireguard_surge(proxy) {
|
|
|
3184
3367
|
);
|
|
3185
3368
|
return result.toString();
|
|
3186
3369
|
}
|
|
3187
|
-
function hysteria2(proxy) {
|
|
3188
|
-
if (
|
|
3189
|
-
|
|
3370
|
+
function hysteria2(proxy, includeUnsupportedProxy) {
|
|
3371
|
+
if (includeUnsupportedProxy) {
|
|
3372
|
+
if (proxy["obfs-password"] && proxy.obfs != "salamander") {
|
|
3373
|
+
throw new Error(`only salamander obfs is supported`);
|
|
3374
|
+
}
|
|
3375
|
+
} else {
|
|
3376
|
+
if (proxy.obfs || proxy["obfs-password"]) {
|
|
3377
|
+
throw new Error(`obfs is unsupported`);
|
|
3378
|
+
}
|
|
3190
3379
|
}
|
|
3191
3380
|
const result = new Result(proxy);
|
|
3192
3381
|
result.append(`${proxy.name}=hysteria2,${proxy.server},${proxy.port}`);
|
|
@@ -3198,6 +3387,9 @@ function hysteria2(proxy) {
|
|
|
3198
3387
|
`,port-hopping-interval=${proxy["hop-interval"]}`,
|
|
3199
3388
|
"hop-interval"
|
|
3200
3389
|
);
|
|
3390
|
+
if (proxy["obfs-password"] && proxy.obfs == "salamander") {
|
|
3391
|
+
result.append(`,salamander-password="${proxy["obfs-password"]}"`);
|
|
3392
|
+
}
|
|
3201
3393
|
const ip_version = ipVersions[proxy["ip-version"]] || proxy["ip-version"];
|
|
3202
3394
|
result.appendIfPresent(`,ip-version=${ip_version}`, "ip-version");
|
|
3203
3395
|
result.appendIfPresent(
|
|
@@ -3234,6 +3426,7 @@ function hysteria2(proxy) {
|
|
|
3234
3426
|
`,interface=${proxy["interface-name"]}`,
|
|
3235
3427
|
"interface-name"
|
|
3236
3428
|
);
|
|
3429
|
+
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
3237
3430
|
if (isPresent2(proxy, "shadow-tls-password")) {
|
|
3238
3431
|
result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
|
|
3239
3432
|
result.appendIfPresent(
|
|
@@ -3281,9 +3474,11 @@ function handleTransport(result, proxy, includeUnsupportedProxy) {
|
|
|
3281
3474
|
} else {
|
|
3282
3475
|
if (includeUnsupportedProxy && ["http"].includes(proxy.network)) {
|
|
3283
3476
|
app_default.info(
|
|
3284
|
-
`Include Unsupported Proxy:
|
|
3477
|
+
`Include Unsupported Proxy: network ${proxy.network} -> tcp`
|
|
3285
3478
|
);
|
|
3286
|
-
} else {
|
|
3479
|
+
} else if (["tcp"].includes(proxy.network) && proxy["reality-opts"]) {
|
|
3480
|
+
throw new Error(`reality is unsupported`);
|
|
3481
|
+
} else if (!["tcp"].includes(proxy.network)) {
|
|
3287
3482
|
throw new Error(`network ${proxy.network} is unsupported`);
|
|
3288
3483
|
}
|
|
3289
3484
|
}
|
|
@@ -3308,7 +3503,7 @@ function ClashMeta_Producer() {
|
|
|
3308
3503
|
if (opts["include-unsupported-proxy"]) return true;
|
|
3309
3504
|
if (proxy.type === "snell" && proxy.version >= 4) {
|
|
3310
3505
|
return false;
|
|
3311
|
-
} else if (["juicity"].includes(proxy.type)) {
|
|
3506
|
+
} else if (["juicity", "naive"].includes(proxy.type)) {
|
|
3312
3507
|
return false;
|
|
3313
3508
|
} else if (["ss"].includes(proxy.type) && ![
|
|
3314
3509
|
"aes-128-ctr",
|
|
@@ -3354,6 +3549,9 @@ function ClashMeta_Producer() {
|
|
|
3354
3549
|
}
|
|
3355
3550
|
return true;
|
|
3356
3551
|
}).map((proxy) => {
|
|
3552
|
+
if (["trojan", "vmess", "vless"].includes(proxy.type)) {
|
|
3553
|
+
proxy["client-fingerprint"] = proxy["client-fingerprint"] || "chrome";
|
|
3554
|
+
}
|
|
3357
3555
|
if (proxy.type === "vmess") {
|
|
3358
3556
|
if (isPresent2(proxy, "aead")) {
|
|
3359
3557
|
if (proxy.aead) {
|
|
@@ -3443,7 +3641,7 @@ function ClashMeta_Producer() {
|
|
|
3443
3641
|
const networkPath = proxy[`${proxy.network}-opts`]?.path;
|
|
3444
3642
|
if (networkPath) {
|
|
3445
3643
|
const reg = /^(.*?)(?:\?ed=(\d+))?$/;
|
|
3446
|
-
const [
|
|
3644
|
+
const [_3, path = "", ed = ""] = reg.exec(networkPath);
|
|
3447
3645
|
proxy[`${proxy.network}-opts`].path = path;
|
|
3448
3646
|
if (ed !== "") {
|
|
3449
3647
|
proxy["ws-opts"]["early-data-header-name"] = "Sec-WebSocket-Protocol";
|
|
@@ -3468,7 +3666,8 @@ function ClashMeta_Producer() {
|
|
|
3468
3666
|
"hysteria",
|
|
3469
3667
|
"hysteria2",
|
|
3470
3668
|
"juicity",
|
|
3471
|
-
"anytls"
|
|
3669
|
+
"anytls",
|
|
3670
|
+
"naive"
|
|
3472
3671
|
].includes(proxy.type)) {
|
|
3473
3672
|
delete proxy.tls;
|
|
3474
3673
|
}
|
|
@@ -3561,6 +3760,7 @@ function external(proxy) {
|
|
|
3561
3760
|
`,no-error-alert=${proxy["no-error-alert"]}`,
|
|
3562
3761
|
"no-error-alert"
|
|
3563
3762
|
);
|
|
3763
|
+
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
3564
3764
|
if (isPresent2(proxy, "tfo")) {
|
|
3565
3765
|
result.append(`,tfo=${proxy["tfo"]}`);
|
|
3566
3766
|
} else if (isPresent2(proxy, "fast-open")) {
|
|
@@ -3578,6 +3778,7 @@ function mihomo(proxy, type, opts) {
|
|
|
3578
3778
|
const external_proxy = {
|
|
3579
3779
|
name: proxy.name,
|
|
3580
3780
|
type: "external",
|
|
3781
|
+
udp: true,
|
|
3581
3782
|
exec: proxy._exec || "/usr/local/bin/mihomo",
|
|
3582
3783
|
"local-port": localPort,
|
|
3583
3784
|
args: [
|
|
@@ -3668,6 +3869,8 @@ function Clash_Producer() {
|
|
|
3668
3869
|
"xchacha20-ietf-poly1305"
|
|
3669
3870
|
].includes(proxy.cipher) || proxy.type === "snell" && proxy.version >= 4 || proxy.type === "vless" && (typeof proxy.flow !== "undefined" || proxy["reality-opts"])) {
|
|
3670
3871
|
return false;
|
|
3872
|
+
} else if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
3873
|
+
return false;
|
|
3671
3874
|
} else if (proxy["underlying-proxy"] || proxy["dialer-proxy"]) {
|
|
3672
3875
|
app_default.error(
|
|
3673
3876
|
`Clash \u4E0D\u652F\u6301\u524D\u7F6E\u4EE3\u7406\u5B57\u6BB5. \u5DF2\u8FC7\u6EE4\u8282\u70B9 ${proxy.name}`
|
|
@@ -3732,7 +3935,7 @@ function Clash_Producer() {
|
|
|
3732
3935
|
const networkPath = proxy[`${proxy.network}-opts`]?.path;
|
|
3733
3936
|
if (networkPath) {
|
|
3734
3937
|
const reg = /^(.*?)(?:\?ed=(\d+))?$/;
|
|
3735
|
-
const [
|
|
3938
|
+
const [_3, path = "", ed = ""] = reg.exec(networkPath);
|
|
3736
3939
|
proxy[`${proxy.network}-opts`].path = path;
|
|
3737
3940
|
if (ed !== "") {
|
|
3738
3941
|
proxy["ws-opts"]["early-data-header-name"] = "Sec-WebSocket-Protocol";
|
|
@@ -3757,7 +3960,8 @@ function Clash_Producer() {
|
|
|
3757
3960
|
"hysteria",
|
|
3758
3961
|
"hysteria2",
|
|
3759
3962
|
"juicity",
|
|
3760
|
-
"anytls"
|
|
3963
|
+
"anytls",
|
|
3964
|
+
"naive"
|
|
3761
3965
|
].includes(proxy.type)) {
|
|
3762
3966
|
delete proxy.tls;
|
|
3763
3967
|
}
|
|
@@ -3810,7 +4014,8 @@ function Stash_Producer() {
|
|
|
3810
4014
|
"hysteria",
|
|
3811
4015
|
"hysteria2",
|
|
3812
4016
|
"ssh",
|
|
3813
|
-
"juicity"
|
|
4017
|
+
"juicity",
|
|
4018
|
+
"anytls"
|
|
3814
4019
|
].includes(proxy.type) || proxy.type === "ss" && ![
|
|
3815
4020
|
"aes-128-gcm",
|
|
3816
4021
|
"aes-192-gcm",
|
|
@@ -3835,6 +4040,16 @@ function Stash_Producer() {
|
|
|
3835
4040
|
`Stash \u6682\u4E0D\u652F\u6301\u524D\u7F6E\u4EE3\u7406\u5B57\u6BB5. \u5DF2\u8FC7\u6EE4\u8282\u70B9 ${proxy.name}. \u8BF7\u4F7F\u7528 \u4EE3\u7406\u7684\u8F6C\u53D1\u94FE https://stash.wiki/proxy-protocols/proxy-groups#relay`
|
|
3836
4041
|
);
|
|
3837
4042
|
return false;
|
|
4043
|
+
} else if (["anytls"].includes(proxy.type) && !opts["include-unsupported-proxy"]) {
|
|
4044
|
+
return false;
|
|
4045
|
+
} else if (["anytls"].includes(proxy.type) && proxy.network && (!["tcp"].includes(proxy.network) || ["tcp"].includes(proxy.network) && proxy["reality-opts"])) {
|
|
4046
|
+
return false;
|
|
4047
|
+
} else if (["xhttp"].includes(proxy.network)) {
|
|
4048
|
+
return false;
|
|
4049
|
+
} else if (proxy.encryption && proxy.encryption !== "none" && ["vless"].includes(proxy.type)) {
|
|
4050
|
+
return false;
|
|
4051
|
+
} else if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
4052
|
+
return false;
|
|
3838
4053
|
}
|
|
3839
4054
|
return true;
|
|
3840
4055
|
}).map((proxy) => {
|
|
@@ -3955,7 +4170,7 @@ function Stash_Producer() {
|
|
|
3955
4170
|
const networkPath = proxy[`${proxy.network}-opts`]?.path;
|
|
3956
4171
|
if (networkPath) {
|
|
3957
4172
|
const reg = /^(.*?)(?:\?ed=(\d+))?$/;
|
|
3958
|
-
const [
|
|
4173
|
+
const [_3, path = "", ed = ""] = reg.exec(networkPath);
|
|
3959
4174
|
proxy[`${proxy.network}-opts`].path = path;
|
|
3960
4175
|
if (ed !== "") {
|
|
3961
4176
|
proxy["ws-opts"]["early-data-header-name"] = "Sec-WebSocket-Protocol";
|
|
@@ -3980,7 +4195,8 @@ function Stash_Producer() {
|
|
|
3980
4195
|
"hysteria",
|
|
3981
4196
|
"hysteria2",
|
|
3982
4197
|
"juicity",
|
|
3983
|
-
"anytls"
|
|
4198
|
+
"anytls",
|
|
4199
|
+
"naive"
|
|
3984
4200
|
].includes(proxy.type)) {
|
|
3985
4201
|
delete proxy.tls;
|
|
3986
4202
|
}
|
|
@@ -4033,6 +4249,11 @@ var ipVersions3 = {
|
|
|
4033
4249
|
};
|
|
4034
4250
|
function Loon_Producer() {
|
|
4035
4251
|
const produce2 = (proxy, type, opts = {}) => {
|
|
4252
|
+
if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
4253
|
+
throw new Error(
|
|
4254
|
+
`Platform ${targetPlatform3} does not support network ${proxy.network} with http upgrade`
|
|
4255
|
+
);
|
|
4256
|
+
}
|
|
4036
4257
|
switch (proxy.type) {
|
|
4037
4258
|
case "ss":
|
|
4038
4259
|
return shadowsocks2(proxy);
|
|
@@ -4348,6 +4569,8 @@ function vmess2(proxy) {
|
|
|
4348
4569
|
return result.toString();
|
|
4349
4570
|
}
|
|
4350
4571
|
function vless(proxy) {
|
|
4572
|
+
if (proxy.encryption && proxy.encryption !== "none")
|
|
4573
|
+
throw new Error(`VLESS encryption is not supported`);
|
|
4351
4574
|
let isXtls = false;
|
|
4352
4575
|
const isReality = !!proxy["reality-opts"];
|
|
4353
4576
|
if (typeof proxy.flow !== "undefined") {
|
|
@@ -4615,6 +4838,18 @@ function vless2(proxy) {
|
|
|
4615
4838
|
if (proxy["skip-cert-verify"]) {
|
|
4616
4839
|
allowInsecure = `&allowInsecure=1`;
|
|
4617
4840
|
}
|
|
4841
|
+
let h2 = "";
|
|
4842
|
+
if (proxy._h2) {
|
|
4843
|
+
h2 = `&h2=1`;
|
|
4844
|
+
}
|
|
4845
|
+
let pcs = "";
|
|
4846
|
+
if (proxy._pcs) {
|
|
4847
|
+
pcs = `&pcs=${encodeURIComponent(proxy._pcs)}`;
|
|
4848
|
+
}
|
|
4849
|
+
let ech = "";
|
|
4850
|
+
if (proxy._echConfigList) {
|
|
4851
|
+
ech = `&ech=${encodeURIComponent(proxy._echConfigList)}`;
|
|
4852
|
+
}
|
|
4618
4853
|
let sni = "";
|
|
4619
4854
|
if (proxy.sni) {
|
|
4620
4855
|
sni = `&sni=${encodeURIComponent(proxy.sni)}`;
|
|
@@ -4687,7 +4922,7 @@ function vless2(proxy) {
|
|
|
4687
4922
|
}
|
|
4688
4923
|
return `vless://${proxy.uuid}@${proxy.server}:${proxy.port}?security=${encodeURIComponent(
|
|
4689
4924
|
security
|
|
4690
|
-
)}${vlessTransport}${alpn}${allowInsecure}${sni}${fp}${flow}${sid}${spx}${pbk}${mode}${extra}${pqv}${encryption}#${encodeURIComponent(
|
|
4925
|
+
)}${vlessTransport}${alpn}${allowInsecure}${pcs}${ech}${h2}${sni}${fp}${flow}${sid}${spx}${pbk}${mode}${extra}${pqv}${encryption}#${encodeURIComponent(
|
|
4691
4926
|
proxy.name
|
|
4692
4927
|
)}`;
|
|
4693
4928
|
}
|
|
@@ -4705,9 +4940,14 @@ function URI_Producer() {
|
|
|
4705
4940
|
delete proxy[key];
|
|
4706
4941
|
}
|
|
4707
4942
|
}
|
|
4708
|
-
if ([
|
|
4709
|
-
|
|
4710
|
-
|
|
4943
|
+
if ([
|
|
4944
|
+
"trojan",
|
|
4945
|
+
"tuic",
|
|
4946
|
+
"hysteria",
|
|
4947
|
+
"hysteria2",
|
|
4948
|
+
"juicity",
|
|
4949
|
+
"anytls"
|
|
4950
|
+
].includes(proxy.type)) {
|
|
4711
4951
|
delete proxy.tls;
|
|
4712
4952
|
}
|
|
4713
4953
|
if (!["vmess"].includes(proxy.type) && proxy.server && isIPv6(proxy.server)) {
|
|
@@ -4726,22 +4966,23 @@ function URI_Producer() {
|
|
|
4726
4966
|
result = `ss://${proxy.cipher?.startsWith("2022-blake3-") ? `${encodeURIComponent(
|
|
4727
4967
|
proxy.cipher
|
|
4728
4968
|
)}:${encodeURIComponent(proxy.password)}` : Base643.encode(userinfo)}@${proxy.server}:${proxy.port}${proxy.plugin ? "/" : ""}`;
|
|
4969
|
+
let query = "";
|
|
4729
4970
|
if (proxy.plugin) {
|
|
4730
|
-
|
|
4971
|
+
query += "&plugin=";
|
|
4731
4972
|
const opts = proxy["plugin-opts"];
|
|
4732
4973
|
switch (proxy.plugin) {
|
|
4733
4974
|
case "obfs":
|
|
4734
|
-
|
|
4975
|
+
query += encodeURIComponent(
|
|
4735
4976
|
`simple-obfs;obfs=${opts.mode}${opts.host ? ";obfs-host=" + opts.host : ""}`
|
|
4736
4977
|
);
|
|
4737
4978
|
break;
|
|
4738
4979
|
case "v2ray-plugin":
|
|
4739
|
-
|
|
4980
|
+
query += encodeURIComponent(
|
|
4740
4981
|
`v2ray-plugin;obfs=${opts.mode}${opts.host ? ";obfs-host" + opts.host : ""}${opts.tls ? ";tls" : ""}`
|
|
4741
4982
|
);
|
|
4742
4983
|
break;
|
|
4743
4984
|
case "shadow-tls":
|
|
4744
|
-
|
|
4985
|
+
query += encodeURIComponent(
|
|
4745
4986
|
`shadow-tls;host=${opts.host};password=${opts.password};version=${opts.version}`
|
|
4746
4987
|
);
|
|
4747
4988
|
break;
|
|
@@ -4752,12 +4993,97 @@ function URI_Producer() {
|
|
|
4752
4993
|
}
|
|
4753
4994
|
}
|
|
4754
4995
|
if (proxy["udp-over-tcp"]) {
|
|
4755
|
-
|
|
4996
|
+
query += "&uot=1";
|
|
4756
4997
|
}
|
|
4757
4998
|
if (proxy.tfo) {
|
|
4758
|
-
|
|
4999
|
+
query += "&tfo=1";
|
|
5000
|
+
}
|
|
5001
|
+
let ssTransport = "";
|
|
5002
|
+
if (proxy.network) {
|
|
5003
|
+
let ssType = proxy.network;
|
|
5004
|
+
if (proxy.network === "ws" && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
5005
|
+
ssType = "httpupgrade";
|
|
5006
|
+
}
|
|
5007
|
+
ssTransport = `&type=${encodeURIComponent(ssType)}`;
|
|
5008
|
+
if (["grpc"].includes(proxy.network)) {
|
|
5009
|
+
let ssTransportServiceName = proxy[`${proxy.network}-opts`]?.[`${proxy.network}-service-name`];
|
|
5010
|
+
let ssTransportAuthority = proxy[`${proxy.network}-opts`]?.["_grpc-authority"];
|
|
5011
|
+
if (ssTransportServiceName) {
|
|
5012
|
+
ssTransport += `&serviceName=${encodeURIComponent(
|
|
5013
|
+
ssTransportServiceName
|
|
5014
|
+
)}`;
|
|
5015
|
+
}
|
|
5016
|
+
if (ssTransportAuthority) {
|
|
5017
|
+
ssTransport += `&authority=${encodeURIComponent(
|
|
5018
|
+
ssTransportAuthority
|
|
5019
|
+
)}`;
|
|
5020
|
+
}
|
|
5021
|
+
ssTransport += `&mode=${encodeURIComponent(
|
|
5022
|
+
proxy[`${proxy.network}-opts`]?.["_grpc-type"] || "gun"
|
|
5023
|
+
)}`;
|
|
5024
|
+
}
|
|
5025
|
+
let ssTransportPath = proxy[`${proxy.network}-opts`]?.path;
|
|
5026
|
+
let ssTransportHost = proxy[`${proxy.network}-opts`]?.headers?.Host;
|
|
5027
|
+
if (ssTransportPath) {
|
|
5028
|
+
ssTransport += `&path=${encodeURIComponent(
|
|
5029
|
+
Array.isArray(ssTransportPath) ? ssTransportPath[0] : ssTransportPath
|
|
5030
|
+
)}`;
|
|
5031
|
+
}
|
|
5032
|
+
if (ssTransportHost) {
|
|
5033
|
+
ssTransport += `&host=${encodeURIComponent(
|
|
5034
|
+
Array.isArray(ssTransportHost) ? ssTransportHost[0] : ssTransportHost
|
|
5035
|
+
)}`;
|
|
5036
|
+
}
|
|
5037
|
+
}
|
|
5038
|
+
let ssFp = "";
|
|
5039
|
+
if (proxy["client-fingerprint"]) {
|
|
5040
|
+
ssFp = `&fp=${encodeURIComponent(
|
|
5041
|
+
proxy["client-fingerprint"]
|
|
5042
|
+
)}`;
|
|
5043
|
+
}
|
|
5044
|
+
let ssAlpn = "";
|
|
5045
|
+
if (proxy.alpn) {
|
|
5046
|
+
ssAlpn = `&alpn=${encodeURIComponent(
|
|
5047
|
+
Array.isArray(proxy.alpn) ? proxy.alpn : proxy.alpn.join(",")
|
|
5048
|
+
)}`;
|
|
5049
|
+
}
|
|
5050
|
+
const ssIsReality = proxy["reality-opts"];
|
|
5051
|
+
let ssSid = "";
|
|
5052
|
+
let ssPbk = "";
|
|
5053
|
+
let ssSpx = "";
|
|
5054
|
+
let ssSecurity = proxy.tls ? "&security=tls" : "";
|
|
5055
|
+
let ssMode = "";
|
|
5056
|
+
let ssExtra = "";
|
|
5057
|
+
if (ssIsReality) {
|
|
5058
|
+
ssSecurity = `&security=reality`;
|
|
5059
|
+
const publicKey = proxy["reality-opts"]?.["public-key"];
|
|
5060
|
+
if (publicKey) {
|
|
5061
|
+
ssPbk = `&pbk=${encodeURIComponent(publicKey)}`;
|
|
5062
|
+
}
|
|
5063
|
+
const shortId = proxy["reality-opts"]?.["short-id"];
|
|
5064
|
+
if (shortId) {
|
|
5065
|
+
ssSid = `&sid=${encodeURIComponent(shortId)}`;
|
|
5066
|
+
}
|
|
5067
|
+
const spiderX = proxy["reality-opts"]?.["_spider-x"];
|
|
5068
|
+
if (spiderX) {
|
|
5069
|
+
ssSpx = `&spx=${encodeURIComponent(spiderX)}`;
|
|
5070
|
+
}
|
|
5071
|
+
if (proxy._extra) {
|
|
5072
|
+
ssExtra = `&extra=${encodeURIComponent(proxy._extra)}`;
|
|
5073
|
+
}
|
|
5074
|
+
if (proxy._mode) {
|
|
5075
|
+
ssMode = `&mode=${encodeURIComponent(proxy._mode)}`;
|
|
5076
|
+
}
|
|
4759
5077
|
}
|
|
4760
|
-
|
|
5078
|
+
if (proxy.tls) {
|
|
5079
|
+
query += `&sni=${encodeURIComponent(
|
|
5080
|
+
proxy.sni || proxy.server
|
|
5081
|
+
)}${proxy["skip-cert-verify"] ? "&allowInsecure=1" : ""}`;
|
|
5082
|
+
}
|
|
5083
|
+
query += `${ssTransport}${ssAlpn}${ssFp}${ssSecurity}${ssSid}${ssPbk}${ssSpx}${ssMode}${ssExtra}#${encodeURIComponent(
|
|
5084
|
+
proxy.name
|
|
5085
|
+
)}`;
|
|
5086
|
+
result += query.replace(/^&/, "?");
|
|
4761
5087
|
break;
|
|
4762
5088
|
case "ssr":
|
|
4763
5089
|
result = `${proxy.server}:${proxy.port}:${proxy.protocol}:${proxy.cipher}:${proxy.obfs}:${Base643.encode(proxy.password)}/`;
|
|
@@ -5189,6 +5515,11 @@ Reason: ${err}`
|
|
|
5189
5515
|
var targetPlatform4 = "QX";
|
|
5190
5516
|
function QX_Producer() {
|
|
5191
5517
|
const produce2 = (proxy, type, opts = {}) => {
|
|
5518
|
+
if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
5519
|
+
throw new Error(
|
|
5520
|
+
`Platform ${targetPlatform4} does not support network ${proxy.network} with http upgrade`
|
|
5521
|
+
);
|
|
5522
|
+
}
|
|
5192
5523
|
switch (proxy.type) {
|
|
5193
5524
|
case "ss":
|
|
5194
5525
|
return shadowsocks3(proxy);
|
|
@@ -5209,7 +5540,25 @@ function QX_Producer() {
|
|
|
5209
5540
|
`Platform ${targetPlatform4} does not support proxy type: ${proxy.type}`
|
|
5210
5541
|
);
|
|
5211
5542
|
};
|
|
5212
|
-
return {
|
|
5543
|
+
return {
|
|
5544
|
+
produce: (proxy, type, opts = {}) => {
|
|
5545
|
+
let result = produce2(proxy, type, opts);
|
|
5546
|
+
if (proxy.flow && proxy.flow !== "xtls-rprx-vision") {
|
|
5547
|
+
throw new Error(
|
|
5548
|
+
`Platform ${targetPlatform4} does not support flow ${proxy.flow}`
|
|
5549
|
+
);
|
|
5550
|
+
}
|
|
5551
|
+
if (proxy["reality-opts"]) {
|
|
5552
|
+
if (proxy["reality-opts"]["public-key"]) {
|
|
5553
|
+
result = `${result},reality-base64-pubkey=${proxy["reality-opts"]["public-key"]}`;
|
|
5554
|
+
}
|
|
5555
|
+
if (proxy["reality-opts"]["short-id"]) {
|
|
5556
|
+
result = `${result},reality-hex-shortid=${proxy["reality-opts"]["short-id"]}`;
|
|
5557
|
+
}
|
|
5558
|
+
}
|
|
5559
|
+
return result;
|
|
5560
|
+
}
|
|
5561
|
+
};
|
|
5213
5562
|
}
|
|
5214
5563
|
function shadowsocks3(proxy) {
|
|
5215
5564
|
const result = new Result(proxy);
|
|
@@ -5354,7 +5703,7 @@ function trojan3(proxy) {
|
|
|
5354
5703
|
`,obfs-host=${proxy["ws-opts"]?.headers?.Host}`,
|
|
5355
5704
|
"ws-opts.headers.Host"
|
|
5356
5705
|
);
|
|
5357
|
-
} else {
|
|
5706
|
+
} else if (!["tcp"].includes(proxy.network)) {
|
|
5358
5707
|
throw new Error(`network ${proxy.network} is unsupported`);
|
|
5359
5708
|
}
|
|
5360
5709
|
}
|
|
@@ -5416,7 +5765,9 @@ function vmess3(proxy) {
|
|
|
5416
5765
|
else append(`,obfs=ws`);
|
|
5417
5766
|
} else if (proxy.network === "http") {
|
|
5418
5767
|
append(`,obfs=http`);
|
|
5419
|
-
} else {
|
|
5768
|
+
} else if (["tcp"].includes(proxy.network)) {
|
|
5769
|
+
if (proxy.tls) append(`,obfs=over-tls`);
|
|
5770
|
+
} else if (!["tcp"].includes(proxy.network)) {
|
|
5420
5771
|
throw new Error(`network ${proxy.network} is unsupported`);
|
|
5421
5772
|
}
|
|
5422
5773
|
let transportPath = proxy[`${proxy.network}-opts`]?.path;
|
|
@@ -5471,9 +5822,8 @@ function vmess3(proxy) {
|
|
|
5471
5822
|
return result.toString();
|
|
5472
5823
|
}
|
|
5473
5824
|
function vless3(proxy) {
|
|
5474
|
-
if (
|
|
5475
|
-
throw new Error(`VLESS
|
|
5476
|
-
}
|
|
5825
|
+
if (proxy.encryption && proxy.encryption !== "none")
|
|
5826
|
+
throw new Error(`VLESS encryption is not supported`);
|
|
5477
5827
|
const result = new Result(proxy);
|
|
5478
5828
|
const append = result.append.bind(result);
|
|
5479
5829
|
const appendIfPresent = result.appendIfPresent.bind(result);
|
|
@@ -5532,6 +5882,7 @@ function vless3(proxy) {
|
|
|
5532
5882
|
);
|
|
5533
5883
|
appendIfPresent(`,tls-host=${proxy.sni}`, "sni");
|
|
5534
5884
|
}
|
|
5885
|
+
appendIfPresent(`,vless-flow=${proxy.flow}`, "flow");
|
|
5535
5886
|
appendIfPresent(`,fast-open=${proxy.tfo}`, "tfo");
|
|
5536
5887
|
appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
5537
5888
|
result.appendIfPresent(
|
|
@@ -5641,7 +5992,13 @@ function Shadowrocket_Producer() {
|
|
|
5641
5992
|
if (opts["include-unsupported-proxy"]) return true;
|
|
5642
5993
|
if (proxy.type === "snell" && proxy.version >= 4) {
|
|
5643
5994
|
return false;
|
|
5644
|
-
} else if (["mieru"].includes(proxy.type)) {
|
|
5995
|
+
} else if (["mieru", "sudoku", "naive"].includes(proxy.type)) {
|
|
5996
|
+
return false;
|
|
5997
|
+
} else if (proxy.encryption && proxy.encryption !== "none" && ["vless"].includes(proxy.type)) {
|
|
5998
|
+
return false;
|
|
5999
|
+
} else if (["anytls"].includes(proxy.type) && proxy.network && (!["tcp"].includes(proxy.network) || ["tcp"].includes(proxy.network) && proxy["reality-opts"])) {
|
|
6000
|
+
return false;
|
|
6001
|
+
} else if (["xhttp"].includes(proxy.network)) {
|
|
5645
6002
|
return false;
|
|
5646
6003
|
}
|
|
5647
6004
|
return true;
|
|
@@ -5717,10 +6074,6 @@ function Shadowrocket_Producer() {
|
|
|
5717
6074
|
delete proxy["shadow-tls-sni"];
|
|
5718
6075
|
delete proxy["shadow-tls-version"];
|
|
5719
6076
|
}
|
|
5720
|
-
} else if (["anytls"].includes(proxy.type) && proxy.network && (!["tcp"].includes(proxy.network) || ["tcp"].includes(proxy.network) && proxy["reality-opts"])) {
|
|
5721
|
-
return false;
|
|
5722
|
-
} else if (["xhttp"].includes(proxy.network)) {
|
|
5723
|
-
return false;
|
|
5724
6077
|
}
|
|
5725
6078
|
if (["vmess", "vless"].includes(proxy.type) && proxy.network === "http") {
|
|
5726
6079
|
let httpPath = proxy["http-opts"]?.path;
|
|
@@ -5746,7 +6099,7 @@ function Shadowrocket_Producer() {
|
|
|
5746
6099
|
const networkPath = proxy[`${proxy.network}-opts`]?.path;
|
|
5747
6100
|
if (networkPath) {
|
|
5748
6101
|
const reg = /^(.*?)(?:\?ed=(\d+))?$/;
|
|
5749
|
-
const [
|
|
6102
|
+
const [_3, path = "", ed = ""] = reg.exec(networkPath);
|
|
5750
6103
|
proxy[`${proxy.network}-opts`].path = path;
|
|
5751
6104
|
if (ed !== "") {
|
|
5752
6105
|
proxy["ws-opts"]["early-data-header-name"] = "Sec-WebSocket-Protocol";
|
|
@@ -5771,7 +6124,8 @@ function Shadowrocket_Producer() {
|
|
|
5771
6124
|
"hysteria",
|
|
5772
6125
|
"hysteria2",
|
|
5773
6126
|
"juicity",
|
|
5774
|
-
"anytls"
|
|
6127
|
+
"anytls",
|
|
6128
|
+
"naive"
|
|
5775
6129
|
].includes(proxy.type)) {
|
|
5776
6130
|
delete proxy.tls;
|
|
5777
6131
|
}
|
|
@@ -5815,6 +6169,11 @@ function Shadowrocket_Producer() {
|
|
|
5815
6169
|
var targetPlatform5 = "Surfboard";
|
|
5816
6170
|
function Surfboard_Producer() {
|
|
5817
6171
|
const produce2 = (proxy) => {
|
|
6172
|
+
if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
6173
|
+
throw new Error(
|
|
6174
|
+
`Platform ${targetPlatform5} does not support network ${proxy.network} with http upgrade`
|
|
6175
|
+
);
|
|
6176
|
+
}
|
|
5818
6177
|
proxy.name = proxy.name.replace(/=|,/g, "");
|
|
5819
6178
|
switch (proxy.type) {
|
|
5820
6179
|
case "ss":
|
|
@@ -5977,7 +6336,9 @@ function handleTransport2(result, proxy) {
|
|
|
5977
6336
|
}
|
|
5978
6337
|
}
|
|
5979
6338
|
}
|
|
5980
|
-
} else {
|
|
6339
|
+
} else if (["tcp"].includes(proxy.network) && proxy["reality-opts"]) {
|
|
6340
|
+
throw new Error(`reality is unsupported`);
|
|
6341
|
+
} else if (!["tcp"].includes(proxy.network)) {
|
|
5981
6342
|
throw new Error(`network ${proxy.network} is unsupported`);
|
|
5982
6343
|
}
|
|
5983
6344
|
}
|
|
@@ -6099,7 +6460,7 @@ var wsParser = (proxy, parsedProxy) => {
|
|
|
6099
6460
|
transport.path = `${proxy["ws-path"]}`;
|
|
6100
6461
|
if (transport.path) {
|
|
6101
6462
|
const reg = /^(.*?)(?:\?ed=(\d+))?$/;
|
|
6102
|
-
const [
|
|
6463
|
+
const [_3, path = "", ed = ""] = reg.exec(transport.path);
|
|
6103
6464
|
transport.path = path;
|
|
6104
6465
|
if (ed !== "") {
|
|
6105
6466
|
transport.early_data_header_name = "Sec-WebSocket-Protocol";
|
|
@@ -6235,11 +6596,27 @@ var tlsParser = (proxy, parsedProxy) => {
|
|
|
6235
6596
|
enabled: true,
|
|
6236
6597
|
fingerprint: proxy["client-fingerprint"]
|
|
6237
6598
|
};
|
|
6599
|
+
if (proxy._ech && isPlainObject(proxy._ech)) {
|
|
6600
|
+
parsedProxy.tls.ech = proxy._ech;
|
|
6601
|
+
}
|
|
6238
6602
|
if (proxy["_fragment"]) parsedProxy.tls.fragment = !!proxy["_fragment"];
|
|
6239
6603
|
if (proxy["_fragment_fallback_delay"])
|
|
6240
6604
|
parsedProxy.tls.fragment_fallback_delay = proxy["_fragment_fallback_delay"];
|
|
6241
6605
|
if (proxy["_record_fragment"])
|
|
6242
6606
|
parsedProxy.tls.record_fragment = !!proxy["_record_fragment"];
|
|
6607
|
+
if (proxy["_certificate"])
|
|
6608
|
+
parsedProxy.tls.certificate = proxy["_certificate"];
|
|
6609
|
+
if (proxy["_certificate_path"])
|
|
6610
|
+
parsedProxy.tls.certificate_path = proxy["_certificate_path"];
|
|
6611
|
+
if (proxy["_certificate_public_key_sha256"])
|
|
6612
|
+
parsedProxy.tls.certificate_public_key_sha256 = proxy["_certificate_public_key_sha256"];
|
|
6613
|
+
if (proxy["_client_certificate"])
|
|
6614
|
+
parsedProxy.tls.client_certificate = proxy["_client_certificate"];
|
|
6615
|
+
if (proxy["_client_certificate_path"])
|
|
6616
|
+
parsedProxy.tls.client_certificate_path = proxy["_client_certificate_path"];
|
|
6617
|
+
if (proxy["_client_key"]) parsedProxy.tls.client_key = proxy["_client_key"];
|
|
6618
|
+
if (proxy["_client_key_path"])
|
|
6619
|
+
parsedProxy.tls.client_key_path = proxy["_client_key_path"];
|
|
6243
6620
|
if (!parsedProxy.tls.enabled) delete parsedProxy.tls;
|
|
6244
6621
|
};
|
|
6245
6622
|
var sshParser = (proxy = {}) => {
|
|
@@ -6306,7 +6683,6 @@ var socks5Parser = (proxy = {}) => {
|
|
|
6306
6683
|
type: "socks",
|
|
6307
6684
|
server: proxy.server,
|
|
6308
6685
|
server_port: parseInt(`${proxy.port}`, 10),
|
|
6309
|
-
password: proxy.password,
|
|
6310
6686
|
version: "5"
|
|
6311
6687
|
};
|
|
6312
6688
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
@@ -6314,7 +6690,12 @@ var socks5Parser = (proxy = {}) => {
|
|
|
6314
6690
|
if (proxy.username) parsedProxy.username = proxy.username;
|
|
6315
6691
|
if (proxy.password) parsedProxy.password = proxy.password;
|
|
6316
6692
|
if (proxy.uot) parsedProxy.udp_over_tcp = true;
|
|
6317
|
-
if (proxy["udp-over-tcp"])
|
|
6693
|
+
if (proxy["udp-over-tcp"]) {
|
|
6694
|
+
parsedProxy.udp_over_tcp = {
|
|
6695
|
+
enabled: true,
|
|
6696
|
+
version: !proxy["udp-over-tcp-version"] || proxy["udp-over-tcp-version"] === 1 ? 1 : 2
|
|
6697
|
+
};
|
|
6698
|
+
}
|
|
6318
6699
|
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
6319
6700
|
networkParser(proxy, parsedProxy);
|
|
6320
6701
|
tfoParser(proxy, parsedProxy);
|
|
@@ -6549,6 +6930,50 @@ var trojanParser = (proxy = {}) => {
|
|
|
6549
6930
|
ipVersionParser(proxy, parsedProxy);
|
|
6550
6931
|
return parsedProxy;
|
|
6551
6932
|
};
|
|
6933
|
+
var naiveParser = (proxy = {}) => {
|
|
6934
|
+
const parsedProxy = {
|
|
6935
|
+
tag: proxy.name,
|
|
6936
|
+
type: "naive",
|
|
6937
|
+
server: proxy.server,
|
|
6938
|
+
server_port: parseInt(`${proxy.port}`, 10),
|
|
6939
|
+
tls: { enabled: true, server_name: proxy.server, insecure: false }
|
|
6940
|
+
};
|
|
6941
|
+
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
6942
|
+
throw "invalid port";
|
|
6943
|
+
if (proxy.username) parsedProxy.username = proxy.username;
|
|
6944
|
+
if (proxy.password) parsedProxy.password = proxy.password;
|
|
6945
|
+
if (proxy.uot) parsedProxy.udp_over_tcp = true;
|
|
6946
|
+
if (proxy["udp-over-tcp"]) {
|
|
6947
|
+
parsedProxy.udp_over_tcp = {
|
|
6948
|
+
enabled: true,
|
|
6949
|
+
version: !proxy["udp-over-tcp-version"] || proxy["udp-over-tcp-version"] === 1 ? 1 : 2
|
|
6950
|
+
};
|
|
6951
|
+
}
|
|
6952
|
+
const insecure_concurrency = parseInt(
|
|
6953
|
+
`${proxy["insecure-concurrency"]}`,
|
|
6954
|
+
10
|
|
6955
|
+
);
|
|
6956
|
+
if (Number.isInteger(insecure_concurrency) && insecure_concurrency >= 0)
|
|
6957
|
+
parsedProxy.insecure_concurrency = insecure_concurrency;
|
|
6958
|
+
if (proxy["extra-headers"])
|
|
6959
|
+
parsedProxy.extra_headers = proxy["extra-headers"];
|
|
6960
|
+
if (proxy.quic) parsedProxy.quic = !!proxy.quic;
|
|
6961
|
+
if (proxy["quic-congestion-control"])
|
|
6962
|
+
parsedProxy.quic_congestion_control = proxy["quic-congestion-control"];
|
|
6963
|
+
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
6964
|
+
tfoParser(proxy, parsedProxy);
|
|
6965
|
+
detourParser(proxy, parsedProxy);
|
|
6966
|
+
tlsParser(proxy, parsedProxy);
|
|
6967
|
+
smuxParser(proxy.smux, parsedProxy);
|
|
6968
|
+
ipVersionParser(proxy, parsedProxy);
|
|
6969
|
+
if (parsedProxy.tls?.insecure) {
|
|
6970
|
+
app_default.info(
|
|
6971
|
+
`Platform sing-box: insecure is not supported on naive outbound`
|
|
6972
|
+
);
|
|
6973
|
+
delete parsedProxy.tls.insecure;
|
|
6974
|
+
}
|
|
6975
|
+
return parsedProxy;
|
|
6976
|
+
};
|
|
6552
6977
|
var hysteriaParser = (proxy = {}) => {
|
|
6553
6978
|
const parsedProxy = {
|
|
6554
6979
|
tag: proxy.name,
|
|
@@ -6785,7 +7210,7 @@ function singbox_Producer() {
|
|
|
6785
7210
|
}
|
|
6786
7211
|
break;
|
|
6787
7212
|
case "vmess":
|
|
6788
|
-
if (!proxy.network || ["ws", "grpc", "h2", "http"].includes(
|
|
7213
|
+
if (!proxy.network || ["tcp", "ws", "grpc", "h2", "http"].includes(
|
|
6789
7214
|
proxy.network
|
|
6790
7215
|
)) {
|
|
6791
7216
|
list.push(vmessParser(proxy));
|
|
@@ -6796,6 +7221,11 @@ function singbox_Producer() {
|
|
|
6796
7221
|
}
|
|
6797
7222
|
break;
|
|
6798
7223
|
case "vless":
|
|
7224
|
+
if (proxy.encryption && proxy.encryption !== "none") {
|
|
7225
|
+
throw new Error(
|
|
7226
|
+
`VLESS encryption is not supported`
|
|
7227
|
+
);
|
|
7228
|
+
}
|
|
6799
7229
|
if (!proxy.flow || ["xtls-rprx-vision"].includes(proxy.flow)) {
|
|
6800
7230
|
list.push(vlessParser(proxy));
|
|
6801
7231
|
} else {
|
|
@@ -6813,6 +7243,9 @@ function singbox_Producer() {
|
|
|
6813
7243
|
);
|
|
6814
7244
|
}
|
|
6815
7245
|
break;
|
|
7246
|
+
case "naive":
|
|
7247
|
+
list.push(naiveParser(proxy));
|
|
7248
|
+
break;
|
|
6816
7249
|
case "hysteria":
|
|
6817
7250
|
list.push(hysteriaParser(proxy));
|
|
6818
7251
|
break;
|
|
@@ -6860,13 +7293,15 @@ function Egern_Producer() {
|
|
|
6860
7293
|
const list = proxies.filter((proxy) => {
|
|
6861
7294
|
if (![
|
|
6862
7295
|
"http",
|
|
7296
|
+
"https",
|
|
6863
7297
|
"socks5",
|
|
6864
7298
|
"ss",
|
|
6865
7299
|
"trojan",
|
|
6866
7300
|
"hysteria2",
|
|
6867
7301
|
"vless",
|
|
6868
7302
|
"vmess",
|
|
6869
|
-
"tuic"
|
|
7303
|
+
"tuic",
|
|
7304
|
+
...opts["include-unsupported-proxy"] ? ["wireguard"] : []
|
|
6870
7305
|
].includes(proxy.type) || proxy.type === "ss" && (proxy.plugin === "obfs" && !["http", "tls"].includes(
|
|
6871
7306
|
proxy["plugin-opts"]?.mode
|
|
6872
7307
|
) || ![
|
|
@@ -6898,7 +7333,9 @@ function Egern_Producer() {
|
|
|
6898
7333
|
"chacha20-ietf",
|
|
6899
7334
|
"2022-blake3-aes-128-gcm",
|
|
6900
7335
|
"2022-blake3-aes-256-gcm"
|
|
6901
|
-
].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" &&
|
|
7336
|
+
].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" && !["http", "ws", "tcp"].includes(proxy.network) && proxy.network || proxy.type === "tuic" && proxy.token && proxy.token.length !== 0) {
|
|
7337
|
+
return false;
|
|
7338
|
+
} else if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
6902
7339
|
return false;
|
|
6903
7340
|
}
|
|
6904
7341
|
return true;
|
|
@@ -6911,14 +7348,18 @@ function Egern_Producer() {
|
|
|
6911
7348
|
const prev_hop = proxy.prev_hop || proxy["underlying-proxy"] || proxy["dialer-proxy"] || proxy.detour;
|
|
6912
7349
|
if (proxy.type === "http") {
|
|
6913
7350
|
proxy = {
|
|
6914
|
-
type: "http",
|
|
7351
|
+
type: proxy.tls ? "https" : "http",
|
|
6915
7352
|
name: proxy.name,
|
|
6916
7353
|
server: proxy.server,
|
|
6917
7354
|
port: proxy.port,
|
|
6918
7355
|
username: proxy.username,
|
|
6919
7356
|
password: proxy.password,
|
|
6920
7357
|
tfo: proxy.tfo || proxy["fast-open"],
|
|
6921
|
-
next_hop: proxy.next_hop
|
|
7358
|
+
next_hop: proxy.next_hop,
|
|
7359
|
+
...proxy.tls ? {
|
|
7360
|
+
sni: proxy.sni,
|
|
7361
|
+
skip_tls_verify: proxy["skip-cert-verify"]
|
|
7362
|
+
} : {}
|
|
6922
7363
|
};
|
|
6923
7364
|
} else if (proxy.type === "socks5") {
|
|
6924
7365
|
proxy = {
|
|
@@ -7081,6 +7522,8 @@ function Egern_Producer() {
|
|
|
7081
7522
|
// skip_tls_verify: proxy['skip-cert-verify'],
|
|
7082
7523
|
};
|
|
7083
7524
|
} else if (proxy.type === "vless") {
|
|
7525
|
+
if (proxy.encryption && proxy.encryption !== "none")
|
|
7526
|
+
throw new Error(`VLESS encryption is not supported`);
|
|
7084
7527
|
if (proxy.network === "ws") {
|
|
7085
7528
|
proxy.transport = {
|
|
7086
7529
|
[proxy.tls ? "wss" : "ws"]: {
|
|
@@ -7120,6 +7563,13 @@ function Egern_Producer() {
|
|
|
7120
7563
|
reality
|
|
7121
7564
|
}
|
|
7122
7565
|
};
|
|
7566
|
+
if (typeof proxy.flow !== "undefined") {
|
|
7567
|
+
if (!["xtls-rprx-vision"].includes(proxy.flow)) {
|
|
7568
|
+
throw new Error(
|
|
7569
|
+
`VLESS flow(${proxy.flow}) is not supported`
|
|
7570
|
+
);
|
|
7571
|
+
}
|
|
7572
|
+
}
|
|
7123
7573
|
flow = proxy.flow;
|
|
7124
7574
|
}
|
|
7125
7575
|
proxy = {
|
|
@@ -7137,9 +7587,36 @@ function Egern_Producer() {
|
|
|
7137
7587
|
// sni: proxy.sni,
|
|
7138
7588
|
// skip_tls_verify: proxy['skip-cert-verify'],
|
|
7139
7589
|
};
|
|
7590
|
+
} else if (proxy.type === "wireguard") {
|
|
7591
|
+
if (Array.isArray(proxy.peers) && proxy.peers.length > 0) {
|
|
7592
|
+
proxy.server = proxy.peers[0].server;
|
|
7593
|
+
proxy.port = proxy.peers[0].port;
|
|
7594
|
+
proxy.ip = proxy.peers[0].ip;
|
|
7595
|
+
proxy.ipv6 = proxy.peers[0].ipv6;
|
|
7596
|
+
proxy["public-key"] = proxy.peers[0]["public-key"];
|
|
7597
|
+
proxy["preshared-key"] = proxy.peers[0]["pre-shared-key"];
|
|
7598
|
+
proxy["allowed-ips"] = proxy.peers[0]["allowed-ips"];
|
|
7599
|
+
proxy.reserved = proxy.peers[0].reserved;
|
|
7600
|
+
}
|
|
7601
|
+
proxy = {
|
|
7602
|
+
type: "wireguard",
|
|
7603
|
+
name: proxy.name,
|
|
7604
|
+
local_ipv4: proxy.ip,
|
|
7605
|
+
local_ipv6: proxy.ipv6,
|
|
7606
|
+
server: proxy.server,
|
|
7607
|
+
port: proxy.port,
|
|
7608
|
+
private_key: proxy["private-key"],
|
|
7609
|
+
peer_public_key: proxy["public-key"],
|
|
7610
|
+
preshared_key: proxy["preshared-key"],
|
|
7611
|
+
reserved: proxy.reserved ? Array.isArray(proxy.reserved) ? proxy.reserved : proxy.reserved.split(/\s*\/\s*/).map((item) => item.trim()).filter((item) => item.length > 0) : void 0,
|
|
7612
|
+
dns_servers: proxy.dns ? Array.isArray(proxy.dns) ? proxy.dns : proxy.dns.split(/\s*,\s*/).map((item) => item.trim()).filter((item) => item.length > 0) : void 0,
|
|
7613
|
+
mtu: proxy.mtu,
|
|
7614
|
+
keepalive: proxy.keepalive
|
|
7615
|
+
};
|
|
7140
7616
|
}
|
|
7141
7617
|
if ([
|
|
7142
7618
|
"http",
|
|
7619
|
+
"https",
|
|
7143
7620
|
"socks5",
|
|
7144
7621
|
"ss",
|
|
7145
7622
|
"trojan",
|
|
@@ -7166,6 +7643,26 @@ function Egern_Producer() {
|
|
|
7166
7643
|
};
|
|
7167
7644
|
}
|
|
7168
7645
|
}
|
|
7646
|
+
if ([
|
|
7647
|
+
"socks5",
|
|
7648
|
+
"ss",
|
|
7649
|
+
"trojan",
|
|
7650
|
+
"vless",
|
|
7651
|
+
"vmess",
|
|
7652
|
+
"wireguard",
|
|
7653
|
+
"tuic",
|
|
7654
|
+
"hysteria2"
|
|
7655
|
+
].includes(original.type)) {
|
|
7656
|
+
if (["on", "true", true, "1", 1].includes(
|
|
7657
|
+
original["block-quic"]
|
|
7658
|
+
)) {
|
|
7659
|
+
proxy.block_quic = true;
|
|
7660
|
+
} else if (["off", "false", false, "0", 0].includes(
|
|
7661
|
+
original["block-quic"]
|
|
7662
|
+
)) {
|
|
7663
|
+
proxy.block_quic = false;
|
|
7664
|
+
}
|
|
7665
|
+
}
|
|
7169
7666
|
if (["ss"].includes(original.type) && proxy.shadow_tls && original["udp-port"] > 0 && original["udp-port"] <= 65535) {
|
|
7170
7667
|
proxy["udp_port"] = original["udp-port"];
|
|
7171
7668
|
}
|