sub-store-convert 2.21.15 → 2.21.45

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 +515 -34
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -78,7 +78,7 @@ var grammars = String.raw`
78
78
  }
79
79
  }
80
80
 
81
- start = (anytls/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) {
82
82
  return proxy;
83
83
  }
84
84
 
@@ -163,6 +163,11 @@ anytls = tag equals "anytls" address (passwordk/reuse/ip_version/underlying_prox
163
163
  proxy.type = "anytls";
164
164
  proxy.tls = true;
165
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 = "trusttunnel";
168
+ proxy.tls = true;
169
+ }
170
+
166
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)* {
167
172
  proxy.type = "direct";
168
173
  }
@@ -350,7 +355,7 @@ var grammars2 = String.raw`
350
355
  }
351
356
  }
352
357
 
353
- start = (shadowsocksr/shadowsocks/vmess/vless/trojan/https/http/socks5/hysteria2) {
358
+ start = (shadowsocksr/shadowsocks/vmess/vless/trojan/https/http/socks5/hysteria2/anytls) {
354
359
  return proxy;
355
360
  }
356
361
 
@@ -359,7 +364,7 @@ shadowsocksr = tag equals "shadowsocksr"i address method password (ssr_protocol/
359
364
  // handle ssr obfs
360
365
  proxy.obfs = obfs.type;
361
366
  }
362
- shadowsocks = tag equals "shadowsocks"i address method password (obfs_typev obfs_hostv)? (obfs_ss/obfs_host/obfs_uri/fast_open/udp_relay/udp_port/shadow_tls_version/shadow_tls_sni/shadow_tls_password/ip_mode/block_quic/others)* {
367
+ shadowsocks = tag equals "shadowsocks"i address method password (obfs_typev obfs_hostv)? (obfs_ss/obfs_host/obfs_uri/fast_open/udp_relay/udp_port/shadow_tls_version/shadow_tls_sni/shadow_tls_password/ip_mode/block_quic/udp_over_tcp/others)* {
363
368
  proxy.type = "ss";
364
369
  // handle ss obfs
365
370
  if (obfs.type == "http" || obfs.type === "tls") {
@@ -383,6 +388,10 @@ trojan = tag equals "trojan"i address password (transport/transport_host/transpo
383
388
  proxy.type = "trojan";
384
389
  handleTransport();
385
390
  }
391
+ anytls = tag equals "anytls"i address password (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/block_quic/idle_session_check_interval/idle_session_timeout/min_idle_session/max_stream_count/others)* {
392
+ proxy.type = "anytls";
393
+ handleTransport();
394
+ }
386
395
  hysteria2 = tag equals "hysteria2"i address password (tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/udp_relay/fast_open/download_bandwidth/salamander_password/ecn/ip_mode/block_quic/others)* {
387
396
  proxy.type = "hysteria2";
388
397
  }
@@ -510,6 +519,13 @@ salamander_password = comma "salamander-password" equals match:[^,]+ { proxy['ob
510
519
 
511
520
  block_quic = comma "block-quic" equals flag:bool { if(flag) proxy["block-quic"] = "on"; else proxy["block-quic"] = "off"; }
512
521
 
522
+ idle_session_check_interval = comma "idle-session-check-interval" equals match:$[0-9]+ { proxy["idle-session-check-interval"] = parseInt(match.trim()); }
523
+ idle_session_timeout = comma "idle-session-timeout" equals match:$[0-9]+ { proxy["idle-session-timeout"] = parseInt(match.trim()); }
524
+ min_idle_session = comma "min-idle-session" equals match:$[0-9]+ { proxy["min-idle-session"] = parseInt(match.trim()); }
525
+ max_stream_count = comma "max-stream-count" equals match:$[0-9]+ { proxy["max-stream-count"] = parseInt(match.trim()); }
526
+
527
+ udp_over_tcp = comma "udp-over-tcp" equals flag:bool { proxy["udp-over-tcp"] = true; proxy["udp-over-tcp-version"] = 2; }
528
+
513
529
  tag = match:[^=,]* { proxy.name = match.join("").trim(); }
514
530
  comma = _ "," _
515
531
  equals = _ "=" _
@@ -1204,7 +1220,7 @@ function URI_SS() {
1204
1220
  proxy.plugin = "v2ray-plugin";
1205
1221
  proxy["plugin-opts"] = {
1206
1222
  mode: "websocket",
1207
- host: getIfNotBlank(params2["obfs-host"]),
1223
+ host: getIfNotBlank(params2["obfs-host"]) || getIfNotBlank(params2["host"]),
1208
1224
  path: getIfNotBlank(params2.path),
1209
1225
  tls: getIfPresent(params2.tls)
1210
1226
  };
@@ -2019,9 +2035,11 @@ function Clash_All() {
2019
2035
  proxy = yaml_default.parse(line);
2020
2036
  }
2021
2037
  if (![
2038
+ "trusttunnel",
2022
2039
  "naive",
2023
2040
  "anytls",
2024
2041
  "mieru",
2042
+ "masque",
2025
2043
  "sudoku",
2026
2044
  "juicity",
2027
2045
  "ss",
@@ -2043,7 +2061,7 @@ function Clash_All() {
2043
2061
  `Clash does not support proxy with type: ${proxy.type}`
2044
2062
  );
2045
2063
  }
2046
- if (["vmess", "vless"].includes(proxy.type)) {
2064
+ if (["vmess", "vless"].includes(proxy.type) && proxy.servername) {
2047
2065
  proxy.sni = proxy.servername;
2048
2066
  delete proxy.servername;
2049
2067
  }
@@ -2165,6 +2183,14 @@ function Loon_Trojan() {
2165
2183
  const parse = (line) => getParser2().parse(line);
2166
2184
  return { name, test, parse };
2167
2185
  }
2186
+ function Loon_AnyTLS() {
2187
+ const name = "Loon AnyTLS Parser";
2188
+ const test = (line) => {
2189
+ return /^.*=\s*anytls/i.test(line.split(",")[0]);
2190
+ };
2191
+ const parse = (line) => getParser2().parse(line);
2192
+ return { name, test, parse };
2193
+ }
2168
2194
  function Loon_Hysteria2() {
2169
2195
  const name = "Loon Hysteria2 Parser";
2170
2196
  const test = (line) => {
@@ -2297,14 +2323,22 @@ function Surge_Direct() {
2297
2323
  const parse = (line) => getParser().parse(line);
2298
2324
  return { name, test, parse };
2299
2325
  }
2300
- function Surge_Anytls() {
2301
- const name = "Surge Anytls Parser";
2326
+ function Surge_AnyTLS() {
2327
+ const name = "Surge AnyTLS Parser";
2302
2328
  const test = (line) => {
2303
2329
  return /^.*=\s*anytls/.test(line.split(",")[0]);
2304
2330
  };
2305
2331
  const parse = (line) => getParser().parse(line);
2306
2332
  return { name, test, parse };
2307
2333
  }
2334
+ function Surge_TrustTunnel() {
2335
+ const name = "Surge TrustTunnel Parser";
2336
+ const test = (line) => {
2337
+ return /^.*=\s*trust-tunnel/.test(line.split(",")[0]);
2338
+ };
2339
+ const parse = (line) => getParser().parse(line);
2340
+ return { name, test, parse };
2341
+ }
2308
2342
  function Surge_SSH() {
2309
2343
  const name = "Surge SSH Parser";
2310
2344
  const test = (line) => {
@@ -2473,7 +2507,8 @@ var parsers_default = [
2473
2507
  URI_AnyTLS(),
2474
2508
  Clash_All(),
2475
2509
  Surge_Direct(),
2476
- Surge_Anytls(),
2510
+ Surge_AnyTLS(),
2511
+ Surge_TrustTunnel(),
2477
2512
  Surge_SSH(),
2478
2513
  Surge_SS(),
2479
2514
  Surge_VMess(),
@@ -2491,6 +2526,7 @@ var parsers_default = [
2491
2526
  Loon_Vless(),
2492
2527
  Loon_Hysteria2(),
2493
2528
  Loon_Trojan(),
2529
+ Loon_AnyTLS(),
2494
2530
  Loon_Http(),
2495
2531
  Loon_Socks5(),
2496
2532
  Loon_WireGuard(),
@@ -2585,6 +2621,9 @@ function Surge_Producer() {
2585
2621
  }
2586
2622
  return anytls(proxy);
2587
2623
  }
2624
+ if (opts["include-unsupported-proxy"] && proxy.type === "trusttunnel") {
2625
+ return trusttunnel(proxy);
2626
+ }
2588
2627
  throw new Error(
2589
2628
  `Platform ${targetPlatform} does not support proxy type: ${proxy.type}`
2590
2629
  );
@@ -2816,6 +2855,53 @@ function anytls(proxy) {
2816
2855
  result.appendIfPresent(`,reuse=${proxy["reuse"]}`, "reuse");
2817
2856
  return result.toString();
2818
2857
  }
2858
+ function trusttunnel(proxy) {
2859
+ const result = new Result(proxy);
2860
+ result.append(`${proxy.name}=trust-tunnel,${proxy.server},${proxy.port}`);
2861
+ result.appendIfPresent(`,username="${proxy.username}"`, "username");
2862
+ result.appendIfPresent(`,password="${proxy.password}"`, "password");
2863
+ const ip_version = ipVersions[proxy["ip-version"]] || proxy["ip-version"];
2864
+ result.appendIfPresent(`,ip-version=${ip_version}`, "ip-version");
2865
+ result.appendIfPresent(
2866
+ `,no-error-alert=${proxy["no-error-alert"]}`,
2867
+ "no-error-alert"
2868
+ );
2869
+ result.appendIfPresent(
2870
+ `,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
2871
+ "tls-fingerprint"
2872
+ );
2873
+ result.appendIfPresent(`,sni=${proxy.sni}`, "sni");
2874
+ result.appendIfPresent(
2875
+ `,skip-cert-verify=${proxy["skip-cert-verify"]}`,
2876
+ "skip-cert-verify"
2877
+ );
2878
+ result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
2879
+ result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
2880
+ result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
2881
+ result.appendIfPresent(
2882
+ `,test-timeout=${proxy["test-timeout"]}`,
2883
+ "test-timeout"
2884
+ );
2885
+ result.appendIfPresent(`,test-udp=${proxy["test-udp"]}`, "test-udp");
2886
+ result.appendIfPresent(`,hybrid=${proxy["hybrid"]}`, "hybrid");
2887
+ result.appendIfPresent(`,tos=${proxy["tos"]}`, "tos");
2888
+ result.appendIfPresent(
2889
+ `,allow-other-interface=${proxy["allow-other-interface"]}`,
2890
+ "allow-other-interface"
2891
+ );
2892
+ result.appendIfPresent(
2893
+ `,interface=${proxy["interface-name"]}`,
2894
+ "interface-name"
2895
+ );
2896
+ result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
2897
+ result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
2898
+ result.appendIfPresent(
2899
+ `,underlying-proxy=${proxy["underlying-proxy"]}`,
2900
+ "underlying-proxy"
2901
+ );
2902
+ result.appendIfPresent(`,reuse=${proxy["reuse"]}`, "reuse");
2903
+ return result.toString();
2904
+ }
2819
2905
  function vmess(proxy, includeUnsupportedProxy) {
2820
2906
  const result = new Result(proxy);
2821
2907
  result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`);
@@ -3667,6 +3753,7 @@ function ClashMeta_Producer() {
3667
3753
  "hysteria2",
3668
3754
  "juicity",
3669
3755
  "anytls",
3756
+ "trusttunnel",
3670
3757
  "naive"
3671
3758
  ].includes(proxy.type)) {
3672
3759
  delete proxy.tls;
@@ -3961,6 +4048,7 @@ function Clash_Producer() {
3961
4048
  "hysteria2",
3962
4049
  "juicity",
3963
4050
  "anytls",
4051
+ "trusttunnel",
3964
4052
  "naive"
3965
4053
  ].includes(proxy.type)) {
3966
4054
  delete proxy.tls;
@@ -4035,13 +4123,6 @@ function Stash_Producer() {
4035
4123
  "2022-blake3-aes-256-gcm"
4036
4124
  ].includes(proxy.cipher) || proxy.type === "snell" && proxy.version >= 4 || proxy.type === "vless" && proxy["reality-opts"] && !["xtls-rprx-vision"].includes(proxy.flow)) {
4037
4125
  return false;
4038
- } else if (proxy["underlying-proxy"] || proxy["dialer-proxy"]) {
4039
- app_default.error(
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`
4041
- );
4042
- return false;
4043
- } else if (["anytls"].includes(proxy.type) && !opts["include-unsupported-proxy"]) {
4044
- return false;
4045
4126
  } else if (["anytls"].includes(proxy.type) && proxy.network && (!["tcp"].includes(proxy.network) || ["tcp"].includes(proxy.network) && proxy["reality-opts"])) {
4046
4127
  return false;
4047
4128
  } else if (["xhttp"].includes(proxy.network)) {
@@ -4196,6 +4277,7 @@ function Stash_Producer() {
4196
4277
  "hysteria2",
4197
4278
  "juicity",
4198
4279
  "anytls",
4280
+ "trusttunnel",
4199
4281
  "naive"
4200
4282
  ].includes(proxy.type)) {
4201
4283
  delete proxy.tls;
@@ -4204,6 +4286,10 @@ function Stash_Producer() {
4204
4286
  proxy["server-cert-fingerprint"] = proxy["tls-fingerprint"];
4205
4287
  }
4206
4288
  delete proxy["tls-fingerprint"];
4289
+ if (proxy["underlying-proxy"]) {
4290
+ proxy["dialer-proxy"] = proxy["underlying-proxy"];
4291
+ }
4292
+ delete proxy["underlying-proxy"];
4207
4293
  if (isPresent2(proxy, "tls") && typeof proxy.tls !== "boolean") {
4208
4294
  delete proxy.tls;
4209
4295
  }
@@ -4261,6 +4347,8 @@ function Loon_Producer() {
4261
4347
  return shadowsocksr(proxy);
4262
4348
  case "trojan":
4263
4349
  return trojan2(proxy);
4350
+ case "anytls":
4351
+ return anytls2(proxy);
4264
4352
  case "vmess":
4265
4353
  return vmess2(proxy, opts["include-unsupported-proxy"]);
4266
4354
  case "vless":
@@ -4365,6 +4453,21 @@ function shadowsocks2(proxy) {
4365
4453
  );
4366
4454
  }
4367
4455
  }
4456
+ if (proxy["udp-over-tcp"]) {
4457
+ if (proxy["udp-over-tcp-version"] === 2) {
4458
+ if (proxy.plugin === "obfs") {
4459
+ app_default.error(
4460
+ `Platform ${targetPlatform3} shadowsocks udp-over-tcp does not support obfs`
4461
+ );
4462
+ } else {
4463
+ result.append(`,udp-over-tcp=true`);
4464
+ }
4465
+ } else {
4466
+ app_default.error(
4467
+ `Platform ${targetPlatform3} shadowsocks only supports udp-over-tcp-version 2`
4468
+ );
4469
+ }
4470
+ }
4368
4471
  result.appendIfPresent(`,fast-open=${proxy.tfo}`, "tfo");
4369
4472
  if (proxy["block-quic"] === "on") {
4370
4473
  result.append(",block-quic=true");
@@ -4486,6 +4589,47 @@ function trojan2(proxy) {
4486
4589
  result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
4487
4590
  return result.toString();
4488
4591
  }
4592
+ function anytls2(proxy) {
4593
+ const result = new Result(proxy);
4594
+ result.append(
4595
+ `${proxy.name}=anytls,${proxy.server},${proxy.port},"${proxy.password}"`
4596
+ );
4597
+ for (const key of [
4598
+ // 'idle-session-check-interval',
4599
+ "idle-session-timeout",
4600
+ // 'min-idle-session',
4601
+ "max-stream-count"
4602
+ ]) {
4603
+ if (isPresent2(proxy, key) && Number.isInteger(proxy[key])) {
4604
+ result.append(`,${key}=${proxy[key]}`);
4605
+ }
4606
+ }
4607
+ result.appendIfPresent(
4608
+ `,skip-cert-verify=${proxy["skip-cert-verify"]}`,
4609
+ "skip-cert-verify"
4610
+ );
4611
+ result.appendIfPresent(`,tls-name=${proxy.sni}`, "sni");
4612
+ result.appendIfPresent(
4613
+ `,tls-cert-sha256=${proxy["tls-fingerprint"]}`,
4614
+ "tls-fingerprint"
4615
+ );
4616
+ result.appendIfPresent(
4617
+ `,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
4618
+ "tls-pubkey-sha256"
4619
+ );
4620
+ result.appendIfPresent(`,fast-open=${proxy.tfo}`, "tfo");
4621
+ if (proxy["block-quic"] === "on") {
4622
+ result.append(",block-quic=true");
4623
+ } else if (proxy["block-quic"] === "off") {
4624
+ result.append(",block-quic=false");
4625
+ }
4626
+ if (proxy.udp) {
4627
+ result.append(`,udp=true`);
4628
+ }
4629
+ const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
4630
+ result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
4631
+ return result.toString();
4632
+ }
4489
4633
  function vmess2(proxy) {
4490
4634
  const isReality = !!proxy["reality-opts"];
4491
4635
  const result = new Result(proxy);
@@ -4941,12 +5085,11 @@ function URI_Producer() {
4941
5085
  }
4942
5086
  }
4943
5087
  if ([
4944
- "trojan",
4945
5088
  "tuic",
4946
5089
  "hysteria",
4947
5090
  "hysteria2",
4948
5091
  "juicity",
4949
- "anytls"
5092
+ "trusttunnel"
4950
5093
  ].includes(proxy.type)) {
4951
5094
  delete proxy.tls;
4952
5095
  }
@@ -4978,7 +5121,7 @@ function URI_Producer() {
4978
5121
  break;
4979
5122
  case "v2ray-plugin":
4980
5123
  query += encodeURIComponent(
4981
- `v2ray-plugin;obfs=${opts.mode}${opts.host ? ";obfs-host" + opts.host : ""}${opts.tls ? ";tls" : ""}`
5124
+ `v2ray-plugin;obfs=${opts.mode}${opts.host ? ";obfs-host=" + opts.host : ""}${opts.host ? ";host=" + opts.host : ""}${opts.path ? ";path=" + opts.path : ""}${opts.tls ? ";tls" : ""}`
4982
5125
  );
4983
5126
  break;
4984
5127
  case "shadow-tls":
@@ -5992,7 +6135,13 @@ function Shadowrocket_Producer() {
5992
6135
  if (opts["include-unsupported-proxy"]) return true;
5993
6136
  if (proxy.type === "snell" && proxy.version >= 4) {
5994
6137
  return false;
5995
- } else if (["mieru", "sudoku", "naive"].includes(proxy.type)) {
6138
+ } else if ([
6139
+ "trusttunnel",
6140
+ "mieru",
6141
+ "sudoku",
6142
+ "naive",
6143
+ "masque"
6144
+ ].includes(proxy.type)) {
5996
6145
  return false;
5997
6146
  } else if (proxy.encryption && proxy.encryption !== "none" && ["vless"].includes(proxy.type)) {
5998
6147
  return false;
@@ -6125,6 +6274,7 @@ function Shadowrocket_Producer() {
6125
6274
  "hysteria2",
6126
6275
  "juicity",
6127
6276
  "anytls",
6277
+ "trusttunnel",
6128
6278
  "naive"
6129
6279
  ].includes(proxy.type)) {
6130
6280
  delete proxy.tls;
@@ -6184,8 +6334,12 @@ function Surfboard_Producer() {
6184
6334
  return vmess4(proxy);
6185
6335
  case "http":
6186
6336
  return http4(proxy);
6337
+ case "snell":
6338
+ return snell2(proxy);
6187
6339
  case "socks5":
6188
6340
  return socks54(proxy);
6341
+ case "anytls":
6342
+ return anytls3(proxy);
6189
6343
  case "wireguard-surge":
6190
6344
  return wireguard3(proxy);
6191
6345
  }
@@ -6195,6 +6349,48 @@ function Surfboard_Producer() {
6195
6349
  };
6196
6350
  return { produce: produce2 };
6197
6351
  }
6352
+ function anytls3(proxy) {
6353
+ const result = new Result(proxy);
6354
+ result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`);
6355
+ result.appendIfPresent(`,password="${proxy.password}"`, "password");
6356
+ result.appendIfPresent(`,sni=${proxy.sni}`, "sni");
6357
+ result.appendIfPresent(
6358
+ `,skip-cert-verify=${proxy["skip-cert-verify"]}`,
6359
+ "skip-cert-verify"
6360
+ );
6361
+ result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
6362
+ result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
6363
+ result.appendIfPresent(`,reuse=${proxy["reuse"]}`, "reuse");
6364
+ return result.toString();
6365
+ }
6366
+ function snell2(proxy) {
6367
+ if (proxy.version > 3) {
6368
+ throw new Error(
6369
+ `Platform ${targetPlatform5} does not support snell version ${proxy.version}`
6370
+ );
6371
+ }
6372
+ const result = new Result(proxy);
6373
+ result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`);
6374
+ result.appendIfPresent(`,version=${proxy.version}`, "version");
6375
+ result.appendIfPresent(`,psk=${proxy.psk}`, "psk");
6376
+ result.appendIfPresent(
6377
+ `,obfs=${proxy["obfs-opts"]?.mode}`,
6378
+ "obfs-opts.mode"
6379
+ );
6380
+ result.appendIfPresent(
6381
+ `,obfs-host=${proxy["obfs-opts"]?.host}`,
6382
+ "obfs-opts.host"
6383
+ );
6384
+ result.appendIfPresent(
6385
+ `,obfs-uri=${proxy["obfs-opts"]?.path}`,
6386
+ "obfs-opts.path"
6387
+ );
6388
+ result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
6389
+ if (proxy.version >= 3) {
6390
+ result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
6391
+ }
6392
+ return result.toString();
6393
+ }
6198
6394
  function shadowsocks4(proxy) {
6199
6395
  const result = new Result(proxy);
6200
6396
  result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`);
@@ -6218,12 +6414,14 @@ function shadowsocks4(proxy) {
6218
6414
  "camellia-256-cfb",
6219
6415
  "salsa20",
6220
6416
  "chacha20",
6221
- "chacha20-ietf"
6417
+ "chacha20-ietf",
6418
+ "2022-blake3-aes-128-gcm",
6419
+ "2022-blake3-aes-256-gcm"
6222
6420
  ].includes(proxy.cipher)) {
6223
6421
  throw new Error(`cipher ${proxy.cipher} is not supported`);
6224
6422
  }
6225
6423
  result.append(`,encrypt-method=${proxy.cipher}`);
6226
- result.appendIfPresent(`,password=${proxy.password}`, "password");
6424
+ result.appendIfPresent(`,password="${proxy.password}"`, "password");
6227
6425
  if (isPresent2(proxy, "plugin")) {
6228
6426
  if (proxy.plugin === "obfs") {
6229
6427
  result.append(`,obfs=${proxy["plugin-opts"].mode}`);
@@ -6599,6 +6797,9 @@ var tlsParser = (proxy, parsedProxy) => {
6599
6797
  if (proxy._ech && isPlainObject(proxy._ech)) {
6600
6798
  parsedProxy.tls.ech = proxy._ech;
6601
6799
  }
6800
+ if (proxy._curve_preferences && Array.isArray(proxy._curve_preferences)) {
6801
+ parsedProxy.tls.curve_preferences = proxy._curve_preferences;
6802
+ }
6602
6803
  if (proxy["_fragment"]) parsedProxy.tls.fragment = !!proxy["_fragment"];
6603
6804
  if (proxy["_fragment_fallback_delay"])
6604
6805
  parsedProxy.tls.fragment_fallback_delay = proxy["_fragment_fallback_delay"];
@@ -7289,7 +7490,7 @@ function singbox_Producer() {
7289
7490
  // src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/egern.js
7290
7491
  function Egern_Producer() {
7291
7492
  const type = "ALL";
7292
- const produce2 = (proxies, type2, opts = {}) => {
7493
+ const produce2 = (proxies, type2) => {
7293
7494
  const list = proxies.filter((proxy) => {
7294
7495
  if (![
7295
7496
  "http",
@@ -7301,7 +7502,8 @@ function Egern_Producer() {
7301
7502
  "vless",
7302
7503
  "vmess",
7303
7504
  "tuic",
7304
- ...opts["include-unsupported-proxy"] ? ["wireguard"] : []
7505
+ "wireguard",
7506
+ "anytls"
7305
7507
  ].includes(proxy.type) || proxy.type === "ss" && (proxy.plugin === "obfs" && !["http", "tls"].includes(
7306
7508
  proxy["plugin-opts"]?.mode
7307
7509
  ) || ![
@@ -7333,7 +7535,11 @@ function Egern_Producer() {
7333
7535
  "chacha20-ietf",
7334
7536
  "2022-blake3-aes-128-gcm",
7335
7537
  "2022-blake3-aes-256-gcm"
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) {
7538
+ ].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 || typeof proxy.flow !== "undefined" && !["xtls-rprx-vision", ""].includes(
7539
+ proxy.flow
7540
+ )) || proxy.type === "tuic" && proxy.token && proxy.token.length !== 0) {
7541
+ return false;
7542
+ } else if (["anytls"].includes(proxy.type) && proxy.network && (!["tcp"].includes(proxy.network) || ["tcp"].includes(proxy.network) && proxy["reality-opts"])) {
7337
7543
  return false;
7338
7544
  } else if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
7339
7545
  return false;
@@ -7444,6 +7650,19 @@ function Egern_Producer() {
7444
7650
  skip_tls_verify: proxy["skip-cert-verify"],
7445
7651
  websocket: proxy.websocket
7446
7652
  };
7653
+ } else if (proxy.type === "anytls") {
7654
+ proxy = {
7655
+ type: "anytls",
7656
+ name: proxy.name,
7657
+ server: proxy.server,
7658
+ port: proxy.port,
7659
+ password: proxy.password,
7660
+ tfo: proxy.tfo || proxy["fast-open"],
7661
+ udp_relay: proxy.udp || proxy.udp_relay || proxy.udp_relay,
7662
+ next_hop: proxy.next_hop,
7663
+ sni: proxy.sni,
7664
+ skip_tls_verify: proxy["skip-cert-verify"]
7665
+ };
7447
7666
  } else if (proxy.type === "vmess") {
7448
7667
  let security = proxy.cipher;
7449
7668
  if (security && ![
@@ -7563,14 +7782,8 @@ function Egern_Producer() {
7563
7782
  reality
7564
7783
  }
7565
7784
  };
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
- }
7573
7785
  flow = proxy.flow;
7786
+ if (flow === "") flow = void 0;
7574
7787
  }
7575
7788
  proxy = {
7576
7789
  type: "vless",
@@ -7621,7 +7834,8 @@ function Egern_Producer() {
7621
7834
  "ss",
7622
7835
  "trojan",
7623
7836
  "vless",
7624
- "vmess"
7837
+ "vmess",
7838
+ "anytls"
7625
7839
  ].includes(original.type)) {
7626
7840
  if (isPresent2(original, "shadow-tls-password")) {
7627
7841
  if (original["shadow-tls-version"] != 3)
@@ -7651,7 +7865,8 @@ function Egern_Producer() {
7651
7865
  "vmess",
7652
7866
  "wireguard",
7653
7867
  "tuic",
7654
- "hysteria2"
7868
+ "hysteria2",
7869
+ "anytls"
7655
7870
  ].includes(original.type)) {
7656
7871
  if (["on", "true", true, "1", 1].includes(
7657
7872
  original["block-quic"]
@@ -7745,10 +7960,276 @@ var producers_default = {
7745
7960
  Egern: Egern_Producer()
7746
7961
  };
7747
7962
 
7963
+ // src/vendors/Sub-Store/backend/src/core/proxy-utils/preprocessors/index.js
7964
+ import { Base64 as Base645 } from "js-base64";
7965
+ function HTML() {
7966
+ const name = "HTML";
7967
+ const test = (raw) => /^<!DOCTYPE html>/.test(raw);
7968
+ const parse = () => "";
7969
+ return { name, test, parse };
7970
+ }
7971
+ function Base64Encoded() {
7972
+ const name = "Base64 Pre-processor";
7973
+ const keys = [
7974
+ "dm1lc3M",
7975
+ // vmess
7976
+ "c3NyOi8v",
7977
+ // ssr://
7978
+ "c29ja3M6Ly",
7979
+ // socks://
7980
+ "dHJvamFu",
7981
+ // trojan
7982
+ "c3M6Ly",
7983
+ // ss:/
7984
+ "c3NkOi8v",
7985
+ // ssd://
7986
+ "c2hhZG93",
7987
+ // shadow
7988
+ "aHR0c",
7989
+ // htt
7990
+ "dmxlc3M=",
7991
+ // vless
7992
+ "aHlzdGVyaWEy",
7993
+ // hysteria2
7994
+ "aHkyOi8v",
7995
+ // hy2://
7996
+ "d2lyZWd1YXJkOi8v",
7997
+ // wireguard://
7998
+ "d2c6Ly8=",
7999
+ // wg://
8000
+ "dHVpYzovLw=="
8001
+ // tuic://
8002
+ ];
8003
+ const test = function(raw) {
8004
+ return !/^\w+:\/\/\w+/im.test(raw) && keys.some((k) => raw.indexOf(k) !== -1);
8005
+ };
8006
+ const parse = function(raw) {
8007
+ const decoded = Base645.decode(raw);
8008
+ if (!/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(decoded)) {
8009
+ app_default.error(
8010
+ `Base64 Pre-processor error: decoded line does not start with protocol`
8011
+ );
8012
+ return raw;
8013
+ }
8014
+ return decoded;
8015
+ };
8016
+ return { name, test, parse };
8017
+ }
8018
+ function fallbackBase64Encoded() {
8019
+ const name = "Fallback Base64 Pre-processor";
8020
+ const test = function(raw) {
8021
+ return true;
8022
+ };
8023
+ const parse = function(raw) {
8024
+ const decoded = Base645.decode(raw);
8025
+ if (!/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(decoded)) {
8026
+ app_default.error(
8027
+ `Fallback Base64 Pre-processor error: decoded line does not start with protocol`
8028
+ );
8029
+ return raw;
8030
+ }
8031
+ return decoded;
8032
+ };
8033
+ return { name, test, parse };
8034
+ }
8035
+ function Clash() {
8036
+ const name = "Clash Pre-processor";
8037
+ const test = function(raw) {
8038
+ if (!/proxies/.test(raw)) return false;
8039
+ const content = safeLoad(raw);
8040
+ return content.proxies && Array.isArray(content.proxies);
8041
+ };
8042
+ const parse = function(raw, includeProxies) {
8043
+ const afterReplace = raw.replace(
8044
+ /short-id:([ \t]*[^#\n,}]*)/g,
8045
+ (matched, value) => {
8046
+ const afterTrim = value.trim();
8047
+ if (!afterTrim || afterTrim === "") {
8048
+ return 'short-id: ""';
8049
+ }
8050
+ if (/^(['"]).*\1$/.test(afterTrim)) {
8051
+ return `short-id: ${afterTrim}`;
8052
+ } else if (["null"].includes(afterTrim)) {
8053
+ return `short-id: ${afterTrim}`;
8054
+ } else {
8055
+ return `short-id: "${afterTrim}"`;
8056
+ }
8057
+ }
8058
+ );
8059
+ const {
8060
+ proxies,
8061
+ "global-client-fingerprint": globalClientFingerprint
8062
+ } = safeLoad(afterReplace);
8063
+ return (includeProxies ? "proxies:\n" : "") + proxies.map((p) => {
8064
+ if (globalClientFingerprint && ["trojan", "vmess", "vless"].includes(p.type) && !p["client-fingerprint"]) {
8065
+ p["client-fingerprint"] = globalClientFingerprint;
8066
+ }
8067
+ return `${includeProxies ? " - " : ""}${JSON.stringify(
8068
+ p
8069
+ )}
8070
+ `;
8071
+ }).join("");
8072
+ };
8073
+ return { name, test, parse };
8074
+ }
8075
+ function SSD() {
8076
+ const name = "SSD Pre-processor";
8077
+ const test = function(raw) {
8078
+ return raw.indexOf("ssd://") === 0;
8079
+ };
8080
+ const parse = function(raw) {
8081
+ const output = [];
8082
+ let ssdinfo = JSON.parse(Base645.decode(raw.split("ssd://")[1]));
8083
+ let port = ssdinfo.port;
8084
+ let method = ssdinfo.encryption;
8085
+ let password = ssdinfo.password;
8086
+ let servers = ssdinfo.servers;
8087
+ for (let i = 0; i < servers.length; i++) {
8088
+ let server = servers[i];
8089
+ method = server.encryption ? server.encryption : method;
8090
+ password = server.password ? server.password : password;
8091
+ let userinfo = Base645.encode(method + ":" + password);
8092
+ let hostname = server.server;
8093
+ port = server.port ? server.port : port;
8094
+ let tag = server.remarks ? server.remarks : i;
8095
+ let plugin = server.plugin_options ? "/?plugin=" + encodeURIComponent(
8096
+ server.plugin + ";" + server.plugin_options
8097
+ ) : "";
8098
+ output[i] = "ss://" + userinfo + "@" + hostname + ":" + port + plugin + "#" + tag;
8099
+ }
8100
+ return output.join("\n");
8101
+ };
8102
+ return { name, test, parse };
8103
+ }
8104
+ function FullConfig() {
8105
+ const name = "Full Config Preprocessor";
8106
+ const test = function(raw) {
8107
+ return /^(\[server_local\]|\[Proxy\])/gm.test(raw);
8108
+ };
8109
+ const parse = function(raw) {
8110
+ const match = raw.match(
8111
+ /^\[server_local|Proxy\]([\s\S]+?)^\[.+?\](\r?\n|$)/im
8112
+ )?.[1];
8113
+ return match || raw;
8114
+ };
8115
+ return { name, test, parse };
8116
+ }
8117
+ var preprocessors_default = [
8118
+ HTML(),
8119
+ Clash(),
8120
+ Base64Encoded(),
8121
+ SSD(),
8122
+ FullConfig(),
8123
+ fallbackBase64Encoded()
8124
+ ];
8125
+
7748
8126
  // src/index.js
7749
8127
  var parsers = parsers_default;
7750
8128
  var produce = producers_default;
8129
+ var preprocessors = preprocessors_default;
8130
+ function loadProducer(target) {
8131
+ const targetLower = target.toLowerCase();
8132
+ for (const key of Object.keys(produce)) {
8133
+ if (key.toLowerCase() === targetLower) {
8134
+ return produce[key];
8135
+ }
8136
+ }
8137
+ return null;
8138
+ }
8139
+ async function loadRemoteData(url) {
8140
+ try {
8141
+ const response = await fetch(url);
8142
+ const raw = await response.text();
8143
+ for (const preprocessor of preprocessors) {
8144
+ try {
8145
+ if (preprocessor.test(raw)) {
8146
+ return preprocessor.parse(raw).split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
8147
+ }
8148
+ } catch (error) {
8149
+ console.error("Preprocessor error:", error);
8150
+ }
8151
+ }
8152
+ return [];
8153
+ } catch (error) {
8154
+ console.error("Failed to load remote data:", error);
8155
+ return [];
8156
+ }
8157
+ }
8158
+ function tryParseProxy(parser5, line) {
8159
+ try {
8160
+ if (parser5.test(line)) {
8161
+ return parser5.parse(line);
8162
+ }
8163
+ } catch (error) {
8164
+ console.error("Parser test/parse error:", error);
8165
+ }
8166
+ return null;
8167
+ }
8168
+ function buildProxyServer(proxy, opts) {
8169
+ const server = { ...proxy, ...opts };
8170
+ if (server.name) {
8171
+ server.name = server.name.trim();
8172
+ }
8173
+ return server;
8174
+ }
8175
+ function parseProxyLines(lines, opts) {
8176
+ const proxyList = [];
8177
+ let lastParser = null;
8178
+ for (const line of lines) {
8179
+ if (line.length === 0) continue;
8180
+ let proxy = null;
8181
+ if (lastParser) {
8182
+ proxy = tryParseProxy(lastParser, line);
8183
+ if (proxy) {
8184
+ proxyList.push(buildProxyServer(proxy, opts));
8185
+ continue;
8186
+ }
8187
+ }
8188
+ for (const parser5 of parsers) {
8189
+ proxy = tryParseProxy(parser5, line);
8190
+ if (proxy) {
8191
+ proxyList.push(buildProxyServer(proxy, opts));
8192
+ lastParser = parser5;
8193
+ break;
8194
+ }
8195
+ }
8196
+ }
8197
+ return proxyList;
8198
+ }
8199
+ function produceOutput(producer, proxyList) {
8200
+ if (producer.type === "ALL") {
8201
+ return producer.produce(proxyList);
8202
+ }
8203
+ const results = [];
8204
+ for (const proxy of proxyList) {
8205
+ try {
8206
+ results.push(producer.produce(proxy, proxy.type));
8207
+ } catch (error) {
8208
+ console.error("Producer error:", error);
8209
+ }
8210
+ }
8211
+ return results.join("\n");
8212
+ }
8213
+ async function convert(url, target, opts = {}) {
8214
+ const producer = loadProducer(target);
8215
+ if (!producer) {
8216
+ throw new Error(`Unknown target: ${target}`);
8217
+ }
8218
+ const urls = url.split("|");
8219
+ const allLines = await Promise.all(urls.map(loadRemoteData));
8220
+ const lines = allLines.flat();
8221
+ const proxyList = parseProxyLines(lines, opts);
8222
+ return produceOutput(producer, proxyList);
8223
+ }
7751
8224
  export {
8225
+ buildProxyServer,
8226
+ convert,
8227
+ loadProducer,
8228
+ loadRemoteData,
8229
+ parseProxyLines,
7752
8230
  parsers,
7753
- produce
8231
+ preprocessors,
8232
+ produce,
8233
+ produceOutput,
8234
+ tryParseProxy
7754
8235
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sub-store-convert",
3
- "version": "2.21.15",
3
+ "version": "2.21.45",
4
4
  "description": "Advanced Subscription Converter for QX, Loon, Surge, Stash and ShadowRocket.",
5
5
  "type": "module",
6
6
  "module": "./index.js",