sub-store-convert 2.20.32 → 2.21.25

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.
Files changed (2) hide show
  1. package/index.js +684 -92
  2. 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/trust_tunnel/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,15 @@ 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
+ }
166
+ trust_tunnel = tag equals "trust-tunnel" address (usernamek/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)* {
167
+ proxy.type = "trust-tunnel";
168
+ proxy.tls = true;
169
+ }
170
+
159
171
  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
172
  proxy.type = "direct";
161
173
  }
@@ -288,6 +300,7 @@ shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { proxy["sh
288
300
  token = comma "token" equals match:[^,]+ { proxy.token = match.join(""); }
289
301
  alpn = comma "alpn" equals match:[^,]+ { proxy.alpn = match.join(""); }
290
302
  uuidk = comma "uuid" equals match:[^,]+ { proxy.uuid = match.join(""); }
303
+ salamander_password = comma "salamander-password" equals match:[^,]+ { proxy['obfs-password'] = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); proxy.obfs = 'salamander'; }
291
304
 
292
305
  tag = match:[^=,]* { proxy.name = match.join("").trim(); }
293
306
  comma = _ "," _
@@ -563,13 +576,13 @@ start = (trojan/shadowsocks/vmess/vless/http/socks5) {
563
576
  }
564
577
 
565
578
  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)* {
579
+ (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
580
  proxy.type = "trojan";
568
581
  handleObfs();
569
582
  }
570
583
 
571
584
  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)* {
585
+ (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
586
  if (proxy.protocol || proxy.type === "ssr") {
574
587
  proxy.type = "ssr";
575
588
  if (!proxy.protocol) {
@@ -603,7 +616,7 @@ shadowsocks = "shadowsocks" equals address
603
616
  }
604
617
 
605
618
  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)* {
619
+ (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
620
  proxy.type = "vmess";
608
621
  proxy.cipher = proxy.cipher || "none";
609
622
  if (proxy.aead === false) {
@@ -615,19 +628,19 @@ vmess = "vmess" equals address
615
628
  }
616
629
 
617
630
  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)* {
631
+ (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
632
  proxy.type = "vless";
620
633
  proxy.cipher = proxy.cipher || "none";
621
634
  handleObfs();
622
635
  }
623
636
 
624
637
  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)*{
638
+ (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
639
  proxy.type = "http";
627
640
  }
628
641
 
629
642
  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)* {
643
+ (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
644
  proxy.type = "socks5";
632
645
  }
633
646
 
@@ -706,6 +719,14 @@ obfs_uri = comma "obfs-uri" equals uri:uri { obfs.path = uri; }
706
719
  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
720
  ssr_protocol_param = comma "ssr-protocol-param" equals param:$[^=,]+ { proxy["protocol-param"] = param; }
708
721
 
722
+ reality_base64_pubkey = comma "reality-base64-pubkey" equals param:$[^=,]+ {
723
+ $set(proxy, "reality-opts.public-key", param);
724
+ }
725
+ reality_hex_shortid = comma "reality-hex-shortid" equals param:$[^=,]+ {
726
+ $set(proxy, "reality-opts.short-id", param);
727
+ }
728
+
729
+ vless_flow = comma "vless-flow" equals param:$[^=,]+ { proxy["flow"] = param; }
709
730
  server_check_url = comma "server_check_url" equals param:$[^=,]+ { proxy["test-url"] = param; }
710
731
 
711
732
  uri = $[^,]+
@@ -949,6 +970,7 @@ var yaml_default = {
949
970
  };
950
971
 
951
972
  // src/vendors/Sub-Store/backend/src/core/proxy-utils/parsers/index.js
973
+ import _ from "lodash";
952
974
  import { Base64 } from "js-base64";
953
975
  function surge_port_hopping(raw) {
954
976
  const [parts, port_hopping] = raw.match(
@@ -1074,6 +1096,88 @@ function URI_SS() {
1074
1096
  const parsed = content.match(/(\?.*)$/);
1075
1097
  query = parsed[1];
1076
1098
  }
1099
+ const params = {};
1100
+ for (const addon of query.replace(/^\?/, "").split("&")) {
1101
+ if (addon) {
1102
+ const [key, valueRaw] = addon.split("=");
1103
+ let value = valueRaw;
1104
+ value = decodeURIComponent(valueRaw);
1105
+ params[key] = value;
1106
+ }
1107
+ }
1108
+ proxy.tls = params.security && params.security !== "none";
1109
+ proxy["skip-cert-verify"] = !!params["allowInsecure"];
1110
+ proxy.sni = params["sni"] || params["peer"];
1111
+ proxy["client-fingerprint"] = params.fp;
1112
+ proxy.alpn = params.alpn ? decodeURIComponent(params.alpn).split(",") : void 0;
1113
+ if (params["ws"]) {
1114
+ proxy.network = "ws";
1115
+ _.set(proxy, "ws-opts.path", params["wspath"]);
1116
+ }
1117
+ if (params["type"]) {
1118
+ let httpupgrade;
1119
+ proxy.network = params["type"];
1120
+ if (proxy.network === "httpupgrade") {
1121
+ proxy.network = "ws";
1122
+ httpupgrade = true;
1123
+ }
1124
+ if (["grpc"].includes(proxy.network)) {
1125
+ proxy[proxy.network + "-opts"] = {
1126
+ "grpc-service-name": params["serviceName"],
1127
+ "_grpc-type": params["mode"],
1128
+ "_grpc-authority": params["authority"]
1129
+ };
1130
+ } else {
1131
+ if (params["path"]) {
1132
+ _.set(
1133
+ proxy,
1134
+ proxy.network + "-opts.path",
1135
+ decodeURIComponent(params["path"])
1136
+ );
1137
+ }
1138
+ if (params["host"]) {
1139
+ _.set(
1140
+ proxy,
1141
+ proxy.network + "-opts.headers.Host",
1142
+ decodeURIComponent(params["host"])
1143
+ );
1144
+ }
1145
+ if (httpupgrade) {
1146
+ _.set(
1147
+ proxy,
1148
+ proxy.network + "-opts.v2ray-http-upgrade",
1149
+ true
1150
+ );
1151
+ _.set(
1152
+ proxy,
1153
+ proxy.network + "-opts.v2ray-http-upgrade-fast-open",
1154
+ true
1155
+ );
1156
+ }
1157
+ }
1158
+ if (["reality"].includes(params.security)) {
1159
+ const opts = {};
1160
+ if (params.pbk) {
1161
+ opts["public-key"] = params.pbk;
1162
+ }
1163
+ if (params.sid) {
1164
+ opts["short-id"] = params.sid;
1165
+ }
1166
+ if (params.spx) {
1167
+ opts["_spider-x"] = params.spx;
1168
+ }
1169
+ if (params.mode) {
1170
+ proxy._mode = params.mode;
1171
+ }
1172
+ if (params.extra) {
1173
+ proxy._extra = params.extra;
1174
+ }
1175
+ if (Object.keys(opts).length > 0) {
1176
+ _.set(proxy, params.security + "-opts", opts);
1177
+ }
1178
+ }
1179
+ }
1180
+ proxy.udp = !!params["udp"];
1077
1181
  const serverAndPort = serverAndPortArray[1];
1078
1182
  const portIdx = serverAndPort.lastIndexOf(":");
1079
1183
  proxy.server = serverAndPort.substring(0, portIdx);
@@ -1087,54 +1191,54 @@ function URI_SS() {
1087
1191
  const shadowTlsMatch = content.match(/[?&]shadow-tls=([^&]+)/);
1088
1192
  if (pluginMatch) {
1089
1193
  const pluginInfo = ("plugin=" + decodeURIComponent(pluginMatch[1])).split(";");
1090
- const params = {};
1194
+ const params2 = {};
1091
1195
  for (const item of pluginInfo) {
1092
1196
  const [key, val] = item.split("=");
1093
- if (key) params[key] = val || true;
1197
+ if (key) params2[key] = val || true;
1094
1198
  }
1095
- switch (params.plugin) {
1199
+ switch (params2.plugin) {
1096
1200
  case "obfs-local":
1097
1201
  case "simple-obfs":
1098
1202
  proxy.plugin = "obfs";
1099
1203
  proxy["plugin-opts"] = {
1100
- mode: params.obfs,
1101
- host: getIfNotBlank(params["obfs-host"])
1204
+ mode: params2.obfs,
1205
+ host: getIfNotBlank(params2["obfs-host"])
1102
1206
  };
1103
1207
  break;
1104
1208
  case "v2ray-plugin":
1105
1209
  proxy.plugin = "v2ray-plugin";
1106
1210
  proxy["plugin-opts"] = {
1107
1211
  mode: "websocket",
1108
- host: getIfNotBlank(params["obfs-host"]),
1109
- path: getIfNotBlank(params.path),
1110
- tls: getIfPresent(params.tls)
1212
+ host: getIfNotBlank(params2["obfs-host"]),
1213
+ path: getIfNotBlank(params2.path),
1214
+ tls: getIfPresent(params2.tls)
1111
1215
  };
1112
1216
  break;
1113
1217
  case "shadow-tls": {
1114
1218
  proxy.plugin = "shadow-tls";
1115
- const version = getIfNotBlank(params["version"]);
1219
+ const version = getIfNotBlank(params2["version"]);
1116
1220
  proxy["plugin-opts"] = {
1117
- host: getIfNotBlank(params["host"]),
1118
- password: getIfNotBlank(params["password"]),
1221
+ host: getIfNotBlank(params2["host"]),
1222
+ password: getIfNotBlank(params2["password"]),
1119
1223
  version: version ? parseInt(version, 10) : void 0
1120
1224
  };
1121
1225
  break;
1122
1226
  }
1123
1227
  default:
1124
1228
  throw new Error(
1125
- `Unsupported plugin option: ${params.plugin}`
1229
+ `Unsupported plugin option: ${params2.plugin}`
1126
1230
  );
1127
1231
  }
1128
1232
  }
1129
1233
  if (shadowTlsMatch) {
1130
- const params = JSON.parse(Base64.decode(shadowTlsMatch[1]));
1131
- const version = getIfNotBlank(params["version"]);
1132
- const address = getIfNotBlank(params["address"]);
1133
- const port = getIfNotBlank(params["port"]);
1234
+ const params2 = JSON.parse(Base64.decode(shadowTlsMatch[1]));
1235
+ const version = getIfNotBlank(params2["version"]);
1236
+ const address = getIfNotBlank(params2["address"]);
1237
+ const port = getIfNotBlank(params2["port"]);
1134
1238
  proxy.plugin = "shadow-tls";
1135
1239
  proxy["plugin-opts"] = {
1136
- host: getIfNotBlank(params["host"]),
1137
- password: getIfNotBlank(params["password"]),
1240
+ host: getIfNotBlank(params2["host"]),
1241
+ password: getIfNotBlank(params2["password"]),
1138
1242
  version: version ? parseInt(version, 10) : void 0
1139
1243
  };
1140
1244
  if (address) {
@@ -1278,9 +1382,9 @@ function URI_VMess() {
1278
1382
  params[key] = value.split(",");
1279
1383
  }
1280
1384
  }
1281
- let [___, cipher, uuid2, server2, port2] = /(^[^:]+?):([^:]+?)@(.*):(\d+)$/.exec(content);
1385
+ let [___, cipher, uuid, server2, port2] = /(^[^:]+?):([^:]+?)@(.*):(\d+)$/.exec(content);
1282
1386
  params.scy = cipher;
1283
- params.id = uuid2;
1387
+ params.id = uuid;
1284
1388
  params.port = port2;
1285
1389
  params.add = server2;
1286
1390
  }
@@ -1406,17 +1510,17 @@ function URI_VLESS() {
1406
1510
  let isShadowrocket;
1407
1511
  let parsed = /^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(line);
1408
1512
  if (!parsed) {
1409
- let [_2, base64, other] = /^(.*?)(\?.*?$)/.exec(line);
1513
+ let [_3, base64, other] = /^(.*?)(\?.*?$)/.exec(line);
1410
1514
  line = `${Base64.decode(base64)}${other}`;
1411
1515
  parsed = /^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(line);
1412
1516
  isShadowrocket = true;
1413
1517
  }
1414
- let [__, uuid2, server, port, ___, addons = "", name2] = parsed;
1518
+ let [__, uuid, server, port, ___, addons = "", name2] = parsed;
1415
1519
  if (isShadowrocket) {
1416
- uuid2 = uuid2.replace(/^.*?:/g, "");
1520
+ uuid = uuid.replace(/^.*?:/g, "");
1417
1521
  }
1418
1522
  port = parseInt(`${port}`, 10);
1419
- uuid2 = decodeURIComponent(uuid2);
1523
+ uuid = decodeURIComponent(uuid);
1420
1524
  if (name2 != null) {
1421
1525
  name2 = decodeURIComponent(name2);
1422
1526
  }
@@ -1425,7 +1529,7 @@ function URI_VLESS() {
1425
1529
  name: name2,
1426
1530
  server,
1427
1531
  port,
1428
- uuid: uuid2
1532
+ uuid
1429
1533
  };
1430
1534
  const params = {};
1431
1535
  for (const addon of addons.split("&")) {
@@ -1453,6 +1557,9 @@ function URI_VLESS() {
1453
1557
  proxy["client-fingerprint"] = params.fp;
1454
1558
  proxy.alpn = params.alpn ? params.alpn.split(",") : void 0;
1455
1559
  proxy["skip-cert-verify"] = /(TRUE)|1/i.test(params.allowInsecure);
1560
+ proxy._echConfigList = getIfPresent(params.ech);
1561
+ proxy._pcs = getIfPresent(params.pcs);
1562
+ proxy._h2 = /(TRUE)|1/i.test(params.h2);
1456
1563
  if (["reality"].includes(params.security)) {
1457
1564
  const opts = {};
1458
1565
  if (params.pbk) {
@@ -1755,7 +1862,7 @@ function URI_TUIC() {
1755
1862
  line = line.split(/tuic:\/\//)[1];
1756
1863
  let [__, auth, server, port, addons = "", name2] = /^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(line);
1757
1864
  auth = decodeURIComponent(auth);
1758
- let [uuid2, ...passwordParts] = auth.split(":");
1865
+ let [uuid, ...passwordParts] = auth.split(":");
1759
1866
  let password = passwordParts.join(":");
1760
1867
  port = parseInt(`${port}`, 10);
1761
1868
  if (isNaN(port)) {
@@ -1772,7 +1879,7 @@ function URI_TUIC() {
1772
1879
  server,
1773
1880
  port,
1774
1881
  password,
1775
- uuid: uuid2
1882
+ uuid
1776
1883
  };
1777
1884
  for (const addon of addons.split("&")) {
1778
1885
  if (addon) {
@@ -1917,8 +2024,12 @@ function Clash_All() {
1917
2024
  proxy = yaml_default.parse(line);
1918
2025
  }
1919
2026
  if (![
2027
+ "trust-tunnel",
2028
+ "naive",
1920
2029
  "anytls",
1921
2030
  "mieru",
2031
+ "masque",
2032
+ "sudoku",
1922
2033
  "juicity",
1923
2034
  "ss",
1924
2035
  "ssr",
@@ -2193,6 +2304,22 @@ function Surge_Direct() {
2193
2304
  const parse = (line) => getParser().parse(line);
2194
2305
  return { name, test, parse };
2195
2306
  }
2307
+ function Surge_Anytls() {
2308
+ const name = "Surge Anytls Parser";
2309
+ const test = (line) => {
2310
+ return /^.*=\s*anytls/.test(line.split(",")[0]);
2311
+ };
2312
+ const parse = (line) => getParser().parse(line);
2313
+ return { name, test, parse };
2314
+ }
2315
+ function Surge_TrustTunnel() {
2316
+ const name = "Surge TrustTunnel Parser";
2317
+ const test = (line) => {
2318
+ return /^.*=\s*trust-tunnel/.test(line.split(",")[0]);
2319
+ };
2320
+ const parse = (line) => getParser().parse(line);
2321
+ return { name, test, parse };
2322
+ }
2196
2323
  function Surge_SSH() {
2197
2324
  const name = "Surge SSH Parser";
2198
2325
  const test = (line) => {
@@ -2248,7 +2375,7 @@ function Surge_External() {
2248
2375
  };
2249
2376
  const parse = (line) => {
2250
2377
  let parsed = /^\s*(.*?)\s*?=\s*?external\s*?,\s*(.*?)\s*$/.exec(line);
2251
- let [_2, name2, other] = parsed;
2378
+ let [_3, name2, other] = parsed;
2252
2379
  line = other;
2253
2380
  let exec = /(,|^)\s*?exec\s*?=\s*"(.*?)"\s*?(,|$)/.exec(line)?.[2];
2254
2381
  if (!exec) {
@@ -2361,6 +2488,8 @@ var parsers_default = [
2361
2488
  URI_AnyTLS(),
2362
2489
  Clash_All(),
2363
2490
  Surge_Direct(),
2491
+ Surge_Anytls(),
2492
+ Surge_TrustTunnel(),
2364
2493
  Surge_SSH(),
2365
2494
  Surge_SS(),
2366
2495
  Surge_VMess(),
@@ -2391,7 +2520,7 @@ var parsers_default = [
2391
2520
  ];
2392
2521
 
2393
2522
  // src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/utils.js
2394
- import _ from "lodash";
2523
+ import _2 from "lodash";
2395
2524
  var Result = class {
2396
2525
  constructor(proxy) {
2397
2526
  this.proxy = proxy;
@@ -2413,7 +2542,7 @@ var Result = class {
2413
2542
  }
2414
2543
  };
2415
2544
  function isPresent2(obj, attr) {
2416
- const data = _.get(obj, attr);
2545
+ const data = _2.get(obj, attr);
2417
2546
  return typeof data !== "undefined" && data !== null;
2418
2547
  }
2419
2548
 
@@ -2428,13 +2557,18 @@ var ipVersions = {
2428
2557
  };
2429
2558
  function Surge_Producer() {
2430
2559
  const produce2 = (proxy, type, opts = {}) => {
2560
+ if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
2561
+ throw new Error(
2562
+ `Platform ${targetPlatform} does not support network ${proxy.network} with http upgrade`
2563
+ );
2564
+ }
2431
2565
  proxy.name = proxy.name.replace(/=|,/g, "");
2432
2566
  if (proxy.ports) {
2433
2567
  proxy.ports = String(proxy.ports);
2434
2568
  }
2435
2569
  switch (proxy.type) {
2436
2570
  case "ss":
2437
- return shadowsocks(proxy, opts["include-unsupported-proxy"]);
2571
+ return shadowsocks(proxy);
2438
2572
  case "trojan":
2439
2573
  return trojan(proxy);
2440
2574
  case "vmess":
@@ -2452,13 +2586,24 @@ function Surge_Producer() {
2452
2586
  case "wireguard-surge":
2453
2587
  return wireguard_surge(proxy);
2454
2588
  case "hysteria2":
2455
- return hysteria2(proxy);
2589
+ return hysteria2(proxy, opts["include-unsupported-proxy"]);
2456
2590
  case "ssh":
2457
2591
  return ssh(proxy);
2458
2592
  }
2459
2593
  if (opts["include-unsupported-proxy"] && proxy.type === "wireguard") {
2460
2594
  return wireguard(proxy);
2461
2595
  }
2596
+ if (opts["include-unsupported-proxy"] && proxy.type === "anytls") {
2597
+ if (proxy.network && (!["tcp"].includes(proxy.network) || ["tcp"].includes(proxy.network) && proxy["reality-opts"])) {
2598
+ throw new Error(
2599
+ `Platform ${targetPlatform} does not support proxy type ${proxy.type} with network or reality`
2600
+ );
2601
+ }
2602
+ return anytls(proxy);
2603
+ }
2604
+ if (opts["include-unsupported-proxy"] && proxy.type === "trust-tunnel") {
2605
+ return trust_tunnel(proxy);
2606
+ }
2462
2607
  throw new Error(
2463
2608
  `Platform ${targetPlatform} does not support proxy type: ${proxy.type}`
2464
2609
  );
@@ -2544,6 +2689,7 @@ function shadowsocks(proxy) {
2544
2689
  `,interface=${proxy["interface-name"]}`,
2545
2690
  "interface-name"
2546
2691
  );
2692
+ result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
2547
2693
  if (isPresent2(proxy, "shadow-tls-password")) {
2548
2694
  result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
2549
2695
  result.appendIfPresent(
@@ -2624,6 +2770,7 @@ function trojan(proxy) {
2624
2770
  `,interface=${proxy["interface-name"]}`,
2625
2771
  "interface-name"
2626
2772
  );
2773
+ result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
2627
2774
  if (isPresent2(proxy, "shadow-tls-password")) {
2628
2775
  result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
2629
2776
  result.appendIfPresent(
@@ -2642,6 +2789,98 @@ function trojan(proxy) {
2642
2789
  );
2643
2790
  return result.toString();
2644
2791
  }
2792
+ function anytls(proxy) {
2793
+ const result = new Result(proxy);
2794
+ result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`);
2795
+ result.appendIfPresent(`,password="${proxy.password}"`, "password");
2796
+ const ip_version = ipVersions[proxy["ip-version"]] || proxy["ip-version"];
2797
+ result.appendIfPresent(`,ip-version=${ip_version}`, "ip-version");
2798
+ result.appendIfPresent(
2799
+ `,no-error-alert=${proxy["no-error-alert"]}`,
2800
+ "no-error-alert"
2801
+ );
2802
+ result.appendIfPresent(
2803
+ `,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
2804
+ "tls-fingerprint"
2805
+ );
2806
+ result.appendIfPresent(`,sni=${proxy.sni}`, "sni");
2807
+ result.appendIfPresent(
2808
+ `,skip-cert-verify=${proxy["skip-cert-verify"]}`,
2809
+ "skip-cert-verify"
2810
+ );
2811
+ result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
2812
+ result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
2813
+ result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
2814
+ result.appendIfPresent(
2815
+ `,test-timeout=${proxy["test-timeout"]}`,
2816
+ "test-timeout"
2817
+ );
2818
+ result.appendIfPresent(`,test-udp=${proxy["test-udp"]}`, "test-udp");
2819
+ result.appendIfPresent(`,hybrid=${proxy["hybrid"]}`, "hybrid");
2820
+ result.appendIfPresent(`,tos=${proxy["tos"]}`, "tos");
2821
+ result.appendIfPresent(
2822
+ `,allow-other-interface=${proxy["allow-other-interface"]}`,
2823
+ "allow-other-interface"
2824
+ );
2825
+ result.appendIfPresent(
2826
+ `,interface=${proxy["interface-name"]}`,
2827
+ "interface-name"
2828
+ );
2829
+ result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
2830
+ result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
2831
+ result.appendIfPresent(
2832
+ `,underlying-proxy=${proxy["underlying-proxy"]}`,
2833
+ "underlying-proxy"
2834
+ );
2835
+ result.appendIfPresent(`,reuse=${proxy["reuse"]}`, "reuse");
2836
+ return result.toString();
2837
+ }
2838
+ function trust_tunnel(proxy) {
2839
+ const result = new Result(proxy);
2840
+ result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`);
2841
+ result.appendIfPresent(`,password="${proxy.password}"`, "password");
2842
+ const ip_version = ipVersions[proxy["ip-version"]] || proxy["ip-version"];
2843
+ result.appendIfPresent(`,ip-version=${ip_version}`, "ip-version");
2844
+ result.appendIfPresent(
2845
+ `,no-error-alert=${proxy["no-error-alert"]}`,
2846
+ "no-error-alert"
2847
+ );
2848
+ result.appendIfPresent(
2849
+ `,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
2850
+ "tls-fingerprint"
2851
+ );
2852
+ result.appendIfPresent(`,sni=${proxy.sni}`, "sni");
2853
+ result.appendIfPresent(
2854
+ `,skip-cert-verify=${proxy["skip-cert-verify"]}`,
2855
+ "skip-cert-verify"
2856
+ );
2857
+ result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
2858
+ result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
2859
+ result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
2860
+ result.appendIfPresent(
2861
+ `,test-timeout=${proxy["test-timeout"]}`,
2862
+ "test-timeout"
2863
+ );
2864
+ result.appendIfPresent(`,test-udp=${proxy["test-udp"]}`, "test-udp");
2865
+ result.appendIfPresent(`,hybrid=${proxy["hybrid"]}`, "hybrid");
2866
+ result.appendIfPresent(`,tos=${proxy["tos"]}`, "tos");
2867
+ result.appendIfPresent(
2868
+ `,allow-other-interface=${proxy["allow-other-interface"]}`,
2869
+ "allow-other-interface"
2870
+ );
2871
+ result.appendIfPresent(
2872
+ `,interface=${proxy["interface-name"]}`,
2873
+ "interface-name"
2874
+ );
2875
+ result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
2876
+ result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
2877
+ result.appendIfPresent(
2878
+ `,underlying-proxy=${proxy["underlying-proxy"]}`,
2879
+ "underlying-proxy"
2880
+ );
2881
+ result.appendIfPresent(`,reuse=${proxy["reuse"]}`, "reuse");
2882
+ return result.toString();
2883
+ }
2645
2884
  function vmess(proxy, includeUnsupportedProxy) {
2646
2885
  const result = new Result(proxy);
2647
2886
  result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`);
@@ -2686,6 +2925,7 @@ function vmess(proxy, includeUnsupportedProxy) {
2686
2925
  `,interface=${proxy["interface-name"]}`,
2687
2926
  "interface-name"
2688
2927
  );
2928
+ result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
2689
2929
  if (isPresent2(proxy, "shadow-tls-password")) {
2690
2930
  result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
2691
2931
  result.appendIfPresent(
@@ -2745,6 +2985,7 @@ function ssh(proxy) {
2745
2985
  `,interface=${proxy["interface-name"]}`,
2746
2986
  "interface-name"
2747
2987
  );
2988
+ result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
2748
2989
  result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
2749
2990
  result.appendIfPresent(
2750
2991
  `,underlying-proxy=${proxy["underlying-proxy"]}`,
@@ -2794,6 +3035,7 @@ function http(proxy) {
2794
3035
  `,interface=${proxy["interface-name"]}`,
2795
3036
  "interface-name"
2796
3037
  );
3038
+ result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
2797
3039
  if (isPresent2(proxy, "shadow-tls-password")) {
2798
3040
  result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
2799
3041
  result.appendIfPresent(
@@ -2840,6 +3082,7 @@ function direct(proxy) {
2840
3082
  `,interface=${proxy["interface-name"]}`,
2841
3083
  "interface-name"
2842
3084
  );
3085
+ result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
2843
3086
  result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
2844
3087
  result.appendIfPresent(
2845
3088
  `,underlying-proxy=${proxy["underlying-proxy"]}`,
@@ -2888,6 +3131,7 @@ function socks5(proxy) {
2888
3131
  `,interface=${proxy["interface-name"]}`,
2889
3132
  "interface-name"
2890
3133
  );
3134
+ result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
2891
3135
  if (isPresent2(proxy, "shadow-tls-password")) {
2892
3136
  result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
2893
3137
  result.appendIfPresent(
@@ -2947,6 +3191,7 @@ function snell(proxy) {
2947
3191
  `,interface=${proxy["interface-name"]}`,
2948
3192
  "interface-name"
2949
3193
  );
3194
+ result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
2950
3195
  if (isPresent2(proxy, "shadow-tls-password")) {
2951
3196
  result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
2952
3197
  result.appendIfPresent(
@@ -3023,6 +3268,7 @@ function tuic(proxy) {
3023
3268
  `,interface=${proxy["interface-name"]}`,
3024
3269
  "interface-name"
3025
3270
  );
3271
+ result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
3026
3272
  if (isPresent2(proxy, "shadow-tls-password")) {
3027
3273
  result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
3028
3274
  result.appendIfPresent(
@@ -3083,6 +3329,7 @@ function wireguard(proxy) {
3083
3329
  `,interface=${proxy["interface-name"]}`,
3084
3330
  "interface-name"
3085
3331
  );
3332
+ result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
3086
3333
  if (isPresent2(proxy, "shadow-tls-password")) {
3087
3334
  result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
3088
3335
  result.appendIfPresent(
@@ -3166,6 +3413,7 @@ function wireguard_surge(proxy) {
3166
3413
  `,interface=${proxy["interface-name"]}`,
3167
3414
  "interface-name"
3168
3415
  );
3416
+ result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
3169
3417
  if (isPresent2(proxy, "shadow-tls-password")) {
3170
3418
  result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
3171
3419
  result.appendIfPresent(
@@ -3184,9 +3432,15 @@ function wireguard_surge(proxy) {
3184
3432
  );
3185
3433
  return result.toString();
3186
3434
  }
3187
- function hysteria2(proxy) {
3188
- if (proxy.obfs || proxy["obfs-password"]) {
3189
- throw new Error(`obfs is unsupported`);
3435
+ function hysteria2(proxy, includeUnsupportedProxy) {
3436
+ if (includeUnsupportedProxy) {
3437
+ if (proxy["obfs-password"] && proxy.obfs != "salamander") {
3438
+ throw new Error(`only salamander obfs is supported`);
3439
+ }
3440
+ } else {
3441
+ if (proxy.obfs || proxy["obfs-password"]) {
3442
+ throw new Error(`obfs is unsupported`);
3443
+ }
3190
3444
  }
3191
3445
  const result = new Result(proxy);
3192
3446
  result.append(`${proxy.name}=hysteria2,${proxy.server},${proxy.port}`);
@@ -3198,6 +3452,9 @@ function hysteria2(proxy) {
3198
3452
  `,port-hopping-interval=${proxy["hop-interval"]}`,
3199
3453
  "hop-interval"
3200
3454
  );
3455
+ if (proxy["obfs-password"] && proxy.obfs == "salamander") {
3456
+ result.append(`,salamander-password="${proxy["obfs-password"]}"`);
3457
+ }
3201
3458
  const ip_version = ipVersions[proxy["ip-version"]] || proxy["ip-version"];
3202
3459
  result.appendIfPresent(`,ip-version=${ip_version}`, "ip-version");
3203
3460
  result.appendIfPresent(
@@ -3234,6 +3491,7 @@ function hysteria2(proxy) {
3234
3491
  `,interface=${proxy["interface-name"]}`,
3235
3492
  "interface-name"
3236
3493
  );
3494
+ result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
3237
3495
  if (isPresent2(proxy, "shadow-tls-password")) {
3238
3496
  result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
3239
3497
  result.appendIfPresent(
@@ -3281,9 +3539,11 @@ function handleTransport(result, proxy, includeUnsupportedProxy) {
3281
3539
  } else {
3282
3540
  if (includeUnsupportedProxy && ["http"].includes(proxy.network)) {
3283
3541
  app_default.info(
3284
- `Include Unsupported Proxy: nework ${proxy.network} -> tcp`
3542
+ `Include Unsupported Proxy: network ${proxy.network} -> tcp`
3285
3543
  );
3286
- } else {
3544
+ } else if (["tcp"].includes(proxy.network) && proxy["reality-opts"]) {
3545
+ throw new Error(`reality is unsupported`);
3546
+ } else if (!["tcp"].includes(proxy.network)) {
3287
3547
  throw new Error(`network ${proxy.network} is unsupported`);
3288
3548
  }
3289
3549
  }
@@ -3308,7 +3568,7 @@ function ClashMeta_Producer() {
3308
3568
  if (opts["include-unsupported-proxy"]) return true;
3309
3569
  if (proxy.type === "snell" && proxy.version >= 4) {
3310
3570
  return false;
3311
- } else if (["juicity"].includes(proxy.type)) {
3571
+ } else if (["trust-tunnel", "juicity", "naive"].includes(proxy.type)) {
3312
3572
  return false;
3313
3573
  } else if (["ss"].includes(proxy.type) && ![
3314
3574
  "aes-128-ctr",
@@ -3354,6 +3614,9 @@ function ClashMeta_Producer() {
3354
3614
  }
3355
3615
  return true;
3356
3616
  }).map((proxy) => {
3617
+ if (["trojan", "vmess", "vless"].includes(proxy.type)) {
3618
+ proxy["client-fingerprint"] = proxy["client-fingerprint"] || "chrome";
3619
+ }
3357
3620
  if (proxy.type === "vmess") {
3358
3621
  if (isPresent2(proxy, "aead")) {
3359
3622
  if (proxy.aead) {
@@ -3443,7 +3706,7 @@ function ClashMeta_Producer() {
3443
3706
  const networkPath = proxy[`${proxy.network}-opts`]?.path;
3444
3707
  if (networkPath) {
3445
3708
  const reg = /^(.*?)(?:\?ed=(\d+))?$/;
3446
- const [_2, path = "", ed = ""] = reg.exec(networkPath);
3709
+ const [_3, path = "", ed = ""] = reg.exec(networkPath);
3447
3710
  proxy[`${proxy.network}-opts`].path = path;
3448
3711
  if (ed !== "") {
3449
3712
  proxy["ws-opts"]["early-data-header-name"] = "Sec-WebSocket-Protocol";
@@ -3468,7 +3731,9 @@ function ClashMeta_Producer() {
3468
3731
  "hysteria",
3469
3732
  "hysteria2",
3470
3733
  "juicity",
3471
- "anytls"
3734
+ "anytls",
3735
+ "trust-tunnel",
3736
+ "naive"
3472
3737
  ].includes(proxy.type)) {
3473
3738
  delete proxy.tls;
3474
3739
  }
@@ -3561,6 +3826,7 @@ function external(proxy) {
3561
3826
  `,no-error-alert=${proxy["no-error-alert"]}`,
3562
3827
  "no-error-alert"
3563
3828
  );
3829
+ result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
3564
3830
  if (isPresent2(proxy, "tfo")) {
3565
3831
  result.append(`,tfo=${proxy["tfo"]}`);
3566
3832
  } else if (isPresent2(proxy, "fast-open")) {
@@ -3578,6 +3844,7 @@ function mihomo(proxy, type, opts) {
3578
3844
  const external_proxy = {
3579
3845
  name: proxy.name,
3580
3846
  type: "external",
3847
+ udp: true,
3581
3848
  exec: proxy._exec || "/usr/local/bin/mihomo",
3582
3849
  "local-port": localPort,
3583
3850
  args: [
@@ -3668,6 +3935,8 @@ function Clash_Producer() {
3668
3935
  "xchacha20-ietf-poly1305"
3669
3936
  ].includes(proxy.cipher) || proxy.type === "snell" && proxy.version >= 4 || proxy.type === "vless" && (typeof proxy.flow !== "undefined" || proxy["reality-opts"])) {
3670
3937
  return false;
3938
+ } else if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
3939
+ return false;
3671
3940
  } else if (proxy["underlying-proxy"] || proxy["dialer-proxy"]) {
3672
3941
  app_default.error(
3673
3942
  `Clash \u4E0D\u652F\u6301\u524D\u7F6E\u4EE3\u7406\u5B57\u6BB5. \u5DF2\u8FC7\u6EE4\u8282\u70B9 ${proxy.name}`
@@ -3732,7 +4001,7 @@ function Clash_Producer() {
3732
4001
  const networkPath = proxy[`${proxy.network}-opts`]?.path;
3733
4002
  if (networkPath) {
3734
4003
  const reg = /^(.*?)(?:\?ed=(\d+))?$/;
3735
- const [_2, path = "", ed = ""] = reg.exec(networkPath);
4004
+ const [_3, path = "", ed = ""] = reg.exec(networkPath);
3736
4005
  proxy[`${proxy.network}-opts`].path = path;
3737
4006
  if (ed !== "") {
3738
4007
  proxy["ws-opts"]["early-data-header-name"] = "Sec-WebSocket-Protocol";
@@ -3757,7 +4026,9 @@ function Clash_Producer() {
3757
4026
  "hysteria",
3758
4027
  "hysteria2",
3759
4028
  "juicity",
3760
- "anytls"
4029
+ "anytls",
4030
+ "trust-tunnel",
4031
+ "naive"
3761
4032
  ].includes(proxy.type)) {
3762
4033
  delete proxy.tls;
3763
4034
  }
@@ -3810,7 +4081,8 @@ function Stash_Producer() {
3810
4081
  "hysteria",
3811
4082
  "hysteria2",
3812
4083
  "ssh",
3813
- "juicity"
4084
+ "juicity",
4085
+ "anytls"
3814
4086
  ].includes(proxy.type) || proxy.type === "ss" && ![
3815
4087
  "aes-128-gcm",
3816
4088
  "aes-192-gcm",
@@ -3830,10 +4102,15 @@ function Stash_Producer() {
3830
4102
  "2022-blake3-aes-256-gcm"
3831
4103
  ].includes(proxy.cipher) || proxy.type === "snell" && proxy.version >= 4 || proxy.type === "vless" && proxy["reality-opts"] && !["xtls-rprx-vision"].includes(proxy.flow)) {
3832
4104
  return false;
3833
- } else if (proxy["underlying-proxy"] || proxy["dialer-proxy"]) {
3834
- app_default.error(
3835
- `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
- );
4105
+ } else if (["anytls"].includes(proxy.type) && !opts["include-unsupported-proxy"]) {
4106
+ return false;
4107
+ } else if (["anytls"].includes(proxy.type) && proxy.network && (!["tcp"].includes(proxy.network) || ["tcp"].includes(proxy.network) && proxy["reality-opts"])) {
4108
+ return false;
4109
+ } else if (["xhttp"].includes(proxy.network)) {
4110
+ return false;
4111
+ } else if (proxy.encryption && proxy.encryption !== "none" && ["vless"].includes(proxy.type)) {
4112
+ return false;
4113
+ } else if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
3837
4114
  return false;
3838
4115
  }
3839
4116
  return true;
@@ -3955,7 +4232,7 @@ function Stash_Producer() {
3955
4232
  const networkPath = proxy[`${proxy.network}-opts`]?.path;
3956
4233
  if (networkPath) {
3957
4234
  const reg = /^(.*?)(?:\?ed=(\d+))?$/;
3958
- const [_2, path = "", ed = ""] = reg.exec(networkPath);
4235
+ const [_3, path = "", ed = ""] = reg.exec(networkPath);
3959
4236
  proxy[`${proxy.network}-opts`].path = path;
3960
4237
  if (ed !== "") {
3961
4238
  proxy["ws-opts"]["early-data-header-name"] = "Sec-WebSocket-Protocol";
@@ -3980,7 +4257,9 @@ function Stash_Producer() {
3980
4257
  "hysteria",
3981
4258
  "hysteria2",
3982
4259
  "juicity",
3983
- "anytls"
4260
+ "anytls",
4261
+ "trust-tunnel",
4262
+ "naive"
3984
4263
  ].includes(proxy.type)) {
3985
4264
  delete proxy.tls;
3986
4265
  }
@@ -4033,6 +4312,11 @@ var ipVersions3 = {
4033
4312
  };
4034
4313
  function Loon_Producer() {
4035
4314
  const produce2 = (proxy, type, opts = {}) => {
4315
+ if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
4316
+ throw new Error(
4317
+ `Platform ${targetPlatform3} does not support network ${proxy.network} with http upgrade`
4318
+ );
4319
+ }
4036
4320
  switch (proxy.type) {
4037
4321
  case "ss":
4038
4322
  return shadowsocks2(proxy);
@@ -4348,6 +4632,8 @@ function vmess2(proxy) {
4348
4632
  return result.toString();
4349
4633
  }
4350
4634
  function vless(proxy) {
4635
+ if (proxy.encryption && proxy.encryption !== "none")
4636
+ throw new Error(`VLESS encryption is not supported`);
4351
4637
  let isXtls = false;
4352
4638
  const isReality = !!proxy["reality-opts"];
4353
4639
  if (typeof proxy.flow !== "undefined") {
@@ -4615,6 +4901,18 @@ function vless2(proxy) {
4615
4901
  if (proxy["skip-cert-verify"]) {
4616
4902
  allowInsecure = `&allowInsecure=1`;
4617
4903
  }
4904
+ let h2 = "";
4905
+ if (proxy._h2) {
4906
+ h2 = `&h2=1`;
4907
+ }
4908
+ let pcs = "";
4909
+ if (proxy._pcs) {
4910
+ pcs = `&pcs=${encodeURIComponent(proxy._pcs)}`;
4911
+ }
4912
+ let ech = "";
4913
+ if (proxy._echConfigList) {
4914
+ ech = `&ech=${encodeURIComponent(proxy._echConfigList)}`;
4915
+ }
4618
4916
  let sni = "";
4619
4917
  if (proxy.sni) {
4620
4918
  sni = `&sni=${encodeURIComponent(proxy.sni)}`;
@@ -4687,7 +4985,7 @@ function vless2(proxy) {
4687
4985
  }
4688
4986
  return `vless://${proxy.uuid}@${proxy.server}:${proxy.port}?security=${encodeURIComponent(
4689
4987
  security
4690
- )}${vlessTransport}${alpn}${allowInsecure}${sni}${fp}${flow}${sid}${spx}${pbk}${mode}${extra}${pqv}${encryption}#${encodeURIComponent(
4988
+ )}${vlessTransport}${alpn}${allowInsecure}${pcs}${ech}${h2}${sni}${fp}${flow}${sid}${spx}${pbk}${mode}${extra}${pqv}${encryption}#${encodeURIComponent(
4691
4989
  proxy.name
4692
4990
  )}`;
4693
4991
  }
@@ -4705,9 +5003,15 @@ function URI_Producer() {
4705
5003
  delete proxy[key];
4706
5004
  }
4707
5005
  }
4708
- if (["trojan", "tuic", "hysteria", "hysteria2", "juicity"].includes(
4709
- proxy.type
4710
- )) {
5006
+ if ([
5007
+ "trojan",
5008
+ "tuic",
5009
+ "hysteria",
5010
+ "hysteria2",
5011
+ "juicity",
5012
+ "anytls",
5013
+ "trust-tunnel"
5014
+ ].includes(proxy.type)) {
4711
5015
  delete proxy.tls;
4712
5016
  }
4713
5017
  if (!["vmess"].includes(proxy.type) && proxy.server && isIPv6(proxy.server)) {
@@ -4726,22 +5030,23 @@ function URI_Producer() {
4726
5030
  result = `ss://${proxy.cipher?.startsWith("2022-blake3-") ? `${encodeURIComponent(
4727
5031
  proxy.cipher
4728
5032
  )}:${encodeURIComponent(proxy.password)}` : Base643.encode(userinfo)}@${proxy.server}:${proxy.port}${proxy.plugin ? "/" : ""}`;
5033
+ let query = "";
4729
5034
  if (proxy.plugin) {
4730
- result += "?plugin=";
5035
+ query += "&plugin=";
4731
5036
  const opts = proxy["plugin-opts"];
4732
5037
  switch (proxy.plugin) {
4733
5038
  case "obfs":
4734
- result += encodeURIComponent(
5039
+ query += encodeURIComponent(
4735
5040
  `simple-obfs;obfs=${opts.mode}${opts.host ? ";obfs-host=" + opts.host : ""}`
4736
5041
  );
4737
5042
  break;
4738
5043
  case "v2ray-plugin":
4739
- result += encodeURIComponent(
5044
+ query += encodeURIComponent(
4740
5045
  `v2ray-plugin;obfs=${opts.mode}${opts.host ? ";obfs-host" + opts.host : ""}${opts.tls ? ";tls" : ""}`
4741
5046
  );
4742
5047
  break;
4743
5048
  case "shadow-tls":
4744
- result += encodeURIComponent(
5049
+ query += encodeURIComponent(
4745
5050
  `shadow-tls;host=${opts.host};password=${opts.password};version=${opts.version}`
4746
5051
  );
4747
5052
  break;
@@ -4752,12 +5057,97 @@ function URI_Producer() {
4752
5057
  }
4753
5058
  }
4754
5059
  if (proxy["udp-over-tcp"]) {
4755
- result = `${result}${proxy.plugin ? "&" : "?"}uot=1`;
5060
+ query += "&uot=1";
4756
5061
  }
4757
5062
  if (proxy.tfo) {
4758
- result = `${result}${proxy.plugin || proxy["udp-over-tcp"] ? "&" : "?"}tfo=1`;
5063
+ query += "&tfo=1";
4759
5064
  }
4760
- result += `#${encodeURIComponent(proxy.name)}`;
5065
+ let ssTransport = "";
5066
+ if (proxy.network) {
5067
+ let ssType = proxy.network;
5068
+ if (proxy.network === "ws" && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
5069
+ ssType = "httpupgrade";
5070
+ }
5071
+ ssTransport = `&type=${encodeURIComponent(ssType)}`;
5072
+ if (["grpc"].includes(proxy.network)) {
5073
+ let ssTransportServiceName = proxy[`${proxy.network}-opts`]?.[`${proxy.network}-service-name`];
5074
+ let ssTransportAuthority = proxy[`${proxy.network}-opts`]?.["_grpc-authority"];
5075
+ if (ssTransportServiceName) {
5076
+ ssTransport += `&serviceName=${encodeURIComponent(
5077
+ ssTransportServiceName
5078
+ )}`;
5079
+ }
5080
+ if (ssTransportAuthority) {
5081
+ ssTransport += `&authority=${encodeURIComponent(
5082
+ ssTransportAuthority
5083
+ )}`;
5084
+ }
5085
+ ssTransport += `&mode=${encodeURIComponent(
5086
+ proxy[`${proxy.network}-opts`]?.["_grpc-type"] || "gun"
5087
+ )}`;
5088
+ }
5089
+ let ssTransportPath = proxy[`${proxy.network}-opts`]?.path;
5090
+ let ssTransportHost = proxy[`${proxy.network}-opts`]?.headers?.Host;
5091
+ if (ssTransportPath) {
5092
+ ssTransport += `&path=${encodeURIComponent(
5093
+ Array.isArray(ssTransportPath) ? ssTransportPath[0] : ssTransportPath
5094
+ )}`;
5095
+ }
5096
+ if (ssTransportHost) {
5097
+ ssTransport += `&host=${encodeURIComponent(
5098
+ Array.isArray(ssTransportHost) ? ssTransportHost[0] : ssTransportHost
5099
+ )}`;
5100
+ }
5101
+ }
5102
+ let ssFp = "";
5103
+ if (proxy["client-fingerprint"]) {
5104
+ ssFp = `&fp=${encodeURIComponent(
5105
+ proxy["client-fingerprint"]
5106
+ )}`;
5107
+ }
5108
+ let ssAlpn = "";
5109
+ if (proxy.alpn) {
5110
+ ssAlpn = `&alpn=${encodeURIComponent(
5111
+ Array.isArray(proxy.alpn) ? proxy.alpn : proxy.alpn.join(",")
5112
+ )}`;
5113
+ }
5114
+ const ssIsReality = proxy["reality-opts"];
5115
+ let ssSid = "";
5116
+ let ssPbk = "";
5117
+ let ssSpx = "";
5118
+ let ssSecurity = proxy.tls ? "&security=tls" : "";
5119
+ let ssMode = "";
5120
+ let ssExtra = "";
5121
+ if (ssIsReality) {
5122
+ ssSecurity = `&security=reality`;
5123
+ const publicKey = proxy["reality-opts"]?.["public-key"];
5124
+ if (publicKey) {
5125
+ ssPbk = `&pbk=${encodeURIComponent(publicKey)}`;
5126
+ }
5127
+ const shortId = proxy["reality-opts"]?.["short-id"];
5128
+ if (shortId) {
5129
+ ssSid = `&sid=${encodeURIComponent(shortId)}`;
5130
+ }
5131
+ const spiderX = proxy["reality-opts"]?.["_spider-x"];
5132
+ if (spiderX) {
5133
+ ssSpx = `&spx=${encodeURIComponent(spiderX)}`;
5134
+ }
5135
+ if (proxy._extra) {
5136
+ ssExtra = `&extra=${encodeURIComponent(proxy._extra)}`;
5137
+ }
5138
+ if (proxy._mode) {
5139
+ ssMode = `&mode=${encodeURIComponent(proxy._mode)}`;
5140
+ }
5141
+ }
5142
+ if (proxy.tls) {
5143
+ query += `&sni=${encodeURIComponent(
5144
+ proxy.sni || proxy.server
5145
+ )}${proxy["skip-cert-verify"] ? "&allowInsecure=1" : ""}`;
5146
+ }
5147
+ query += `${ssTransport}${ssAlpn}${ssFp}${ssSecurity}${ssSid}${ssPbk}${ssSpx}${ssMode}${ssExtra}#${encodeURIComponent(
5148
+ proxy.name
5149
+ )}`;
5150
+ result += query.replace(/^&/, "?");
4761
5151
  break;
4762
5152
  case "ssr":
4763
5153
  result = `${proxy.server}:${proxy.port}:${proxy.protocol}:${proxy.cipher}:${proxy.obfs}:${Base643.encode(proxy.password)}/`;
@@ -5189,6 +5579,11 @@ Reason: ${err}`
5189
5579
  var targetPlatform4 = "QX";
5190
5580
  function QX_Producer() {
5191
5581
  const produce2 = (proxy, type, opts = {}) => {
5582
+ if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
5583
+ throw new Error(
5584
+ `Platform ${targetPlatform4} does not support network ${proxy.network} with http upgrade`
5585
+ );
5586
+ }
5192
5587
  switch (proxy.type) {
5193
5588
  case "ss":
5194
5589
  return shadowsocks3(proxy);
@@ -5209,7 +5604,25 @@ function QX_Producer() {
5209
5604
  `Platform ${targetPlatform4} does not support proxy type: ${proxy.type}`
5210
5605
  );
5211
5606
  };
5212
- return { produce: produce2 };
5607
+ return {
5608
+ produce: (proxy, type, opts = {}) => {
5609
+ let result = produce2(proxy, type, opts);
5610
+ if (proxy.flow && proxy.flow !== "xtls-rprx-vision") {
5611
+ throw new Error(
5612
+ `Platform ${targetPlatform4} does not support flow ${proxy.flow}`
5613
+ );
5614
+ }
5615
+ if (proxy["reality-opts"]) {
5616
+ if (proxy["reality-opts"]["public-key"]) {
5617
+ result = `${result},reality-base64-pubkey=${proxy["reality-opts"]["public-key"]}`;
5618
+ }
5619
+ if (proxy["reality-opts"]["short-id"]) {
5620
+ result = `${result},reality-hex-shortid=${proxy["reality-opts"]["short-id"]}`;
5621
+ }
5622
+ }
5623
+ return result;
5624
+ }
5625
+ };
5213
5626
  }
5214
5627
  function shadowsocks3(proxy) {
5215
5628
  const result = new Result(proxy);
@@ -5354,7 +5767,7 @@ function trojan3(proxy) {
5354
5767
  `,obfs-host=${proxy["ws-opts"]?.headers?.Host}`,
5355
5768
  "ws-opts.headers.Host"
5356
5769
  );
5357
- } else {
5770
+ } else if (!["tcp"].includes(proxy.network)) {
5358
5771
  throw new Error(`network ${proxy.network} is unsupported`);
5359
5772
  }
5360
5773
  }
@@ -5416,7 +5829,9 @@ function vmess3(proxy) {
5416
5829
  else append(`,obfs=ws`);
5417
5830
  } else if (proxy.network === "http") {
5418
5831
  append(`,obfs=http`);
5419
- } else {
5832
+ } else if (["tcp"].includes(proxy.network)) {
5833
+ if (proxy.tls) append(`,obfs=over-tls`);
5834
+ } else if (!["tcp"].includes(proxy.network)) {
5420
5835
  throw new Error(`network ${proxy.network} is unsupported`);
5421
5836
  }
5422
5837
  let transportPath = proxy[`${proxy.network}-opts`]?.path;
@@ -5471,9 +5886,8 @@ function vmess3(proxy) {
5471
5886
  return result.toString();
5472
5887
  }
5473
5888
  function vless3(proxy) {
5474
- if (typeof proxy.flow !== "undefined" || proxy["reality-opts"]) {
5475
- throw new Error(`VLESS XTLS/REALITY is not supported`);
5476
- }
5889
+ if (proxy.encryption && proxy.encryption !== "none")
5890
+ throw new Error(`VLESS encryption is not supported`);
5477
5891
  const result = new Result(proxy);
5478
5892
  const append = result.append.bind(result);
5479
5893
  const appendIfPresent = result.appendIfPresent.bind(result);
@@ -5532,6 +5946,7 @@ function vless3(proxy) {
5532
5946
  );
5533
5947
  appendIfPresent(`,tls-host=${proxy.sni}`, "sni");
5534
5948
  }
5949
+ appendIfPresent(`,vless-flow=${proxy.flow}`, "flow");
5535
5950
  appendIfPresent(`,fast-open=${proxy.tfo}`, "tfo");
5536
5951
  appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
5537
5952
  result.appendIfPresent(
@@ -5641,7 +6056,19 @@ function Shadowrocket_Producer() {
5641
6056
  if (opts["include-unsupported-proxy"]) return true;
5642
6057
  if (proxy.type === "snell" && proxy.version >= 4) {
5643
6058
  return false;
5644
- } else if (["mieru"].includes(proxy.type)) {
6059
+ } else if ([
6060
+ "trust-tunnel",
6061
+ "mieru",
6062
+ "sudoku",
6063
+ "naive",
6064
+ "masque"
6065
+ ].includes(proxy.type)) {
6066
+ return false;
6067
+ } else if (proxy.encryption && proxy.encryption !== "none" && ["vless"].includes(proxy.type)) {
6068
+ return false;
6069
+ } else if (["anytls"].includes(proxy.type) && proxy.network && (!["tcp"].includes(proxy.network) || ["tcp"].includes(proxy.network) && proxy["reality-opts"])) {
6070
+ return false;
6071
+ } else if (["xhttp"].includes(proxy.network)) {
5645
6072
  return false;
5646
6073
  }
5647
6074
  return true;
@@ -5717,10 +6144,6 @@ function Shadowrocket_Producer() {
5717
6144
  delete proxy["shadow-tls-sni"];
5718
6145
  delete proxy["shadow-tls-version"];
5719
6146
  }
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
6147
  }
5725
6148
  if (["vmess", "vless"].includes(proxy.type) && proxy.network === "http") {
5726
6149
  let httpPath = proxy["http-opts"]?.path;
@@ -5746,7 +6169,7 @@ function Shadowrocket_Producer() {
5746
6169
  const networkPath = proxy[`${proxy.network}-opts`]?.path;
5747
6170
  if (networkPath) {
5748
6171
  const reg = /^(.*?)(?:\?ed=(\d+))?$/;
5749
- const [_2, path = "", ed = ""] = reg.exec(networkPath);
6172
+ const [_3, path = "", ed = ""] = reg.exec(networkPath);
5750
6173
  proxy[`${proxy.network}-opts`].path = path;
5751
6174
  if (ed !== "") {
5752
6175
  proxy["ws-opts"]["early-data-header-name"] = "Sec-WebSocket-Protocol";
@@ -5771,7 +6194,9 @@ function Shadowrocket_Producer() {
5771
6194
  "hysteria",
5772
6195
  "hysteria2",
5773
6196
  "juicity",
5774
- "anytls"
6197
+ "anytls",
6198
+ "trust-tunnel",
6199
+ "naive"
5775
6200
  ].includes(proxy.type)) {
5776
6201
  delete proxy.tls;
5777
6202
  }
@@ -5815,6 +6240,11 @@ function Shadowrocket_Producer() {
5815
6240
  var targetPlatform5 = "Surfboard";
5816
6241
  function Surfboard_Producer() {
5817
6242
  const produce2 = (proxy) => {
6243
+ if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
6244
+ throw new Error(
6245
+ `Platform ${targetPlatform5} does not support network ${proxy.network} with http upgrade`
6246
+ );
6247
+ }
5818
6248
  proxy.name = proxy.name.replace(/=|,/g, "");
5819
6249
  switch (proxy.type) {
5820
6250
  case "ss":
@@ -5827,6 +6257,8 @@ function Surfboard_Producer() {
5827
6257
  return http4(proxy);
5828
6258
  case "socks5":
5829
6259
  return socks54(proxy);
6260
+ case "anytls":
6261
+ return anytls2(proxy);
5830
6262
  case "wireguard-surge":
5831
6263
  return wireguard3(proxy);
5832
6264
  }
@@ -5836,6 +6268,20 @@ function Surfboard_Producer() {
5836
6268
  };
5837
6269
  return { produce: produce2 };
5838
6270
  }
6271
+ function anytls2(proxy) {
6272
+ const result = new Result(proxy);
6273
+ result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`);
6274
+ result.appendIfPresent(`,password="${proxy.password}"`, "password");
6275
+ result.appendIfPresent(`,sni=${proxy.sni}`, "sni");
6276
+ result.appendIfPresent(
6277
+ `,skip-cert-verify=${proxy["skip-cert-verify"]}`,
6278
+ "skip-cert-verify"
6279
+ );
6280
+ result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
6281
+ result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
6282
+ result.appendIfPresent(`,reuse=${proxy["reuse"]}`, "reuse");
6283
+ return result.toString();
6284
+ }
5839
6285
  function shadowsocks4(proxy) {
5840
6286
  const result = new Result(proxy);
5841
6287
  result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`);
@@ -5859,12 +6305,14 @@ function shadowsocks4(proxy) {
5859
6305
  "camellia-256-cfb",
5860
6306
  "salsa20",
5861
6307
  "chacha20",
5862
- "chacha20-ietf"
6308
+ "chacha20-ietf",
6309
+ "2022-blake3-aes-128-gcm",
6310
+ "2022-blake3-aes-256-gcm"
5863
6311
  ].includes(proxy.cipher)) {
5864
6312
  throw new Error(`cipher ${proxy.cipher} is not supported`);
5865
6313
  }
5866
6314
  result.append(`,encrypt-method=${proxy.cipher}`);
5867
- result.appendIfPresent(`,password=${proxy.password}`, "password");
6315
+ result.appendIfPresent(`,password="${proxy.password}"`, "password");
5868
6316
  if (isPresent2(proxy, "plugin")) {
5869
6317
  if (proxy.plugin === "obfs") {
5870
6318
  result.append(`,obfs=${proxy["plugin-opts"].mode}`);
@@ -5977,7 +6425,9 @@ function handleTransport2(result, proxy) {
5977
6425
  }
5978
6426
  }
5979
6427
  }
5980
- } else {
6428
+ } else if (["tcp"].includes(proxy.network) && proxy["reality-opts"]) {
6429
+ throw new Error(`reality is unsupported`);
6430
+ } else if (!["tcp"].includes(proxy.network)) {
5981
6431
  throw new Error(`network ${proxy.network} is unsupported`);
5982
6432
  }
5983
6433
  }
@@ -6099,7 +6549,7 @@ var wsParser = (proxy, parsedProxy) => {
6099
6549
  transport.path = `${proxy["ws-path"]}`;
6100
6550
  if (transport.path) {
6101
6551
  const reg = /^(.*?)(?:\?ed=(\d+))?$/;
6102
- const [_2, path = "", ed = ""] = reg.exec(transport.path);
6552
+ const [_3, path = "", ed = ""] = reg.exec(transport.path);
6103
6553
  transport.path = path;
6104
6554
  if (ed !== "") {
6105
6555
  transport.early_data_header_name = "Sec-WebSocket-Protocol";
@@ -6235,11 +6685,30 @@ var tlsParser = (proxy, parsedProxy) => {
6235
6685
  enabled: true,
6236
6686
  fingerprint: proxy["client-fingerprint"]
6237
6687
  };
6688
+ if (proxy._ech && isPlainObject(proxy._ech)) {
6689
+ parsedProxy.tls.ech = proxy._ech;
6690
+ }
6691
+ if (proxy._curve_preferences && Array.isArray(proxy._curve_preferences)) {
6692
+ parsedProxy.tls.curve_preferences = proxy._curve_preferences;
6693
+ }
6238
6694
  if (proxy["_fragment"]) parsedProxy.tls.fragment = !!proxy["_fragment"];
6239
6695
  if (proxy["_fragment_fallback_delay"])
6240
6696
  parsedProxy.tls.fragment_fallback_delay = proxy["_fragment_fallback_delay"];
6241
6697
  if (proxy["_record_fragment"])
6242
6698
  parsedProxy.tls.record_fragment = !!proxy["_record_fragment"];
6699
+ if (proxy["_certificate"])
6700
+ parsedProxy.tls.certificate = proxy["_certificate"];
6701
+ if (proxy["_certificate_path"])
6702
+ parsedProxy.tls.certificate_path = proxy["_certificate_path"];
6703
+ if (proxy["_certificate_public_key_sha256"])
6704
+ parsedProxy.tls.certificate_public_key_sha256 = proxy["_certificate_public_key_sha256"];
6705
+ if (proxy["_client_certificate"])
6706
+ parsedProxy.tls.client_certificate = proxy["_client_certificate"];
6707
+ if (proxy["_client_certificate_path"])
6708
+ parsedProxy.tls.client_certificate_path = proxy["_client_certificate_path"];
6709
+ if (proxy["_client_key"]) parsedProxy.tls.client_key = proxy["_client_key"];
6710
+ if (proxy["_client_key_path"])
6711
+ parsedProxy.tls.client_key_path = proxy["_client_key_path"];
6243
6712
  if (!parsedProxy.tls.enabled) delete parsedProxy.tls;
6244
6713
  };
6245
6714
  var sshParser = (proxy = {}) => {
@@ -6306,7 +6775,6 @@ var socks5Parser = (proxy = {}) => {
6306
6775
  type: "socks",
6307
6776
  server: proxy.server,
6308
6777
  server_port: parseInt(`${proxy.port}`, 10),
6309
- password: proxy.password,
6310
6778
  version: "5"
6311
6779
  };
6312
6780
  if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
@@ -6314,7 +6782,12 @@ var socks5Parser = (proxy = {}) => {
6314
6782
  if (proxy.username) parsedProxy.username = proxy.username;
6315
6783
  if (proxy.password) parsedProxy.password = proxy.password;
6316
6784
  if (proxy.uot) parsedProxy.udp_over_tcp = true;
6317
- if (proxy["udp-over-tcp"]) parsedProxy.udp_over_tcp = true;
6785
+ if (proxy["udp-over-tcp"]) {
6786
+ parsedProxy.udp_over_tcp = {
6787
+ enabled: true,
6788
+ version: !proxy["udp-over-tcp-version"] || proxy["udp-over-tcp-version"] === 1 ? 1 : 2
6789
+ };
6790
+ }
6318
6791
  if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
6319
6792
  networkParser(proxy, parsedProxy);
6320
6793
  tfoParser(proxy, parsedProxy);
@@ -6549,6 +7022,50 @@ var trojanParser = (proxy = {}) => {
6549
7022
  ipVersionParser(proxy, parsedProxy);
6550
7023
  return parsedProxy;
6551
7024
  };
7025
+ var naiveParser = (proxy = {}) => {
7026
+ const parsedProxy = {
7027
+ tag: proxy.name,
7028
+ type: "naive",
7029
+ server: proxy.server,
7030
+ server_port: parseInt(`${proxy.port}`, 10),
7031
+ tls: { enabled: true, server_name: proxy.server, insecure: false }
7032
+ };
7033
+ if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
7034
+ throw "invalid port";
7035
+ if (proxy.username) parsedProxy.username = proxy.username;
7036
+ if (proxy.password) parsedProxy.password = proxy.password;
7037
+ if (proxy.uot) parsedProxy.udp_over_tcp = true;
7038
+ if (proxy["udp-over-tcp"]) {
7039
+ parsedProxy.udp_over_tcp = {
7040
+ enabled: true,
7041
+ version: !proxy["udp-over-tcp-version"] || proxy["udp-over-tcp-version"] === 1 ? 1 : 2
7042
+ };
7043
+ }
7044
+ const insecure_concurrency = parseInt(
7045
+ `${proxy["insecure-concurrency"]}`,
7046
+ 10
7047
+ );
7048
+ if (Number.isInteger(insecure_concurrency) && insecure_concurrency >= 0)
7049
+ parsedProxy.insecure_concurrency = insecure_concurrency;
7050
+ if (proxy["extra-headers"])
7051
+ parsedProxy.extra_headers = proxy["extra-headers"];
7052
+ if (proxy.quic) parsedProxy.quic = !!proxy.quic;
7053
+ if (proxy["quic-congestion-control"])
7054
+ parsedProxy.quic_congestion_control = proxy["quic-congestion-control"];
7055
+ if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
7056
+ tfoParser(proxy, parsedProxy);
7057
+ detourParser(proxy, parsedProxy);
7058
+ tlsParser(proxy, parsedProxy);
7059
+ smuxParser(proxy.smux, parsedProxy);
7060
+ ipVersionParser(proxy, parsedProxy);
7061
+ if (parsedProxy.tls?.insecure) {
7062
+ app_default.info(
7063
+ `Platform sing-box: insecure is not supported on naive outbound`
7064
+ );
7065
+ delete parsedProxy.tls.insecure;
7066
+ }
7067
+ return parsedProxy;
7068
+ };
6552
7069
  var hysteriaParser = (proxy = {}) => {
6553
7070
  const parsedProxy = {
6554
7071
  tag: proxy.name,
@@ -6785,7 +7302,7 @@ function singbox_Producer() {
6785
7302
  }
6786
7303
  break;
6787
7304
  case "vmess":
6788
- if (!proxy.network || ["ws", "grpc", "h2", "http"].includes(
7305
+ if (!proxy.network || ["tcp", "ws", "grpc", "h2", "http"].includes(
6789
7306
  proxy.network
6790
7307
  )) {
6791
7308
  list.push(vmessParser(proxy));
@@ -6796,6 +7313,11 @@ function singbox_Producer() {
6796
7313
  }
6797
7314
  break;
6798
7315
  case "vless":
7316
+ if (proxy.encryption && proxy.encryption !== "none") {
7317
+ throw new Error(
7318
+ `VLESS encryption is not supported`
7319
+ );
7320
+ }
6799
7321
  if (!proxy.flow || ["xtls-rprx-vision"].includes(proxy.flow)) {
6800
7322
  list.push(vlessParser(proxy));
6801
7323
  } else {
@@ -6813,6 +7335,9 @@ function singbox_Producer() {
6813
7335
  );
6814
7336
  }
6815
7337
  break;
7338
+ case "naive":
7339
+ list.push(naiveParser(proxy));
7340
+ break;
6816
7341
  case "hysteria":
6817
7342
  list.push(hysteriaParser(proxy));
6818
7343
  break;
@@ -6860,13 +7385,18 @@ function Egern_Producer() {
6860
7385
  const list = proxies.filter((proxy) => {
6861
7386
  if (![
6862
7387
  "http",
7388
+ "https",
6863
7389
  "socks5",
6864
7390
  "ss",
6865
7391
  "trojan",
6866
7392
  "hysteria2",
6867
7393
  "vless",
6868
7394
  "vmess",
6869
- "tuic"
7395
+ "tuic",
7396
+ "wireguard"
7397
+ // ...(opts['include-unsupported-proxy']
7398
+ // ? ['wireguard']
7399
+ // : []),
6870
7400
  ].includes(proxy.type) || proxy.type === "ss" && (proxy.plugin === "obfs" && !["http", "tls"].includes(
6871
7401
  proxy["plugin-opts"]?.mode
6872
7402
  ) || ![
@@ -6898,7 +7428,9 @@ function Egern_Producer() {
6898
7428
  "chacha20-ietf",
6899
7429
  "2022-blake3-aes-128-gcm",
6900
7430
  "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" && (!opts["include-unsupported-proxy"] && (typeof proxy.flow !== "undefined" || proxy["reality-opts"]) || opts["include-unsupported-proxy"] && typeof proxy.flow !== "undefined" && proxy.flow !== "xtls-rprx-vision" || !["http", "ws", "tcp"].includes(proxy.network) && proxy.network) || proxy.type === "tuic" && proxy.token && proxy.token.length !== 0) {
7431
+ ].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) {
7432
+ return false;
7433
+ } else if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
6902
7434
  return false;
6903
7435
  }
6904
7436
  return true;
@@ -6911,14 +7443,18 @@ function Egern_Producer() {
6911
7443
  const prev_hop = proxy.prev_hop || proxy["underlying-proxy"] || proxy["dialer-proxy"] || proxy.detour;
6912
7444
  if (proxy.type === "http") {
6913
7445
  proxy = {
6914
- type: "http",
7446
+ type: proxy.tls ? "https" : "http",
6915
7447
  name: proxy.name,
6916
7448
  server: proxy.server,
6917
7449
  port: proxy.port,
6918
7450
  username: proxy.username,
6919
7451
  password: proxy.password,
6920
7452
  tfo: proxy.tfo || proxy["fast-open"],
6921
- next_hop: proxy.next_hop
7453
+ next_hop: proxy.next_hop,
7454
+ ...proxy.tls ? {
7455
+ sni: proxy.sni,
7456
+ skip_tls_verify: proxy["skip-cert-verify"]
7457
+ } : {}
6922
7458
  };
6923
7459
  } else if (proxy.type === "socks5") {
6924
7460
  proxy = {
@@ -7081,6 +7617,8 @@ function Egern_Producer() {
7081
7617
  // skip_tls_verify: proxy['skip-cert-verify'],
7082
7618
  };
7083
7619
  } else if (proxy.type === "vless") {
7620
+ if (proxy.encryption && proxy.encryption !== "none")
7621
+ throw new Error(`VLESS encryption is not supported`);
7084
7622
  if (proxy.network === "ws") {
7085
7623
  proxy.transport = {
7086
7624
  [proxy.tls ? "wss" : "ws"]: {
@@ -7120,6 +7658,13 @@ function Egern_Producer() {
7120
7658
  reality
7121
7659
  }
7122
7660
  };
7661
+ if (typeof proxy.flow !== "undefined") {
7662
+ if (!["xtls-rprx-vision"].includes(proxy.flow)) {
7663
+ throw new Error(
7664
+ `VLESS flow(${proxy.flow}) is not supported`
7665
+ );
7666
+ }
7667
+ }
7123
7668
  flow = proxy.flow;
7124
7669
  }
7125
7670
  proxy = {
@@ -7137,9 +7682,36 @@ function Egern_Producer() {
7137
7682
  // sni: proxy.sni,
7138
7683
  // skip_tls_verify: proxy['skip-cert-verify'],
7139
7684
  };
7685
+ } else if (proxy.type === "wireguard") {
7686
+ if (Array.isArray(proxy.peers) && proxy.peers.length > 0) {
7687
+ proxy.server = proxy.peers[0].server;
7688
+ proxy.port = proxy.peers[0].port;
7689
+ proxy.ip = proxy.peers[0].ip;
7690
+ proxy.ipv6 = proxy.peers[0].ipv6;
7691
+ proxy["public-key"] = proxy.peers[0]["public-key"];
7692
+ proxy["preshared-key"] = proxy.peers[0]["pre-shared-key"];
7693
+ proxy["allowed-ips"] = proxy.peers[0]["allowed-ips"];
7694
+ proxy.reserved = proxy.peers[0].reserved;
7695
+ }
7696
+ proxy = {
7697
+ type: "wireguard",
7698
+ name: proxy.name,
7699
+ local_ipv4: proxy.ip,
7700
+ local_ipv6: proxy.ipv6,
7701
+ server: proxy.server,
7702
+ port: proxy.port,
7703
+ private_key: proxy["private-key"],
7704
+ peer_public_key: proxy["public-key"],
7705
+ preshared_key: proxy["preshared-key"],
7706
+ 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,
7707
+ 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,
7708
+ mtu: proxy.mtu,
7709
+ keepalive: proxy.keepalive
7710
+ };
7140
7711
  }
7141
7712
  if ([
7142
7713
  "http",
7714
+ "https",
7143
7715
  "socks5",
7144
7716
  "ss",
7145
7717
  "trojan",
@@ -7166,6 +7738,26 @@ function Egern_Producer() {
7166
7738
  };
7167
7739
  }
7168
7740
  }
7741
+ if ([
7742
+ "socks5",
7743
+ "ss",
7744
+ "trojan",
7745
+ "vless",
7746
+ "vmess",
7747
+ "wireguard",
7748
+ "tuic",
7749
+ "hysteria2"
7750
+ ].includes(original.type)) {
7751
+ if (["on", "true", true, "1", 1].includes(
7752
+ original["block-quic"]
7753
+ )) {
7754
+ proxy.block_quic = true;
7755
+ } else if (["off", "false", false, "0", 0].includes(
7756
+ original["block-quic"]
7757
+ )) {
7758
+ proxy.block_quic = false;
7759
+ }
7760
+ }
7169
7761
  if (["ss"].includes(original.type) && proxy.shadow_tls && original["udp-port"] > 0 && original["udp-port"] <= 65535) {
7170
7762
  proxy["udp_port"] = original["udp-port"];
7171
7763
  }