sub-store-convert 2.44.20 → 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 +383 -59
- 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(),
|
|
@@ -6715,28 +6834,24 @@ import _3 from "lodash";
|
|
|
6715
6834
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/preprocessors/index.js
|
|
6716
6835
|
import { Base64 as Base642 } from "js-base64";
|
|
6717
6836
|
import { isAlias, isScalar, isSeq, parseDocument, visit } from "yaml";
|
|
6837
|
+
var CLASH_YAML_PARSE_OPTIONS = { merge: true, logLevel: "error" };
|
|
6838
|
+
function mayContainShortIds(raw) {
|
|
6839
|
+
return typeof raw === "string" && raw.includes("short-id");
|
|
6840
|
+
}
|
|
6718
6841
|
function normalizeClashYaml(raw) {
|
|
6719
|
-
if (
|
|
6720
|
-
return raw;
|
|
6721
|
-
}
|
|
6722
|
-
let document;
|
|
6842
|
+
if (!mayContainShortIds(raw)) return raw;
|
|
6723
6843
|
try {
|
|
6724
|
-
document = parseDocument(raw,
|
|
6725
|
-
|
|
6726
|
-
logLevel: "error"
|
|
6727
|
-
});
|
|
6728
|
-
const content = document.errors.length > 0 ? safeLoad(raw) : document.toJS();
|
|
6729
|
-
if (![content.proxies, content.listeners].some(
|
|
6730
|
-
(items) => Array.isArray(items) && items.length > 0
|
|
6731
|
-
))
|
|
6732
|
-
return raw;
|
|
6844
|
+
const document = parseDocument(raw, CLASH_YAML_PARSE_OPTIONS);
|
|
6845
|
+
return normalizeClashYamlDocument(raw, document);
|
|
6733
6846
|
} catch (e) {
|
|
6734
6847
|
return raw;
|
|
6735
6848
|
}
|
|
6849
|
+
}
|
|
6850
|
+
function normalizeClashYamlDocument(raw, document, content) {
|
|
6736
6851
|
const anchors = /* @__PURE__ */ new Map();
|
|
6737
6852
|
const aliases = /* @__PURE__ */ new Map();
|
|
6738
6853
|
visit(document, {
|
|
6739
|
-
Node(
|
|
6854
|
+
Node(_6, node) {
|
|
6740
6855
|
if (isAlias(node)) {
|
|
6741
6856
|
aliases.set(node.range[0], anchors.get(node.source));
|
|
6742
6857
|
} else if (node.anchor) {
|
|
@@ -6748,28 +6863,26 @@ function normalizeClashYaml(raw) {
|
|
|
6748
6863
|
const needsQuotes = (node) => isScalar(node) && typeof node.value !== "string" && node.value !== null && !node.tag && node.source;
|
|
6749
6864
|
const realityConfigs = /* @__PURE__ */ new Set();
|
|
6750
6865
|
visit(document, {
|
|
6751
|
-
Pair(
|
|
6866
|
+
Pair(_6, { key, value }) {
|
|
6752
6867
|
const name = resolveAlias(key)?.value;
|
|
6753
6868
|
if (["reality-opts", "reality-config"].includes(name)) {
|
|
6754
6869
|
realityConfigs.add(value);
|
|
6755
6870
|
}
|
|
6756
6871
|
}
|
|
6757
6872
|
});
|
|
6873
|
+
const shortIds = /* @__PURE__ */ new Set();
|
|
6758
6874
|
for (const config of realityConfigs) {
|
|
6759
6875
|
visit(config, {
|
|
6760
|
-
Alias(
|
|
6876
|
+
Alias(_6, alias) {
|
|
6761
6877
|
realityConfigs.add(resolveAlias(alias));
|
|
6878
|
+
},
|
|
6879
|
+
Pair(_6, { key, value }) {
|
|
6880
|
+
if (resolveAlias(key)?.value === "short-id") {
|
|
6881
|
+
shortIds.add(value);
|
|
6882
|
+
}
|
|
6762
6883
|
}
|
|
6763
6884
|
});
|
|
6764
6885
|
}
|
|
6765
|
-
const shortIds = /* @__PURE__ */ new Set();
|
|
6766
|
-
visit(document, {
|
|
6767
|
-
Pair(_5, { key, value }, path) {
|
|
6768
|
-
if (resolveAlias(key)?.value === "short-id" && path.some((node) => realityConfigs.has(node))) {
|
|
6769
|
-
shortIds.add(value);
|
|
6770
|
-
}
|
|
6771
|
-
}
|
|
6772
|
-
});
|
|
6773
6886
|
const replacements = /* @__PURE__ */ new Map();
|
|
6774
6887
|
for (const value of shortIds) {
|
|
6775
6888
|
const node = resolveAlias(value);
|
|
@@ -6779,12 +6892,20 @@ function normalizeClashYaml(raw) {
|
|
|
6779
6892
|
replacements.set(node, JSON.stringify(node.source));
|
|
6780
6893
|
}
|
|
6781
6894
|
}
|
|
6895
|
+
if (replacements.size === 0) return raw;
|
|
6896
|
+
if (content === void 0) {
|
|
6897
|
+
content = document.errors.length > 0 ? safeLoad(raw) : document.toJS();
|
|
6898
|
+
}
|
|
6899
|
+
if (![content?.proxies, content?.listeners].some(
|
|
6900
|
+
(items) => Array.isArray(items) && items.length > 0
|
|
6901
|
+
))
|
|
6902
|
+
return raw;
|
|
6782
6903
|
const chunks = [];
|
|
6783
6904
|
let offset = 0;
|
|
6784
|
-
for (const [node,
|
|
6905
|
+
for (const [node, content2] of [...replacements].sort(
|
|
6785
6906
|
([left], [right]) => left.range[0] - right.range[0]
|
|
6786
6907
|
)) {
|
|
6787
|
-
chunks.push(raw.slice(offset, node.range[0]),
|
|
6908
|
+
chunks.push(raw.slice(offset, node.range[0]), content2);
|
|
6788
6909
|
offset = node.range[1];
|
|
6789
6910
|
}
|
|
6790
6911
|
return chunks.join("") + raw.slice(offset);
|
|
@@ -6861,14 +6982,34 @@ function fallbackBase64Encoded() {
|
|
|
6861
6982
|
}
|
|
6862
6983
|
function Clash() {
|
|
6863
6984
|
const name = "Clash Pre-processor";
|
|
6864
|
-
const
|
|
6865
|
-
if (!/proxies/.test(raw)) return false;
|
|
6866
|
-
|
|
6867
|
-
|
|
6985
|
+
const prepare = function(raw, detect) {
|
|
6986
|
+
if (detect && !/proxies/.test(raw)) return false;
|
|
6987
|
+
let document;
|
|
6988
|
+
let content;
|
|
6989
|
+
if (mayContainShortIds(raw)) {
|
|
6990
|
+
try {
|
|
6991
|
+
document = parseDocument(raw, CLASH_YAML_PARSE_OPTIONS);
|
|
6992
|
+
if (document.errors.length === 0) content = document.toJS();
|
|
6993
|
+
} catch (e) {
|
|
6994
|
+
document = void 0;
|
|
6995
|
+
}
|
|
6996
|
+
}
|
|
6997
|
+
if (content === void 0) content = safeLoad(raw);
|
|
6998
|
+
if (detect && !Array.isArray(content.proxies) && !Array.isArray(content["proxy-groups"]))
|
|
6999
|
+
return false;
|
|
7000
|
+
if (document) {
|
|
7001
|
+
const normalized = normalizeClashYamlDocument(
|
|
7002
|
+
raw,
|
|
7003
|
+
document,
|
|
7004
|
+
content
|
|
7005
|
+
);
|
|
7006
|
+
if (normalized !== raw) return { normalized };
|
|
7007
|
+
}
|
|
7008
|
+
return { content };
|
|
6868
7009
|
};
|
|
6869
|
-
const
|
|
6870
|
-
|
|
6871
|
-
const { proxies } = safeLoad(
|
|
7010
|
+
const test = (raw) => prepare(raw, true);
|
|
7011
|
+
const parse2 = function(raw, includeProxies, match = prepare(raw)) {
|
|
7012
|
+
const { proxies } = match.normalized === void 0 ? match.content : safeLoad(match.normalized);
|
|
6872
7013
|
return (includeProxies ? "proxies:\n" : "") + (Array.isArray(proxies) ? proxies : []).map((p) => {
|
|
6873
7014
|
return `${includeProxies ? " - " : ""}${JSON.stringify(
|
|
6874
7015
|
p
|
|
@@ -6954,6 +7095,16 @@ function isPresent2(obj, attr) {
|
|
|
6954
7095
|
const data = _3.get(obj, attr);
|
|
6955
7096
|
return typeof data !== "undefined" && data !== null;
|
|
6956
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
|
+
}
|
|
6957
7108
|
function supportsTrustTunnelClientRandomAuth(proxy, targetPlatform6) {
|
|
6958
7109
|
if (proxy.type !== "trusttunnel" || !isPresent2(proxy, "client-random-auth-key") || ["surge", "surgemac", "json"].includes(targetPlatform6.toLowerCase())) {
|
|
6959
7110
|
return true;
|
|
@@ -7651,15 +7802,13 @@ function appendVlessParams(result, proxy) {
|
|
|
7651
7802
|
const network = proxy.network ?? "tcp";
|
|
7652
7803
|
const reality = proxy["reality-opts"];
|
|
7653
7804
|
const tls = proxy.tls || reality;
|
|
7654
|
-
const encrypted = isNotBlank(proxy.encryption) && proxy.encryption.trim() !== "none";
|
|
7655
7805
|
if (!["tcp", "raw", "none", "ws", "grpc", "xhttp"].includes(network)) {
|
|
7656
7806
|
throw unsupported(`VLESS network ${network} is unsupported`);
|
|
7657
7807
|
}
|
|
7658
7808
|
if (proxy.encryption && /[,\r\n"']/.test(proxy.encryption)) {
|
|
7659
7809
|
throw unsupported("VLESS encryption contains unsupported characters");
|
|
7660
7810
|
}
|
|
7661
|
-
|
|
7662
|
-
if (network === "ws" && reality || network === "grpc" && !tls || proxy.flow && !supportsVision) {
|
|
7811
|
+
if (!supportsVlessTransportSecurity(proxy)) {
|
|
7663
7812
|
throw unsupported(
|
|
7664
7813
|
"Unsupported VLESS transport, TLS or flow combination"
|
|
7665
7814
|
);
|
|
@@ -11199,6 +11348,31 @@ function URI_Producer() {
|
|
|
11199
11348
|
const fragment = fragmentMatch ? `#${fragmentMatch[1]}` : "";
|
|
11200
11349
|
result = `${baseUrl}?${newParams}${fragment}`;
|
|
11201
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
|
+
}
|
|
11202
11376
|
case "wireguard":
|
|
11203
11377
|
let wireguardParams = [];
|
|
11204
11378
|
Object.keys(proxy).forEach((key) => {
|
|
@@ -11330,6 +11504,8 @@ function QX_Producer() {
|
|
|
11330
11504
|
return anytls3(proxy);
|
|
11331
11505
|
case "hysteria2":
|
|
11332
11506
|
return hysteria23(proxy);
|
|
11507
|
+
case "mieru":
|
|
11508
|
+
return mieru(proxy);
|
|
11333
11509
|
}
|
|
11334
11510
|
throw new Error(
|
|
11335
11511
|
`Platform ${targetPlatform4} does not support proxy type: ${proxy.type}`
|
|
@@ -11739,8 +11915,11 @@ function anytls3(proxy) {
|
|
|
11739
11915
|
return result.toString();
|
|
11740
11916
|
}
|
|
11741
11917
|
function hysteria23(proxy) {
|
|
11742
|
-
|
|
11743
|
-
|
|
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
|
+
);
|
|
11744
11923
|
}
|
|
11745
11924
|
const result = new Result(proxy);
|
|
11746
11925
|
result.append(`hysteria2=${proxy.server}:${proxy.port}`);
|
|
@@ -11751,10 +11930,19 @@ function hysteria23(proxy) {
|
|
|
11751
11930
|
if (Number.isInteger(interval) && interval >= 5 && interval <= 3600) {
|
|
11752
11931
|
result.append(`,port-hopping-interval=${interval}`);
|
|
11753
11932
|
}
|
|
11754
|
-
|
|
11755
|
-
|
|
11756
|
-
"
|
|
11757
|
-
|
|
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
|
+
}
|
|
11758
11946
|
result.appendIfPresent(`,tls-host=${proxy.sni}`, "sni");
|
|
11759
11947
|
result.appendIfPresent(
|
|
11760
11948
|
`,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
|
|
@@ -11866,6 +12054,48 @@ function socks53(proxy) {
|
|
|
11866
12054
|
append(`,tag=${proxy.name}`);
|
|
11867
12055
|
return result.toString();
|
|
11868
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
|
+
}
|
|
11869
12099
|
function needTls(proxy) {
|
|
11870
12100
|
return proxy.tls;
|
|
11871
12101
|
}
|
|
@@ -12085,6 +12315,7 @@ function hasShadowrocketSnellShadowTlsObfsConflict(proxy) {
|
|
|
12085
12315
|
}
|
|
12086
12316
|
|
|
12087
12317
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/surfboard.js
|
|
12318
|
+
import _5 from "lodash";
|
|
12088
12319
|
var targetPlatform5 = "Surfboard";
|
|
12089
12320
|
function hasNonBlankValue2(value) {
|
|
12090
12321
|
return value != null && `${value}`.trim().length > 0;
|
|
@@ -12105,7 +12336,7 @@ function appendTlsProxyParams2(result, proxy, enabled = true) {
|
|
|
12105
12336
|
}
|
|
12106
12337
|
function Surfboard_Producer() {
|
|
12107
12338
|
const produce2 = (proxy) => {
|
|
12108
|
-
if (
|
|
12339
|
+
if (proxy.type !== "vless" && proxy.network === "ws" && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
12109
12340
|
throw new Error(
|
|
12110
12341
|
`Platform ${targetPlatform5} does not support network ${proxy.network} with http upgrade`
|
|
12111
12342
|
);
|
|
@@ -12117,6 +12348,8 @@ function Surfboard_Producer() {
|
|
|
12117
12348
|
return trojan4(proxy);
|
|
12118
12349
|
case "vmess":
|
|
12119
12350
|
return vmess3(proxy);
|
|
12351
|
+
case "vless":
|
|
12352
|
+
return vless4(proxy);
|
|
12120
12353
|
case "http":
|
|
12121
12354
|
return http4(proxy);
|
|
12122
12355
|
case "snell":
|
|
@@ -12316,6 +12549,97 @@ function vmess3(proxy) {
|
|
|
12316
12549
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
12317
12550
|
return result.toString();
|
|
12318
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
|
+
}
|
|
12319
12643
|
function http4(proxy) {
|
|
12320
12644
|
const result = new Result(proxy);
|
|
12321
12645
|
const type = proxy.tls ? "https" : "http";
|