sub-store-convert 2.20.30-b → 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 +585 -84
- 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",
|
|
@@ -3349,9 +3544,14 @@ function ClashMeta_Producer() {
|
|
|
3349
3544
|
return false;
|
|
3350
3545
|
} else if (["anytls"].includes(proxy.type) && proxy.network && (!["tcp"].includes(proxy.network) || ["tcp"].includes(proxy.network) && proxy["reality-opts"])) {
|
|
3351
3546
|
return false;
|
|
3547
|
+
} else if (["xhttp"].includes(proxy.network)) {
|
|
3548
|
+
return false;
|
|
3352
3549
|
}
|
|
3353
3550
|
return true;
|
|
3354
3551
|
}).map((proxy) => {
|
|
3552
|
+
if (["trojan", "vmess", "vless"].includes(proxy.type)) {
|
|
3553
|
+
proxy["client-fingerprint"] = proxy["client-fingerprint"] || "chrome";
|
|
3554
|
+
}
|
|
3355
3555
|
if (proxy.type === "vmess") {
|
|
3356
3556
|
if (isPresent2(proxy, "aead")) {
|
|
3357
3557
|
if (proxy.aead) {
|
|
@@ -3441,7 +3641,7 @@ function ClashMeta_Producer() {
|
|
|
3441
3641
|
const networkPath = proxy[`${proxy.network}-opts`]?.path;
|
|
3442
3642
|
if (networkPath) {
|
|
3443
3643
|
const reg = /^(.*?)(?:\?ed=(\d+))?$/;
|
|
3444
|
-
const [
|
|
3644
|
+
const [_3, path = "", ed = ""] = reg.exec(networkPath);
|
|
3445
3645
|
proxy[`${proxy.network}-opts`].path = path;
|
|
3446
3646
|
if (ed !== "") {
|
|
3447
3647
|
proxy["ws-opts"]["early-data-header-name"] = "Sec-WebSocket-Protocol";
|
|
@@ -3466,7 +3666,8 @@ function ClashMeta_Producer() {
|
|
|
3466
3666
|
"hysteria",
|
|
3467
3667
|
"hysteria2",
|
|
3468
3668
|
"juicity",
|
|
3469
|
-
"anytls"
|
|
3669
|
+
"anytls",
|
|
3670
|
+
"naive"
|
|
3470
3671
|
].includes(proxy.type)) {
|
|
3471
3672
|
delete proxy.tls;
|
|
3472
3673
|
}
|
|
@@ -3559,6 +3760,7 @@ function external(proxy) {
|
|
|
3559
3760
|
`,no-error-alert=${proxy["no-error-alert"]}`,
|
|
3560
3761
|
"no-error-alert"
|
|
3561
3762
|
);
|
|
3763
|
+
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
3562
3764
|
if (isPresent2(proxy, "tfo")) {
|
|
3563
3765
|
result.append(`,tfo=${proxy["tfo"]}`);
|
|
3564
3766
|
} else if (isPresent2(proxy, "fast-open")) {
|
|
@@ -3576,6 +3778,7 @@ function mihomo(proxy, type, opts) {
|
|
|
3576
3778
|
const external_proxy = {
|
|
3577
3779
|
name: proxy.name,
|
|
3578
3780
|
type: "external",
|
|
3781
|
+
udp: true,
|
|
3579
3782
|
exec: proxy._exec || "/usr/local/bin/mihomo",
|
|
3580
3783
|
"local-port": localPort,
|
|
3581
3784
|
args: [
|
|
@@ -3666,6 +3869,8 @@ function Clash_Producer() {
|
|
|
3666
3869
|
"xchacha20-ietf-poly1305"
|
|
3667
3870
|
].includes(proxy.cipher) || proxy.type === "snell" && proxy.version >= 4 || proxy.type === "vless" && (typeof proxy.flow !== "undefined" || proxy["reality-opts"])) {
|
|
3668
3871
|
return false;
|
|
3872
|
+
} else if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
3873
|
+
return false;
|
|
3669
3874
|
} else if (proxy["underlying-proxy"] || proxy["dialer-proxy"]) {
|
|
3670
3875
|
app_default.error(
|
|
3671
3876
|
`Clash \u4E0D\u652F\u6301\u524D\u7F6E\u4EE3\u7406\u5B57\u6BB5. \u5DF2\u8FC7\u6EE4\u8282\u70B9 ${proxy.name}`
|
|
@@ -3730,7 +3935,7 @@ function Clash_Producer() {
|
|
|
3730
3935
|
const networkPath = proxy[`${proxy.network}-opts`]?.path;
|
|
3731
3936
|
if (networkPath) {
|
|
3732
3937
|
const reg = /^(.*?)(?:\?ed=(\d+))?$/;
|
|
3733
|
-
const [
|
|
3938
|
+
const [_3, path = "", ed = ""] = reg.exec(networkPath);
|
|
3734
3939
|
proxy[`${proxy.network}-opts`].path = path;
|
|
3735
3940
|
if (ed !== "") {
|
|
3736
3941
|
proxy["ws-opts"]["early-data-header-name"] = "Sec-WebSocket-Protocol";
|
|
@@ -3755,7 +3960,8 @@ function Clash_Producer() {
|
|
|
3755
3960
|
"hysteria",
|
|
3756
3961
|
"hysteria2",
|
|
3757
3962
|
"juicity",
|
|
3758
|
-
"anytls"
|
|
3963
|
+
"anytls",
|
|
3964
|
+
"naive"
|
|
3759
3965
|
].includes(proxy.type)) {
|
|
3760
3966
|
delete proxy.tls;
|
|
3761
3967
|
}
|
|
@@ -3808,7 +4014,8 @@ function Stash_Producer() {
|
|
|
3808
4014
|
"hysteria",
|
|
3809
4015
|
"hysteria2",
|
|
3810
4016
|
"ssh",
|
|
3811
|
-
"juicity"
|
|
4017
|
+
"juicity",
|
|
4018
|
+
"anytls"
|
|
3812
4019
|
].includes(proxy.type) || proxy.type === "ss" && ![
|
|
3813
4020
|
"aes-128-gcm",
|
|
3814
4021
|
"aes-192-gcm",
|
|
@@ -3833,6 +4040,16 @@ function Stash_Producer() {
|
|
|
3833
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`
|
|
3834
4041
|
);
|
|
3835
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;
|
|
3836
4053
|
}
|
|
3837
4054
|
return true;
|
|
3838
4055
|
}).map((proxy) => {
|
|
@@ -3953,7 +4170,7 @@ function Stash_Producer() {
|
|
|
3953
4170
|
const networkPath = proxy[`${proxy.network}-opts`]?.path;
|
|
3954
4171
|
if (networkPath) {
|
|
3955
4172
|
const reg = /^(.*?)(?:\?ed=(\d+))?$/;
|
|
3956
|
-
const [
|
|
4173
|
+
const [_3, path = "", ed = ""] = reg.exec(networkPath);
|
|
3957
4174
|
proxy[`${proxy.network}-opts`].path = path;
|
|
3958
4175
|
if (ed !== "") {
|
|
3959
4176
|
proxy["ws-opts"]["early-data-header-name"] = "Sec-WebSocket-Protocol";
|
|
@@ -3978,7 +4195,8 @@ function Stash_Producer() {
|
|
|
3978
4195
|
"hysteria",
|
|
3979
4196
|
"hysteria2",
|
|
3980
4197
|
"juicity",
|
|
3981
|
-
"anytls"
|
|
4198
|
+
"anytls",
|
|
4199
|
+
"naive"
|
|
3982
4200
|
].includes(proxy.type)) {
|
|
3983
4201
|
delete proxy.tls;
|
|
3984
4202
|
}
|
|
@@ -4031,6 +4249,11 @@ var ipVersions3 = {
|
|
|
4031
4249
|
};
|
|
4032
4250
|
function Loon_Producer() {
|
|
4033
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
|
+
}
|
|
4034
4257
|
switch (proxy.type) {
|
|
4035
4258
|
case "ss":
|
|
4036
4259
|
return shadowsocks2(proxy);
|
|
@@ -4346,6 +4569,8 @@ function vmess2(proxy) {
|
|
|
4346
4569
|
return result.toString();
|
|
4347
4570
|
}
|
|
4348
4571
|
function vless(proxy) {
|
|
4572
|
+
if (proxy.encryption && proxy.encryption !== "none")
|
|
4573
|
+
throw new Error(`VLESS encryption is not supported`);
|
|
4349
4574
|
let isXtls = false;
|
|
4350
4575
|
const isReality = !!proxy["reality-opts"];
|
|
4351
4576
|
if (typeof proxy.flow !== "undefined") {
|
|
@@ -4613,6 +4838,18 @@ function vless2(proxy) {
|
|
|
4613
4838
|
if (proxy["skip-cert-verify"]) {
|
|
4614
4839
|
allowInsecure = `&allowInsecure=1`;
|
|
4615
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
|
+
}
|
|
4616
4853
|
let sni = "";
|
|
4617
4854
|
if (proxy.sni) {
|
|
4618
4855
|
sni = `&sni=${encodeURIComponent(proxy.sni)}`;
|
|
@@ -4685,7 +4922,7 @@ function vless2(proxy) {
|
|
|
4685
4922
|
}
|
|
4686
4923
|
return `vless://${proxy.uuid}@${proxy.server}:${proxy.port}?security=${encodeURIComponent(
|
|
4687
4924
|
security
|
|
4688
|
-
)}${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(
|
|
4689
4926
|
proxy.name
|
|
4690
4927
|
)}`;
|
|
4691
4928
|
}
|
|
@@ -4703,9 +4940,14 @@ function URI_Producer() {
|
|
|
4703
4940
|
delete proxy[key];
|
|
4704
4941
|
}
|
|
4705
4942
|
}
|
|
4706
|
-
if ([
|
|
4707
|
-
|
|
4708
|
-
|
|
4943
|
+
if ([
|
|
4944
|
+
"trojan",
|
|
4945
|
+
"tuic",
|
|
4946
|
+
"hysteria",
|
|
4947
|
+
"hysteria2",
|
|
4948
|
+
"juicity",
|
|
4949
|
+
"anytls"
|
|
4950
|
+
].includes(proxy.type)) {
|
|
4709
4951
|
delete proxy.tls;
|
|
4710
4952
|
}
|
|
4711
4953
|
if (!["vmess"].includes(proxy.type) && proxy.server && isIPv6(proxy.server)) {
|
|
@@ -4724,22 +4966,23 @@ function URI_Producer() {
|
|
|
4724
4966
|
result = `ss://${proxy.cipher?.startsWith("2022-blake3-") ? `${encodeURIComponent(
|
|
4725
4967
|
proxy.cipher
|
|
4726
4968
|
)}:${encodeURIComponent(proxy.password)}` : Base643.encode(userinfo)}@${proxy.server}:${proxy.port}${proxy.plugin ? "/" : ""}`;
|
|
4969
|
+
let query = "";
|
|
4727
4970
|
if (proxy.plugin) {
|
|
4728
|
-
|
|
4971
|
+
query += "&plugin=";
|
|
4729
4972
|
const opts = proxy["plugin-opts"];
|
|
4730
4973
|
switch (proxy.plugin) {
|
|
4731
4974
|
case "obfs":
|
|
4732
|
-
|
|
4975
|
+
query += encodeURIComponent(
|
|
4733
4976
|
`simple-obfs;obfs=${opts.mode}${opts.host ? ";obfs-host=" + opts.host : ""}`
|
|
4734
4977
|
);
|
|
4735
4978
|
break;
|
|
4736
4979
|
case "v2ray-plugin":
|
|
4737
|
-
|
|
4980
|
+
query += encodeURIComponent(
|
|
4738
4981
|
`v2ray-plugin;obfs=${opts.mode}${opts.host ? ";obfs-host" + opts.host : ""}${opts.tls ? ";tls" : ""}`
|
|
4739
4982
|
);
|
|
4740
4983
|
break;
|
|
4741
4984
|
case "shadow-tls":
|
|
4742
|
-
|
|
4985
|
+
query += encodeURIComponent(
|
|
4743
4986
|
`shadow-tls;host=${opts.host};password=${opts.password};version=${opts.version}`
|
|
4744
4987
|
);
|
|
4745
4988
|
break;
|
|
@@ -4750,12 +4993,97 @@ function URI_Producer() {
|
|
|
4750
4993
|
}
|
|
4751
4994
|
}
|
|
4752
4995
|
if (proxy["udp-over-tcp"]) {
|
|
4753
|
-
|
|
4996
|
+
query += "&uot=1";
|
|
4754
4997
|
}
|
|
4755
4998
|
if (proxy.tfo) {
|
|
4756
|
-
|
|
4999
|
+
query += "&tfo=1";
|
|
4757
5000
|
}
|
|
4758
|
-
|
|
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
|
+
}
|
|
5077
|
+
}
|
|
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(/^&/, "?");
|
|
4759
5087
|
break;
|
|
4760
5088
|
case "ssr":
|
|
4761
5089
|
result = `${proxy.server}:${proxy.port}:${proxy.protocol}:${proxy.cipher}:${proxy.obfs}:${Base643.encode(proxy.password)}/`;
|
|
@@ -5187,6 +5515,11 @@ Reason: ${err}`
|
|
|
5187
5515
|
var targetPlatform4 = "QX";
|
|
5188
5516
|
function QX_Producer() {
|
|
5189
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
|
+
}
|
|
5190
5523
|
switch (proxy.type) {
|
|
5191
5524
|
case "ss":
|
|
5192
5525
|
return shadowsocks3(proxy);
|
|
@@ -5207,7 +5540,25 @@ function QX_Producer() {
|
|
|
5207
5540
|
`Platform ${targetPlatform4} does not support proxy type: ${proxy.type}`
|
|
5208
5541
|
);
|
|
5209
5542
|
};
|
|
5210
|
-
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
|
+
};
|
|
5211
5562
|
}
|
|
5212
5563
|
function shadowsocks3(proxy) {
|
|
5213
5564
|
const result = new Result(proxy);
|
|
@@ -5352,7 +5703,7 @@ function trojan3(proxy) {
|
|
|
5352
5703
|
`,obfs-host=${proxy["ws-opts"]?.headers?.Host}`,
|
|
5353
5704
|
"ws-opts.headers.Host"
|
|
5354
5705
|
);
|
|
5355
|
-
} else {
|
|
5706
|
+
} else if (!["tcp"].includes(proxy.network)) {
|
|
5356
5707
|
throw new Error(`network ${proxy.network} is unsupported`);
|
|
5357
5708
|
}
|
|
5358
5709
|
}
|
|
@@ -5414,7 +5765,9 @@ function vmess3(proxy) {
|
|
|
5414
5765
|
else append(`,obfs=ws`);
|
|
5415
5766
|
} else if (proxy.network === "http") {
|
|
5416
5767
|
append(`,obfs=http`);
|
|
5417
|
-
} else {
|
|
5768
|
+
} else if (["tcp"].includes(proxy.network)) {
|
|
5769
|
+
if (proxy.tls) append(`,obfs=over-tls`);
|
|
5770
|
+
} else if (!["tcp"].includes(proxy.network)) {
|
|
5418
5771
|
throw new Error(`network ${proxy.network} is unsupported`);
|
|
5419
5772
|
}
|
|
5420
5773
|
let transportPath = proxy[`${proxy.network}-opts`]?.path;
|
|
@@ -5469,9 +5822,8 @@ function vmess3(proxy) {
|
|
|
5469
5822
|
return result.toString();
|
|
5470
5823
|
}
|
|
5471
5824
|
function vless3(proxy) {
|
|
5472
|
-
if (
|
|
5473
|
-
throw new Error(`VLESS
|
|
5474
|
-
}
|
|
5825
|
+
if (proxy.encryption && proxy.encryption !== "none")
|
|
5826
|
+
throw new Error(`VLESS encryption is not supported`);
|
|
5475
5827
|
const result = new Result(proxy);
|
|
5476
5828
|
const append = result.append.bind(result);
|
|
5477
5829
|
const appendIfPresent = result.appendIfPresent.bind(result);
|
|
@@ -5530,6 +5882,7 @@ function vless3(proxy) {
|
|
|
5530
5882
|
);
|
|
5531
5883
|
appendIfPresent(`,tls-host=${proxy.sni}`, "sni");
|
|
5532
5884
|
}
|
|
5885
|
+
appendIfPresent(`,vless-flow=${proxy.flow}`, "flow");
|
|
5533
5886
|
appendIfPresent(`,fast-open=${proxy.tfo}`, "tfo");
|
|
5534
5887
|
appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
5535
5888
|
result.appendIfPresent(
|
|
@@ -5639,7 +5992,13 @@ function Shadowrocket_Producer() {
|
|
|
5639
5992
|
if (opts["include-unsupported-proxy"]) return true;
|
|
5640
5993
|
if (proxy.type === "snell" && proxy.version >= 4) {
|
|
5641
5994
|
return false;
|
|
5642
|
-
} 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)) {
|
|
5643
6002
|
return false;
|
|
5644
6003
|
}
|
|
5645
6004
|
return true;
|
|
@@ -5715,8 +6074,6 @@ function Shadowrocket_Producer() {
|
|
|
5715
6074
|
delete proxy["shadow-tls-sni"];
|
|
5716
6075
|
delete proxy["shadow-tls-version"];
|
|
5717
6076
|
}
|
|
5718
|
-
} else if (["anytls"].includes(proxy.type) && proxy.network && (!["tcp"].includes(proxy.network) || ["tcp"].includes(proxy.network) && proxy["reality-opts"])) {
|
|
5719
|
-
return false;
|
|
5720
6077
|
}
|
|
5721
6078
|
if (["vmess", "vless"].includes(proxy.type) && proxy.network === "http") {
|
|
5722
6079
|
let httpPath = proxy["http-opts"]?.path;
|
|
@@ -5742,7 +6099,7 @@ function Shadowrocket_Producer() {
|
|
|
5742
6099
|
const networkPath = proxy[`${proxy.network}-opts`]?.path;
|
|
5743
6100
|
if (networkPath) {
|
|
5744
6101
|
const reg = /^(.*?)(?:\?ed=(\d+))?$/;
|
|
5745
|
-
const [
|
|
6102
|
+
const [_3, path = "", ed = ""] = reg.exec(networkPath);
|
|
5746
6103
|
proxy[`${proxy.network}-opts`].path = path;
|
|
5747
6104
|
if (ed !== "") {
|
|
5748
6105
|
proxy["ws-opts"]["early-data-header-name"] = "Sec-WebSocket-Protocol";
|
|
@@ -5767,7 +6124,8 @@ function Shadowrocket_Producer() {
|
|
|
5767
6124
|
"hysteria",
|
|
5768
6125
|
"hysteria2",
|
|
5769
6126
|
"juicity",
|
|
5770
|
-
"anytls"
|
|
6127
|
+
"anytls",
|
|
6128
|
+
"naive"
|
|
5771
6129
|
].includes(proxy.type)) {
|
|
5772
6130
|
delete proxy.tls;
|
|
5773
6131
|
}
|
|
@@ -5811,6 +6169,11 @@ function Shadowrocket_Producer() {
|
|
|
5811
6169
|
var targetPlatform5 = "Surfboard";
|
|
5812
6170
|
function Surfboard_Producer() {
|
|
5813
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
|
+
}
|
|
5814
6177
|
proxy.name = proxy.name.replace(/=|,/g, "");
|
|
5815
6178
|
switch (proxy.type) {
|
|
5816
6179
|
case "ss":
|
|
@@ -5973,7 +6336,9 @@ function handleTransport2(result, proxy) {
|
|
|
5973
6336
|
}
|
|
5974
6337
|
}
|
|
5975
6338
|
}
|
|
5976
|
-
} 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)) {
|
|
5977
6342
|
throw new Error(`network ${proxy.network} is unsupported`);
|
|
5978
6343
|
}
|
|
5979
6344
|
}
|
|
@@ -6095,7 +6460,7 @@ var wsParser = (proxy, parsedProxy) => {
|
|
|
6095
6460
|
transport.path = `${proxy["ws-path"]}`;
|
|
6096
6461
|
if (transport.path) {
|
|
6097
6462
|
const reg = /^(.*?)(?:\?ed=(\d+))?$/;
|
|
6098
|
-
const [
|
|
6463
|
+
const [_3, path = "", ed = ""] = reg.exec(transport.path);
|
|
6099
6464
|
transport.path = path;
|
|
6100
6465
|
if (ed !== "") {
|
|
6101
6466
|
transport.early_data_header_name = "Sec-WebSocket-Protocol";
|
|
@@ -6231,11 +6596,27 @@ var tlsParser = (proxy, parsedProxy) => {
|
|
|
6231
6596
|
enabled: true,
|
|
6232
6597
|
fingerprint: proxy["client-fingerprint"]
|
|
6233
6598
|
};
|
|
6599
|
+
if (proxy._ech && isPlainObject(proxy._ech)) {
|
|
6600
|
+
parsedProxy.tls.ech = proxy._ech;
|
|
6601
|
+
}
|
|
6234
6602
|
if (proxy["_fragment"]) parsedProxy.tls.fragment = !!proxy["_fragment"];
|
|
6235
6603
|
if (proxy["_fragment_fallback_delay"])
|
|
6236
6604
|
parsedProxy.tls.fragment_fallback_delay = proxy["_fragment_fallback_delay"];
|
|
6237
6605
|
if (proxy["_record_fragment"])
|
|
6238
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"];
|
|
6239
6620
|
if (!parsedProxy.tls.enabled) delete parsedProxy.tls;
|
|
6240
6621
|
};
|
|
6241
6622
|
var sshParser = (proxy = {}) => {
|
|
@@ -6302,7 +6683,6 @@ var socks5Parser = (proxy = {}) => {
|
|
|
6302
6683
|
type: "socks",
|
|
6303
6684
|
server: proxy.server,
|
|
6304
6685
|
server_port: parseInt(`${proxy.port}`, 10),
|
|
6305
|
-
password: proxy.password,
|
|
6306
6686
|
version: "5"
|
|
6307
6687
|
};
|
|
6308
6688
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
@@ -6310,7 +6690,12 @@ var socks5Parser = (proxy = {}) => {
|
|
|
6310
6690
|
if (proxy.username) parsedProxy.username = proxy.username;
|
|
6311
6691
|
if (proxy.password) parsedProxy.password = proxy.password;
|
|
6312
6692
|
if (proxy.uot) parsedProxy.udp_over_tcp = true;
|
|
6313
|
-
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
|
+
}
|
|
6314
6699
|
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
6315
6700
|
networkParser(proxy, parsedProxy);
|
|
6316
6701
|
tfoParser(proxy, parsedProxy);
|
|
@@ -6545,6 +6930,50 @@ var trojanParser = (proxy = {}) => {
|
|
|
6545
6930
|
ipVersionParser(proxy, parsedProxy);
|
|
6546
6931
|
return parsedProxy;
|
|
6547
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
|
+
};
|
|
6548
6977
|
var hysteriaParser = (proxy = {}) => {
|
|
6549
6978
|
const parsedProxy = {
|
|
6550
6979
|
tag: proxy.name,
|
|
@@ -6781,7 +7210,7 @@ function singbox_Producer() {
|
|
|
6781
7210
|
}
|
|
6782
7211
|
break;
|
|
6783
7212
|
case "vmess":
|
|
6784
|
-
if (!proxy.network || ["ws", "grpc", "h2", "http"].includes(
|
|
7213
|
+
if (!proxy.network || ["tcp", "ws", "grpc", "h2", "http"].includes(
|
|
6785
7214
|
proxy.network
|
|
6786
7215
|
)) {
|
|
6787
7216
|
list.push(vmessParser(proxy));
|
|
@@ -6792,6 +7221,11 @@ function singbox_Producer() {
|
|
|
6792
7221
|
}
|
|
6793
7222
|
break;
|
|
6794
7223
|
case "vless":
|
|
7224
|
+
if (proxy.encryption && proxy.encryption !== "none") {
|
|
7225
|
+
throw new Error(
|
|
7226
|
+
`VLESS encryption is not supported`
|
|
7227
|
+
);
|
|
7228
|
+
}
|
|
6795
7229
|
if (!proxy.flow || ["xtls-rprx-vision"].includes(proxy.flow)) {
|
|
6796
7230
|
list.push(vlessParser(proxy));
|
|
6797
7231
|
} else {
|
|
@@ -6809,6 +7243,9 @@ function singbox_Producer() {
|
|
|
6809
7243
|
);
|
|
6810
7244
|
}
|
|
6811
7245
|
break;
|
|
7246
|
+
case "naive":
|
|
7247
|
+
list.push(naiveParser(proxy));
|
|
7248
|
+
break;
|
|
6812
7249
|
case "hysteria":
|
|
6813
7250
|
list.push(hysteriaParser(proxy));
|
|
6814
7251
|
break;
|
|
@@ -6856,13 +7293,15 @@ function Egern_Producer() {
|
|
|
6856
7293
|
const list = proxies.filter((proxy) => {
|
|
6857
7294
|
if (![
|
|
6858
7295
|
"http",
|
|
7296
|
+
"https",
|
|
6859
7297
|
"socks5",
|
|
6860
7298
|
"ss",
|
|
6861
7299
|
"trojan",
|
|
6862
7300
|
"hysteria2",
|
|
6863
7301
|
"vless",
|
|
6864
7302
|
"vmess",
|
|
6865
|
-
"tuic"
|
|
7303
|
+
"tuic",
|
|
7304
|
+
...opts["include-unsupported-proxy"] ? ["wireguard"] : []
|
|
6866
7305
|
].includes(proxy.type) || proxy.type === "ss" && (proxy.plugin === "obfs" && !["http", "tls"].includes(
|
|
6867
7306
|
proxy["plugin-opts"]?.mode
|
|
6868
7307
|
) || ![
|
|
@@ -6894,7 +7333,9 @@ function Egern_Producer() {
|
|
|
6894
7333
|
"chacha20-ietf",
|
|
6895
7334
|
"2022-blake3-aes-128-gcm",
|
|
6896
7335
|
"2022-blake3-aes-256-gcm"
|
|
6897
|
-
].includes(proxy.cipher)) || proxy.type === "vmess" && !["http", "ws", "tcp"].includes(proxy.network) && proxy.network || proxy.type === "trojan" && !["http", "ws", "tcp"].includes(proxy.network) && proxy.network || proxy.type === "vless" &&
|
|
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"]) {
|
|
6898
7339
|
return false;
|
|
6899
7340
|
}
|
|
6900
7341
|
return true;
|
|
@@ -6907,14 +7348,18 @@ function Egern_Producer() {
|
|
|
6907
7348
|
const prev_hop = proxy.prev_hop || proxy["underlying-proxy"] || proxy["dialer-proxy"] || proxy.detour;
|
|
6908
7349
|
if (proxy.type === "http") {
|
|
6909
7350
|
proxy = {
|
|
6910
|
-
type: "http",
|
|
7351
|
+
type: proxy.tls ? "https" : "http",
|
|
6911
7352
|
name: proxy.name,
|
|
6912
7353
|
server: proxy.server,
|
|
6913
7354
|
port: proxy.port,
|
|
6914
7355
|
username: proxy.username,
|
|
6915
7356
|
password: proxy.password,
|
|
6916
7357
|
tfo: proxy.tfo || proxy["fast-open"],
|
|
6917
|
-
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
|
+
} : {}
|
|
6918
7363
|
};
|
|
6919
7364
|
} else if (proxy.type === "socks5") {
|
|
6920
7365
|
proxy = {
|
|
@@ -7077,6 +7522,8 @@ function Egern_Producer() {
|
|
|
7077
7522
|
// skip_tls_verify: proxy['skip-cert-verify'],
|
|
7078
7523
|
};
|
|
7079
7524
|
} else if (proxy.type === "vless") {
|
|
7525
|
+
if (proxy.encryption && proxy.encryption !== "none")
|
|
7526
|
+
throw new Error(`VLESS encryption is not supported`);
|
|
7080
7527
|
if (proxy.network === "ws") {
|
|
7081
7528
|
proxy.transport = {
|
|
7082
7529
|
[proxy.tls ? "wss" : "ws"]: {
|
|
@@ -7116,6 +7563,13 @@ function Egern_Producer() {
|
|
|
7116
7563
|
reality
|
|
7117
7564
|
}
|
|
7118
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
|
+
}
|
|
7119
7573
|
flow = proxy.flow;
|
|
7120
7574
|
}
|
|
7121
7575
|
proxy = {
|
|
@@ -7133,9 +7587,36 @@ function Egern_Producer() {
|
|
|
7133
7587
|
// sni: proxy.sni,
|
|
7134
7588
|
// skip_tls_verify: proxy['skip-cert-verify'],
|
|
7135
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
|
+
};
|
|
7136
7616
|
}
|
|
7137
7617
|
if ([
|
|
7138
7618
|
"http",
|
|
7619
|
+
"https",
|
|
7139
7620
|
"socks5",
|
|
7140
7621
|
"ss",
|
|
7141
7622
|
"trojan",
|
|
@@ -7162,6 +7643,26 @@ function Egern_Producer() {
|
|
|
7162
7643
|
};
|
|
7163
7644
|
}
|
|
7164
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
|
+
}
|
|
7165
7666
|
if (["ss"].includes(original.type) && proxy.shadow_tls && original["udp-port"] > 0 && original["udp-port"] <= 65535) {
|
|
7166
7667
|
proxy["udp_port"] = original["udp-port"];
|
|
7167
7668
|
}
|