sub-store-convert 2.44.22 → 2.44.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.
- package/index.js +332 -30
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -2206,13 +2206,26 @@ var grammars = String.raw`
|
|
|
2206
2206
|
|
|
2207
2207
|
return trimmed;
|
|
2208
2208
|
}
|
|
2209
|
+
function isQuotedEscape(text, index) {
|
|
2210
|
+
return text[index] === "\\" &&
|
|
2211
|
+
(text[index + 1] === '"' || text[index + 1] === "\\");
|
|
2212
|
+
}
|
|
2213
|
+
function unescapeQuotedValue(value) {
|
|
2214
|
+
return value.replace(/\\(["\\])/g, "$1");
|
|
2215
|
+
}
|
|
2209
2216
|
function readQuotedHeaderKey(text, start) {
|
|
2210
2217
|
const quote = text[start];
|
|
2218
|
+
const withEscapes = proxy.type === "vless" && quote === '"';
|
|
2211
2219
|
let index = start + 1;
|
|
2212
2220
|
let hasKey = false;
|
|
2213
2221
|
|
|
2214
2222
|
while (index < text.length) {
|
|
2215
2223
|
const char = text[index];
|
|
2224
|
+
if (withEscapes && isQuotedEscape(text, index)) {
|
|
2225
|
+
hasKey = true;
|
|
2226
|
+
index += 2;
|
|
2227
|
+
continue;
|
|
2228
|
+
}
|
|
2216
2229
|
if (char === quote) {
|
|
2217
2230
|
return hasKey ? index + 1 : -1;
|
|
2218
2231
|
}
|
|
@@ -2373,6 +2386,7 @@ var grammars = String.raw`
|
|
|
2373
2386
|
}
|
|
2374
2387
|
function readQuotedHeadersEnd(text, start, pairSeparator) {
|
|
2375
2388
|
const quote = text[start];
|
|
2389
|
+
const withEscapes = proxy.type === "vless";
|
|
2376
2390
|
let index = start + 1;
|
|
2377
2391
|
let innerQuote = "";
|
|
2378
2392
|
let quoteRole = "";
|
|
@@ -2380,6 +2394,10 @@ var grammars = String.raw`
|
|
|
2380
2394
|
|
|
2381
2395
|
while (index < text.length) {
|
|
2382
2396
|
const char = text[index];
|
|
2397
|
+
if (withEscapes && isQuotedEscape(text, index)) {
|
|
2398
|
+
index += 2;
|
|
2399
|
+
continue;
|
|
2400
|
+
}
|
|
2383
2401
|
|
|
2384
2402
|
if (innerQuote) {
|
|
2385
2403
|
if (char === innerQuote) {
|
|
@@ -2439,7 +2457,7 @@ var grammars = String.raw`
|
|
|
2439
2457
|
|
|
2440
2458
|
return readUnquotedHeadersEnd(text, start, pairSeparator);
|
|
2441
2459
|
}
|
|
2442
|
-
function splitHeaders(headers, pairSeparator) {
|
|
2460
|
+
function splitHeaders(headers, pairSeparator, withEscapes) {
|
|
2443
2461
|
const result = [];
|
|
2444
2462
|
let start = 0;
|
|
2445
2463
|
let quote = "";
|
|
@@ -2448,6 +2466,10 @@ var grammars = String.raw`
|
|
|
2448
2466
|
|
|
2449
2467
|
for (let index = 0; index < headers.length; index++) {
|
|
2450
2468
|
const char = headers[index];
|
|
2469
|
+
if (withEscapes && isQuotedEscape(headers, index)) {
|
|
2470
|
+
index++;
|
|
2471
|
+
continue;
|
|
2472
|
+
}
|
|
2451
2473
|
|
|
2452
2474
|
if (quote) {
|
|
2453
2475
|
if (char === quote) {
|
|
@@ -2485,7 +2507,10 @@ var grammars = String.raw`
|
|
|
2485
2507
|
}
|
|
2486
2508
|
function parseHeaders(headers, pairSeparator) {
|
|
2487
2509
|
const result = {};
|
|
2488
|
-
|
|
2510
|
+
const trimmed = headers.trim();
|
|
2511
|
+
const content = stripOuterHeadersQuotes(trimmed);
|
|
2512
|
+
const withEscapes = proxy.type === "vless" && content !== trimmed;
|
|
2513
|
+
splitHeaders(content, pairSeparator, withEscapes).forEach((pair) => {
|
|
2489
2514
|
const index = findHeaderSeparator(pair);
|
|
2490
2515
|
if (index === -1) return;
|
|
2491
2516
|
|
|
@@ -2493,7 +2518,7 @@ var grammars = String.raw`
|
|
|
2493
2518
|
const value = stripQuotes(pair.slice(index + 1));
|
|
2494
2519
|
|
|
2495
2520
|
if (key) {
|
|
2496
|
-
result[key] = value;
|
|
2521
|
+
result[key] = withEscapes ? unescapeQuotedValue(value) : value;
|
|
2497
2522
|
}
|
|
2498
2523
|
});
|
|
2499
2524
|
return result;
|
|
@@ -2557,8 +2582,7 @@ vmess = tag equals "vmess" address (vmess_uuid/vmess_aead/ws/ws_http_upgrade/ws_
|
|
|
2557
2582
|
handleWebsocket();
|
|
2558
2583
|
handleShadowTLS();
|
|
2559
2584
|
}
|
|
2560
|
-
vless = tag equals
|
|
2561
|
-
proxy.type = "vless";
|
|
2585
|
+
vless = tag equals vless_address (vless_username/vless_option/reality_option/ws/ws_http_upgrade/ws_path/ws_headers/grpc/grpc_service_name/grpc_mode/grpc_authority/xhttp/xhttp_headers/xhttp_option/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls/sni/cert_verify_name/alpn/tls_fingerprint/client_fingerprint/tls_verification/client_cert/ech_config/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
2562
2586
|
proxy["packet-encoding"] = "xudp";
|
|
2563
2587
|
if (proxy["reality-opts"] && proxy["reality-opts"]["public-key"]) proxy.tls = true;
|
|
2564
2588
|
if (xhttpEnabled) {
|
|
@@ -2569,6 +2593,7 @@ vless = tag equals "vless" address (vless_username/vless_option/reality_option/w
|
|
|
2569
2593
|
}
|
|
2570
2594
|
handleShadowTLS();
|
|
2571
2595
|
}
|
|
2596
|
+
vless_address = "vless" address { proxy.type = "vless"; }
|
|
2572
2597
|
trojan = tag equals "trojan" address (passwordk/ws/ws_http_upgrade/ws_path/ws_headers/tls/sni/cert_verify_name/alpn/tls_fingerprint/client_fingerprint/tls_verification/client_cert/ech_config/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
2573
2598
|
proxy.type = "trojan";
|
|
2574
2599
|
handleWebsocket();
|
|
@@ -2758,7 +2783,7 @@ pipe_headers = & {
|
|
|
2758
2783
|
peg$currPos = index;
|
|
2759
2784
|
return $.headers.trim().length > 0;
|
|
2760
2785
|
} { return parseHeaders($.headers, "|"); }
|
|
2761
|
-
ws_path = comma "ws-path" equals path:uri { obfs.path = path
|
|
2786
|
+
ws_path = comma "ws-path" equals path:(vless_quoted_value / value:uri { return stripQuotes(value); }) { obfs.path = path; }
|
|
2762
2787
|
grpc = comma "grpc" equals flag:bool { if (flag) proxy.network = "grpc"; }
|
|
2763
2788
|
grpc_service_name = comma "grpc-service-name" equals value:quoted_value { $set(proxy, "grpc-opts.grpc-service-name", value.trim()); }
|
|
2764
2789
|
grpc_mode = comma "grpc-mode" equals value:quoted_value { $set(proxy, "grpc-opts._grpc-type", value.trim()); }
|
|
@@ -2795,7 +2820,7 @@ tfo = comma "tfo" equals flag:bool { proxy.tfo = flag; }
|
|
|
2795
2820
|
ip_version = comma "ip-version" equals match:[^,]+ { proxy["ip-version"] = match.join(""); }
|
|
2796
2821
|
section_name = comma "section-name" equals match:[^,]+ { proxy["section-name"] = match.join(""); }
|
|
2797
2822
|
no_error_alert = comma "no-error-alert" equals match:[^,]+ { proxy["no-error-alert"] = match.join(""); }
|
|
2798
|
-
underlying_proxy = comma "underlying-proxy" equals
|
|
2823
|
+
underlying_proxy = comma "underlying-proxy" equals value:(vless_quoted_value / uri) { proxy["underlying-proxy"] = value; }
|
|
2799
2824
|
download_bandwidth = comma "download-bandwidth" equals match:[^,]+ { proxy.down = match.join(""); }
|
|
2800
2825
|
test_url = comma "test-url" equals match:[^,]+ { proxy["test-url"] = match.join(""); }
|
|
2801
2826
|
test_udp = comma "test-udp" equals match:[^,]+ { proxy["test-udp"] = match.join(""); }
|
|
@@ -2820,7 +2845,13 @@ alpn = comma "alpn" equals match:quoted_value {
|
|
|
2820
2845
|
if (values.length > 0) proxy.alpn = values;
|
|
2821
2846
|
}
|
|
2822
2847
|
h3 = comma "h3" equals flag:bool { if (flag) proxy.network = "h3"; }
|
|
2823
|
-
quoted_value
|
|
2848
|
+
quoted_value
|
|
2849
|
+
= double_quoted_vless_value
|
|
2850
|
+
/ '"' match:$[^"]* '"' { return match; }
|
|
2851
|
+
/ "'" match:$[^']* "'" { return proxy.type === "vless" ? unescapeQuotedValue(match) : match; }
|
|
2852
|
+
/ uri
|
|
2853
|
+
vless_quoted_value = &{ return proxy.type === "vless"; } value:quoted_value { return value.trim(); }
|
|
2854
|
+
double_quoted_vless_value = &{ return proxy.type === "vless"; } '"' value:$(("\\" ('"' / "\\") / [^"])*) '"' &(_ ("," / !.)) { return unescapeQuotedValue(value); }
|
|
2824
2855
|
uuidk = comma "uuid" equals match:[^,]+ { proxy.uuid = match.join(""); }
|
|
2825
2856
|
salamander_password = comma "salamander-password" equals match:[^,]+ { proxy['obfs-password'] = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); proxy.obfs = 'salamander'; }
|
|
2826
2857
|
gecko_password = comma "gecko-password" equals match:[^,]+ { proxy['obfs-password'] = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); proxy.obfs = 'gecko'; }
|
|
@@ -3271,6 +3302,7 @@ var grammars3 = String.raw`
|
|
|
3271
3302
|
const proxy = {};
|
|
3272
3303
|
const obfs = {};
|
|
3273
3304
|
const $ = {};
|
|
3305
|
+
let mieruUdpOverTcp = false;
|
|
3274
3306
|
|
|
3275
3307
|
function setQxHttpObfs(type) {
|
|
3276
3308
|
// Preserve the original QX http-obfs token for round-trip output,
|
|
@@ -3305,7 +3337,7 @@ var grammars3 = String.raw`
|
|
|
3305
3337
|
}
|
|
3306
3338
|
}
|
|
3307
3339
|
|
|
3308
|
-
start = (trojan/shadowsocks/vmess/vless/anytls/hysteria2/http/socks5) {
|
|
3340
|
+
start = (trojan/shadowsocks/vmess/vless/anytls/mieru/hysteria2/http/socks5) {
|
|
3309
3341
|
return proxy
|
|
3310
3342
|
}
|
|
3311
3343
|
|
|
@@ -3377,8 +3409,14 @@ anytls = "anytls" equals address
|
|
|
3377
3409
|
proxy.tls = true;
|
|
3378
3410
|
}
|
|
3379
3411
|
|
|
3412
|
+
mieru = "mieru" equals address
|
|
3413
|
+
(username/password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/udp_relay/mieru_udp_over_tcp/fast_open/server_check_url/reality_base64_pubkey/reality_hex_shortid/others)* {
|
|
3414
|
+
proxy.type = "mieru";
|
|
3415
|
+
proxy.udp = proxy.udp === true && mieruUdpOverTcp;
|
|
3416
|
+
}
|
|
3417
|
+
|
|
3380
3418
|
hysteria2 = "hysteria2" equals address
|
|
3381
|
-
(password/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/udp_relay/download_bandwidth/
|
|
3419
|
+
(password/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/udp_relay/download_bandwidth/hysteria2_obfs_password/port_hopping/port_hopping_interval/server_check_url/tag/others)* {
|
|
3382
3420
|
proxy.type = "hysteria2";
|
|
3383
3421
|
proxy.tls = true;
|
|
3384
3422
|
}
|
|
@@ -3441,11 +3479,25 @@ aead = comma "aead" equals flag:bool { proxy.aead = flag; }
|
|
|
3441
3479
|
udp_relay = comma "udp-relay" equals flag:bool { proxy.udp = flag; }
|
|
3442
3480
|
udp_over_tcp = comma "udp-over-tcp" equals flag:bool { throw new Error("UDP over TCP is not supported"); }
|
|
3443
3481
|
udp_over_tcp_new = comma "udp-over-tcp" equals param:$[^=,]+ { if (param === "sp.v1") { proxy["udp-over-tcp"] = true; proxy["udp-over-tcp-version"] = 1; } else if (param === "sp.v2") { proxy["udp-over-tcp"] = true; proxy["udp-over-tcp-version"] = 2; } else if (param === "true") { proxy["_ssr_python_uot"] = true; } else { throw new Error("Invalid value for udp-over-tcp"); } }
|
|
3482
|
+
mieru_udp_over_tcp = comma "udp-over-tcp" equals raw:$[^,]* {
|
|
3483
|
+
const value = raw.trim();
|
|
3484
|
+
if (value !== "true" && value !== "false") {
|
|
3485
|
+
throw new Error("mieru udp-over-tcp must be true or false");
|
|
3486
|
+
}
|
|
3487
|
+
mieruUdpOverTcp = value === "true";
|
|
3488
|
+
}
|
|
3444
3489
|
|
|
3445
3490
|
download_bandwidth = comma "download-bandwidth" equals value:$[^,]+ { proxy.down = value.trim(); }
|
|
3446
|
-
|
|
3447
|
-
proxy.obfs
|
|
3448
|
-
|
|
3491
|
+
hysteria2_obfs_password = comma type:("salamander"/"gecko") "-password" equals value:$((!next_parameter .)*) {
|
|
3492
|
+
if (proxy.obfs && proxy.obfs !== type) {
|
|
3493
|
+
throw new Error("QX Hysteria 2 cannot combine salamander-password and gecko-password");
|
|
3494
|
+
}
|
|
3495
|
+
const password = value.trim();
|
|
3496
|
+
if (options.byteLength(password, "utf8") < 4) {
|
|
3497
|
+
throw new Error("QX Hysteria 2 " + type + "-password must be at least 4 bytes");
|
|
3498
|
+
}
|
|
3499
|
+
proxy.obfs = type;
|
|
3500
|
+
proxy["obfs-password"] = password;
|
|
3449
3501
|
}
|
|
3450
3502
|
port_hopping = comma "port-hopping" equals ports:$(hopping_port (comma hopping_port)*) {
|
|
3451
3503
|
proxy.ports = ports.replace(/\s/g, "");
|
|
@@ -3538,7 +3590,10 @@ function getParser3() {
|
|
|
3538
3590
|
const generated = peggy3.generate(grammars3);
|
|
3539
3591
|
parser3 = {
|
|
3540
3592
|
parse(input, options) {
|
|
3541
|
-
const proxy = generated.parse(input,
|
|
3593
|
+
const proxy = generated.parse(input, {
|
|
3594
|
+
...options,
|
|
3595
|
+
byteLength: import_buffer.Buffer.byteLength
|
|
3596
|
+
});
|
|
3542
3597
|
const alpn = decodeQxAlpn(proxy["tls-alpn"]);
|
|
3543
3598
|
if (alpn) proxy.alpn = alpn;
|
|
3544
3599
|
return proxy;
|
|
@@ -5467,7 +5522,7 @@ function URI_VLESS() {
|
|
|
5467
5522
|
let isShadowrocket;
|
|
5468
5523
|
let parsed = /^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
5469
5524
|
if (!parsed) {
|
|
5470
|
-
let [
|
|
5525
|
+
let [_6, base64, other] = /^(.*?)(\?.*?$)/.exec(line);
|
|
5471
5526
|
line = `${Base64.decode(base64)}${other}`;
|
|
5472
5527
|
parsed = /^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
5473
5528
|
isShadowrocket = true;
|
|
@@ -5783,6 +5838,62 @@ function URI_AnyTLS() {
|
|
|
5783
5838
|
};
|
|
5784
5839
|
return { name, test, parse: parse2 };
|
|
5785
5840
|
}
|
|
5841
|
+
function URI_Mieru() {
|
|
5842
|
+
const name = "URI Mieru Parser";
|
|
5843
|
+
const test = (line) => /^mierus:\/\//i.test(line);
|
|
5844
|
+
const parse2 = (line) => {
|
|
5845
|
+
const { content, fragment } = splitURIFragment(line);
|
|
5846
|
+
const match = /^mierus:\/\/([^:@/?]+):([^@/?]+)@(\[[^\]]+\]|[^:/?@\s]+)\/?\?(.+)$/i.exec(
|
|
5847
|
+
content
|
|
5848
|
+
);
|
|
5849
|
+
if (!match) throw new Error("Invalid Mieru URI");
|
|
5850
|
+
const [, username, password, server, query] = match;
|
|
5851
|
+
const params = /* @__PURE__ */ new Map();
|
|
5852
|
+
for (const part of query.split("&")) {
|
|
5853
|
+
const { key, value } = splitQueryPart(part);
|
|
5854
|
+
if (!params.has(key)) params.set(key, []);
|
|
5855
|
+
params.get(key).push(value);
|
|
5856
|
+
}
|
|
5857
|
+
const ports = params.get("port") || [];
|
|
5858
|
+
const protocols = params.get("protocol") || [];
|
|
5859
|
+
if (ports.length === 0 || ports.length !== protocols.length) {
|
|
5860
|
+
throw new Error("Mieru URI requires matching ports and protocols");
|
|
5861
|
+
}
|
|
5862
|
+
const baseName = fragment || params.get("profile")?.[0] || server;
|
|
5863
|
+
const proxy = {
|
|
5864
|
+
type: "mieru",
|
|
5865
|
+
server,
|
|
5866
|
+
username: decodeURIComponent(username),
|
|
5867
|
+
password: decodeURIComponent(password)
|
|
5868
|
+
};
|
|
5869
|
+
for (const key of [
|
|
5870
|
+
"multiplexing",
|
|
5871
|
+
"handshake-mode",
|
|
5872
|
+
"traffic-pattern"
|
|
5873
|
+
]) {
|
|
5874
|
+
const value = params.get(key)?.[0];
|
|
5875
|
+
if (value) proxy[key] = value;
|
|
5876
|
+
}
|
|
5877
|
+
return ports.map((port, index) => {
|
|
5878
|
+
const transport = protocols[index];
|
|
5879
|
+
const [, first, last = first] = /^(\d+)(?:-(\d+))?$/.exec(port) || [];
|
|
5880
|
+
const start = Number(first);
|
|
5881
|
+
const end = Number(last);
|
|
5882
|
+
if (!(1 <= start && start <= end && end <= 65535) || transport !== "TCP" && transport !== "UDP") {
|
|
5883
|
+
throw new Error("Invalid Mieru port binding");
|
|
5884
|
+
}
|
|
5885
|
+
const binding = {
|
|
5886
|
+
...proxy,
|
|
5887
|
+
name: ports.length === 1 ? baseName : `${baseName}:${port}/${transport}`,
|
|
5888
|
+
transport
|
|
5889
|
+
};
|
|
5890
|
+
if (port.includes("-")) binding["port-range"] = port;
|
|
5891
|
+
else binding.port = start;
|
|
5892
|
+
return binding;
|
|
5893
|
+
});
|
|
5894
|
+
};
|
|
5895
|
+
return { name, test, parse: parse2 };
|
|
5896
|
+
}
|
|
5786
5897
|
function URI_Hysteria2() {
|
|
5787
5898
|
const name = "URI Hysteria2 Parser";
|
|
5788
5899
|
const test = (line) => {
|
|
@@ -6234,6 +6345,12 @@ function QX_AnyTLS() {
|
|
|
6234
6345
|
const parse2 = (line) => getParser3().parse(line);
|
|
6235
6346
|
return { name, test, parse: parse2 };
|
|
6236
6347
|
}
|
|
6348
|
+
function QX_Mieru() {
|
|
6349
|
+
const name = "QX Mieru Parser";
|
|
6350
|
+
const test = (line) => /^mieru\s*=/.test(line);
|
|
6351
|
+
const parse2 = (line) => getParser3().parse(line);
|
|
6352
|
+
return { name, test, parse: parse2 };
|
|
6353
|
+
}
|
|
6237
6354
|
function QX_Hysteria2() {
|
|
6238
6355
|
const name = "QX Hysteria2 Parser";
|
|
6239
6356
|
const test = (line) => /^hysteria2\s*=/.test(line);
|
|
@@ -6552,7 +6669,7 @@ function Surge_External() {
|
|
|
6552
6669
|
};
|
|
6553
6670
|
const parse2 = (line) => {
|
|
6554
6671
|
let parsed = /^\s*(.*?)\s*?=\s*?external\s*?,\s*(.*?)\s*$/.exec(line);
|
|
6555
|
-
let [
|
|
6672
|
+
let [_6, name2, other] = parsed;
|
|
6556
6673
|
line = other;
|
|
6557
6674
|
let exec = /(,|^)\s*?exec\s*?=\s*"(.*?)"\s*?(,|$)/.exec(line)?.[2];
|
|
6558
6675
|
if (!exec) {
|
|
@@ -6666,6 +6783,7 @@ var parsers_default = [
|
|
|
6666
6783
|
URI_Hysteria2(),
|
|
6667
6784
|
URI_Trojan(),
|
|
6668
6785
|
URI_AnyTLS(),
|
|
6786
|
+
URI_Mieru(),
|
|
6669
6787
|
Clash_All(),
|
|
6670
6788
|
Surge_Direct(),
|
|
6671
6789
|
Surge_AnyTLS(),
|
|
@@ -6700,6 +6818,7 @@ var parsers_default = [
|
|
|
6700
6818
|
QX_VMess(),
|
|
6701
6819
|
QX_VLESS(),
|
|
6702
6820
|
QX_AnyTLS(),
|
|
6821
|
+
QX_Mieru(),
|
|
6703
6822
|
QX_Hysteria2(),
|
|
6704
6823
|
QX_Trojan(),
|
|
6705
6824
|
QX_Http(),
|
|
@@ -6732,7 +6851,7 @@ function normalizeClashYamlDocument(raw, document, content) {
|
|
|
6732
6851
|
const anchors = /* @__PURE__ */ new Map();
|
|
6733
6852
|
const aliases = /* @__PURE__ */ new Map();
|
|
6734
6853
|
visit(document, {
|
|
6735
|
-
Node(
|
|
6854
|
+
Node(_6, node) {
|
|
6736
6855
|
if (isAlias(node)) {
|
|
6737
6856
|
aliases.set(node.range[0], anchors.get(node.source));
|
|
6738
6857
|
} else if (node.anchor) {
|
|
@@ -6744,7 +6863,7 @@ function normalizeClashYamlDocument(raw, document, content) {
|
|
|
6744
6863
|
const needsQuotes = (node) => isScalar(node) && typeof node.value !== "string" && node.value !== null && !node.tag && node.source;
|
|
6745
6864
|
const realityConfigs = /* @__PURE__ */ new Set();
|
|
6746
6865
|
visit(document, {
|
|
6747
|
-
Pair(
|
|
6866
|
+
Pair(_6, { key, value }) {
|
|
6748
6867
|
const name = resolveAlias(key)?.value;
|
|
6749
6868
|
if (["reality-opts", "reality-config"].includes(name)) {
|
|
6750
6869
|
realityConfigs.add(value);
|
|
@@ -6754,10 +6873,10 @@ function normalizeClashYamlDocument(raw, document, content) {
|
|
|
6754
6873
|
const shortIds = /* @__PURE__ */ new Set();
|
|
6755
6874
|
for (const config of realityConfigs) {
|
|
6756
6875
|
visit(config, {
|
|
6757
|
-
Alias(
|
|
6876
|
+
Alias(_6, alias) {
|
|
6758
6877
|
realityConfigs.add(resolveAlias(alias));
|
|
6759
6878
|
},
|
|
6760
|
-
Pair(
|
|
6879
|
+
Pair(_6, { key, value }) {
|
|
6761
6880
|
if (resolveAlias(key)?.value === "short-id") {
|
|
6762
6881
|
shortIds.add(value);
|
|
6763
6882
|
}
|
|
@@ -6976,6 +7095,16 @@ function isPresent2(obj, attr) {
|
|
|
6976
7095
|
const data = _3.get(obj, attr);
|
|
6977
7096
|
return typeof data !== "undefined" && data !== null;
|
|
6978
7097
|
}
|
|
7098
|
+
function supportsVlessTransportSecurity(proxy) {
|
|
7099
|
+
const { network, flow, encryption } = proxy;
|
|
7100
|
+
const reality = proxy["reality-opts"];
|
|
7101
|
+
const secure = Boolean(proxy.tls || reality);
|
|
7102
|
+
if (network === "ws" && reality) return false;
|
|
7103
|
+
if (network === "grpc") return secure && !flow;
|
|
7104
|
+
if (!flow) return true;
|
|
7105
|
+
const encrypted = isNotBlank(encryption) && encryption.trim() !== "none";
|
|
7106
|
+
return encrypted || secure && !["ws", "xhttp"].includes(network);
|
|
7107
|
+
}
|
|
6979
7108
|
function supportsTrustTunnelClientRandomAuth(proxy, targetPlatform6) {
|
|
6980
7109
|
if (proxy.type !== "trusttunnel" || !isPresent2(proxy, "client-random-auth-key") || ["surge", "surgemac", "json"].includes(targetPlatform6.toLowerCase())) {
|
|
6981
7110
|
return true;
|
|
@@ -7673,15 +7802,13 @@ function appendVlessParams(result, proxy) {
|
|
|
7673
7802
|
const network = proxy.network ?? "tcp";
|
|
7674
7803
|
const reality = proxy["reality-opts"];
|
|
7675
7804
|
const tls = proxy.tls || reality;
|
|
7676
|
-
const encrypted = isNotBlank(proxy.encryption) && proxy.encryption.trim() !== "none";
|
|
7677
7805
|
if (!["tcp", "raw", "none", "ws", "grpc", "xhttp"].includes(network)) {
|
|
7678
7806
|
throw unsupported(`VLESS network ${network} is unsupported`);
|
|
7679
7807
|
}
|
|
7680
7808
|
if (proxy.encryption && /[,\r\n"']/.test(proxy.encryption)) {
|
|
7681
7809
|
throw unsupported("VLESS encryption contains unsupported characters");
|
|
7682
7810
|
}
|
|
7683
|
-
|
|
7684
|
-
if (network === "ws" && reality || network === "grpc" && !tls || proxy.flow && !supportsVision) {
|
|
7811
|
+
if (!supportsVlessTransportSecurity(proxy)) {
|
|
7685
7812
|
throw unsupported(
|
|
7686
7813
|
"Unsupported VLESS transport, TLS or flow combination"
|
|
7687
7814
|
);
|
|
@@ -11221,6 +11348,31 @@ function URI_Producer() {
|
|
|
11221
11348
|
const fragment = fragmentMatch ? `#${fragmentMatch[1]}` : "";
|
|
11222
11349
|
result = `${baseUrl}?${newParams}${fragment}`;
|
|
11223
11350
|
break;
|
|
11351
|
+
case "mieru": {
|
|
11352
|
+
const port = proxy["port-range"] || proxy.port;
|
|
11353
|
+
const username = encodeURIComponent(proxy.username ?? "");
|
|
11354
|
+
const password = encodeURIComponent(proxy.password ?? "");
|
|
11355
|
+
if (!proxy.server || !port || !username || !password) {
|
|
11356
|
+
throw new Error(
|
|
11357
|
+
"Mieru URI requires a server, port and credentials"
|
|
11358
|
+
);
|
|
11359
|
+
}
|
|
11360
|
+
const params = [
|
|
11361
|
+
`port=${encodeURIComponent(port)}`,
|
|
11362
|
+
`protocol=${encodeURIComponent(proxy.transport || "TCP")}`,
|
|
11363
|
+
`profile=${encodeURIComponent(proxy.name || proxy.server)}`
|
|
11364
|
+
];
|
|
11365
|
+
for (const key of [
|
|
11366
|
+
"multiplexing",
|
|
11367
|
+
"handshake-mode",
|
|
11368
|
+
"traffic-pattern"
|
|
11369
|
+
]) {
|
|
11370
|
+
if (proxy[key])
|
|
11371
|
+
params.push(`${key}=${encodeURIComponent(proxy[key])}`);
|
|
11372
|
+
}
|
|
11373
|
+
result = `mierus://${username}:${password}@${proxy.server}?${params.join("&")}`;
|
|
11374
|
+
break;
|
|
11375
|
+
}
|
|
11224
11376
|
case "wireguard":
|
|
11225
11377
|
let wireguardParams = [];
|
|
11226
11378
|
Object.keys(proxy).forEach((key) => {
|
|
@@ -11352,6 +11504,8 @@ function QX_Producer() {
|
|
|
11352
11504
|
return anytls3(proxy);
|
|
11353
11505
|
case "hysteria2":
|
|
11354
11506
|
return hysteria23(proxy);
|
|
11507
|
+
case "mieru":
|
|
11508
|
+
return mieru(proxy);
|
|
11355
11509
|
}
|
|
11356
11510
|
throw new Error(
|
|
11357
11511
|
`Platform ${targetPlatform4} does not support proxy type: ${proxy.type}`
|
|
@@ -11761,8 +11915,11 @@ function anytls3(proxy) {
|
|
|
11761
11915
|
return result.toString();
|
|
11762
11916
|
}
|
|
11763
11917
|
function hysteria23(proxy) {
|
|
11764
|
-
|
|
11765
|
-
|
|
11918
|
+
const obfs = proxy.obfs || "salamander";
|
|
11919
|
+
if (!["salamander", "gecko"].includes(obfs)) {
|
|
11920
|
+
throw new Error(
|
|
11921
|
+
"QX Hysteria 2 only supports Salamander and Gecko obfuscation"
|
|
11922
|
+
);
|
|
11766
11923
|
}
|
|
11767
11924
|
const result = new Result(proxy);
|
|
11768
11925
|
result.append(`hysteria2=${proxy.server}:${proxy.port}`);
|
|
@@ -11773,10 +11930,19 @@ function hysteria23(proxy) {
|
|
|
11773
11930
|
if (Number.isInteger(interval) && interval >= 5 && interval <= 3600) {
|
|
11774
11931
|
result.append(`,port-hopping-interval=${interval}`);
|
|
11775
11932
|
}
|
|
11776
|
-
|
|
11777
|
-
|
|
11778
|
-
"
|
|
11779
|
-
|
|
11933
|
+
if (isPresent2(proxy, "obfs-password")) {
|
|
11934
|
+
const obfsPassword = String(proxy["obfs-password"]);
|
|
11935
|
+
if (import_buffer3.Buffer.byteLength(obfsPassword, "utf8") < 4) {
|
|
11936
|
+
throw new Error(
|
|
11937
|
+
`QX Hysteria 2 ${obfs}-password must be at least 4 bytes`
|
|
11938
|
+
);
|
|
11939
|
+
}
|
|
11940
|
+
result.append(`,${obfs}-password=${obfsPassword}`);
|
|
11941
|
+
} else if (obfs === "gecko") {
|
|
11942
|
+
throw new Error(
|
|
11943
|
+
"QX Hysteria 2 Gecko obfuscation requires gecko-password"
|
|
11944
|
+
);
|
|
11945
|
+
}
|
|
11780
11946
|
result.appendIfPresent(`,tls-host=${proxy.sni}`, "sni");
|
|
11781
11947
|
result.appendIfPresent(
|
|
11782
11948
|
`,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
|
|
@@ -11888,6 +12054,48 @@ function socks53(proxy) {
|
|
|
11888
12054
|
append(`,tag=${proxy.name}`);
|
|
11889
12055
|
return result.toString();
|
|
11890
12056
|
}
|
|
12057
|
+
function mieru(proxy) {
|
|
12058
|
+
const result = new Result(proxy);
|
|
12059
|
+
result.append(`mieru=${proxy.server}:${proxy.port}`);
|
|
12060
|
+
result.appendIfPresent(`,username=${proxy.username}`, "username");
|
|
12061
|
+
result.appendIfPresent(`,password=${proxy.password}`, "password");
|
|
12062
|
+
if (needTls(proxy)) {
|
|
12063
|
+
proxy.tls = true;
|
|
12064
|
+
}
|
|
12065
|
+
result.appendIfPresent(`,over-tls=${proxy.tls}`, "tls");
|
|
12066
|
+
if (needTls(proxy)) {
|
|
12067
|
+
result.appendIfPresent(
|
|
12068
|
+
`,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
|
|
12069
|
+
"tls-pubkey-sha256"
|
|
12070
|
+
);
|
|
12071
|
+
appendTlsAlpn(result, proxy);
|
|
12072
|
+
result.appendIfPresent(
|
|
12073
|
+
`,tls-no-session-ticket=${proxy["tls-no-session-ticket"]}`,
|
|
12074
|
+
"tls-no-session-ticket"
|
|
12075
|
+
);
|
|
12076
|
+
result.appendIfPresent(
|
|
12077
|
+
`,tls-no-session-reuse=${proxy["tls-no-session-reuse"]}`,
|
|
12078
|
+
"tls-no-session-reuse"
|
|
12079
|
+
);
|
|
12080
|
+
result.appendIfPresent(
|
|
12081
|
+
`,tls-cert-sha256=${proxy["tls-fingerprint"]}`,
|
|
12082
|
+
"tls-fingerprint"
|
|
12083
|
+
);
|
|
12084
|
+
appendTlsVerification(result, proxy);
|
|
12085
|
+
result.appendIfPresent(`,tls-host=${proxy.sni}`, "sni");
|
|
12086
|
+
}
|
|
12087
|
+
result.appendIfPresent(`,fast-open=${proxy.tfo}`, "tfo");
|
|
12088
|
+
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
12089
|
+
if (proxy.udp === true) {
|
|
12090
|
+
result.append(",udp-over-tcp=true");
|
|
12091
|
+
}
|
|
12092
|
+
result.appendIfPresent(
|
|
12093
|
+
`,server_check_url=${proxy["test-url"]}`,
|
|
12094
|
+
"test-url"
|
|
12095
|
+
);
|
|
12096
|
+
result.append(`,tag=${proxy.name}`);
|
|
12097
|
+
return result.toString();
|
|
12098
|
+
}
|
|
11891
12099
|
function needTls(proxy) {
|
|
11892
12100
|
return proxy.tls;
|
|
11893
12101
|
}
|
|
@@ -12107,6 +12315,7 @@ function hasShadowrocketSnellShadowTlsObfsConflict(proxy) {
|
|
|
12107
12315
|
}
|
|
12108
12316
|
|
|
12109
12317
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/surfboard.js
|
|
12318
|
+
import _5 from "lodash";
|
|
12110
12319
|
var targetPlatform5 = "Surfboard";
|
|
12111
12320
|
function hasNonBlankValue2(value) {
|
|
12112
12321
|
return value != null && `${value}`.trim().length > 0;
|
|
@@ -12127,7 +12336,7 @@ function appendTlsProxyParams2(result, proxy, enabled = true) {
|
|
|
12127
12336
|
}
|
|
12128
12337
|
function Surfboard_Producer() {
|
|
12129
12338
|
const produce2 = (proxy) => {
|
|
12130
|
-
if (
|
|
12339
|
+
if (proxy.type !== "vless" && proxy.network === "ws" && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
12131
12340
|
throw new Error(
|
|
12132
12341
|
`Platform ${targetPlatform5} does not support network ${proxy.network} with http upgrade`
|
|
12133
12342
|
);
|
|
@@ -12139,6 +12348,8 @@ function Surfboard_Producer() {
|
|
|
12139
12348
|
return trojan4(proxy);
|
|
12140
12349
|
case "vmess":
|
|
12141
12350
|
return vmess3(proxy);
|
|
12351
|
+
case "vless":
|
|
12352
|
+
return vless4(proxy);
|
|
12142
12353
|
case "http":
|
|
12143
12354
|
return http4(proxy);
|
|
12144
12355
|
case "snell":
|
|
@@ -12338,6 +12549,97 @@ function vmess3(proxy) {
|
|
|
12338
12549
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
12339
12550
|
return result.toString();
|
|
12340
12551
|
}
|
|
12552
|
+
function vless4(proxy) {
|
|
12553
|
+
if (!hasNonBlankValue2(proxy.uuid)) {
|
|
12554
|
+
throw new Error("VLESS username is missing");
|
|
12555
|
+
}
|
|
12556
|
+
if (proxy.flow && !["xtls-rprx-vision", "xtls-rprx-vision-udp443"].includes(proxy.flow)) {
|
|
12557
|
+
throw new Error("Unsupported VLESS flow");
|
|
12558
|
+
}
|
|
12559
|
+
if (!supportsVlessTransportSecurity(proxy)) {
|
|
12560
|
+
throw new Error("Unsupported VLESS transport, TLS or flow combination");
|
|
12561
|
+
}
|
|
12562
|
+
const result = new Result(proxy);
|
|
12563
|
+
result.append(`${proxy.name}=vless,${proxy.server},${proxy.port}`);
|
|
12564
|
+
const append = (key, value) => {
|
|
12565
|
+
if (value == null) return;
|
|
12566
|
+
const text = String(value);
|
|
12567
|
+
const param = !text || /[,;"'\s\\]/.test(text) ? `"${text.replace(/["\\]/g, "\\$&")}"` : text;
|
|
12568
|
+
result.append(`,${key}=${param}`);
|
|
12569
|
+
};
|
|
12570
|
+
append("username", proxy.uuid);
|
|
12571
|
+
const network = proxy.network ?? "tcp";
|
|
12572
|
+
if (network === "ws") {
|
|
12573
|
+
const ws = proxy["ws-opts"];
|
|
12574
|
+
append("ws", true);
|
|
12575
|
+
if (ws?.["v2ray-http-upgrade"]) append("ws-http-upgrade", true);
|
|
12576
|
+
append("ws-path", ws?.path);
|
|
12577
|
+
append(
|
|
12578
|
+
"ws-headers",
|
|
12579
|
+
formatVlessHeaders(Object.entries(ws?.headers ?? {}))
|
|
12580
|
+
);
|
|
12581
|
+
} else if (network === "grpc") {
|
|
12582
|
+
const grpc = proxy["grpc-opts"];
|
|
12583
|
+
append("grpc", true);
|
|
12584
|
+
append("grpc-service-name", grpc?.["grpc-service-name"]);
|
|
12585
|
+
append("grpc-mode", grpc?.["_grpc-type"]);
|
|
12586
|
+
append("grpc-authority", grpc?.["_grpc-authority"]);
|
|
12587
|
+
} else if (network === "xhttp") {
|
|
12588
|
+
const xhttp = proxy["xhttp-opts"];
|
|
12589
|
+
if (xhttp?.["download-settings"]) {
|
|
12590
|
+
throw new Error("VLESS XHTTP download-settings are unsupported");
|
|
12591
|
+
}
|
|
12592
|
+
append("xhttp", true);
|
|
12593
|
+
const headers = Object.entries(xhttp?.headers ?? {});
|
|
12594
|
+
const host = xhttp?.host ?? headers.find(([key]) => /^host$/i.test(key))?.[1];
|
|
12595
|
+
for (const [key, field] of Object.entries(SURGE_XHTTP_FIELDS)) {
|
|
12596
|
+
append(`xhttp-${key}`, key === "host" ? host : _5.get(xhttp, field));
|
|
12597
|
+
}
|
|
12598
|
+
append(
|
|
12599
|
+
"xhttp-headers",
|
|
12600
|
+
formatVlessHeaders(headers.filter(([key]) => !/^host$/i.test(key)))
|
|
12601
|
+
);
|
|
12602
|
+
} else if (!["tcp", "raw", "none"].includes(network)) {
|
|
12603
|
+
throw new Error(`VLESS network ${network} is unsupported`);
|
|
12604
|
+
}
|
|
12605
|
+
if (proxy.flow) append("flow", proxy.flow);
|
|
12606
|
+
if (proxy.encryption) append("encryption", proxy.encryption);
|
|
12607
|
+
const reality = proxy["reality-opts"];
|
|
12608
|
+
if (reality) {
|
|
12609
|
+
append("reality-public-key", reality["public-key"]);
|
|
12610
|
+
append("reality-short-id", reality["short-id"]);
|
|
12611
|
+
} else {
|
|
12612
|
+
append("tls", proxy.tls);
|
|
12613
|
+
if (proxy.tls) {
|
|
12614
|
+
append("server-cert-fingerprint-sha256", proxy["tls-fingerprint"]);
|
|
12615
|
+
append("server-cert-verify-name", proxy["name-cert-verify"]);
|
|
12616
|
+
append("skip-cert-verify", proxy["skip-cert-verify"]);
|
|
12617
|
+
}
|
|
12618
|
+
}
|
|
12619
|
+
if (proxy.tls || reality) {
|
|
12620
|
+
append("sni", proxy.sni);
|
|
12621
|
+
if (hasNonBlankValue2(proxy.alpn)) append("alpn", proxy.alpn);
|
|
12622
|
+
}
|
|
12623
|
+
append("udp-relay", proxy.udp);
|
|
12624
|
+
append("block-quic", proxy["block-quic"]);
|
|
12625
|
+
append("underlying-proxy", proxy["underlying-proxy"]);
|
|
12626
|
+
const line = result.toString();
|
|
12627
|
+
if (/[\r\n]/.test(line))
|
|
12628
|
+
throw new Error("VLESS proxy contains a line break");
|
|
12629
|
+
return line;
|
|
12630
|
+
}
|
|
12631
|
+
function formatVlessHeaders(headers) {
|
|
12632
|
+
const entries = [];
|
|
12633
|
+
for (const [key, value] of headers) {
|
|
12634
|
+
if (value == null) continue;
|
|
12635
|
+
const text = String(value);
|
|
12636
|
+
if (key.includes("|") || text.includes("|")) {
|
|
12637
|
+
throw new Error('VLESS header names and values cannot contain "|"');
|
|
12638
|
+
}
|
|
12639
|
+
entries.push(`${key}:${text}`);
|
|
12640
|
+
}
|
|
12641
|
+
return entries.join("|") || void 0;
|
|
12642
|
+
}
|
|
12341
12643
|
function http4(proxy) {
|
|
12342
12644
|
const result = new Result(proxy);
|
|
12343
12645
|
const type = proxy.tls ? "https" : "http";
|