sub-store-convert 2.23.22 → 2.24.19
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 +964 -614
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -83,21 +83,10 @@ var grammars = String.raw`
|
|
|
83
83
|
(quote === '"' || quote === "'") &&
|
|
84
84
|
trimmed[trimmed.length - 1] === quote
|
|
85
85
|
) {
|
|
86
|
-
return trimmed.slice(1, -1)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return trimmed.replace(/\\(["'\\])/g, "$1");
|
|
90
|
-
}
|
|
91
|
-
function isEscaped(text, index) {
|
|
92
|
-
let count = 0;
|
|
93
|
-
let cursor = index - 1;
|
|
94
|
-
|
|
95
|
-
while (cursor >= 0 && text[cursor] === "\\") {
|
|
96
|
-
count++;
|
|
97
|
-
cursor--;
|
|
86
|
+
return trimmed.slice(1, -1);
|
|
98
87
|
}
|
|
99
88
|
|
|
100
|
-
return
|
|
89
|
+
return trimmed;
|
|
101
90
|
}
|
|
102
91
|
function readQuotedHeaderKey(text, start) {
|
|
103
92
|
const quote = text[start];
|
|
@@ -106,11 +95,6 @@ var grammars = String.raw`
|
|
|
106
95
|
|
|
107
96
|
while (index < text.length) {
|
|
108
97
|
const char = text[index];
|
|
109
|
-
if (char === "\\" && index + 1 < text.length) {
|
|
110
|
-
hasKey = true;
|
|
111
|
-
index += 2;
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
98
|
if (char === quote) {
|
|
115
99
|
return hasKey ? index + 1 : -1;
|
|
116
100
|
}
|
|
@@ -166,15 +150,35 @@ var grammars = String.raw`
|
|
|
166
150
|
while (index < text.length && /\s/.test(text[index])) index++;
|
|
167
151
|
return text[index] === ":";
|
|
168
152
|
}
|
|
169
|
-
function
|
|
153
|
+
function isOptionStart(text, start) {
|
|
154
|
+
let index = start;
|
|
155
|
+
while (index < text.length && /\s/.test(text[index])) index++;
|
|
156
|
+
|
|
157
|
+
const keyStart = index;
|
|
158
|
+
while (index < text.length && /[0-9A-Za-z-]/.test(text[index])) index++;
|
|
159
|
+
if (index === keyStart) return false;
|
|
160
|
+
|
|
161
|
+
while (index < text.length && /\s/.test(text[index])) index++;
|
|
162
|
+
return text[index] === "=";
|
|
163
|
+
}
|
|
164
|
+
function isHeaderValueQuoteEnd(text, index, pairSeparator, allowCommaEnd, containerQuote) {
|
|
170
165
|
let cursor = index + 1;
|
|
171
166
|
while (cursor < text.length && /\s/.test(text[cursor])) cursor++;
|
|
172
167
|
|
|
173
|
-
return
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
)
|
|
168
|
+
if (cursor >= text.length) return true;
|
|
169
|
+
if (allowCommaEnd && text[cursor] === "," && isOptionStart(text, cursor + 1)) {
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
if (text[cursor] === pairSeparator && isHeaderKeyStart(text, cursor + 1)) {
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
if (containerQuote && text[cursor] === containerQuote) {
|
|
176
|
+
let next = cursor + 1;
|
|
177
|
+
while (next < text.length && /\s/.test(text[next])) next++;
|
|
178
|
+
return next >= text.length || text[next] === ",";
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return false;
|
|
178
182
|
}
|
|
179
183
|
function findHeaderSeparator(pair) {
|
|
180
184
|
let quote = "";
|
|
@@ -183,10 +187,6 @@ var grammars = String.raw`
|
|
|
183
187
|
const char = pair[index];
|
|
184
188
|
|
|
185
189
|
if (quote) {
|
|
186
|
-
if (char === "\\" && index + 1 < pair.length) {
|
|
187
|
-
index++;
|
|
188
|
-
continue;
|
|
189
|
-
}
|
|
190
190
|
if (char === quote) {
|
|
191
191
|
quote = "";
|
|
192
192
|
}
|
|
@@ -205,7 +205,7 @@ var grammars = String.raw`
|
|
|
205
205
|
|
|
206
206
|
return -1;
|
|
207
207
|
}
|
|
208
|
-
function readUnquotedHeadersEnd(text, start) {
|
|
208
|
+
function readUnquotedHeadersEnd(text, start, pairSeparator) {
|
|
209
209
|
let index = start;
|
|
210
210
|
let quote = "";
|
|
211
211
|
let quoteRole = "";
|
|
@@ -215,14 +215,10 @@ var grammars = String.raw`
|
|
|
215
215
|
const char = text[index];
|
|
216
216
|
|
|
217
217
|
if (quote) {
|
|
218
|
-
if (char === "\\" && index + 1 < text.length) {
|
|
219
|
-
index += 2;
|
|
220
|
-
continue;
|
|
221
|
-
}
|
|
222
218
|
if (char === quote) {
|
|
223
219
|
if (
|
|
224
220
|
quoteRole === "key" ||
|
|
225
|
-
isHeaderValueQuoteEnd(text, index)
|
|
221
|
+
isHeaderValueQuoteEnd(text, index, pairSeparator, true)
|
|
226
222
|
) {
|
|
227
223
|
quote = "";
|
|
228
224
|
quoteRole = "";
|
|
@@ -245,7 +241,7 @@ var grammars = String.raw`
|
|
|
245
241
|
continue;
|
|
246
242
|
}
|
|
247
243
|
|
|
248
|
-
if (char ===
|
|
244
|
+
if (char === pairSeparator && isHeaderKeyStart(text, index + 1)) {
|
|
249
245
|
seenSeparator = false;
|
|
250
246
|
index++;
|
|
251
247
|
continue;
|
|
@@ -257,24 +253,62 @@ var grammars = String.raw`
|
|
|
257
253
|
|
|
258
254
|
return index;
|
|
259
255
|
}
|
|
260
|
-
function readQuotedHeadersEnd(text, start) {
|
|
256
|
+
function readQuotedHeadersEnd(text, start, pairSeparator) {
|
|
261
257
|
const quote = text[start];
|
|
262
258
|
let index = start + 1;
|
|
259
|
+
let innerQuote = "";
|
|
260
|
+
let quoteRole = "";
|
|
261
|
+
let seenSeparator = false;
|
|
263
262
|
|
|
264
263
|
while (index < text.length) {
|
|
265
|
-
|
|
264
|
+
const char = text[index];
|
|
265
|
+
|
|
266
|
+
if (innerQuote) {
|
|
267
|
+
if (char === innerQuote) {
|
|
268
|
+
if (
|
|
269
|
+
quoteRole === "key" ||
|
|
270
|
+
isHeaderValueQuoteEnd(text, index, pairSeparator, false, quote)
|
|
271
|
+
) {
|
|
272
|
+
innerQuote = "";
|
|
273
|
+
quoteRole = "";
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
index++;
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
if (char === quote) {
|
|
266
281
|
let cursor = index + 1;
|
|
267
282
|
while (cursor < text.length && /\s/.test(text[cursor])) cursor++;
|
|
268
283
|
if (cursor >= text.length || text[cursor] === ",") {
|
|
269
284
|
return index + 1;
|
|
270
285
|
}
|
|
271
286
|
}
|
|
287
|
+
|
|
288
|
+
if (char === '"' || char === "'") {
|
|
289
|
+
innerQuote = char;
|
|
290
|
+
quoteRole = seenSeparator ? "value" : "key";
|
|
291
|
+
index++;
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (char === ":" && !seenSeparator) {
|
|
296
|
+
seenSeparator = true;
|
|
297
|
+
index++;
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
if (char === pairSeparator && isHeaderKeyStart(text, index + 1)) {
|
|
302
|
+
seenSeparator = false;
|
|
303
|
+
index++;
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
272
306
|
index++;
|
|
273
307
|
}
|
|
274
308
|
|
|
275
309
|
return text.length;
|
|
276
310
|
}
|
|
277
|
-
function readHeadersEnd(text, start) {
|
|
311
|
+
function readHeadersEnd(text, start, pairSeparator) {
|
|
278
312
|
let index = start;
|
|
279
313
|
while (index < text.length && /\s/.test(text[index])) index++;
|
|
280
314
|
|
|
@@ -282,12 +316,12 @@ var grammars = String.raw`
|
|
|
282
316
|
(text[index] === '"' || text[index] === "'") &&
|
|
283
317
|
!startsWithQuotedHeaderKey(text.slice(index))
|
|
284
318
|
) {
|
|
285
|
-
return readQuotedHeadersEnd(text, index);
|
|
319
|
+
return readQuotedHeadersEnd(text, index, pairSeparator);
|
|
286
320
|
}
|
|
287
321
|
|
|
288
|
-
return readUnquotedHeadersEnd(text, start);
|
|
322
|
+
return readUnquotedHeadersEnd(text, start, pairSeparator);
|
|
289
323
|
}
|
|
290
|
-
function splitHeaders(headers) {
|
|
324
|
+
function splitHeaders(headers, pairSeparator) {
|
|
291
325
|
const result = [];
|
|
292
326
|
let start = 0;
|
|
293
327
|
let quote = "";
|
|
@@ -298,14 +332,10 @@ var grammars = String.raw`
|
|
|
298
332
|
const char = headers[index];
|
|
299
333
|
|
|
300
334
|
if (quote) {
|
|
301
|
-
if (char === "\\" && index + 1 < headers.length) {
|
|
302
|
-
index++;
|
|
303
|
-
continue;
|
|
304
|
-
}
|
|
305
335
|
if (char === quote) {
|
|
306
336
|
if (
|
|
307
337
|
quoteRole === "key" ||
|
|
308
|
-
isHeaderValueQuoteEnd(headers, index)
|
|
338
|
+
isHeaderValueQuoteEnd(headers, index, pairSeparator, false)
|
|
309
339
|
) {
|
|
310
340
|
quote = "";
|
|
311
341
|
quoteRole = "";
|
|
@@ -325,7 +355,7 @@ var grammars = String.raw`
|
|
|
325
355
|
continue;
|
|
326
356
|
}
|
|
327
357
|
|
|
328
|
-
if (char ===
|
|
358
|
+
if (char === pairSeparator && isHeaderKeyStart(headers, index + 1)) {
|
|
329
359
|
result.push(headers.slice(start, index));
|
|
330
360
|
start = index + 1;
|
|
331
361
|
seenSeparator = false;
|
|
@@ -335,9 +365,9 @@ var grammars = String.raw`
|
|
|
335
365
|
result.push(headers.slice(start));
|
|
336
366
|
return result;
|
|
337
367
|
}
|
|
338
|
-
function parseHeaders(headers) {
|
|
368
|
+
function parseHeaders(headers, pairSeparator) {
|
|
339
369
|
const result = {};
|
|
340
|
-
splitHeaders(stripOuterHeadersQuotes(headers)).forEach((pair) => {
|
|
370
|
+
splitHeaders(stripOuterHeadersQuotes(headers), pairSeparator).forEach((pair) => {
|
|
341
371
|
const index = findHeaderSeparator(pair);
|
|
342
372
|
if (index === -1) return;
|
|
343
373
|
|
|
@@ -350,6 +380,12 @@ var grammars = String.raw`
|
|
|
350
380
|
});
|
|
351
381
|
return result;
|
|
352
382
|
}
|
|
383
|
+
function normalizeVmessSecurity(security) {
|
|
384
|
+
const normalized = String(security || "").trim().toLowerCase();
|
|
385
|
+
const supported = ["aes-128-gcm", "chacha20-ietf-poly1305"];
|
|
386
|
+
if (!supported.includes(normalized)) return "auto";
|
|
387
|
+
return normalized === "chacha20-ietf-poly1305" ? "chacha20-poly1305" : normalized;
|
|
388
|
+
}
|
|
353
389
|
}
|
|
354
390
|
|
|
355
391
|
start = (anytls/shadowsocks/vmess/trojan/h2_connect/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2/ssh/trust_tunnel/direct) {
|
|
@@ -367,9 +403,9 @@ shadowsocks = tag equals "ss" address (method/passwordk/obfs/obfs_host/obfs_uri/
|
|
|
367
403
|
}
|
|
368
404
|
handleShadowTLS();
|
|
369
405
|
}
|
|
370
|
-
vmess = tag equals "vmess" address (vmess_uuid/vmess_aead/ws/ws_path/ws_headers/
|
|
406
|
+
vmess = tag equals "vmess" address (vmess_uuid/vmess_aead/ws/ws_path/ws_headers/vmess_method/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls/sni/tls_fingerprint/tls_verification/client_cert/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
371
407
|
proxy.type = "vmess";
|
|
372
|
-
proxy.cipher = proxy.cipher || "
|
|
408
|
+
proxy.cipher = proxy.cipher || "auto";
|
|
373
409
|
// Surfboard 与 Surge 默认不一致, 不管 Surfboard https://getsurfboard.com/docs/profile-format/proxy/external-proxy/vmess
|
|
374
410
|
if (proxy.aead) {
|
|
375
411
|
proxy.alterId = 0;
|
|
@@ -523,7 +559,7 @@ tls_verification = comma "skip-cert-verify" equals flag:bool { proxy["skip-cert-
|
|
|
523
559
|
tls_fingerprint = comma "server-cert-fingerprint-sha256" equals tls_fingerprint:$[^,]+ { proxy["tls-fingerprint"] = tls_fingerprint.trim(); }
|
|
524
560
|
client_cert = comma "client-cert" equals match:[^,]+ { proxy["keystore-client-cert"] = stripQuotes(match.join("")); }
|
|
525
561
|
|
|
526
|
-
snell_psk = comma "psk" equals match:[^,]+ { proxy.psk = match.join(""); }
|
|
562
|
+
snell_psk = comma "psk" equals match:[^,]+ { proxy.psk = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
|
527
563
|
snell_version = comma "version" equals match:$[0-9]+ { proxy.version = parseInt(match.trim()); }
|
|
528
564
|
|
|
529
565
|
usernamek = comma "username" equals match:[^,]+ { proxy.username = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
|
@@ -534,27 +570,29 @@ vmess_aead = comma "vmess-aead" equals flag:bool { proxy.aead = flag; }
|
|
|
534
570
|
method = comma "encrypt-method" equals cipher:cipher {
|
|
535
571
|
proxy.cipher = cipher;
|
|
536
572
|
}
|
|
573
|
+
vmess_method = comma "encrypt-method" equals cipher:$[^,]+ {
|
|
574
|
+
proxy.cipher = normalizeVmessSecurity(cipher);
|
|
575
|
+
}
|
|
537
576
|
cipher = ("aes-128-cfb"/"aes-128-ctr"/"aes-128-gcm"/"aes-192-cfb"/"aes-192-ctr"/"aes-192-gcm"/"aes-256-cfb"/"aes-256-ctr"/"aes-256-gcm"/"bf-cfb"/"camellia-128-cfb"/"camellia-192-cfb"/"camellia-256-cfb"/"cast5-cfb"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"des-cfb"/"idea-cfb"/"none"/"rc2-cfb"/"rc4-md5"/"rc4"/"salsa20"/"seed-cfb"/"xchacha20-ietf-poly1305"/"2022-blake3-aes-128-gcm"/"2022-blake3-aes-256-gcm");
|
|
538
577
|
|
|
539
578
|
ws = comma "ws" equals flag:bool { obfs.type = "ws"; }
|
|
540
|
-
ws_headers = comma "ws-headers" equals
|
|
541
|
-
const
|
|
542
|
-
const
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
}
|
|
579
|
+
ws_headers = comma "ws-headers" equals & {
|
|
580
|
+
const start = peg$currPos;
|
|
581
|
+
const index = readHeadersEnd(input, start, "|");
|
|
582
|
+
|
|
583
|
+
$.headers = input.substring(start, index);
|
|
584
|
+
peg$currPos = index;
|
|
585
|
+
return $.headers.trim().length > 0;
|
|
586
|
+
} { obfs["ws-headers"] = parseHeaders($.headers, "|"); }
|
|
549
587
|
ws_path = comma "ws-path" equals path:uri { obfs.path = path.trim().replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
|
550
588
|
headers = comma "headers" equals & {
|
|
551
589
|
const start = peg$currPos;
|
|
552
|
-
const index = readHeadersEnd(input, start);
|
|
590
|
+
const index = readHeadersEnd(input, start, ";");
|
|
553
591
|
|
|
554
592
|
$.headers = input.substring(start, index);
|
|
555
593
|
peg$currPos = index;
|
|
556
594
|
return $.headers.trim().length > 0;
|
|
557
|
-
} { proxy.headers = parseHeaders($.headers); }
|
|
595
|
+
} { proxy.headers = parseHeaders($.headers, ";"); }
|
|
558
596
|
|
|
559
597
|
obfs = comma "obfs" equals type:("http"/"tls") { obfs.type = type; }
|
|
560
598
|
obfs_host = comma "obfs-host" equals match:[^,]+ { obfs.host = match.join("").replace(/^"(.*)"$/, '$1'); };
|
|
@@ -644,6 +682,23 @@ var grammars2 = String.raw`
|
|
|
644
682
|
$set(proxy, "http-opts.headers.Host", transport.host);
|
|
645
683
|
}
|
|
646
684
|
}
|
|
685
|
+
|
|
686
|
+
function normalizeVmessSecurity(security) {
|
|
687
|
+
const normalized = String(security || "").trim().toLowerCase();
|
|
688
|
+
const supported = ["none", "auto", "aes-128-gcm", "chacha20-ietf-poly1305"];
|
|
689
|
+
if (!supported.includes(normalized)) return "auto";
|
|
690
|
+
return normalized === "chacha20-ietf-poly1305" ? "chacha20-poly1305" : normalized;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
function loonClientFingerprint(tlsProfile) {
|
|
694
|
+
switch (String(tlsProfile || "").trim()) {
|
|
695
|
+
case "chrome":
|
|
696
|
+
return "chrome";
|
|
697
|
+
case "ios18":
|
|
698
|
+
case "ios26":
|
|
699
|
+
return "ios";
|
|
700
|
+
}
|
|
701
|
+
}
|
|
647
702
|
}
|
|
648
703
|
|
|
649
704
|
start = (shadowsocksr/shadowsocks/vmess/vless/trojan/https/http/socks5/hysteria2/anytls) {
|
|
@@ -665,35 +720,35 @@ shadowsocks = tag equals "shadowsocks"i address method password (obfs_typev obfs
|
|
|
665
720
|
$set(proxy, "plugin-opts.path", obfs.path);
|
|
666
721
|
}
|
|
667
722
|
}
|
|
668
|
-
vmess = tag equals "vmess"i address
|
|
723
|
+
vmess = tag equals "vmess"i address vmess_method uuid (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/vmess_alterId/fast_open/udp_relay/ip_mode/public_key/short_id/block_quic/others)* {
|
|
669
724
|
proxy.type = "vmess";
|
|
670
|
-
proxy.cipher = proxy.cipher || "
|
|
725
|
+
proxy.cipher = proxy.cipher || "auto";
|
|
671
726
|
proxy.alterId = proxy.alterId || 0;
|
|
672
727
|
handleTransport();
|
|
673
728
|
}
|
|
674
|
-
vless = tag equals "vless"i address uuid (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/flow/public_key/short_id/block_quic/others)* {
|
|
729
|
+
vless = tag equals "vless"i address uuid (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/fast_open/udp_relay/ip_mode/flow/public_key/short_id/block_quic/others)* {
|
|
675
730
|
proxy.type = "vless";
|
|
676
731
|
handleTransport();
|
|
677
732
|
}
|
|
678
|
-
trojan = tag equals "trojan"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/others)* {
|
|
733
|
+
trojan = tag equals "trojan"i address password (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/fast_open/udp_relay/ip_mode/block_quic/others)* {
|
|
679
734
|
proxy.type = "trojan";
|
|
680
735
|
handleTransport();
|
|
681
736
|
}
|
|
682
|
-
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)* {
|
|
737
|
+
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/tls_profile/alpn/fast_open/udp_relay/ip_mode/block_quic/idle_session_check_interval/idle_session_timeout/min_idle_session/max_stream_count/others)* {
|
|
683
738
|
proxy.type = "anytls";
|
|
684
739
|
handleTransport();
|
|
685
740
|
}
|
|
686
|
-
hysteria2 = tag equals "hysteria2"i address password (tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/udp_relay/fast_open/download_bandwidth/server_ports/hop_interval/salamander_password/ecn/ip_mode/block_quic/others)* {
|
|
741
|
+
hysteria2 = tag equals "hysteria2"i address password (tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/udp_relay/fast_open/download_bandwidth/server_ports/hop_interval/salamander_password/ecn/ip_mode/block_quic/others)* {
|
|
687
742
|
proxy.type = "hysteria2";
|
|
688
743
|
}
|
|
689
|
-
https = tag equals "https"i address (username password)? (tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/block_quic/others)* {
|
|
744
|
+
https = tag equals "https"i address (username password)? (tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/fast_open/udp_relay/ip_mode/block_quic/others)* {
|
|
690
745
|
proxy.type = "http";
|
|
691
746
|
proxy.tls = true;
|
|
692
747
|
}
|
|
693
748
|
http = tag equals "http"i address (username password)? (fast_open/udp_relay/ip_mode/block_quic/others)* {
|
|
694
749
|
proxy.type = "http";
|
|
695
750
|
}
|
|
696
|
-
socks5 = tag equals "socks5"i address (username password)? (over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/block_quic/others)* {
|
|
751
|
+
socks5 = tag equals "socks5"i address (username password)? (over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/fast_open/udp_relay/ip_mode/block_quic/others)* {
|
|
697
752
|
proxy.type = "socks5";
|
|
698
753
|
}
|
|
699
754
|
|
|
@@ -735,6 +790,9 @@ port = digits:[0-9]+ {
|
|
|
735
790
|
method = comma cipher:cipher {
|
|
736
791
|
proxy.cipher = cipher;
|
|
737
792
|
}
|
|
793
|
+
vmess_method = comma cipher:$[^,]+ {
|
|
794
|
+
proxy.cipher = normalizeVmessSecurity(cipher);
|
|
795
|
+
}
|
|
738
796
|
cipher = ("aes-128-cfb"/"aes-128-ctr"/"aes-128-gcm"/"aes-192-cfb"/"aes-192-ctr"/"aes-192-gcm"/"aes-256-cfb"/"aes-256-ctr"/"aes-256-gcm"/"auto"/"bf-cfb"/"camellia-128-cfb"/"camellia-192-cfb"/"camellia-256-cfb"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"none"/"rc4-md5"/"rc4"/"salsa20"/"xchacha20-ietf-poly1305"/"2022-blake3-aes-128-gcm"/"2022-blake3-aes-256-gcm");
|
|
739
797
|
|
|
740
798
|
username = & {
|
|
@@ -787,7 +845,7 @@ vmess_alterId = comma "alterId" equals alterId:$[0-9]+ { proxy.alterId = parseIn
|
|
|
787
845
|
udp_port = comma "udp-port" equals match:$[0-9]+ { proxy["udp-port"] = parseInt(match.trim()); }
|
|
788
846
|
shadow_tls_version = comma "shadow-tls-version" equals match:$[0-9]+ { proxy["shadow-tls-version"] = parseInt(match.trim()); }
|
|
789
847
|
shadow_tls_sni = comma "shadow-tls-sni" equals match:[^,]+ { proxy["shadow-tls-sni"] = match.join(""); }
|
|
790
|
-
shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { proxy["shadow-tls-password"] = match.join(""); }
|
|
848
|
+
shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { proxy["shadow-tls-password"] = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
|
791
849
|
|
|
792
850
|
over_tls = comma "over-tls" equals flag:bool { proxy.tls = flag; }
|
|
793
851
|
tls_name = comma sni:("tls-name") equals match:[^,]+ { proxy.sni = match.join("").replace(/^"(.*)"$/, '$1'); }
|
|
@@ -795,6 +853,19 @@ sni = comma "sni" equals match:[^,]+ { proxy.sni = match.join("").replace(/^"(.*
|
|
|
795
853
|
tls_verification = comma "skip-cert-verify" equals flag:bool { proxy["skip-cert-verify"] = flag; }
|
|
796
854
|
tls_cert_sha256 = comma "tls-cert-sha256" equals match:[^,]+ { proxy["tls-fingerprint"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
|
797
855
|
tls_pubkey_sha256 = comma "tls-pubkey-sha256" equals match:[^,]+ { proxy["tls-pubkey-sha256"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
|
856
|
+
tls_profile = comma "tls-profile" equals match:[^,]+ {
|
|
857
|
+
const tlsProfile = match.join("").replace(/^"(.*)"$/, '$1').trim();
|
|
858
|
+
proxy["_loon_tls_profile"] = tlsProfile;
|
|
859
|
+
const clientFingerprint = loonClientFingerprint(tlsProfile);
|
|
860
|
+
if (clientFingerprint) proxy["client-fingerprint"] = clientFingerprint;
|
|
861
|
+
}
|
|
862
|
+
alpn = comma "alpn" equals '"' match:$[^"]* '"' {
|
|
863
|
+
const values = match
|
|
864
|
+
.split(",")
|
|
865
|
+
.map((item) => item.trim())
|
|
866
|
+
.filter((item) => item !== "");
|
|
867
|
+
if (values.length > 0) proxy.alpn = values;
|
|
868
|
+
}
|
|
798
869
|
|
|
799
870
|
flow = comma "flow" equals match:[^,]+ { proxy["flow"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
|
800
871
|
public_key = comma "public-key" equals match:[^,]+ { proxy["reality-opts"] = proxy["reality-opts"] || {}; proxy["reality-opts"]["public-key"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
|
@@ -1423,7 +1494,7 @@ import _ from "lodash";
|
|
|
1423
1494
|
import { Base64 } from "js-base64";
|
|
1424
1495
|
|
|
1425
1496
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/xhttp-utils.js
|
|
1426
|
-
function parseNormalizedXhttpRangeBounds(value, { allowZeroUpperBound = true } = {}) {
|
|
1497
|
+
function parseNormalizedXhttpRangeBounds(value, { allowZeroLowerBound = true, allowZeroUpperBound = true } = {}) {
|
|
1427
1498
|
if (typeof value !== "string" && typeof value !== "number") {
|
|
1428
1499
|
return void 0;
|
|
1429
1500
|
}
|
|
@@ -1437,9 +1508,14 @@ function parseNormalizedXhttpRangeBounds(value, { allowZeroUpperBound = true } =
|
|
|
1437
1508
|
};
|
|
1438
1509
|
const normalizedValue = `${value}`.trim();
|
|
1439
1510
|
const rangeParts = normalizedValue.split("-");
|
|
1511
|
+
const minimumAllowedLowerBound = allowZeroLowerBound ? 0 : 1;
|
|
1512
|
+
const minimumAllowedUpperBound = allowZeroUpperBound ? 0 : 1;
|
|
1440
1513
|
if (rangeParts.length === 1) {
|
|
1441
1514
|
const normalizedInteger = parseUnsignedIntegerToken(rangeParts[0]);
|
|
1442
|
-
const minimumAllowedValue =
|
|
1515
|
+
const minimumAllowedValue = Math.max(
|
|
1516
|
+
minimumAllowedLowerBound,
|
|
1517
|
+
minimumAllowedUpperBound
|
|
1518
|
+
);
|
|
1443
1519
|
return normalizedInteger >= minimumAllowedValue ? {
|
|
1444
1520
|
lowerBound: normalizedInteger,
|
|
1445
1521
|
upperBound: normalizedInteger
|
|
@@ -1453,8 +1529,7 @@ function parseNormalizedXhttpRangeBounds(value, { allowZeroUpperBound = true } =
|
|
|
1453
1529
|
if (lowerBound == null || upperBound == null) {
|
|
1454
1530
|
return void 0;
|
|
1455
1531
|
}
|
|
1456
|
-
|
|
1457
|
-
return upperBound >= minimumAllowedUpperBound && upperBound >= lowerBound ? {
|
|
1532
|
+
return lowerBound >= minimumAllowedLowerBound && upperBound >= minimumAllowedUpperBound && upperBound >= lowerBound ? {
|
|
1458
1533
|
lowerBound,
|
|
1459
1534
|
upperBound
|
|
1460
1535
|
} : void 0;
|
|
@@ -1464,9 +1539,11 @@ function parseNormalizedXhttpPositiveRangeBounds(value) {
|
|
|
1464
1539
|
allowZeroUpperBound: false
|
|
1465
1540
|
});
|
|
1466
1541
|
}
|
|
1467
|
-
function
|
|
1468
|
-
|
|
1469
|
-
|
|
1542
|
+
function parseNormalizedXhttpStrictPositiveRangeBounds(value) {
|
|
1543
|
+
return parseNormalizedXhttpRangeBounds(value, {
|
|
1544
|
+
allowZeroLowerBound: false,
|
|
1545
|
+
allowZeroUpperBound: false
|
|
1546
|
+
});
|
|
1470
1547
|
}
|
|
1471
1548
|
function normalizeXhttpPositiveRange(value) {
|
|
1472
1549
|
const normalizedBounds = parseNormalizedXhttpPositiveRangeBounds(value);
|
|
@@ -1476,6 +1553,22 @@ function normalizeXhttpPositiveRange(value) {
|
|
|
1476
1553
|
const { lowerBound, upperBound } = normalizedBounds;
|
|
1477
1554
|
return lowerBound === upperBound ? upperBound : `${lowerBound}-${upperBound}`;
|
|
1478
1555
|
}
|
|
1556
|
+
function normalizeXhttpStrictPositiveRangeString(value) {
|
|
1557
|
+
const normalizedBounds = parseNormalizedXhttpStrictPositiveRangeBounds(value);
|
|
1558
|
+
if (!normalizedBounds) {
|
|
1559
|
+
return void 0;
|
|
1560
|
+
}
|
|
1561
|
+
const { lowerBound, upperBound } = normalizedBounds;
|
|
1562
|
+
return lowerBound === upperBound ? `${upperBound}` : `${lowerBound}-${upperBound}`;
|
|
1563
|
+
}
|
|
1564
|
+
function normalizeXhttpStrictPositiveRangeValue(value) {
|
|
1565
|
+
const normalizedBounds = parseNormalizedXhttpStrictPositiveRangeBounds(value);
|
|
1566
|
+
if (!normalizedBounds) {
|
|
1567
|
+
return void 0;
|
|
1568
|
+
}
|
|
1569
|
+
const { lowerBound, upperBound } = normalizedBounds;
|
|
1570
|
+
return lowerBound === upperBound ? upperBound : `${lowerBound}-${upperBound}`;
|
|
1571
|
+
}
|
|
1479
1572
|
function normalizeXhttpNonNegativeRange(value) {
|
|
1480
1573
|
const normalizedBounds = parseNormalizedXhttpRangeBounds(value);
|
|
1481
1574
|
if (!normalizedBounds) {
|
|
@@ -1743,6 +1836,69 @@ function buildXrayEchConfigListFromMihomo(echOpts, fallbackEchConfigList, option
|
|
|
1743
1836
|
return buildXrayEchFieldsFromMihomo(echOpts, fallbackEchConfigList, options).echConfigList;
|
|
1744
1837
|
}
|
|
1745
1838
|
|
|
1839
|
+
// src/vendors/Sub-Store/backend/src/core/proxy-utils/vmess-security.js
|
|
1840
|
+
var VMESS_SECURITY_AUTO = "auto";
|
|
1841
|
+
var VMESS_SECURITY_COMMON_VALUES = [
|
|
1842
|
+
VMESS_SECURITY_AUTO,
|
|
1843
|
+
"none",
|
|
1844
|
+
"zero",
|
|
1845
|
+
"aes-128-gcm",
|
|
1846
|
+
"chacha20-poly1305"
|
|
1847
|
+
];
|
|
1848
|
+
var VMESS_SECURITY_CLASH_VALUES = [
|
|
1849
|
+
VMESS_SECURITY_AUTO,
|
|
1850
|
+
"aes-128-gcm",
|
|
1851
|
+
"chacha20-poly1305",
|
|
1852
|
+
"none"
|
|
1853
|
+
];
|
|
1854
|
+
var VMESS_SECURITY_QX_METHOD_VALUES = ["none", "chacha20-poly1305"];
|
|
1855
|
+
var VMESS_SECURITY_ALIASES = {
|
|
1856
|
+
"chacha20-ietf-poly1305": "chacha20-poly1305"
|
|
1857
|
+
};
|
|
1858
|
+
function normalizeSecurityValue(security) {
|
|
1859
|
+
if (security == null) return "";
|
|
1860
|
+
return `${security}`.trim().toLowerCase();
|
|
1861
|
+
}
|
|
1862
|
+
function canonicalizeVmessSecurity(security) {
|
|
1863
|
+
return VMESS_SECURITY_ALIASES[security] || security;
|
|
1864
|
+
}
|
|
1865
|
+
function normalizeVmessSecurity(security, supportedValues = VMESS_SECURITY_COMMON_VALUES, { acceptAliases = true, fallback = VMESS_SECURITY_AUTO } = {}) {
|
|
1866
|
+
const normalized = normalizeSecurityValue(security);
|
|
1867
|
+
if (!normalized) return fallback;
|
|
1868
|
+
const normalizedSupported = supportedValues.map(normalizeSecurityValue);
|
|
1869
|
+
if (normalizedSupported.includes(normalized)) {
|
|
1870
|
+
return canonicalizeVmessSecurity(normalized);
|
|
1871
|
+
}
|
|
1872
|
+
const canonical = canonicalizeVmessSecurity(normalized);
|
|
1873
|
+
const canonicalSupported = normalizedSupported.map(
|
|
1874
|
+
canonicalizeVmessSecurity
|
|
1875
|
+
);
|
|
1876
|
+
if (acceptAliases && canonicalSupported.includes(canonical)) {
|
|
1877
|
+
return canonical;
|
|
1878
|
+
}
|
|
1879
|
+
return fallback;
|
|
1880
|
+
}
|
|
1881
|
+
function normalizeClashVmessSecurity(security) {
|
|
1882
|
+
return normalizeVmessSecurity(security, VMESS_SECURITY_CLASH_VALUES);
|
|
1883
|
+
}
|
|
1884
|
+
function formatQXVmessMethod(security) {
|
|
1885
|
+
return normalizeVmessSecurity(security, VMESS_SECURITY_QX_METHOD_VALUES, {
|
|
1886
|
+
fallback: "chacha20-poly1305"
|
|
1887
|
+
});
|
|
1888
|
+
}
|
|
1889
|
+
function formatLoonVmessSecurity(security) {
|
|
1890
|
+
const normalized = normalizeClashVmessSecurity(security);
|
|
1891
|
+
return normalized === "chacha20-poly1305" ? "chacha20-ietf-poly1305" : normalized;
|
|
1892
|
+
}
|
|
1893
|
+
function formatSurgeVmessEncryptMethod(security) {
|
|
1894
|
+
const normalized = normalizeVmessSecurity(security, [
|
|
1895
|
+
"aes-128-gcm",
|
|
1896
|
+
"chacha20-poly1305"
|
|
1897
|
+
]);
|
|
1898
|
+
if (normalized === VMESS_SECURITY_AUTO) return void 0;
|
|
1899
|
+
return normalized === "chacha20-poly1305" ? "chacha20-ietf-poly1305" : normalized;
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1746
1902
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/parsers/index.js
|
|
1747
1903
|
function surge_port_hopping(raw) {
|
|
1748
1904
|
const [parts, port_hopping] = raw.match(
|
|
@@ -2255,7 +2411,9 @@ function URI_VMess() {
|
|
|
2255
2411
|
type: "vmess",
|
|
2256
2412
|
server: partitions[1],
|
|
2257
2413
|
port: partitions[2],
|
|
2258
|
-
cipher:
|
|
2414
|
+
cipher: normalizeVmessSecurity(
|
|
2415
|
+
getIfNotBlank(partitions[3], "auto")
|
|
2416
|
+
),
|
|
2259
2417
|
uuid: partitions[4].match(/^"(.*)"$/)[1],
|
|
2260
2418
|
tls: params.obfs === "wss",
|
|
2261
2419
|
udp: getIfPresent(params["udp-relay"]),
|
|
@@ -2319,12 +2477,7 @@ function URI_VMess() {
|
|
|
2319
2477
|
port,
|
|
2320
2478
|
// https://github.com/2dust/v2rayN/wiki/Description-of-VMess-share-link
|
|
2321
2479
|
// https://github.com/XTLS/Xray-core/issues/91
|
|
2322
|
-
cipher:
|
|
2323
|
-
"auto",
|
|
2324
|
-
"aes-128-gcm",
|
|
2325
|
-
"chacha20-poly1305",
|
|
2326
|
-
"none"
|
|
2327
|
-
].includes(params.scy) ? params.scy : "auto",
|
|
2480
|
+
cipher: normalizeVmessSecurity(params.scy),
|
|
2328
2481
|
uuid: params.id,
|
|
2329
2482
|
alterId: parseInt(
|
|
2330
2483
|
getIfPresent(params.aid ?? params.alterId, 0),
|
|
@@ -2423,7 +2576,9 @@ function URI_VMess() {
|
|
|
2423
2576
|
};
|
|
2424
2577
|
const normalizedTransportHost = getIfNotBlank(transportHost);
|
|
2425
2578
|
if (proxy.network === "h2") {
|
|
2426
|
-
const h2Hosts = splitURIHostList(
|
|
2579
|
+
const h2Hosts = splitURIHostList(
|
|
2580
|
+
normalizedTransportHost
|
|
2581
|
+
);
|
|
2427
2582
|
if (h2Hosts) {
|
|
2428
2583
|
opts.host = h2Hosts;
|
|
2429
2584
|
}
|
|
@@ -2497,7 +2652,7 @@ function URI_VLESS() {
|
|
|
2497
2652
|
}
|
|
2498
2653
|
const parsedHeaders = {};
|
|
2499
2654
|
for (const [key, value] of Object.entries(headers)) {
|
|
2500
|
-
if (typeof value === "string"
|
|
2655
|
+
if (typeof value === "string") {
|
|
2501
2656
|
parsedHeaders[key] = value;
|
|
2502
2657
|
}
|
|
2503
2658
|
}
|
|
@@ -2549,7 +2704,7 @@ function URI_VLESS() {
|
|
|
2549
2704
|
}
|
|
2550
2705
|
const unsupportedHeaders = {};
|
|
2551
2706
|
for (const [key, value] of Object.entries(headers)) {
|
|
2552
|
-
if (typeof value === "string"
|
|
2707
|
+
if (typeof value === "string") {
|
|
2553
2708
|
continue;
|
|
2554
2709
|
}
|
|
2555
2710
|
setUnsupportedXhttpField(unsupportedHeaders, key, value);
|
|
@@ -2615,18 +2770,37 @@ function URI_VLESS() {
|
|
|
2615
2770
|
}
|
|
2616
2771
|
break;
|
|
2617
2772
|
case "xPaddingBytes":
|
|
2773
|
+
if (normalizeXhttpStrictPositiveRangeString(value) == null) {
|
|
2774
|
+
setUnsupportedXhttpField(
|
|
2775
|
+
unsupportedExtra,
|
|
2776
|
+
key,
|
|
2777
|
+
value
|
|
2778
|
+
);
|
|
2779
|
+
}
|
|
2780
|
+
break;
|
|
2618
2781
|
case "xPaddingKey":
|
|
2619
2782
|
case "xPaddingHeader":
|
|
2620
2783
|
case "xPaddingPlacement":
|
|
2621
2784
|
case "xPaddingMethod":
|
|
2622
2785
|
case "uplinkHTTPMethod":
|
|
2786
|
+
case "sessionIDPlacement":
|
|
2623
2787
|
case "sessionPlacement":
|
|
2788
|
+
case "sessionIDKey":
|
|
2624
2789
|
case "sessionKey":
|
|
2625
2790
|
case "seqPlacement":
|
|
2626
2791
|
case "seqKey":
|
|
2627
2792
|
case "uplinkDataPlacement":
|
|
2628
2793
|
case "uplinkDataKey":
|
|
2629
|
-
if (
|
|
2794
|
+
if (typeof value !== "string") {
|
|
2795
|
+
setUnsupportedXhttpField(
|
|
2796
|
+
unsupportedExtra,
|
|
2797
|
+
key,
|
|
2798
|
+
value
|
|
2799
|
+
);
|
|
2800
|
+
}
|
|
2801
|
+
break;
|
|
2802
|
+
case "sessionIDTable":
|
|
2803
|
+
if (typeof value !== "string") {
|
|
2630
2804
|
setUnsupportedXhttpField(
|
|
2631
2805
|
unsupportedExtra,
|
|
2632
2806
|
key,
|
|
@@ -2644,7 +2818,7 @@ function URI_VLESS() {
|
|
|
2644
2818
|
}
|
|
2645
2819
|
break;
|
|
2646
2820
|
case "scMaxEachPostBytes":
|
|
2647
|
-
if (
|
|
2821
|
+
if (normalizeXhttpStrictPositiveRangeString(value) == null) {
|
|
2648
2822
|
setUnsupportedXhttpField(
|
|
2649
2823
|
unsupportedExtra,
|
|
2650
2824
|
key,
|
|
@@ -2661,6 +2835,15 @@ function URI_VLESS() {
|
|
|
2661
2835
|
);
|
|
2662
2836
|
}
|
|
2663
2837
|
break;
|
|
2838
|
+
case "sessionIDLength":
|
|
2839
|
+
if (normalizeXhttpStrictPositiveRangeString(value) == null) {
|
|
2840
|
+
setUnsupportedXhttpField(
|
|
2841
|
+
unsupportedExtra,
|
|
2842
|
+
key,
|
|
2843
|
+
value
|
|
2844
|
+
);
|
|
2845
|
+
}
|
|
2846
|
+
break;
|
|
2664
2847
|
case "xmux": {
|
|
2665
2848
|
const unsupportedXmux = collectUnsupportedXmux(value);
|
|
2666
2849
|
if (unsupportedXmux !== void 0) {
|
|
@@ -2973,8 +3156,11 @@ function URI_VLESS() {
|
|
|
2973
3156
|
if (extra.noGRPCHeader === true) {
|
|
2974
3157
|
target["no-grpc-header"] = true;
|
|
2975
3158
|
}
|
|
2976
|
-
|
|
2977
|
-
|
|
3159
|
+
const xPaddingBytes = normalizeXhttpStrictPositiveRangeString(
|
|
3160
|
+
extra.xPaddingBytes
|
|
3161
|
+
);
|
|
3162
|
+
if (xPaddingBytes != null) {
|
|
3163
|
+
target["x-padding-bytes"] = xPaddingBytes;
|
|
2978
3164
|
}
|
|
2979
3165
|
if (extra.xPaddingObfsMode === true) {
|
|
2980
3166
|
target["x-padding-obfs-mode"] = true;
|
|
@@ -2994,12 +3180,25 @@ function URI_VLESS() {
|
|
|
2994
3180
|
if (isNotBlank(extra.uplinkHTTPMethod)) {
|
|
2995
3181
|
target["uplink-http-method"] = extra.uplinkHTTPMethod;
|
|
2996
3182
|
}
|
|
2997
|
-
if (isNotBlank(extra.
|
|
3183
|
+
if (isNotBlank(extra.sessionIDPlacement)) {
|
|
3184
|
+
target["session-placement"] = extra.sessionIDPlacement;
|
|
3185
|
+
} else if (isNotBlank(extra.sessionPlacement)) {
|
|
2998
3186
|
target["session-placement"] = extra.sessionPlacement;
|
|
2999
3187
|
}
|
|
3000
|
-
if (isNotBlank(extra.
|
|
3188
|
+
if (isNotBlank(extra.sessionIDKey)) {
|
|
3189
|
+
target["session-key"] = extra.sessionIDKey;
|
|
3190
|
+
} else if (isNotBlank(extra.sessionKey)) {
|
|
3001
3191
|
target["session-key"] = extra.sessionKey;
|
|
3002
3192
|
}
|
|
3193
|
+
if (typeof extra.sessionIDTable === "string") {
|
|
3194
|
+
target["session-table"] = extra.sessionIDTable;
|
|
3195
|
+
}
|
|
3196
|
+
const sessionIDLength = normalizeXhttpStrictPositiveRangeString(
|
|
3197
|
+
extra.sessionIDLength
|
|
3198
|
+
);
|
|
3199
|
+
if (sessionIDLength != null) {
|
|
3200
|
+
target["session-length"] = sessionIDLength;
|
|
3201
|
+
}
|
|
3003
3202
|
if (isNotBlank(extra.seqPlacement)) {
|
|
3004
3203
|
target["seq-placement"] = extra.seqPlacement;
|
|
3005
3204
|
}
|
|
@@ -3018,7 +3217,7 @@ function URI_VLESS() {
|
|
|
3018
3217
|
if (uplinkChunkSize != null) {
|
|
3019
3218
|
target["uplink-chunk-size"] = uplinkChunkSize;
|
|
3020
3219
|
}
|
|
3021
|
-
const scMaxEachPostBytes =
|
|
3220
|
+
const scMaxEachPostBytes = normalizeXhttpStrictPositiveRangeValue(
|
|
3022
3221
|
extra.scMaxEachPostBytes
|
|
3023
3222
|
);
|
|
3024
3223
|
if (scMaxEachPostBytes != null) {
|
|
@@ -3192,14 +3391,15 @@ function URI_VLESS() {
|
|
|
3192
3391
|
}
|
|
3193
3392
|
proxy["tls-fingerprint"] = getIfPresent(params.pcs);
|
|
3194
3393
|
proxy._h2 = /(TRUE)|1/i.test(params.h2);
|
|
3195
|
-
switch (`${params.packetEncoding || ""}`.toLowerCase()) {
|
|
3394
|
+
switch (`${params.packetEncoding || ""}`.trim().toLowerCase()) {
|
|
3196
3395
|
case "none":
|
|
3396
|
+
proxy["packet-encoding"] = "";
|
|
3197
3397
|
break;
|
|
3198
3398
|
case "packet":
|
|
3199
|
-
proxy["packet-
|
|
3399
|
+
proxy["packet-encoding"] = "packetaddr";
|
|
3200
3400
|
break;
|
|
3201
3401
|
default:
|
|
3202
|
-
proxy
|
|
3402
|
+
proxy["packet-encoding"] = "xudp";
|
|
3203
3403
|
break;
|
|
3204
3404
|
}
|
|
3205
3405
|
if (["reality"].includes(params.security)) {
|
|
@@ -3819,6 +4019,9 @@ function Clash_All() {
|
|
|
3819
4019
|
if (proxy["benchmark-timeout"]) {
|
|
3820
4020
|
proxy["test-timeout"] = proxy["benchmark-timeout"];
|
|
3821
4021
|
}
|
|
4022
|
+
if (proxy.type === "vmess") {
|
|
4023
|
+
proxy.cipher = normalizeVmessSecurity(proxy.cipher);
|
|
4024
|
+
}
|
|
3822
4025
|
return proxy;
|
|
3823
4026
|
};
|
|
3824
4027
|
return { name, test, parse };
|
|
@@ -4299,57 +4502,226 @@ var parsers_default = [
|
|
|
4299
4502
|
|
|
4300
4503
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/utils.js
|
|
4301
4504
|
import _2 from "lodash";
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4505
|
+
|
|
4506
|
+
// src/vendors/Sub-Store/backend/src/core/proxy-utils/preprocessors/index.js
|
|
4507
|
+
import { Base64 as Base642 } from "js-base64";
|
|
4508
|
+
function normalizeClashYaml(raw) {
|
|
4509
|
+
if (typeof raw !== "string" || !raw.includes("proxies:") || !raw.includes("short-id:")) {
|
|
4510
|
+
return raw;
|
|
4306
4511
|
}
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4512
|
+
try {
|
|
4513
|
+
const content = safeLoad(raw);
|
|
4514
|
+
if (!Array.isArray(content.proxies) || content.proxies.length === 0)
|
|
4515
|
+
return raw;
|
|
4516
|
+
} catch (e) {
|
|
4517
|
+
return raw;
|
|
4312
4518
|
}
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4519
|
+
return raw.replace(/short-id:([ \t]*[^#\n,}]*)/g, (matched, value) => {
|
|
4520
|
+
const afterTrim = value.trim();
|
|
4521
|
+
if (!afterTrim || afterTrim === "") {
|
|
4522
|
+
return 'short-id: ""';
|
|
4316
4523
|
}
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
}
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
}
|
|
4326
|
-
function isShadowsocksOverTls(proxy) {
|
|
4327
|
-
const normalizedNetwork = typeof proxy?.network === "string" ? proxy.network.trim().toLowerCase() : proxy?.network;
|
|
4328
|
-
return proxy?.type === "ss" && proxy?.tls === true && !isPresent2(proxy, "plugin") && (!isPresent2(proxy, "network") || normalizedNetwork === "tcp");
|
|
4329
|
-
}
|
|
4330
|
-
function normalizePluginMuxValue(mux) {
|
|
4331
|
-
if (typeof mux === "boolean") return Number(mux);
|
|
4332
|
-
if (typeof mux === "string") {
|
|
4333
|
-
const normalized = mux.trim().toLowerCase();
|
|
4334
|
-
if (normalized === "true") return 1;
|
|
4335
|
-
if (normalized === "false") return 0;
|
|
4336
|
-
if (/^\d+$/.test(normalized)) return parseInt(normalized, 10);
|
|
4337
|
-
}
|
|
4338
|
-
return mux;
|
|
4524
|
+
if (/^(['"]).*\1$/.test(afterTrim)) {
|
|
4525
|
+
return `short-id: ${afterTrim}`;
|
|
4526
|
+
} else if (["null"].includes(afterTrim)) {
|
|
4527
|
+
return `short-id: ${afterTrim}`;
|
|
4528
|
+
} else {
|
|
4529
|
+
return `short-id: "${afterTrim}"`;
|
|
4530
|
+
}
|
|
4531
|
+
});
|
|
4339
4532
|
}
|
|
4340
|
-
function
|
|
4341
|
-
|
|
4533
|
+
function HTML() {
|
|
4534
|
+
const name = "HTML";
|
|
4535
|
+
const test = (raw) => /^<!DOCTYPE html>/.test(raw);
|
|
4536
|
+
const parse = () => "";
|
|
4537
|
+
return { name, test, parse };
|
|
4342
4538
|
}
|
|
4343
|
-
function
|
|
4344
|
-
|
|
4345
|
-
const
|
|
4346
|
-
|
|
4539
|
+
function Base64Encoded() {
|
|
4540
|
+
const name = "Base64 Pre-processor";
|
|
4541
|
+
const keys = [
|
|
4542
|
+
"dm1lc3M",
|
|
4543
|
+
// vmess
|
|
4544
|
+
"c3NyOi8v",
|
|
4545
|
+
// ssr://
|
|
4546
|
+
"c29ja3M6Ly",
|
|
4547
|
+
// socks://
|
|
4548
|
+
"dHJvamFu",
|
|
4549
|
+
// trojan
|
|
4550
|
+
"c3M6Ly",
|
|
4551
|
+
// ss:/
|
|
4552
|
+
"c3NkOi8v",
|
|
4553
|
+
// ssd://
|
|
4554
|
+
"c2hhZG93",
|
|
4555
|
+
// shadow
|
|
4556
|
+
"aHR0c",
|
|
4557
|
+
// htt
|
|
4558
|
+
"dmxlc3M=",
|
|
4559
|
+
// vless
|
|
4560
|
+
"aHlzdGVyaWEy",
|
|
4561
|
+
// hysteria2
|
|
4562
|
+
"aHkyOi8v",
|
|
4563
|
+
// hy2://
|
|
4564
|
+
"d2lyZWd1YXJkOi8v",
|
|
4565
|
+
// wireguard://
|
|
4566
|
+
"d2c6Ly8=",
|
|
4567
|
+
// wg://
|
|
4568
|
+
"dHVpYzovLw=="
|
|
4569
|
+
// tuic://
|
|
4570
|
+
];
|
|
4571
|
+
const test = function(raw) {
|
|
4572
|
+
return !/^\w+:\/\/\w+/im.test(raw) && keys.some((k) => raw.indexOf(k) !== -1);
|
|
4573
|
+
};
|
|
4574
|
+
const parse = function(raw) {
|
|
4575
|
+
const decoded = Base642.decode(raw);
|
|
4576
|
+
if (!/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(decoded)) {
|
|
4577
|
+
app_default.error(
|
|
4578
|
+
`Base64 Pre-processor error: decoded line does not start with protocol`
|
|
4579
|
+
);
|
|
4580
|
+
return raw;
|
|
4581
|
+
}
|
|
4582
|
+
return decoded;
|
|
4583
|
+
};
|
|
4584
|
+
return { name, test, parse };
|
|
4347
4585
|
}
|
|
4348
|
-
function
|
|
4349
|
-
|
|
4350
|
-
const
|
|
4351
|
-
|
|
4352
|
-
|
|
4586
|
+
function fallbackBase64Encoded() {
|
|
4587
|
+
const name = "Fallback Base64 Pre-processor";
|
|
4588
|
+
const test = function(raw) {
|
|
4589
|
+
return true;
|
|
4590
|
+
};
|
|
4591
|
+
const parse = function(raw) {
|
|
4592
|
+
const decoded = Base642.decode(raw);
|
|
4593
|
+
if (!/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(decoded)) {
|
|
4594
|
+
app_default.error(
|
|
4595
|
+
`Fallback Base64 Pre-processor error: decoded line does not start with protocol`
|
|
4596
|
+
);
|
|
4597
|
+
return raw;
|
|
4598
|
+
}
|
|
4599
|
+
return decoded;
|
|
4600
|
+
};
|
|
4601
|
+
return { name, test, parse };
|
|
4602
|
+
}
|
|
4603
|
+
function Clash() {
|
|
4604
|
+
const name = "Clash Pre-processor";
|
|
4605
|
+
const test = function(raw) {
|
|
4606
|
+
if (!/proxies/.test(raw)) return false;
|
|
4607
|
+
const content = safeLoad(raw);
|
|
4608
|
+
return content.proxies && Array.isArray(content.proxies);
|
|
4609
|
+
};
|
|
4610
|
+
const parse = function(raw, includeProxies) {
|
|
4611
|
+
const afterReplace = normalizeClashYaml(raw);
|
|
4612
|
+
const { proxies } = safeLoad(afterReplace);
|
|
4613
|
+
return (includeProxies ? "proxies:\n" : "") + proxies.map((p) => {
|
|
4614
|
+
return `${includeProxies ? " - " : ""}${JSON.stringify(
|
|
4615
|
+
p
|
|
4616
|
+
)}
|
|
4617
|
+
`;
|
|
4618
|
+
}).join("");
|
|
4619
|
+
};
|
|
4620
|
+
return { name, test, parse };
|
|
4621
|
+
}
|
|
4622
|
+
function SSD() {
|
|
4623
|
+
const name = "SSD Pre-processor";
|
|
4624
|
+
const test = function(raw) {
|
|
4625
|
+
return raw.indexOf("ssd://") === 0;
|
|
4626
|
+
};
|
|
4627
|
+
const parse = function(raw) {
|
|
4628
|
+
const output = [];
|
|
4629
|
+
let ssdinfo = JSON.parse(Base642.decode(raw.split("ssd://")[1]));
|
|
4630
|
+
let port = ssdinfo.port;
|
|
4631
|
+
let method = ssdinfo.encryption;
|
|
4632
|
+
let password = ssdinfo.password;
|
|
4633
|
+
let servers = ssdinfo.servers;
|
|
4634
|
+
for (let i = 0; i < servers.length; i++) {
|
|
4635
|
+
let server = servers[i];
|
|
4636
|
+
method = server.encryption ? server.encryption : method;
|
|
4637
|
+
password = server.password ? server.password : password;
|
|
4638
|
+
let userinfo = Base642.encode(method + ":" + password);
|
|
4639
|
+
let hostname = server.server;
|
|
4640
|
+
port = server.port ? server.port : port;
|
|
4641
|
+
let tag = server.remarks ? server.remarks : i;
|
|
4642
|
+
let plugin = server.plugin_options ? "/?plugin=" + encodeURIComponent(
|
|
4643
|
+
server.plugin + ";" + server.plugin_options
|
|
4644
|
+
) : "";
|
|
4645
|
+
output[i] = "ss://" + userinfo + "@" + hostname + ":" + port + plugin + "#" + tag;
|
|
4646
|
+
}
|
|
4647
|
+
return output.join("\n");
|
|
4648
|
+
};
|
|
4649
|
+
return { name, test, parse };
|
|
4650
|
+
}
|
|
4651
|
+
function FullConfig() {
|
|
4652
|
+
const name = "Full Config Preprocessor";
|
|
4653
|
+
const test = function(raw) {
|
|
4654
|
+
return /^(\[server_local\]|\[Proxy\])/gm.test(raw);
|
|
4655
|
+
};
|
|
4656
|
+
const parse = function(raw) {
|
|
4657
|
+
const match = raw.match(
|
|
4658
|
+
/^\[server_local|Proxy\]([\s\S]+?)^\[.+?\](\r?\n|$)/im
|
|
4659
|
+
)?.[1];
|
|
4660
|
+
return match || raw;
|
|
4661
|
+
};
|
|
4662
|
+
return { name, test, parse };
|
|
4663
|
+
}
|
|
4664
|
+
var preprocessors_default = [
|
|
4665
|
+
HTML(),
|
|
4666
|
+
Clash(),
|
|
4667
|
+
Base64Encoded(),
|
|
4668
|
+
SSD(),
|
|
4669
|
+
FullConfig(),
|
|
4670
|
+
fallbackBase64Encoded()
|
|
4671
|
+
];
|
|
4672
|
+
|
|
4673
|
+
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/utils.js
|
|
4674
|
+
var Result = class {
|
|
4675
|
+
constructor(proxy) {
|
|
4676
|
+
this.proxy = proxy;
|
|
4677
|
+
this.output = [];
|
|
4678
|
+
}
|
|
4679
|
+
append(data) {
|
|
4680
|
+
if (typeof data === "undefined") {
|
|
4681
|
+
throw new Error("required field is missing");
|
|
4682
|
+
}
|
|
4683
|
+
this.output.push(data);
|
|
4684
|
+
}
|
|
4685
|
+
appendIfPresent(data, attr) {
|
|
4686
|
+
if (isPresent2(this.proxy, attr)) {
|
|
4687
|
+
this.append(data);
|
|
4688
|
+
}
|
|
4689
|
+
}
|
|
4690
|
+
toString() {
|
|
4691
|
+
return this.output.join("");
|
|
4692
|
+
}
|
|
4693
|
+
};
|
|
4694
|
+
function isPresent2(obj, attr) {
|
|
4695
|
+
const data = _2.get(obj, attr);
|
|
4696
|
+
return typeof data !== "undefined" && data !== null;
|
|
4697
|
+
}
|
|
4698
|
+
function isShadowsocksOverTls(proxy) {
|
|
4699
|
+
const normalizedNetwork = typeof proxy?.network === "string" ? proxy.network.trim().toLowerCase() : proxy?.network;
|
|
4700
|
+
return proxy?.type === "ss" && proxy?.tls === true && !isPresent2(proxy, "plugin") && (!isPresent2(proxy, "network") || normalizedNetwork === "tcp");
|
|
4701
|
+
}
|
|
4702
|
+
function normalizePluginMuxValue(mux) {
|
|
4703
|
+
if (typeof mux === "boolean") return Number(mux);
|
|
4704
|
+
if (typeof mux === "string") {
|
|
4705
|
+
const normalized = mux.trim().toLowerCase();
|
|
4706
|
+
if (normalized === "true") return 1;
|
|
4707
|
+
if (normalized === "false") return 0;
|
|
4708
|
+
if (/^\d+$/.test(normalized)) return parseInt(normalized, 10);
|
|
4709
|
+
}
|
|
4710
|
+
return mux;
|
|
4711
|
+
}
|
|
4712
|
+
function normalizePluginMuxBooleanValue(mux) {
|
|
4713
|
+
return Boolean(normalizePluginMuxValue(mux));
|
|
4714
|
+
}
|
|
4715
|
+
function supportsShadowsocksV2rayPluginMode(proxy, supportedModes) {
|
|
4716
|
+
if (proxy?.type !== "ss" || proxy?.plugin !== "v2ray-plugin") return true;
|
|
4717
|
+
const normalizedMode = typeof proxy?.["plugin-opts"]?.mode === "string" ? proxy["plugin-opts"].mode.trim().toLowerCase() : proxy?.["plugin-opts"]?.mode;
|
|
4718
|
+
return supportedModes.includes(normalizedMode);
|
|
4719
|
+
}
|
|
4720
|
+
function parseWireGuardCIDR(cidr, max) {
|
|
4721
|
+
if (cidr == null) return void 0;
|
|
4722
|
+
const normalized = `${cidr}`.trim();
|
|
4723
|
+
if (!/^\d+$/.test(normalized)) return void 0;
|
|
4724
|
+
const parsed = parseInt(normalized, 10);
|
|
4353
4725
|
if (parsed < 0 || parsed > max) return void 0;
|
|
4354
4726
|
return parsed;
|
|
4355
4727
|
}
|
|
@@ -4384,13 +4756,15 @@ function getWireGuardAddressWithCIDR(proxy = {}, family = "ipv4") {
|
|
|
4384
4756
|
function produceProxyListOutput(list, type, opts = {}) {
|
|
4385
4757
|
if (type === "internal") return list;
|
|
4386
4758
|
if (opts.prettyYaml || opts["pretty-yaml"]) {
|
|
4387
|
-
return
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4759
|
+
return normalizeClashYaml(
|
|
4760
|
+
yaml_default.safeDump(
|
|
4761
|
+
{
|
|
4762
|
+
proxies: list
|
|
4763
|
+
},
|
|
4764
|
+
{
|
|
4765
|
+
lineWidth: -1
|
|
4766
|
+
}
|
|
4767
|
+
)
|
|
4394
4768
|
);
|
|
4395
4769
|
}
|
|
4396
4770
|
return "proxies:\n" + list.map((proxy) => " - " + JSON.stringify(proxy) + "\n").join("");
|
|
@@ -4419,17 +4793,30 @@ function stripSurgeQuotes(value) {
|
|
|
4419
4793
|
const trimmed = value.trim();
|
|
4420
4794
|
const quote = trimmed[0];
|
|
4421
4795
|
if ((quote === '"' || quote === "'") && trimmed[trimmed.length - 1] === quote) {
|
|
4422
|
-
return trimmed.slice(1, -1)
|
|
4796
|
+
return trimmed.slice(1, -1);
|
|
4423
4797
|
}
|
|
4424
|
-
return trimmed
|
|
4798
|
+
return trimmed;
|
|
4425
4799
|
}
|
|
4426
4800
|
function quoteSurgeValue(value) {
|
|
4427
|
-
|
|
4801
|
+
const text = String(stripSurgeQuotes(value));
|
|
4802
|
+
return `"${text}"`;
|
|
4428
4803
|
}
|
|
4429
4804
|
function hasNonBlankValue(value) {
|
|
4430
4805
|
return value != null && `${value}`.trim().length > 0;
|
|
4431
4806
|
}
|
|
4432
|
-
function
|
|
4807
|
+
function appendTlsProxyParams(result, proxy, enabled = true) {
|
|
4808
|
+
if (!enabled) {
|
|
4809
|
+
return;
|
|
4810
|
+
}
|
|
4811
|
+
result.appendIfPresent(
|
|
4812
|
+
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
4813
|
+
"tls-fingerprint"
|
|
4814
|
+
);
|
|
4815
|
+
result.appendIfPresent(`,sni="${proxy.sni}"`, "sni");
|
|
4816
|
+
result.appendIfPresent(
|
|
4817
|
+
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
4818
|
+
"skip-cert-verify"
|
|
4819
|
+
);
|
|
4433
4820
|
const clientCert = isPresent2(proxy, "keystore-client-cert") ? proxy["keystore-client-cert"] : proxy["client-cert"];
|
|
4434
4821
|
if (isPresent2(proxy, "keystore-client-cert") || isPresent2(proxy, "client-cert")) {
|
|
4435
4822
|
result.append(`,client-cert=${quoteSurgeValue(clientCert)}`);
|
|
@@ -4449,6 +4836,12 @@ function warnMaxStreamsIfNeeded(proxy) {
|
|
|
4449
4836
|
`Surge ${proxy.type} proxy ${proxy.name}: max-streams=${maxStreams} is greater than 3. Too many streams sharing one TCP connection may hurt performance.`
|
|
4450
4837
|
);
|
|
4451
4838
|
}
|
|
4839
|
+
function hasSnellObfs(proxy) {
|
|
4840
|
+
return isPresent2(proxy, "obfs-opts.mode") || isPresent2(proxy, "obfs-opts.host") || isPresent2(proxy, "obfs-opts.path");
|
|
4841
|
+
}
|
|
4842
|
+
function isUnsupportedSnellV6Obfs(proxy) {
|
|
4843
|
+
return Number(proxy.version) === 6 && hasSnellObfs(proxy);
|
|
4844
|
+
}
|
|
4452
4845
|
function Surge_Producer() {
|
|
4453
4846
|
const produce2 = (proxy, type, opts = {}) => {
|
|
4454
4847
|
if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
@@ -4586,7 +4979,7 @@ function shadowsocks(proxy) {
|
|
|
4586
4979
|
);
|
|
4587
4980
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
4588
4981
|
if (isPresent2(proxy, "shadow-tls-password")) {
|
|
4589
|
-
result.append(`,shadow-tls-password
|
|
4982
|
+
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
4590
4983
|
result.appendIfPresent(
|
|
4591
4984
|
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
4592
4985
|
"shadow-tls-version"
|
|
@@ -4601,7 +4994,7 @@ function shadowsocks(proxy) {
|
|
|
4601
4994
|
const host = proxy["plugin-opts"].host;
|
|
4602
4995
|
const version = proxy["plugin-opts"].version;
|
|
4603
4996
|
if (password) {
|
|
4604
|
-
result.append(`,shadow-tls-password
|
|
4997
|
+
result.append(`,shadow-tls-password="${password}"`);
|
|
4605
4998
|
if (host) {
|
|
4606
4999
|
result.append(`,shadow-tls-sni=${host}`);
|
|
4607
5000
|
}
|
|
@@ -4638,16 +5031,7 @@ function trojan(proxy) {
|
|
|
4638
5031
|
);
|
|
4639
5032
|
handleTransport(result, proxy);
|
|
4640
5033
|
result.appendIfPresent(`,tls=${proxy.tls}`, "tls");
|
|
4641
|
-
result
|
|
4642
|
-
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
4643
|
-
"tls-fingerprint"
|
|
4644
|
-
);
|
|
4645
|
-
result.appendIfPresent(`,sni="${proxy.sni}"`, "sni");
|
|
4646
|
-
result.appendIfPresent(
|
|
4647
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
4648
|
-
"skip-cert-verify"
|
|
4649
|
-
);
|
|
4650
|
-
appendClientCert(result, proxy);
|
|
5034
|
+
appendTlsProxyParams(result, proxy);
|
|
4651
5035
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
4652
5036
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
4653
5037
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
@@ -4668,7 +5052,7 @@ function trojan(proxy) {
|
|
|
4668
5052
|
);
|
|
4669
5053
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
4670
5054
|
if (isPresent2(proxy, "shadow-tls-password")) {
|
|
4671
|
-
result.append(`,shadow-tls-password
|
|
5055
|
+
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
4672
5056
|
result.appendIfPresent(
|
|
4673
5057
|
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
4674
5058
|
"shadow-tls-version"
|
|
@@ -4695,16 +5079,7 @@ function anytls(proxy) {
|
|
|
4695
5079
|
`,no-error-alert=${proxy["no-error-alert"]}`,
|
|
4696
5080
|
"no-error-alert"
|
|
4697
5081
|
);
|
|
4698
|
-
result
|
|
4699
|
-
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
4700
|
-
"tls-fingerprint"
|
|
4701
|
-
);
|
|
4702
|
-
result.appendIfPresent(`,sni="${proxy.sni}"`, "sni");
|
|
4703
|
-
result.appendIfPresent(
|
|
4704
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
4705
|
-
"skip-cert-verify"
|
|
4706
|
-
);
|
|
4707
|
-
appendClientCert(result, proxy);
|
|
5082
|
+
appendTlsProxyParams(result, proxy);
|
|
4708
5083
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
4709
5084
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
4710
5085
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
@@ -4749,16 +5124,7 @@ function trusttunnel(proxy) {
|
|
|
4749
5124
|
`,no-error-alert=${proxy["no-error-alert"]}`,
|
|
4750
5125
|
"no-error-alert"
|
|
4751
5126
|
);
|
|
4752
|
-
result
|
|
4753
|
-
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
4754
|
-
"tls-fingerprint"
|
|
4755
|
-
);
|
|
4756
|
-
result.appendIfPresent(`,sni="${proxy.sni}"`, "sni");
|
|
4757
|
-
result.appendIfPresent(
|
|
4758
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
4759
|
-
"skip-cert-verify"
|
|
4760
|
-
);
|
|
4761
|
-
appendClientCert(result, proxy);
|
|
5127
|
+
appendTlsProxyParams(result, proxy);
|
|
4762
5128
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
4763
5129
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
4764
5130
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
@@ -4803,16 +5169,7 @@ function h2Connect(proxy) {
|
|
|
4803
5169
|
`,no-error-alert=${proxy["no-error-alert"]}`,
|
|
4804
5170
|
"no-error-alert"
|
|
4805
5171
|
);
|
|
4806
|
-
result
|
|
4807
|
-
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
4808
|
-
"tls-fingerprint"
|
|
4809
|
-
);
|
|
4810
|
-
result.appendIfPresent(`,sni="${proxy.sni}"`, "sni");
|
|
4811
|
-
result.appendIfPresent(
|
|
4812
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
4813
|
-
"skip-cert-verify"
|
|
4814
|
-
);
|
|
4815
|
-
appendClientCert(result, proxy);
|
|
5172
|
+
appendTlsProxyParams(result, proxy);
|
|
4816
5173
|
if (proxy.tfo) {
|
|
4817
5174
|
app_default.info(`Option tfo is not supported by Surge, thus omitted`);
|
|
4818
5175
|
}
|
|
@@ -4835,7 +5192,7 @@ function h2Connect(proxy) {
|
|
|
4835
5192
|
);
|
|
4836
5193
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
4837
5194
|
if (isPresent2(proxy, "shadow-tls-password")) {
|
|
4838
|
-
result.append(`,shadow-tls-password
|
|
5195
|
+
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
4839
5196
|
result.appendIfPresent(
|
|
4840
5197
|
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
4841
5198
|
"shadow-tls-version"
|
|
@@ -4856,6 +5213,10 @@ function vmess(proxy, includeUnsupportedProxy) {
|
|
|
4856
5213
|
const result = new Result(proxy);
|
|
4857
5214
|
result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`);
|
|
4858
5215
|
result.appendIfPresent(`,username=${proxy.uuid}`, "uuid");
|
|
5216
|
+
const encryptMethod = formatSurgeVmessEncryptMethod(proxy.cipher);
|
|
5217
|
+
if (encryptMethod) {
|
|
5218
|
+
result.append(`,encrypt-method=${encryptMethod}`);
|
|
5219
|
+
}
|
|
4859
5220
|
const ip_version = ipVersions[proxy["ip-version"]] || proxy["ip-version"];
|
|
4860
5221
|
result.appendIfPresent(`,ip-version=${ip_version}`, "ip-version");
|
|
4861
5222
|
result.appendIfPresent(
|
|
@@ -4868,17 +5229,8 @@ function vmess(proxy, includeUnsupportedProxy) {
|
|
|
4868
5229
|
} else {
|
|
4869
5230
|
result.append(`,vmess-aead=${proxy.alterId === 0}`);
|
|
4870
5231
|
}
|
|
4871
|
-
result.appendIfPresent(
|
|
4872
|
-
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
4873
|
-
"tls-fingerprint"
|
|
4874
|
-
);
|
|
4875
5232
|
result.appendIfPresent(`,tls=${proxy.tls}`, "tls");
|
|
4876
|
-
result
|
|
4877
|
-
result.appendIfPresent(
|
|
4878
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
4879
|
-
"skip-cert-verify"
|
|
4880
|
-
);
|
|
4881
|
-
appendClientCert(result, proxy);
|
|
5233
|
+
appendTlsProxyParams(result, proxy, Boolean(proxy.tls));
|
|
4882
5234
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
4883
5235
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
4884
5236
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
@@ -4899,7 +5251,7 @@ function vmess(proxy, includeUnsupportedProxy) {
|
|
|
4899
5251
|
);
|
|
4900
5252
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
4901
5253
|
if (isPresent2(proxy, "shadow-tls-password")) {
|
|
4902
|
-
result.append(`,shadow-tls-password
|
|
5254
|
+
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
4903
5255
|
result.appendIfPresent(
|
|
4904
5256
|
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
4905
5257
|
"shadow-tls-version"
|
|
@@ -4975,16 +5327,7 @@ function http(proxy) {
|
|
|
4975
5327
|
`,no-error-alert=${proxy["no-error-alert"]}`,
|
|
4976
5328
|
"no-error-alert"
|
|
4977
5329
|
);
|
|
4978
|
-
result.
|
|
4979
|
-
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
4980
|
-
"tls-fingerprint"
|
|
4981
|
-
);
|
|
4982
|
-
result.appendIfPresent(`,sni="${proxy.sni}"`, "sni");
|
|
4983
|
-
result.appendIfPresent(
|
|
4984
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
4985
|
-
"skip-cert-verify"
|
|
4986
|
-
);
|
|
4987
|
-
appendClientCert(result, proxy);
|
|
5330
|
+
appendTlsProxyParams(result, proxy, Boolean(proxy.tls));
|
|
4988
5331
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
4989
5332
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
4990
5333
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
@@ -5005,7 +5348,7 @@ function http(proxy) {
|
|
|
5005
5348
|
);
|
|
5006
5349
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
5007
5350
|
if (isPresent2(proxy, "shadow-tls-password")) {
|
|
5008
|
-
result.append(`,shadow-tls-password
|
|
5351
|
+
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
5009
5352
|
result.appendIfPresent(
|
|
5010
5353
|
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
5011
5354
|
"shadow-tls-version"
|
|
@@ -5070,16 +5413,7 @@ function socks5(proxy) {
|
|
|
5070
5413
|
`,no-error-alert=${proxy["no-error-alert"]}`,
|
|
5071
5414
|
"no-error-alert"
|
|
5072
5415
|
);
|
|
5073
|
-
result.
|
|
5074
|
-
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
5075
|
-
"tls-fingerprint"
|
|
5076
|
-
);
|
|
5077
|
-
result.appendIfPresent(`,sni="${proxy.sni}"`, "sni");
|
|
5078
|
-
result.appendIfPresent(
|
|
5079
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
5080
|
-
"skip-cert-verify"
|
|
5081
|
-
);
|
|
5082
|
-
appendClientCert(result, proxy);
|
|
5416
|
+
appendTlsProxyParams(result, proxy, Boolean(proxy.tls));
|
|
5083
5417
|
if (proxy.tfo) {
|
|
5084
5418
|
app_default.info(`Option tfo is not supported by Surge, thus omitted`);
|
|
5085
5419
|
}
|
|
@@ -5102,7 +5436,7 @@ function socks5(proxy) {
|
|
|
5102
5436
|
);
|
|
5103
5437
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
5104
5438
|
if (isPresent2(proxy, "shadow-tls-password")) {
|
|
5105
|
-
result.append(`,shadow-tls-password
|
|
5439
|
+
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
5106
5440
|
result.appendIfPresent(
|
|
5107
5441
|
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
5108
5442
|
"shadow-tls-version"
|
|
@@ -5122,23 +5456,29 @@ function socks5(proxy) {
|
|
|
5122
5456
|
function appendHeaders(result, proxy) {
|
|
5123
5457
|
const value = formatHeaders(proxy.headers);
|
|
5124
5458
|
if (isNotBlank(value)) {
|
|
5125
|
-
result.append(`,headers
|
|
5459
|
+
result.append(`,headers=${quoteSurgeValue(value)}`);
|
|
5126
5460
|
}
|
|
5127
5461
|
}
|
|
5128
5462
|
function formatHeaders(headers) {
|
|
5463
|
+
return formatHeaderMap(headers, ";");
|
|
5464
|
+
}
|
|
5465
|
+
function formatHeaderMap(headers, separator) {
|
|
5129
5466
|
if (!headers || typeof headers !== "object") {
|
|
5130
5467
|
return "";
|
|
5131
5468
|
}
|
|
5132
|
-
return Object.entries(headers).filter(([key, value]) => isNotBlank(key) && value != null).map(([key, value]) => `${key}
|
|
5133
|
-
}
|
|
5134
|
-
function escapeHeaderValue(value) {
|
|
5135
|
-
return String(value).replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
5469
|
+
return Object.entries(headers).filter(([key, value]) => isNotBlank(key) && value != null).map(([key, value]) => `${key}:${quoteSurgeValue(value)}`).join(separator);
|
|
5136
5470
|
}
|
|
5137
5471
|
function snell(proxy) {
|
|
5472
|
+
if (isUnsupportedSnellV6Obfs(proxy)) {
|
|
5473
|
+
app_default.error(
|
|
5474
|
+
`Platform ${targetPlatform} does not support Snell version ${proxy.version} with obfs`
|
|
5475
|
+
);
|
|
5476
|
+
return "";
|
|
5477
|
+
}
|
|
5138
5478
|
const result = new Result(proxy);
|
|
5139
5479
|
result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`);
|
|
5140
5480
|
result.appendIfPresent(`,version=${proxy.version}`, "version");
|
|
5141
|
-
result.appendIfPresent(`,psk
|
|
5481
|
+
result.appendIfPresent(`,psk="${proxy.psk}"`, "psk");
|
|
5142
5482
|
const ip_version = ipVersions[proxy["ip-version"]] || proxy["ip-version"];
|
|
5143
5483
|
result.appendIfPresent(`,ip-version=${ip_version}`, "ip-version");
|
|
5144
5484
|
result.appendIfPresent(
|
|
@@ -5177,7 +5517,7 @@ function snell(proxy) {
|
|
|
5177
5517
|
);
|
|
5178
5518
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
5179
5519
|
if (isPresent2(proxy, "shadow-tls-password")) {
|
|
5180
|
-
result.append(`,shadow-tls-password
|
|
5520
|
+
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
5181
5521
|
result.appendIfPresent(
|
|
5182
5522
|
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
5183
5523
|
"shadow-tls-version"
|
|
@@ -5223,16 +5563,7 @@ function tuic(proxy) {
|
|
|
5223
5563
|
`,no-error-alert=${proxy["no-error-alert"]}`,
|
|
5224
5564
|
"no-error-alert"
|
|
5225
5565
|
);
|
|
5226
|
-
result
|
|
5227
|
-
result.appendIfPresent(
|
|
5228
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
5229
|
-
"skip-cert-verify"
|
|
5230
|
-
);
|
|
5231
|
-
appendClientCert(result, proxy);
|
|
5232
|
-
result.appendIfPresent(
|
|
5233
|
-
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
5234
|
-
"tls-fingerprint"
|
|
5235
|
-
);
|
|
5566
|
+
appendTlsProxyParams(result, proxy);
|
|
5236
5567
|
if (isPresent2(proxy, "tfo")) {
|
|
5237
5568
|
result.append(`,tfo=${proxy["tfo"]}`);
|
|
5238
5569
|
} else if (isPresent2(proxy, "fast-open")) {
|
|
@@ -5256,7 +5587,7 @@ function tuic(proxy) {
|
|
|
5256
5587
|
);
|
|
5257
5588
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
5258
5589
|
if (isPresent2(proxy, "shadow-tls-password")) {
|
|
5259
|
-
result.append(`,shadow-tls-password
|
|
5590
|
+
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
5260
5591
|
result.appendIfPresent(
|
|
5261
5592
|
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
5262
5593
|
"shadow-tls-version"
|
|
@@ -5317,7 +5648,7 @@ function wireguard(proxy) {
|
|
|
5317
5648
|
);
|
|
5318
5649
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
5319
5650
|
if (isPresent2(proxy, "shadow-tls-password")) {
|
|
5320
|
-
result.append(`,shadow-tls-password
|
|
5651
|
+
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
5321
5652
|
result.appendIfPresent(
|
|
5322
5653
|
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
5323
5654
|
"shadow-tls-version"
|
|
@@ -5401,7 +5732,7 @@ function wireguard_surge(proxy) {
|
|
|
5401
5732
|
);
|
|
5402
5733
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
5403
5734
|
if (isPresent2(proxy, "shadow-tls-password")) {
|
|
5404
|
-
result.append(`,shadow-tls-password
|
|
5735
|
+
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
5405
5736
|
result.appendIfPresent(
|
|
5406
5737
|
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
5407
5738
|
"shadow-tls-version"
|
|
@@ -5442,16 +5773,7 @@ function hysteria2(proxy) {
|
|
|
5442
5773
|
`,no-error-alert=${proxy["no-error-alert"]}`,
|
|
5443
5774
|
"no-error-alert"
|
|
5444
5775
|
);
|
|
5445
|
-
result
|
|
5446
|
-
result.appendIfPresent(
|
|
5447
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
5448
|
-
"skip-cert-verify"
|
|
5449
|
-
);
|
|
5450
|
-
appendClientCert(result, proxy);
|
|
5451
|
-
result.appendIfPresent(
|
|
5452
|
-
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
5453
|
-
"tls-fingerprint"
|
|
5454
|
-
);
|
|
5776
|
+
appendTlsProxyParams(result, proxy);
|
|
5455
5777
|
if (isPresent2(proxy, "tfo")) {
|
|
5456
5778
|
result.append(`,tfo=${proxy["tfo"]}`);
|
|
5457
5779
|
} else if (isPresent2(proxy, "fast-open")) {
|
|
@@ -5475,7 +5797,7 @@ function hysteria2(proxy) {
|
|
|
5475
5797
|
);
|
|
5476
5798
|
result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
|
|
5477
5799
|
if (isPresent2(proxy, "shadow-tls-password")) {
|
|
5478
|
-
result.append(`,shadow-tls-password
|
|
5800
|
+
result.append(`,shadow-tls-password="${proxy["shadow-tls-password"]}"`);
|
|
5479
5801
|
result.appendIfPresent(
|
|
5480
5802
|
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
5481
5803
|
"shadow-tls-version"
|
|
@@ -5508,13 +5830,9 @@ function handleTransport(result, proxy, includeUnsupportedProxy) {
|
|
|
5508
5830
|
);
|
|
5509
5831
|
if (isPresent2(proxy, "ws-opts.headers")) {
|
|
5510
5832
|
const headers = proxy["ws-opts"].headers;
|
|
5511
|
-
const value =
|
|
5512
|
-
let v = headers[k];
|
|
5513
|
-
v = `"${v}"`;
|
|
5514
|
-
return `${k}:${v}`;
|
|
5515
|
-
}).join("|");
|
|
5833
|
+
const value = formatHeaderMap(headers, "|");
|
|
5516
5834
|
if (isNotBlank(value)) {
|
|
5517
|
-
result.append(`,ws-headers=${value}`);
|
|
5835
|
+
result.append(`,ws-headers=${quoteSurgeValue(value)}`);
|
|
5518
5836
|
}
|
|
5519
5837
|
}
|
|
5520
5838
|
}
|
|
@@ -5533,7 +5851,7 @@ function handleTransport(result, proxy, includeUnsupportedProxy) {
|
|
|
5533
5851
|
}
|
|
5534
5852
|
|
|
5535
5853
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/surgemac.js
|
|
5536
|
-
import { Base64 as
|
|
5854
|
+
import { Base64 as Base643 } from "js-base64";
|
|
5537
5855
|
|
|
5538
5856
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/clashmeta.js
|
|
5539
5857
|
var ipVersions2 = {
|
|
@@ -5650,15 +5968,7 @@ function ClashMeta_Producer() {
|
|
|
5650
5968
|
proxy.servername = proxy.sni;
|
|
5651
5969
|
delete proxy.sni;
|
|
5652
5970
|
}
|
|
5653
|
-
|
|
5654
|
-
"auto",
|
|
5655
|
-
"none",
|
|
5656
|
-
"zero",
|
|
5657
|
-
"aes-128-gcm",
|
|
5658
|
-
"chacha20-poly1305"
|
|
5659
|
-
].includes(proxy.cipher)) {
|
|
5660
|
-
proxy.cipher = "auto";
|
|
5661
|
-
}
|
|
5971
|
+
proxy.cipher = normalizeVmessSecurity(proxy.cipher);
|
|
5662
5972
|
} else if (proxy.type === "tuic") {
|
|
5663
5973
|
if (isPresent2(proxy, "alpn")) {
|
|
5664
5974
|
proxy.alpn = Array.isArray(proxy.alpn) ? proxy.alpn : [proxy.alpn];
|
|
@@ -5986,7 +6296,7 @@ function mihomo(proxy, type, opts) {
|
|
|
5986
6296
|
"local-port": localPort,
|
|
5987
6297
|
args: [
|
|
5988
6298
|
"-config",
|
|
5989
|
-
|
|
6299
|
+
Base643.encode(
|
|
5990
6300
|
JSON.stringify({
|
|
5991
6301
|
"mixed-port": localPort,
|
|
5992
6302
|
ipv6,
|
|
@@ -6082,14 +6392,7 @@ function Clash_Producer() {
|
|
|
6082
6392
|
proxy.servername = proxy.sni;
|
|
6083
6393
|
delete proxy.sni;
|
|
6084
6394
|
}
|
|
6085
|
-
|
|
6086
|
-
"auto",
|
|
6087
|
-
"aes-128-gcm",
|
|
6088
|
-
"chacha20-poly1305",
|
|
6089
|
-
"none"
|
|
6090
|
-
].includes(proxy.cipher)) {
|
|
6091
|
-
proxy.cipher = "auto";
|
|
6092
|
-
}
|
|
6395
|
+
proxy.cipher = normalizeClashVmessSecurity(proxy.cipher);
|
|
6093
6396
|
} else if (proxy.type === "wireguard") {
|
|
6094
6397
|
proxy.keepalive = proxy.keepalive ?? proxy["persistent-keepalive"];
|
|
6095
6398
|
proxy["persistent-keepalive"] = proxy.keepalive;
|
|
@@ -6212,7 +6515,8 @@ function Stash_Producer() {
|
|
|
6212
6515
|
"ssh",
|
|
6213
6516
|
"juicity",
|
|
6214
6517
|
"anytls",
|
|
6215
|
-
"tailscale"
|
|
6518
|
+
"tailscale",
|
|
6519
|
+
"trusttunnel"
|
|
6216
6520
|
].includes(proxy.type) || proxy.type === "ss" && ![
|
|
6217
6521
|
"aes-128-gcm",
|
|
6218
6522
|
"aes-192-gcm",
|
|
@@ -6258,14 +6562,7 @@ function Stash_Producer() {
|
|
|
6258
6562
|
proxy.servername = proxy.sni;
|
|
6259
6563
|
delete proxy.sni;
|
|
6260
6564
|
}
|
|
6261
|
-
|
|
6262
|
-
"auto",
|
|
6263
|
-
"aes-128-gcm",
|
|
6264
|
-
"chacha20-poly1305",
|
|
6265
|
-
"none"
|
|
6266
|
-
].includes(proxy.cipher)) {
|
|
6267
|
-
proxy.cipher = "auto";
|
|
6268
|
-
}
|
|
6565
|
+
proxy.cipher = normalizeClashVmessSecurity(proxy.cipher);
|
|
6269
6566
|
} else if (proxy.type === "tuic") {
|
|
6270
6567
|
if (isPresent2(proxy, "alpn")) {
|
|
6271
6568
|
proxy.alpn = Array.isArray(proxy.alpn) ? proxy.alpn : [proxy.alpn];
|
|
@@ -6489,6 +6786,30 @@ function Loon_Producer() {
|
|
|
6489
6786
|
};
|
|
6490
6787
|
return { produce: produce2 };
|
|
6491
6788
|
}
|
|
6789
|
+
function appendTlsProfile(result, proxy) {
|
|
6790
|
+
const tlsProfile = getLoonTlsProfile(proxy);
|
|
6791
|
+
if (tlsProfile) result.append(`,tls-profile=${tlsProfile}`);
|
|
6792
|
+
}
|
|
6793
|
+
function appendAlpn(result, proxy) {
|
|
6794
|
+
const alpn = getLoonAlpn(proxy);
|
|
6795
|
+
if (alpn) result.append(`,alpn="${alpn}"`);
|
|
6796
|
+
}
|
|
6797
|
+
function getLoonAlpn(proxy) {
|
|
6798
|
+
const values = Array.isArray(proxy.alpn) ? proxy.alpn : `${proxy.alpn || ""}`.split(",");
|
|
6799
|
+
return values.map((item) => `${item}`.trim()).filter((item) => item !== "").join(",");
|
|
6800
|
+
}
|
|
6801
|
+
function getLoonTlsProfile(proxy) {
|
|
6802
|
+
const tlsProfile = `${proxy._loon_tls_profile || ""}`.trim();
|
|
6803
|
+
if (["default", "chrome", "ios18", "ios26"].includes(tlsProfile)) {
|
|
6804
|
+
return tlsProfile;
|
|
6805
|
+
}
|
|
6806
|
+
switch (`${proxy["client-fingerprint"] || ""}`.trim()) {
|
|
6807
|
+
case "chrome":
|
|
6808
|
+
return "chrome";
|
|
6809
|
+
case "ios":
|
|
6810
|
+
return "ios26";
|
|
6811
|
+
}
|
|
6812
|
+
}
|
|
6492
6813
|
function shadowsocks2(proxy) {
|
|
6493
6814
|
const result = new Result(proxy);
|
|
6494
6815
|
if (![
|
|
@@ -6688,6 +7009,8 @@ function trojan2(proxy) {
|
|
|
6688
7009
|
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
6689
7010
|
"skip-cert-verify"
|
|
6690
7011
|
);
|
|
7012
|
+
appendTlsProfile(result, proxy);
|
|
7013
|
+
appendAlpn(result, proxy);
|
|
6691
7014
|
result.appendIfPresent(`,tls-name=${proxy.sni}`, "sni");
|
|
6692
7015
|
result.appendIfPresent(
|
|
6693
7016
|
`,tls-cert-sha256=${proxy["tls-fingerprint"]}`,
|
|
@@ -6729,6 +7052,8 @@ function anytls2(proxy) {
|
|
|
6729
7052
|
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
6730
7053
|
"skip-cert-verify"
|
|
6731
7054
|
);
|
|
7055
|
+
appendTlsProfile(result, proxy);
|
|
7056
|
+
appendAlpn(result, proxy);
|
|
6732
7057
|
result.appendIfPresent(`,tls-name=${proxy.sni}`, "sni");
|
|
6733
7058
|
result.appendIfPresent(
|
|
6734
7059
|
`,tls-cert-sha256=${proxy["tls-fingerprint"]}`,
|
|
@@ -6753,9 +7078,10 @@ function anytls2(proxy) {
|
|
|
6753
7078
|
}
|
|
6754
7079
|
function vmess2(proxy) {
|
|
6755
7080
|
const isReality = !!proxy["reality-opts"];
|
|
7081
|
+
const security = formatLoonVmessSecurity(proxy.cipher);
|
|
6756
7082
|
const result = new Result(proxy);
|
|
6757
7083
|
result.append(
|
|
6758
|
-
`${proxy.name}=vmess,${proxy.server},${proxy.port},${
|
|
7084
|
+
`${proxy.name}=vmess,${proxy.server},${proxy.port},${security},"${proxy.uuid}"`
|
|
6759
7085
|
);
|
|
6760
7086
|
if (proxy.network === "tcp") {
|
|
6761
7087
|
delete proxy.network;
|
|
@@ -6794,6 +7120,10 @@ function vmess2(proxy) {
|
|
|
6794
7120
|
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
6795
7121
|
"skip-cert-verify"
|
|
6796
7122
|
);
|
|
7123
|
+
if (proxy.tls || isReality) {
|
|
7124
|
+
appendTlsProfile(result, proxy);
|
|
7125
|
+
appendAlpn(result, proxy);
|
|
7126
|
+
}
|
|
6797
7127
|
if (isReality) {
|
|
6798
7128
|
result.appendIfPresent(`,sni=${proxy.sni}`, "sni");
|
|
6799
7129
|
result.appendIfPresent(
|
|
@@ -6886,6 +7216,10 @@ function vless(proxy) {
|
|
|
6886
7216
|
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
6887
7217
|
"skip-cert-verify"
|
|
6888
7218
|
);
|
|
7219
|
+
if (proxy.tls || isReality || isXtls) {
|
|
7220
|
+
appendTlsProfile(result, proxy);
|
|
7221
|
+
appendAlpn(result, proxy);
|
|
7222
|
+
}
|
|
6889
7223
|
if (isXtls) {
|
|
6890
7224
|
result.appendIfPresent(`,flow=${proxy.flow}`, "flow");
|
|
6891
7225
|
}
|
|
@@ -6934,6 +7268,10 @@ function http2(proxy) {
|
|
|
6934
7268
|
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
6935
7269
|
"skip-cert-verify"
|
|
6936
7270
|
);
|
|
7271
|
+
if (proxy.tls) {
|
|
7272
|
+
appendTlsProfile(result, proxy);
|
|
7273
|
+
appendAlpn(result, proxy);
|
|
7274
|
+
}
|
|
6937
7275
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
6938
7276
|
if (proxy["block-quic"] === "on") {
|
|
6939
7277
|
result.append(",block-quic=true");
|
|
@@ -6955,6 +7293,10 @@ function socks52(proxy) {
|
|
|
6955
7293
|
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
6956
7294
|
"skip-cert-verify"
|
|
6957
7295
|
);
|
|
7296
|
+
if (proxy.tls) {
|
|
7297
|
+
appendTlsProfile(result, proxy);
|
|
7298
|
+
appendAlpn(result, proxy);
|
|
7299
|
+
}
|
|
6958
7300
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
6959
7301
|
if (proxy["block-quic"] === "on") {
|
|
6960
7302
|
result.append(",block-quic=true");
|
|
@@ -7052,6 +7394,8 @@ function hysteria22(proxy) {
|
|
|
7052
7394
|
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
7053
7395
|
"skip-cert-verify"
|
|
7054
7396
|
);
|
|
7397
|
+
appendTlsProfile(result, proxy);
|
|
7398
|
+
appendAlpn(result, proxy);
|
|
7055
7399
|
if (proxy["obfs-password"] && proxy.obfs == "salamander") {
|
|
7056
7400
|
result.append(`,salamander-password=${proxy["obfs-password"]}`);
|
|
7057
7401
|
}
|
|
@@ -7075,14 +7419,14 @@ function hysteria22(proxy) {
|
|
|
7075
7419
|
}
|
|
7076
7420
|
|
|
7077
7421
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/uri.js
|
|
7078
|
-
import { Base64 as
|
|
7422
|
+
import { Base64 as Base644 } from "js-base64";
|
|
7079
7423
|
function toStringHeaderMap(headers, { excludeHost = false } = {}) {
|
|
7080
7424
|
if (!isPlainObject(headers)) {
|
|
7081
7425
|
return void 0;
|
|
7082
7426
|
}
|
|
7083
7427
|
const parsedHeaders = {};
|
|
7084
7428
|
for (const [key, value] of Object.entries(headers)) {
|
|
7085
|
-
if (typeof value !== "string"
|
|
7429
|
+
if (typeof value !== "string") {
|
|
7086
7430
|
continue;
|
|
7087
7431
|
}
|
|
7088
7432
|
if (excludeHost && /^host$/i.test(key)) {
|
|
@@ -7221,10 +7565,21 @@ function applyStructuredXhttpExtraFields(target, xhttpOpts, { excludeHostHeader
|
|
|
7221
7565
|
target.uplinkHTTPMethod = xhttpOpts["uplink-http-method"];
|
|
7222
7566
|
}
|
|
7223
7567
|
if (xhttpOpts["session-placement"]) {
|
|
7224
|
-
target.
|
|
7568
|
+
target.sessionIDPlacement = xhttpOpts["session-placement"];
|
|
7225
7569
|
}
|
|
7226
7570
|
if (xhttpOpts["session-key"]) {
|
|
7227
|
-
target.
|
|
7571
|
+
target.sessionIDKey = xhttpOpts["session-key"];
|
|
7572
|
+
}
|
|
7573
|
+
if (typeof xhttpOpts["session-table"] === "string") {
|
|
7574
|
+
target.sessionIDTable = xhttpOpts["session-table"];
|
|
7575
|
+
}
|
|
7576
|
+
if (xhttpOpts["session-length"] != null) {
|
|
7577
|
+
const sessionIDLength = normalizeXhttpStrictPositiveRangeValue(
|
|
7578
|
+
xhttpOpts["session-length"]
|
|
7579
|
+
);
|
|
7580
|
+
if (sessionIDLength != null) {
|
|
7581
|
+
target.sessionIDLength = sessionIDLength;
|
|
7582
|
+
}
|
|
7228
7583
|
}
|
|
7229
7584
|
if (xhttpOpts["seq-placement"]) {
|
|
7230
7585
|
target.seqPlacement = xhttpOpts["seq-placement"];
|
|
@@ -7245,7 +7600,7 @@ function applyStructuredXhttpExtraFields(target, xhttpOpts, { excludeHostHeader
|
|
|
7245
7600
|
target.uplinkChunkSize = uplinkChunkSize;
|
|
7246
7601
|
}
|
|
7247
7602
|
if (xhttpOpts["sc-max-each-post-bytes"] != null) {
|
|
7248
|
-
const scMaxEachPostBytes =
|
|
7603
|
+
const scMaxEachPostBytes = normalizeXhttpStrictPositiveRangeValue(
|
|
7249
7604
|
xhttpOpts["sc-max-each-post-bytes"]
|
|
7250
7605
|
);
|
|
7251
7606
|
if (scMaxEachPostBytes != null) {
|
|
@@ -7634,10 +7989,26 @@ function vless2(proxy) {
|
|
|
7634
7989
|
vlessTransport += `&eh=${encodeURIComponent(earlyDataHeaderName)}`;
|
|
7635
7990
|
}
|
|
7636
7991
|
let packetEncoding = "";
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7992
|
+
let canonicalPacketEncoding;
|
|
7993
|
+
if (proxy["packet-encoding"] != null) {
|
|
7994
|
+
canonicalPacketEncoding = `${proxy["packet-encoding"]}`.trim().toLowerCase();
|
|
7995
|
+
} else if (proxy.xudp) {
|
|
7996
|
+
canonicalPacketEncoding = "xudp";
|
|
7997
|
+
} else if (proxy["packet-addr"]) {
|
|
7998
|
+
canonicalPacketEncoding = "packetaddr";
|
|
7999
|
+
} else if (proxy.udp === true) {
|
|
8000
|
+
canonicalPacketEncoding = "";
|
|
8001
|
+
}
|
|
8002
|
+
switch (canonicalPacketEncoding) {
|
|
8003
|
+
case "":
|
|
8004
|
+
packetEncoding = "&packetEncoding=none";
|
|
8005
|
+
break;
|
|
8006
|
+
case "packetaddr":
|
|
8007
|
+
packetEncoding = "&packetEncoding=packet";
|
|
8008
|
+
break;
|
|
8009
|
+
case "xudp":
|
|
8010
|
+
packetEncoding = "&packetEncoding=xudp";
|
|
8011
|
+
break;
|
|
7641
8012
|
}
|
|
7642
8013
|
return `vless://${proxy.uuid}@${proxy.server}:${proxy.port}?security=${encodeURIComponent(
|
|
7643
8014
|
security
|
|
@@ -7674,7 +8045,7 @@ function URI_Producer() {
|
|
|
7674
8045
|
switch (proxy.type) {
|
|
7675
8046
|
case "socks5":
|
|
7676
8047
|
result = `socks://${encodeURIComponent(
|
|
7677
|
-
|
|
8048
|
+
Base644.encode(
|
|
7678
8049
|
`${proxy.username ?? ""}:${proxy.password ?? ""}`
|
|
7679
8050
|
)
|
|
7680
8051
|
)}@${proxy.server}:${proxy.port}#${proxy.name}`;
|
|
@@ -7683,7 +8054,7 @@ function URI_Producer() {
|
|
|
7683
8054
|
const userinfo = `${proxy.cipher}:${proxy.password}`;
|
|
7684
8055
|
result = `ss://${proxy.cipher?.startsWith("2022-blake3-") ? `${encodeURIComponent(
|
|
7685
8056
|
proxy.cipher
|
|
7686
|
-
)}:${encodeURIComponent(proxy.password)}` :
|
|
8057
|
+
)}:${encodeURIComponent(proxy.password)}` : Base644.encode(userinfo)}@${proxy.server}:${proxy.port}${proxy.plugin ? "/" : ""}`;
|
|
7687
8058
|
let query = "";
|
|
7688
8059
|
if (proxy.plugin) {
|
|
7689
8060
|
query += "&plugin=";
|
|
@@ -7821,9 +8192,9 @@ function URI_Producer() {
|
|
|
7821
8192
|
result += query.replace(/^&/, "?");
|
|
7822
8193
|
break;
|
|
7823
8194
|
case "ssr":
|
|
7824
|
-
result = `${proxy.server}:${proxy.port}:${proxy.protocol}:${proxy.cipher}:${proxy.obfs}:${
|
|
7825
|
-
result += `?remarks=${
|
|
7826
|
-
result = "ssr://" +
|
|
8195
|
+
result = `${proxy.server}:${proxy.port}:${proxy.protocol}:${proxy.cipher}:${proxy.obfs}:${Base644.encode(proxy.password)}/`;
|
|
8196
|
+
result += `?remarks=${Base644.encode(proxy.name)}${proxy["obfs-param"] ? "&obfsparam=" + Base644.encode(proxy["obfs-param"]) : ""}${proxy["protocol-param"] ? "&protocolparam=" + Base644.encode(proxy["protocol-param"]) : ""}`;
|
|
8197
|
+
result = "ssr://" + Base644.encode(result);
|
|
7827
8198
|
break;
|
|
7828
8199
|
case "vmess":
|
|
7829
8200
|
let type2 = "";
|
|
@@ -7841,7 +8212,7 @@ function URI_Producer() {
|
|
|
7841
8212
|
port: `${proxy.port}`,
|
|
7842
8213
|
id: proxy.uuid,
|
|
7843
8214
|
aid: `${proxy.alterId || 0}`,
|
|
7844
|
-
scy: proxy.cipher,
|
|
8215
|
+
scy: normalizeVmessSecurity(proxy.cipher),
|
|
7845
8216
|
net,
|
|
7846
8217
|
type: type2,
|
|
7847
8218
|
tls: proxy.tls ? "tls" : "",
|
|
@@ -7890,7 +8261,7 @@ function URI_Producer() {
|
|
|
7890
8261
|
}
|
|
7891
8262
|
}
|
|
7892
8263
|
}
|
|
7893
|
-
result = "vmess://" +
|
|
8264
|
+
result = "vmess://" + Base644.encode(JSON.stringify(result));
|
|
7894
8265
|
break;
|
|
7895
8266
|
case "vless":
|
|
7896
8267
|
result = vless2(proxy);
|
|
@@ -8280,7 +8651,7 @@ function URI_Producer() {
|
|
|
8280
8651
|
}
|
|
8281
8652
|
|
|
8282
8653
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/v2ray.js
|
|
8283
|
-
import { Base64 as
|
|
8654
|
+
import { Base64 as Base645 } from "js-base64";
|
|
8284
8655
|
var URI = URI_Producer();
|
|
8285
8656
|
function V2Ray_Producer() {
|
|
8286
8657
|
const type = "ALL";
|
|
@@ -8294,7 +8665,7 @@ function V2Ray_Producer() {
|
|
|
8294
8665
|
Reason: ${err}`);
|
|
8295
8666
|
}
|
|
8296
8667
|
});
|
|
8297
|
-
return
|
|
8668
|
+
return Base645.encode(result.join("\n"));
|
|
8298
8669
|
};
|
|
8299
8670
|
return { type, produce: produce2 };
|
|
8300
8671
|
}
|
|
@@ -8557,12 +8928,7 @@ function vmess3(proxy) {
|
|
|
8557
8928
|
const append = result.append.bind(result);
|
|
8558
8929
|
const appendIfPresent = result.appendIfPresent.bind(result);
|
|
8559
8930
|
append(`vmess=${proxy.server}:${proxy.port}`);
|
|
8560
|
-
let cipher;
|
|
8561
|
-
if (proxy.cipher === "auto") {
|
|
8562
|
-
cipher = "chacha20-ietf-poly1305";
|
|
8563
|
-
} else {
|
|
8564
|
-
cipher = proxy.cipher;
|
|
8565
|
-
}
|
|
8931
|
+
let cipher = formatQXVmessMethod(proxy.cipher);
|
|
8566
8932
|
append(`,method=${cipher}`);
|
|
8567
8933
|
append(`,password=${proxy.uuid}`);
|
|
8568
8934
|
if (needTls(proxy)) {
|
|
@@ -8852,7 +9218,7 @@ function Shadowrocket_Producer() {
|
|
|
8852
9218
|
"grpc"
|
|
8853
9219
|
])) {
|
|
8854
9220
|
return false;
|
|
8855
|
-
} else if (proxy.type === "snell" && proxy.version
|
|
9221
|
+
} else if (proxy.type === "snell" && ![1, 2, 3, 4, 5].includes(proxy.version)) {
|
|
8856
9222
|
return false;
|
|
8857
9223
|
} else if ([
|
|
8858
9224
|
"tailscale",
|
|
@@ -8882,15 +9248,7 @@ function Shadowrocket_Producer() {
|
|
|
8882
9248
|
proxy.servername = proxy.sni;
|
|
8883
9249
|
delete proxy.sni;
|
|
8884
9250
|
}
|
|
8885
|
-
|
|
8886
|
-
"auto",
|
|
8887
|
-
"none",
|
|
8888
|
-
"zero",
|
|
8889
|
-
"aes-128-gcm",
|
|
8890
|
-
"chacha20-poly1305"
|
|
8891
|
-
].includes(proxy.cipher)) {
|
|
8892
|
-
proxy.cipher = "auto";
|
|
8893
|
-
}
|
|
9251
|
+
proxy.cipher = normalizeVmessSecurity(proxy.cipher);
|
|
8894
9252
|
} else if (proxy.type === "tuic") {
|
|
8895
9253
|
if (isPresent2(proxy, "alpn")) {
|
|
8896
9254
|
proxy.alpn = Array.isArray(proxy.alpn) ? proxy.alpn : [proxy.alpn];
|
|
@@ -9046,6 +9404,20 @@ var targetPlatform5 = "Surfboard";
|
|
|
9046
9404
|
function hasNonBlankValue2(value) {
|
|
9047
9405
|
return value != null && `${value}`.trim().length > 0;
|
|
9048
9406
|
}
|
|
9407
|
+
function appendTlsProxyParams2(result, proxy, enabled = true) {
|
|
9408
|
+
if (!enabled) {
|
|
9409
|
+
return;
|
|
9410
|
+
}
|
|
9411
|
+
result.appendIfPresent(
|
|
9412
|
+
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
9413
|
+
"tls-fingerprint"
|
|
9414
|
+
);
|
|
9415
|
+
result.appendIfPresent(`,sni="${proxy.sni}"`, "sni");
|
|
9416
|
+
result.appendIfPresent(
|
|
9417
|
+
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
9418
|
+
"skip-cert-verify"
|
|
9419
|
+
);
|
|
9420
|
+
}
|
|
9049
9421
|
function Surfboard_Producer() {
|
|
9050
9422
|
const produce2 = (proxy) => {
|
|
9051
9423
|
if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
@@ -9101,34 +9473,28 @@ function hysteria23(proxy) {
|
|
|
9101
9473
|
if (hasNonBlankValue2(proxy["hop-interval"])) {
|
|
9102
9474
|
result.append(`,port-hopping-interval=${proxy["hop-interval"]}`);
|
|
9103
9475
|
}
|
|
9104
|
-
result
|
|
9105
|
-
result.appendIfPresent(
|
|
9106
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
9107
|
-
"skip-cert-verify"
|
|
9108
|
-
);
|
|
9476
|
+
appendTlsProxyParams2(result, proxy);
|
|
9109
9477
|
result.appendIfPresent(
|
|
9110
9478
|
`,download-bandwidth=${`${proxy["down"]}`.match(/\d+/)?.[0] || 0}`,
|
|
9111
9479
|
"down"
|
|
9112
9480
|
);
|
|
9113
9481
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
9482
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
9114
9483
|
return result.toString();
|
|
9115
9484
|
}
|
|
9116
9485
|
function anytls4(proxy) {
|
|
9117
9486
|
const result = new Result(proxy);
|
|
9118
9487
|
result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`);
|
|
9119
9488
|
result.appendIfPresent(`,password="${proxy.password}"`, "password");
|
|
9120
|
-
result
|
|
9121
|
-
result.appendIfPresent(
|
|
9122
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
9123
|
-
"skip-cert-verify"
|
|
9124
|
-
);
|
|
9489
|
+
appendTlsProxyParams2(result, proxy);
|
|
9125
9490
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
9126
9491
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
9127
9492
|
result.appendIfPresent(`,reuse=${proxy["reuse"]}`, "reuse");
|
|
9493
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
9128
9494
|
return result.toString();
|
|
9129
9495
|
}
|
|
9130
9496
|
function snell2(proxy) {
|
|
9131
|
-
if (proxy
|
|
9497
|
+
if (isPresent2(proxy, "version") && ![1, 2, 3, 4, 5].includes(Number(proxy.version))) {
|
|
9132
9498
|
throw new Error(
|
|
9133
9499
|
`Platform ${targetPlatform5} does not support snell version ${proxy.version}`
|
|
9134
9500
|
);
|
|
@@ -9136,7 +9502,7 @@ function snell2(proxy) {
|
|
|
9136
9502
|
const result = new Result(proxy);
|
|
9137
9503
|
result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`);
|
|
9138
9504
|
result.appendIfPresent(`,version=${proxy.version}`, "version");
|
|
9139
|
-
result.appendIfPresent(`,psk
|
|
9505
|
+
result.appendIfPresent(`,psk="${proxy.psk}"`, "psk");
|
|
9140
9506
|
result.appendIfPresent(
|
|
9141
9507
|
`,obfs=${proxy["obfs-opts"]?.mode}`,
|
|
9142
9508
|
"obfs-opts.mode"
|
|
@@ -9153,6 +9519,7 @@ function snell2(proxy) {
|
|
|
9153
9519
|
if (proxy.version >= 3) {
|
|
9154
9520
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
9155
9521
|
}
|
|
9522
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
9156
9523
|
return result.toString();
|
|
9157
9524
|
}
|
|
9158
9525
|
function shadowsocks4(proxy) {
|
|
@@ -9202,6 +9569,7 @@ function shadowsocks4(proxy) {
|
|
|
9202
9569
|
}
|
|
9203
9570
|
}
|
|
9204
9571
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
9572
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
9205
9573
|
return result.toString();
|
|
9206
9574
|
}
|
|
9207
9575
|
function trojan4(proxy) {
|
|
@@ -9210,13 +9578,10 @@ function trojan4(proxy) {
|
|
|
9210
9578
|
result.appendIfPresent(`,password=${proxy.password}`, "password");
|
|
9211
9579
|
handleTransport2(result, proxy);
|
|
9212
9580
|
result.appendIfPresent(`,tls=${proxy.tls}`, "tls");
|
|
9213
|
-
result
|
|
9214
|
-
result.appendIfPresent(
|
|
9215
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
9216
|
-
"skip-cert-verify"
|
|
9217
|
-
);
|
|
9581
|
+
appendTlsProxyParams2(result, proxy);
|
|
9218
9582
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
9219
9583
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
9584
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
9220
9585
|
return result.toString();
|
|
9221
9586
|
}
|
|
9222
9587
|
function vmess4(proxy) {
|
|
@@ -9226,16 +9591,13 @@ function vmess4(proxy) {
|
|
|
9226
9591
|
handleTransport2(result, proxy);
|
|
9227
9592
|
if (isPresent2(proxy, "aead")) {
|
|
9228
9593
|
result.append(`,vmess-aead=${proxy.aead}`);
|
|
9229
|
-
} else {
|
|
9230
|
-
result.append(`,vmess-aead=${proxy.alterId === 0}`);
|
|
9231
|
-
}
|
|
9232
|
-
result.appendIfPresent(`,tls=${proxy.tls}`, "tls");
|
|
9233
|
-
result
|
|
9234
|
-
result.appendIfPresent(
|
|
9235
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
9236
|
-
"skip-cert-verify"
|
|
9237
|
-
);
|
|
9594
|
+
} else {
|
|
9595
|
+
result.append(`,vmess-aead=${proxy.alterId === 0}`);
|
|
9596
|
+
}
|
|
9597
|
+
result.appendIfPresent(`,tls=${proxy.tls}`, "tls");
|
|
9598
|
+
appendTlsProxyParams2(result, proxy, Boolean(proxy.tls));
|
|
9238
9599
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
9600
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
9239
9601
|
return result.toString();
|
|
9240
9602
|
}
|
|
9241
9603
|
function http4(proxy) {
|
|
@@ -9244,12 +9606,9 @@ function http4(proxy) {
|
|
|
9244
9606
|
result.append(`${proxy.name}=${type},${proxy.server},${proxy.port}`);
|
|
9245
9607
|
result.appendIfPresent(`,${proxy.username}`, "username");
|
|
9246
9608
|
result.appendIfPresent(`,${proxy.password}`, "password");
|
|
9247
|
-
result
|
|
9248
|
-
result.appendIfPresent(
|
|
9249
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
9250
|
-
"skip-cert-verify"
|
|
9251
|
-
);
|
|
9609
|
+
appendTlsProxyParams2(result, proxy, Boolean(proxy.tls));
|
|
9252
9610
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
9611
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
9253
9612
|
return result.toString();
|
|
9254
9613
|
}
|
|
9255
9614
|
function socks54(proxy) {
|
|
@@ -9258,12 +9617,9 @@ function socks54(proxy) {
|
|
|
9258
9617
|
result.append(`${proxy.name}=${type},${proxy.server},${proxy.port}`);
|
|
9259
9618
|
result.appendIfPresent(`,${proxy.username}`, "username");
|
|
9260
9619
|
result.appendIfPresent(`,${proxy.password}`, "password");
|
|
9261
|
-
result
|
|
9262
|
-
result.appendIfPresent(
|
|
9263
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
9264
|
-
"skip-cert-verify"
|
|
9265
|
-
);
|
|
9620
|
+
appendTlsProxyParams2(result, proxy, Boolean(proxy.tls));
|
|
9266
9621
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
9622
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
9267
9623
|
return result.toString();
|
|
9268
9624
|
}
|
|
9269
9625
|
function wireguard3(proxy) {
|
|
@@ -9273,6 +9629,7 @@ function wireguard3(proxy) {
|
|
|
9273
9629
|
`,section-name=${proxy["section-name"]}`,
|
|
9274
9630
|
"section-name"
|
|
9275
9631
|
);
|
|
9632
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
9276
9633
|
return result.toString();
|
|
9277
9634
|
}
|
|
9278
9635
|
function handleTransport2(result, proxy) {
|
|
@@ -9569,6 +9926,22 @@ var normalizePemLines = (value, label) => {
|
|
|
9569
9926
|
}
|
|
9570
9927
|
return [`-----BEGIN ${label}-----`, ...lines, `-----END ${label}-----`];
|
|
9571
9928
|
};
|
|
9929
|
+
var singBoxUtlsFingerprints = [
|
|
9930
|
+
"chrome",
|
|
9931
|
+
"firefox",
|
|
9932
|
+
"edge",
|
|
9933
|
+
"safari",
|
|
9934
|
+
"360",
|
|
9935
|
+
"qq",
|
|
9936
|
+
"ios",
|
|
9937
|
+
"android",
|
|
9938
|
+
"random",
|
|
9939
|
+
"randomized"
|
|
9940
|
+
];
|
|
9941
|
+
var getSingBoxUtlsFingerprint = (value) => {
|
|
9942
|
+
const fingerprint = `${value || ""}`.trim().toLowerCase();
|
|
9943
|
+
if (singBoxUtlsFingerprints.includes(fingerprint)) return fingerprint;
|
|
9944
|
+
};
|
|
9572
9945
|
var tlsParser = (proxy, parsedProxy) => {
|
|
9573
9946
|
if (proxy.tls) parsedProxy.tls.enabled = true;
|
|
9574
9947
|
if (proxy.servername && proxy.servername !== "")
|
|
@@ -9593,11 +9966,17 @@ var tlsParser = (proxy, parsedProxy) => {
|
|
|
9593
9966
|
parsedProxy.tls.reality.short_id = proxy["reality-opts"]["short-id"];
|
|
9594
9967
|
parsedProxy.tls.utls = { enabled: true };
|
|
9595
9968
|
}
|
|
9596
|
-
if (!["hysteria", "hysteria2", "tuic"].includes(proxy.type) && proxy["client-fingerprint"] && proxy["client-fingerprint"] !== "")
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
9969
|
+
if (!["hysteria", "hysteria2", "tuic"].includes(proxy.type) && proxy["client-fingerprint"] && proxy["client-fingerprint"] !== "") {
|
|
9970
|
+
const fingerprint = getSingBoxUtlsFingerprint(
|
|
9971
|
+
proxy["client-fingerprint"]
|
|
9972
|
+
);
|
|
9973
|
+
if (fingerprint)
|
|
9974
|
+
parsedProxy.tls.utls = {
|
|
9975
|
+
...parsedProxy.tls.utls,
|
|
9976
|
+
enabled: true,
|
|
9977
|
+
fingerprint
|
|
9978
|
+
};
|
|
9979
|
+
}
|
|
9601
9980
|
if (proxy._ech && isPlainObject(proxy._ech)) {
|
|
9602
9981
|
parsedProxy.tls.ech = proxy._ech;
|
|
9603
9982
|
} else if (proxy["ech-opts"] && isPlainObject(proxy["ech-opts"])) {
|
|
@@ -9771,6 +10150,7 @@ var normalizeALPN = (alpn) => {
|
|
|
9771
10150
|
};
|
|
9772
10151
|
var shadowTLSOutboundParser = (proxy = {}, pluginOpts) => {
|
|
9773
10152
|
if (!pluginOpts) throw new Error("shadow-tls plugin options are missing");
|
|
10153
|
+
const fingerprint = getSingBoxUtlsFingerprint(proxy["client-fingerprint"]);
|
|
9774
10154
|
const stPart = {
|
|
9775
10155
|
tag: getShadowTLSTag(proxy),
|
|
9776
10156
|
type: "shadowtls",
|
|
@@ -9783,7 +10163,7 @@ var shadowTLSOutboundParser = (proxy = {}, pluginOpts) => {
|
|
|
9783
10163
|
server_name: pluginOpts.host,
|
|
9784
10164
|
utls: {
|
|
9785
10165
|
enabled: true,
|
|
9786
|
-
fingerprint
|
|
10166
|
+
fingerprint
|
|
9787
10167
|
}
|
|
9788
10168
|
}
|
|
9789
10169
|
};
|
|
@@ -9952,6 +10332,36 @@ var snellParser = (proxy = {}) => {
|
|
|
9952
10332
|
}
|
|
9953
10333
|
return parsedProxy;
|
|
9954
10334
|
};
|
|
10335
|
+
var singBoxPacketEncodings = ["", "packetaddr", "xudp"];
|
|
10336
|
+
var normalizeSingBoxPacketEncoding = (value) => {
|
|
10337
|
+
const packetEncoding = `${value}`.trim().toLowerCase();
|
|
10338
|
+
if (singBoxPacketEncodings.includes(packetEncoding)) {
|
|
10339
|
+
return packetEncoding;
|
|
10340
|
+
}
|
|
10341
|
+
return void 0;
|
|
10342
|
+
};
|
|
10343
|
+
var vmessVlessPacketEncodingParser = (proxy, parsedProxy) => {
|
|
10344
|
+
if (proxy["packet-encoding"] != null) {
|
|
10345
|
+
const packetEncoding = normalizeSingBoxPacketEncoding(
|
|
10346
|
+
proxy["packet-encoding"]
|
|
10347
|
+
);
|
|
10348
|
+
if (packetEncoding != null)
|
|
10349
|
+
parsedProxy.packet_encoding = packetEncoding;
|
|
10350
|
+
} else if (proxy.xudp) {
|
|
10351
|
+
parsedProxy.packet_encoding = "xudp";
|
|
10352
|
+
} else if (proxy["packet-addr"]) {
|
|
10353
|
+
parsedProxy.packet_encoding = "packetaddr";
|
|
10354
|
+
}
|
|
10355
|
+
};
|
|
10356
|
+
var vmessProtocolOptionsParser = (proxy, parsedProxy) => {
|
|
10357
|
+
vmessVlessPacketEncodingParser(proxy, parsedProxy);
|
|
10358
|
+
if (proxy["global-padding"] != null) {
|
|
10359
|
+
parsedProxy.global_padding = !!proxy["global-padding"];
|
|
10360
|
+
}
|
|
10361
|
+
if (proxy["authenticated-length"] != null) {
|
|
10362
|
+
parsedProxy.authenticated_length = !!proxy["authenticated-length"];
|
|
10363
|
+
}
|
|
10364
|
+
};
|
|
9955
10365
|
var vmessParser = (proxy = {}) => {
|
|
9956
10366
|
const parsedProxy = {
|
|
9957
10367
|
tag: proxy.name,
|
|
@@ -9959,22 +10369,13 @@ var vmessParser = (proxy = {}) => {
|
|
|
9959
10369
|
server: proxy.server,
|
|
9960
10370
|
server_port: parseInt(`${proxy.port}`, 10),
|
|
9961
10371
|
uuid: proxy.uuid,
|
|
9962
|
-
security: proxy.cipher,
|
|
10372
|
+
security: normalizeVmessSecurity(proxy.cipher),
|
|
9963
10373
|
alter_id: parseInt(`${proxy.alterId}`, 10),
|
|
9964
10374
|
tls: { enabled: false, server_name: proxy.server, insecure: false }
|
|
9965
10375
|
};
|
|
9966
|
-
if ([
|
|
9967
|
-
"auto",
|
|
9968
|
-
"none",
|
|
9969
|
-
"zero",
|
|
9970
|
-
"aes-128-gcm",
|
|
9971
|
-
"chacha20-poly1305",
|
|
9972
|
-
"aes-128-ctr"
|
|
9973
|
-
].indexOf(parsedProxy.security) === -1)
|
|
9974
|
-
parsedProxy.security = "auto";
|
|
9975
10376
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
9976
10377
|
throw "invalid port";
|
|
9977
|
-
|
|
10378
|
+
vmessProtocolOptionsParser(proxy, parsedProxy);
|
|
9978
10379
|
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
9979
10380
|
if (proxy.network === "ws") wsParser(proxy, parsedProxy);
|
|
9980
10381
|
if (proxy.network === "h2") h2Parser(proxy, parsedProxy);
|
|
@@ -10000,7 +10401,7 @@ var vlessParser = (proxy = {}) => {
|
|
|
10000
10401
|
};
|
|
10001
10402
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10002
10403
|
throw "invalid port";
|
|
10003
|
-
|
|
10404
|
+
vmessVlessPacketEncodingParser(proxy, parsedProxy);
|
|
10004
10405
|
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
10005
10406
|
if (proxy.flow != null) parsedProxy.flow = proxy.flow;
|
|
10006
10407
|
if (proxy.network === "ws") wsParser(proxy, parsedProxy);
|
|
@@ -10161,7 +10562,34 @@ var hysteria2Parser = (proxy = {}) => {
|
|
|
10161
10562
|
});
|
|
10162
10563
|
if (proxy.up) parsedProxy.up_mbps = parseInt(`${proxy.up}`, 10);
|
|
10163
10564
|
if (proxy.down) parsedProxy.down_mbps = parseInt(`${proxy.down}`, 10);
|
|
10164
|
-
if (
|
|
10565
|
+
if (["salamander", "gecko"].includes(proxy.obfs))
|
|
10566
|
+
parsedProxy.obfs.type = proxy.obfs;
|
|
10567
|
+
if (proxy.obfs === "gecko") {
|
|
10568
|
+
const minRaw = proxy["obfs-min-packet-size"];
|
|
10569
|
+
const maxRaw = proxy["obfs-max-packet-size"];
|
|
10570
|
+
const hasMin = minRaw !== void 0 && minRaw !== null && `${minRaw}` !== "";
|
|
10571
|
+
const hasMax = maxRaw !== void 0 && maxRaw !== null && `${maxRaw}` !== "";
|
|
10572
|
+
if (hasMin || hasMax) {
|
|
10573
|
+
const minPacketSize = hasMin ? parseSafeIntegerValue(`${minRaw}`.trim()) : void 0;
|
|
10574
|
+
const rawMaxPacketSize = hasMax ? parseSafeIntegerValue(`${maxRaw}`.trim()) : void 0;
|
|
10575
|
+
const maxPacketSize = rawMaxPacketSize != null ? Math.min(rawMaxPacketSize, 2048) : rawMaxPacketSize;
|
|
10576
|
+
const effectiveMinPacketSize = minPacketSize ?? 512;
|
|
10577
|
+
const effectiveMaxPacketSize = maxPacketSize ?? 1200;
|
|
10578
|
+
if (hasMax && rawMaxPacketSize != null && rawMaxPacketSize > 2048) {
|
|
10579
|
+
app_default.warn(
|
|
10580
|
+
`Gecko obfs max packet size for proxy ${proxy.name} exceeds 2048, clamped to 2048: ${maxRaw}`
|
|
10581
|
+
);
|
|
10582
|
+
}
|
|
10583
|
+
if (hasMin && (minPacketSize == null || minPacketSize <= 0) || hasMax && (rawMaxPacketSize == null || rawMaxPacketSize <= 0) || effectiveMaxPacketSize < effectiveMinPacketSize) {
|
|
10584
|
+
app_default.error(
|
|
10585
|
+
`Invalid obfs packet size for proxy ${proxy.name}: min=${minRaw} max=${maxRaw}`
|
|
10586
|
+
);
|
|
10587
|
+
} else {
|
|
10588
|
+
if (hasMin) parsedProxy.obfs.min_packet_size = minPacketSize;
|
|
10589
|
+
if (hasMax) parsedProxy.obfs.max_packet_size = maxPacketSize;
|
|
10590
|
+
}
|
|
10591
|
+
}
|
|
10592
|
+
}
|
|
10165
10593
|
if (proxy["obfs-password"])
|
|
10166
10594
|
parsedProxy.obfs.password = proxy["obfs-password"];
|
|
10167
10595
|
if (!parsedProxy.obfs.type) delete parsedProxy.obfs;
|
|
@@ -10267,6 +10695,16 @@ var tailscaleParser = (proxy = {}) => {
|
|
|
10267
10695
|
ipVersionParser(proxy, parsedProxy);
|
|
10268
10696
|
domainResolverParser(proxy, parsedProxy);
|
|
10269
10697
|
}
|
|
10698
|
+
if (isPlainObject(proxy["ssh-server"])) {
|
|
10699
|
+
parsedProxy.ssh_server = {
|
|
10700
|
+
enabled: proxy["ssh-server"].enabled !== false,
|
|
10701
|
+
disable_pty: proxy["ssh-server"]["disable-pty"],
|
|
10702
|
+
disable_sftp: proxy["ssh-server"]["disable-sftp"],
|
|
10703
|
+
disable_forwarding: proxy["ssh-server"]["disable-forwarding"]
|
|
10704
|
+
};
|
|
10705
|
+
} else if (proxy["ssh-server"]) {
|
|
10706
|
+
parsedProxy.ssh_server = !!proxy["ssh-server"];
|
|
10707
|
+
}
|
|
10270
10708
|
return parsedProxy;
|
|
10271
10709
|
};
|
|
10272
10710
|
var wireguardParser = (proxy = {}) => {
|
|
@@ -10518,7 +10956,9 @@ function Egern_Producer() {
|
|
|
10518
10956
|
"vmess",
|
|
10519
10957
|
"tuic",
|
|
10520
10958
|
"wireguard",
|
|
10521
|
-
"anytls"
|
|
10959
|
+
"anytls",
|
|
10960
|
+
"ssh",
|
|
10961
|
+
"snell"
|
|
10522
10962
|
].includes(proxy.type) || proxy.type === "ss" && (proxy.plugin === "obfs" && !["http", "tls"].includes(
|
|
10523
10963
|
proxy["plugin-opts"]?.mode
|
|
10524
10964
|
) || ![
|
|
@@ -10550,13 +10990,22 @@ function Egern_Producer() {
|
|
|
10550
10990
|
"chacha20-ietf",
|
|
10551
10991
|
"2022-blake3-aes-128-gcm",
|
|
10552
10992
|
"2022-blake3-aes-256-gcm"
|
|
10553
|
-
].includes(proxy.cipher)) || proxy.type === "vmess" && !["h2", "http", "ws", "tcp"
|
|
10993
|
+
].includes(proxy.cipher)) || proxy.type === "vmess" && (!["h2", "http", "ws", "tcp", "grpc"].includes(
|
|
10554
10994
|
proxy.network
|
|
10555
|
-
) && proxy.network ||
|
|
10995
|
+
) && proxy.network || !isEgernGrpcGun(proxy)) || proxy.type === "trojan" && !["http", "ws", "tcp"].includes(proxy.network) && proxy.network || proxy.type === "vless" && (!["h2", "http", "ws", "tcp", "grpc"].includes(
|
|
10996
|
+
proxy.network
|
|
10997
|
+
) && proxy.network || !isEgernGrpcGun(proxy) || typeof proxy.flow !== "undefined" && !["xtls-rprx-vision", ""].includes(
|
|
10556
10998
|
proxy.flow
|
|
10557
10999
|
)) || proxy.type === "tuic" && proxy.token && proxy.token.length !== 0) {
|
|
10558
11000
|
return false;
|
|
10559
|
-
} else if (
|
|
11001
|
+
} else if (proxy.type === "snell" && normalizeSnellVersion(proxy.version) === null) {
|
|
11002
|
+
return false;
|
|
11003
|
+
} else if (proxy.type === "snell" && hasShadowTls(proxy)) {
|
|
11004
|
+
app_default.error(
|
|
11005
|
+
`Platform Egern does not support Snell shadow-tls proxy ${proxy.name}. Proxy has been filtered.`
|
|
11006
|
+
);
|
|
11007
|
+
return false;
|
|
11008
|
+
} else if (["anytls"].includes(proxy.type) && proxy.network && !["tcp"].includes(proxy.network)) {
|
|
10560
11009
|
return false;
|
|
10561
11010
|
} else if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
10562
11011
|
return false;
|
|
@@ -10582,11 +11031,11 @@ function Egern_Producer() {
|
|
|
10582
11031
|
...hasHeaders(proxy) ? {
|
|
10583
11032
|
headers: proxy.headers
|
|
10584
11033
|
} : {},
|
|
10585
|
-
tfo: proxy
|
|
10586
|
-
next_hop: proxy.next_hop,
|
|
11034
|
+
tfo: getTfo(proxy),
|
|
10587
11035
|
...proxy.tls ? {
|
|
10588
11036
|
sni: proxy.sni,
|
|
10589
|
-
skip_tls_verify: proxy["skip-cert-verify"]
|
|
11037
|
+
skip_tls_verify: proxy["skip-cert-verify"],
|
|
11038
|
+
reality: getReality(proxy)
|
|
10590
11039
|
} : {}
|
|
10591
11040
|
};
|
|
10592
11041
|
} else if (proxy.type === "https") {
|
|
@@ -10600,22 +11049,26 @@ function Egern_Producer() {
|
|
|
10600
11049
|
...hasHeaders(proxy) ? {
|
|
10601
11050
|
headers: proxy.headers
|
|
10602
11051
|
} : {},
|
|
10603
|
-
tfo: proxy
|
|
10604
|
-
next_hop: proxy.next_hop,
|
|
11052
|
+
tfo: getTfo(proxy),
|
|
10605
11053
|
sni: proxy.sni,
|
|
10606
|
-
skip_tls_verify: proxy["skip-cert-verify"]
|
|
11054
|
+
skip_tls_verify: proxy["skip-cert-verify"],
|
|
11055
|
+
reality: getReality(proxy)
|
|
10607
11056
|
};
|
|
10608
11057
|
} else if (proxy.type === "socks5") {
|
|
10609
11058
|
proxy = {
|
|
10610
|
-
type: "socks5",
|
|
11059
|
+
type: proxy.tls ? "socks5_tls" : "socks5",
|
|
10611
11060
|
name: proxy.name,
|
|
10612
11061
|
server: proxy.server,
|
|
10613
11062
|
port: proxy.port,
|
|
10614
11063
|
username: proxy.username,
|
|
10615
11064
|
password: proxy.password,
|
|
10616
|
-
tfo: proxy
|
|
10617
|
-
udp_relay: proxy
|
|
10618
|
-
|
|
11065
|
+
tfo: getTfo(proxy),
|
|
11066
|
+
udp_relay: getUdpRelay(proxy),
|
|
11067
|
+
...proxy.tls ? {
|
|
11068
|
+
sni: proxy.sni,
|
|
11069
|
+
skip_tls_verify: proxy["skip-cert-verify"],
|
|
11070
|
+
reality: getReality(proxy)
|
|
11071
|
+
} : {}
|
|
10619
11072
|
};
|
|
10620
11073
|
} else if (proxy.type === "ss") {
|
|
10621
11074
|
proxy = {
|
|
@@ -10625,9 +11078,8 @@ function Egern_Producer() {
|
|
|
10625
11078
|
server: proxy.server,
|
|
10626
11079
|
port: proxy.port,
|
|
10627
11080
|
password: proxy.password,
|
|
10628
|
-
tfo: proxy
|
|
10629
|
-
udp_relay: proxy
|
|
10630
|
-
next_hop: proxy.next_hop
|
|
11081
|
+
tfo: getTfo(proxy),
|
|
11082
|
+
udp_relay: getUdpRelay(proxy)
|
|
10631
11083
|
};
|
|
10632
11084
|
if (isPresent2(original, "plugin")) {
|
|
10633
11085
|
if (original.plugin === "obfs") {
|
|
@@ -10653,9 +11105,8 @@ function Egern_Producer() {
|
|
|
10653
11105
|
10
|
|
10654
11106
|
)
|
|
10655
11107
|
} : {},
|
|
10656
|
-
tfo: proxy
|
|
10657
|
-
udp_relay: proxy
|
|
10658
|
-
next_hop: proxy.next_hop,
|
|
11108
|
+
tfo: getTfo(proxy),
|
|
11109
|
+
udp_relay: getUdpRelay(proxy),
|
|
10659
11110
|
sni: proxy.sni,
|
|
10660
11111
|
skip_tls_verify: proxy["skip-cert-verify"],
|
|
10661
11112
|
port_hopping: proxy.ports,
|
|
@@ -10673,7 +11124,6 @@ function Egern_Producer() {
|
|
|
10673
11124
|
port: proxy.port,
|
|
10674
11125
|
uuid: proxy.uuid,
|
|
10675
11126
|
password: proxy.password,
|
|
10676
|
-
next_hop: proxy.next_hop,
|
|
10677
11127
|
sni: proxy.sni,
|
|
10678
11128
|
alpn: Array.isArray(proxy.alpn) ? proxy.alpn : [proxy.alpn || "h3"],
|
|
10679
11129
|
skip_tls_verify: proxy["skip-cert-verify"],
|
|
@@ -10693,11 +11143,11 @@ function Egern_Producer() {
|
|
|
10693
11143
|
server: proxy.server,
|
|
10694
11144
|
port: proxy.port,
|
|
10695
11145
|
password: proxy.password,
|
|
10696
|
-
tfo: proxy
|
|
10697
|
-
udp_relay: proxy
|
|
10698
|
-
next_hop: proxy.next_hop,
|
|
11146
|
+
tfo: getTfo(proxy),
|
|
11147
|
+
udp_relay: getUdpRelay(proxy),
|
|
10699
11148
|
sni: proxy.sni,
|
|
10700
11149
|
skip_tls_verify: proxy["skip-cert-verify"],
|
|
11150
|
+
reality: getReality(proxy),
|
|
10701
11151
|
websocket: proxy.websocket
|
|
10702
11152
|
};
|
|
10703
11153
|
} else if (proxy.type === "anytls") {
|
|
@@ -10707,23 +11157,14 @@ function Egern_Producer() {
|
|
|
10707
11157
|
server: proxy.server,
|
|
10708
11158
|
port: proxy.port,
|
|
10709
11159
|
password: proxy.password,
|
|
10710
|
-
tfo: proxy
|
|
10711
|
-
udp_relay: proxy
|
|
10712
|
-
next_hop: proxy.next_hop,
|
|
11160
|
+
tfo: getTfo(proxy),
|
|
11161
|
+
udp_relay: getUdpRelay(proxy),
|
|
10713
11162
|
sni: proxy.sni,
|
|
10714
|
-
skip_tls_verify: proxy["skip-cert-verify"]
|
|
11163
|
+
skip_tls_verify: proxy["skip-cert-verify"],
|
|
11164
|
+
reality: getReality(proxy)
|
|
10715
11165
|
};
|
|
10716
11166
|
} else if (proxy.type === "vmess") {
|
|
10717
|
-
|
|
10718
|
-
if (security && ![
|
|
10719
|
-
"auto",
|
|
10720
|
-
"none",
|
|
10721
|
-
"zero",
|
|
10722
|
-
"aes-128-gcm",
|
|
10723
|
-
"chacha20-poly1305"
|
|
10724
|
-
].includes(security)) {
|
|
10725
|
-
security = "auto";
|
|
10726
|
-
}
|
|
11167
|
+
const security = normalizeVmessSecurity(proxy.cipher);
|
|
10727
11168
|
if (proxy.network === "ws") {
|
|
10728
11169
|
proxy.transport = {
|
|
10729
11170
|
[proxy.tls ? "wss" : "ws"]: {
|
|
@@ -10760,6 +11201,8 @@ function Egern_Producer() {
|
|
|
10760
11201
|
skip_tls_verify: proxy["skip-cert-verify"]
|
|
10761
11202
|
}
|
|
10762
11203
|
};
|
|
11204
|
+
} else if (proxy.network === "grpc") {
|
|
11205
|
+
proxy.transport = getGrpcTransport(proxy);
|
|
10763
11206
|
} else if ((proxy.network === "tcp" || !proxy.network) && proxy.tls) {
|
|
10764
11207
|
proxy.transport = {
|
|
10765
11208
|
tls: {
|
|
@@ -10768,10 +11211,10 @@ function Egern_Producer() {
|
|
|
10768
11211
|
}
|
|
10769
11212
|
};
|
|
10770
11213
|
}
|
|
10771
|
-
let legacy;
|
|
11214
|
+
let legacy = false;
|
|
10772
11215
|
if (isPresent2(proxy, "aead") && !proxy.aead) {
|
|
10773
11216
|
legacy = true;
|
|
10774
|
-
} else if (proxy.alterId !== 0) {
|
|
11217
|
+
} else if (isPresent2(proxy, "alterId") && proxy.alterId !== 0) {
|
|
10775
11218
|
legacy = true;
|
|
10776
11219
|
}
|
|
10777
11220
|
proxy = {
|
|
@@ -10781,10 +11224,9 @@ function Egern_Producer() {
|
|
|
10781
11224
|
port: proxy.port,
|
|
10782
11225
|
user_id: proxy.uuid,
|
|
10783
11226
|
security,
|
|
10784
|
-
tfo: proxy
|
|
11227
|
+
tfo: getTfo(proxy),
|
|
10785
11228
|
legacy,
|
|
10786
|
-
udp_relay: proxy
|
|
10787
|
-
next_hop: proxy.next_hop,
|
|
11229
|
+
udp_relay: getUdpRelay(proxy),
|
|
10788
11230
|
transport: proxy.transport
|
|
10789
11231
|
};
|
|
10790
11232
|
} else if (proxy.type === "vless") {
|
|
@@ -10828,19 +11270,14 @@ function Egern_Producer() {
|
|
|
10828
11270
|
skip_tls_verify: proxy["skip-cert-verify"]
|
|
10829
11271
|
}
|
|
10830
11272
|
};
|
|
11273
|
+
} else if (proxy.network === "grpc") {
|
|
11274
|
+
proxy.transport = getGrpcTransport(proxy);
|
|
10831
11275
|
} else if (proxy.network === "tcp" || !proxy.network) {
|
|
10832
|
-
let reality;
|
|
10833
|
-
if (proxy["reality-opts"]?.["short-id"] || proxy["reality-opts"]?.["public-key"]) {
|
|
10834
|
-
reality = {
|
|
10835
|
-
short_id: proxy["reality-opts"]["short-id"],
|
|
10836
|
-
public_key: proxy["reality-opts"]["public-key"]
|
|
10837
|
-
};
|
|
10838
|
-
}
|
|
10839
11276
|
proxy.transport = {
|
|
10840
11277
|
[proxy.tls ? "tls" : "tcp"]: {
|
|
10841
11278
|
sni: proxy.tls ? proxy.sni : void 0,
|
|
10842
11279
|
skip_tls_verify: proxy.tls ? proxy["skip-cert-verify"] : void 0,
|
|
10843
|
-
reality
|
|
11280
|
+
reality: getReality(proxy)
|
|
10844
11281
|
}
|
|
10845
11282
|
};
|
|
10846
11283
|
flow = proxy.flow;
|
|
@@ -10853,9 +11290,8 @@ function Egern_Producer() {
|
|
|
10853
11290
|
port: proxy.port,
|
|
10854
11291
|
user_id: proxy.uuid,
|
|
10855
11292
|
security: proxy.cipher,
|
|
10856
|
-
tfo: proxy
|
|
10857
|
-
udp_relay: proxy
|
|
10858
|
-
next_hop: proxy.next_hop,
|
|
11293
|
+
tfo: getTfo(proxy),
|
|
11294
|
+
udp_relay: getUdpRelay(proxy),
|
|
10859
11295
|
transport: proxy.transport,
|
|
10860
11296
|
flow
|
|
10861
11297
|
};
|
|
@@ -10891,6 +11327,38 @@ function Egern_Producer() {
|
|
|
10891
11327
|
mtu: proxy.mtu,
|
|
10892
11328
|
keepalive: proxy.keepalive
|
|
10893
11329
|
};
|
|
11330
|
+
} else if (proxy.type === "ssh") {
|
|
11331
|
+
proxy = {
|
|
11332
|
+
type: "ssh",
|
|
11333
|
+
name: proxy.name,
|
|
11334
|
+
server: proxy.server,
|
|
11335
|
+
port: proxy.port,
|
|
11336
|
+
username: proxy.username,
|
|
11337
|
+
password: proxy.password,
|
|
11338
|
+
private_key: proxy["private-key"],
|
|
11339
|
+
// private_key_passphrase: proxy['private-key-passphrase'],
|
|
11340
|
+
host_keys: proxy["host-key"],
|
|
11341
|
+
tfo: getTfo(proxy)
|
|
11342
|
+
};
|
|
11343
|
+
} else if (proxy.type === "snell") {
|
|
11344
|
+
const snellVersion = normalizeSnellVersion(
|
|
11345
|
+
proxy.version
|
|
11346
|
+
);
|
|
11347
|
+
proxy = {
|
|
11348
|
+
type: "snell",
|
|
11349
|
+
name: proxy.name,
|
|
11350
|
+
server: proxy.server,
|
|
11351
|
+
port: proxy.port,
|
|
11352
|
+
psk: proxy.psk,
|
|
11353
|
+
version: snellVersion,
|
|
11354
|
+
...snellVersion == null || snellVersion >= 3 ? {
|
|
11355
|
+
udp_relay: getUdpRelay(proxy)
|
|
11356
|
+
} : {},
|
|
11357
|
+
reuse: proxy.reuse,
|
|
11358
|
+
obfs: proxy["obfs-opts"]?.mode || proxy.obfs,
|
|
11359
|
+
obfs_host: proxy["obfs-opts"]?.host || proxy["obfs-host"] || proxy.obfs_host,
|
|
11360
|
+
tfo: getTfo(proxy)
|
|
11361
|
+
};
|
|
10894
11362
|
}
|
|
10895
11363
|
if ([
|
|
10896
11364
|
"http",
|
|
@@ -10900,7 +11368,8 @@ function Egern_Producer() {
|
|
|
10900
11368
|
"trojan",
|
|
10901
11369
|
"vless",
|
|
10902
11370
|
"vmess",
|
|
10903
|
-
"anytls"
|
|
11371
|
+
"anytls",
|
|
11372
|
+
"ssh"
|
|
10904
11373
|
].includes(original.type)) {
|
|
10905
11374
|
if (isPresent2(original, "shadow-tls-password")) {
|
|
10906
11375
|
if (original["shadow-tls-version"] != 3)
|
|
@@ -10941,7 +11410,9 @@ function Egern_Producer() {
|
|
|
10941
11410
|
"wireguard",
|
|
10942
11411
|
"tuic",
|
|
10943
11412
|
"hysteria2",
|
|
10944
|
-
"anytls"
|
|
11413
|
+
"anytls",
|
|
11414
|
+
"ssh",
|
|
11415
|
+
"snell"
|
|
10945
11416
|
].includes(original.type)) {
|
|
10946
11417
|
if (["on", "true", true, "1", 1].includes(
|
|
10947
11418
|
original["block-quic"]
|
|
@@ -10963,9 +11434,9 @@ function Egern_Producer() {
|
|
|
10963
11434
|
delete proxy["no-resolve"];
|
|
10964
11435
|
if (proxy.transport) {
|
|
10965
11436
|
for (const key in proxy.transport) {
|
|
10966
|
-
if (Object.keys(proxy.transport[key]).length === 0 || Object.values(proxy.transport[key]).every(
|
|
11437
|
+
if (key !== "grpc" && (Object.keys(proxy.transport[key]).length === 0 || Object.values(proxy.transport[key]).every(
|
|
10967
11438
|
(value) => value == null
|
|
10968
|
-
)) {
|
|
11439
|
+
))) {
|
|
10969
11440
|
delete proxy.transport[key];
|
|
10970
11441
|
}
|
|
10971
11442
|
}
|
|
@@ -11002,6 +11473,52 @@ Reason: ${err}`
|
|
|
11002
11473
|
function hasHeaders(proxy) {
|
|
11003
11474
|
return proxy?.headers && typeof proxy.headers === "object" && Object.keys(proxy.headers).length > 0;
|
|
11004
11475
|
}
|
|
11476
|
+
function getTfo(proxy) {
|
|
11477
|
+
return proxy.tfo ?? proxy["fast-open"];
|
|
11478
|
+
}
|
|
11479
|
+
function getUdpRelay(proxy) {
|
|
11480
|
+
return proxy.udp ?? proxy.udp_relay;
|
|
11481
|
+
}
|
|
11482
|
+
function hasShadowTls(proxy) {
|
|
11483
|
+
return proxy.plugin === "shadow-tls" || isPresent2(proxy, "shadow-tls-password") || isPresent2(proxy, "shadow-tls-sni") || isPresent2(proxy, "shadow-tls-version");
|
|
11484
|
+
}
|
|
11485
|
+
function getNonEmptyValue(value) {
|
|
11486
|
+
if (value == null) return void 0;
|
|
11487
|
+
if (typeof value === "string" && value.length === 0) return void 0;
|
|
11488
|
+
return value;
|
|
11489
|
+
}
|
|
11490
|
+
function getReality(proxy) {
|
|
11491
|
+
const realityOpts = proxy?.["reality-opts"];
|
|
11492
|
+
if (!realityOpts) return void 0;
|
|
11493
|
+
const reality = {};
|
|
11494
|
+
const publicKey = getNonEmptyValue(realityOpts["public-key"]);
|
|
11495
|
+
const shortId = getNonEmptyValue(realityOpts["short-id"]);
|
|
11496
|
+
if (publicKey != null) reality.public_key = publicKey;
|
|
11497
|
+
if (shortId != null) reality.short_id = shortId;
|
|
11498
|
+
return Object.keys(reality).length > 0 ? reality : void 0;
|
|
11499
|
+
}
|
|
11500
|
+
function getGrpcTransport(proxy) {
|
|
11501
|
+
return {
|
|
11502
|
+
grpc: {
|
|
11503
|
+
service_name: proxy["grpc-opts"]?.["grpc-service-name"],
|
|
11504
|
+
sni: proxy.sni,
|
|
11505
|
+
reality: getReality(proxy),
|
|
11506
|
+
skip_tls_verify: proxy["skip-cert-verify"]
|
|
11507
|
+
}
|
|
11508
|
+
};
|
|
11509
|
+
}
|
|
11510
|
+
function isEgernGrpcGun(proxy) {
|
|
11511
|
+
if (proxy.network !== "grpc") return true;
|
|
11512
|
+
const grpcType = proxy["grpc-opts"]?.["_grpc-type"];
|
|
11513
|
+
if (grpcType == null) return true;
|
|
11514
|
+
return `${grpcType}`.trim().toLowerCase() === "gun";
|
|
11515
|
+
}
|
|
11516
|
+
function normalizeSnellVersion(version) {
|
|
11517
|
+
if (version == null) return void 0;
|
|
11518
|
+
const normalized = `${version}`.trim();
|
|
11519
|
+
if (!/^[1-5]$/.test(normalized)) return null;
|
|
11520
|
+
return parseInt(normalized, 10);
|
|
11521
|
+
}
|
|
11005
11522
|
function getFirstHeaderValue(headers, ...keys) {
|
|
11006
11523
|
for (const key of keys) {
|
|
11007
11524
|
const value = getFirstValue(headers?.[key]);
|
|
@@ -11043,11 +11560,11 @@ function getFingerprintSha256(proxy) {
|
|
|
11043
11560
|
function supportsRootFingerprintSha256(original, proxy) {
|
|
11044
11561
|
return ["anytls", "https", "hysteria2", "trojan", "tuic"].includes(
|
|
11045
11562
|
original.type
|
|
11046
|
-
) || original.type === "http" && proxy.type === "https";
|
|
11563
|
+
) || original.type === "socks5" && proxy.type === "socks5_tls" || original.type === "http" && proxy.type === "https";
|
|
11047
11564
|
}
|
|
11048
11565
|
function addTransportFingerprintSha256(transport, fingerprintSha256) {
|
|
11049
11566
|
if (!transport) return;
|
|
11050
|
-
for (const key of ["http2", "tls", "wss"]) {
|
|
11567
|
+
for (const key of ["grpc", "http2", "tls", "wss"]) {
|
|
11051
11568
|
if (transport[key]) {
|
|
11052
11569
|
transport[key].fingerprint_sha256 = fingerprintSha256;
|
|
11053
11570
|
}
|
|
@@ -11096,173 +11613,6 @@ var producers_default = {
|
|
|
11096
11613
|
Egern: Egern_Producer()
|
|
11097
11614
|
};
|
|
11098
11615
|
|
|
11099
|
-
// src/vendors/Sub-Store/backend/src/core/proxy-utils/preprocessors/index.js
|
|
11100
|
-
import { Base64 as Base645 } from "js-base64";
|
|
11101
|
-
function normalizeClashYaml(raw) {
|
|
11102
|
-
if (typeof raw !== "string" || !raw.includes("proxies:") || !raw.includes("short-id:")) {
|
|
11103
|
-
return raw;
|
|
11104
|
-
}
|
|
11105
|
-
try {
|
|
11106
|
-
const content = safeLoad(raw);
|
|
11107
|
-
if (!Array.isArray(content.proxies) || content.proxies.length === 0)
|
|
11108
|
-
return raw;
|
|
11109
|
-
} catch (e) {
|
|
11110
|
-
return raw;
|
|
11111
|
-
}
|
|
11112
|
-
return raw.replace(/short-id:([ \t]*[^#\n,}]*)/g, (matched, value) => {
|
|
11113
|
-
const afterTrim = value.trim();
|
|
11114
|
-
if (!afterTrim || afterTrim === "") {
|
|
11115
|
-
return 'short-id: ""';
|
|
11116
|
-
}
|
|
11117
|
-
if (/^(['"]).*\1$/.test(afterTrim)) {
|
|
11118
|
-
return `short-id: ${afterTrim}`;
|
|
11119
|
-
} else if (["null"].includes(afterTrim)) {
|
|
11120
|
-
return `short-id: ${afterTrim}`;
|
|
11121
|
-
} else {
|
|
11122
|
-
return `short-id: "${afterTrim}"`;
|
|
11123
|
-
}
|
|
11124
|
-
});
|
|
11125
|
-
}
|
|
11126
|
-
function HTML() {
|
|
11127
|
-
const name = "HTML";
|
|
11128
|
-
const test = (raw) => /^<!DOCTYPE html>/.test(raw);
|
|
11129
|
-
const parse = () => "";
|
|
11130
|
-
return { name, test, parse };
|
|
11131
|
-
}
|
|
11132
|
-
function Base64Encoded() {
|
|
11133
|
-
const name = "Base64 Pre-processor";
|
|
11134
|
-
const keys = [
|
|
11135
|
-
"dm1lc3M",
|
|
11136
|
-
// vmess
|
|
11137
|
-
"c3NyOi8v",
|
|
11138
|
-
// ssr://
|
|
11139
|
-
"c29ja3M6Ly",
|
|
11140
|
-
// socks://
|
|
11141
|
-
"dHJvamFu",
|
|
11142
|
-
// trojan
|
|
11143
|
-
"c3M6Ly",
|
|
11144
|
-
// ss:/
|
|
11145
|
-
"c3NkOi8v",
|
|
11146
|
-
// ssd://
|
|
11147
|
-
"c2hhZG93",
|
|
11148
|
-
// shadow
|
|
11149
|
-
"aHR0c",
|
|
11150
|
-
// htt
|
|
11151
|
-
"dmxlc3M=",
|
|
11152
|
-
// vless
|
|
11153
|
-
"aHlzdGVyaWEy",
|
|
11154
|
-
// hysteria2
|
|
11155
|
-
"aHkyOi8v",
|
|
11156
|
-
// hy2://
|
|
11157
|
-
"d2lyZWd1YXJkOi8v",
|
|
11158
|
-
// wireguard://
|
|
11159
|
-
"d2c6Ly8=",
|
|
11160
|
-
// wg://
|
|
11161
|
-
"dHVpYzovLw=="
|
|
11162
|
-
// tuic://
|
|
11163
|
-
];
|
|
11164
|
-
const test = function(raw) {
|
|
11165
|
-
return !/^\w+:\/\/\w+/im.test(raw) && keys.some((k) => raw.indexOf(k) !== -1);
|
|
11166
|
-
};
|
|
11167
|
-
const parse = function(raw) {
|
|
11168
|
-
const decoded = Base645.decode(raw);
|
|
11169
|
-
if (!/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(decoded)) {
|
|
11170
|
-
app_default.error(
|
|
11171
|
-
`Base64 Pre-processor error: decoded line does not start with protocol`
|
|
11172
|
-
);
|
|
11173
|
-
return raw;
|
|
11174
|
-
}
|
|
11175
|
-
return decoded;
|
|
11176
|
-
};
|
|
11177
|
-
return { name, test, parse };
|
|
11178
|
-
}
|
|
11179
|
-
function fallbackBase64Encoded() {
|
|
11180
|
-
const name = "Fallback Base64 Pre-processor";
|
|
11181
|
-
const test = function(raw) {
|
|
11182
|
-
return true;
|
|
11183
|
-
};
|
|
11184
|
-
const parse = function(raw) {
|
|
11185
|
-
const decoded = Base645.decode(raw);
|
|
11186
|
-
if (!/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(decoded)) {
|
|
11187
|
-
app_default.error(
|
|
11188
|
-
`Fallback Base64 Pre-processor error: decoded line does not start with protocol`
|
|
11189
|
-
);
|
|
11190
|
-
return raw;
|
|
11191
|
-
}
|
|
11192
|
-
return decoded;
|
|
11193
|
-
};
|
|
11194
|
-
return { name, test, parse };
|
|
11195
|
-
}
|
|
11196
|
-
function Clash() {
|
|
11197
|
-
const name = "Clash Pre-processor";
|
|
11198
|
-
const test = function(raw) {
|
|
11199
|
-
if (!/proxies/.test(raw)) return false;
|
|
11200
|
-
const content = safeLoad(raw);
|
|
11201
|
-
return content.proxies && Array.isArray(content.proxies);
|
|
11202
|
-
};
|
|
11203
|
-
const parse = function(raw, includeProxies) {
|
|
11204
|
-
const afterReplace = normalizeClashYaml(raw);
|
|
11205
|
-
const { proxies } = safeLoad(afterReplace);
|
|
11206
|
-
return (includeProxies ? "proxies:\n" : "") + proxies.map((p) => {
|
|
11207
|
-
return `${includeProxies ? " - " : ""}${JSON.stringify(
|
|
11208
|
-
p
|
|
11209
|
-
)}
|
|
11210
|
-
`;
|
|
11211
|
-
}).join("");
|
|
11212
|
-
};
|
|
11213
|
-
return { name, test, parse };
|
|
11214
|
-
}
|
|
11215
|
-
function SSD() {
|
|
11216
|
-
const name = "SSD Pre-processor";
|
|
11217
|
-
const test = function(raw) {
|
|
11218
|
-
return raw.indexOf("ssd://") === 0;
|
|
11219
|
-
};
|
|
11220
|
-
const parse = function(raw) {
|
|
11221
|
-
const output = [];
|
|
11222
|
-
let ssdinfo = JSON.parse(Base645.decode(raw.split("ssd://")[1]));
|
|
11223
|
-
let port = ssdinfo.port;
|
|
11224
|
-
let method = ssdinfo.encryption;
|
|
11225
|
-
let password = ssdinfo.password;
|
|
11226
|
-
let servers = ssdinfo.servers;
|
|
11227
|
-
for (let i = 0; i < servers.length; i++) {
|
|
11228
|
-
let server = servers[i];
|
|
11229
|
-
method = server.encryption ? server.encryption : method;
|
|
11230
|
-
password = server.password ? server.password : password;
|
|
11231
|
-
let userinfo = Base645.encode(method + ":" + password);
|
|
11232
|
-
let hostname = server.server;
|
|
11233
|
-
port = server.port ? server.port : port;
|
|
11234
|
-
let tag = server.remarks ? server.remarks : i;
|
|
11235
|
-
let plugin = server.plugin_options ? "/?plugin=" + encodeURIComponent(
|
|
11236
|
-
server.plugin + ";" + server.plugin_options
|
|
11237
|
-
) : "";
|
|
11238
|
-
output[i] = "ss://" + userinfo + "@" + hostname + ":" + port + plugin + "#" + tag;
|
|
11239
|
-
}
|
|
11240
|
-
return output.join("\n");
|
|
11241
|
-
};
|
|
11242
|
-
return { name, test, parse };
|
|
11243
|
-
}
|
|
11244
|
-
function FullConfig() {
|
|
11245
|
-
const name = "Full Config Preprocessor";
|
|
11246
|
-
const test = function(raw) {
|
|
11247
|
-
return /^(\[server_local\]|\[Proxy\])/gm.test(raw);
|
|
11248
|
-
};
|
|
11249
|
-
const parse = function(raw) {
|
|
11250
|
-
const match = raw.match(
|
|
11251
|
-
/^\[server_local|Proxy\]([\s\S]+?)^\[.+?\](\r?\n|$)/im
|
|
11252
|
-
)?.[1];
|
|
11253
|
-
return match || raw;
|
|
11254
|
-
};
|
|
11255
|
-
return { name, test, parse };
|
|
11256
|
-
}
|
|
11257
|
-
var preprocessors_default = [
|
|
11258
|
-
HTML(),
|
|
11259
|
-
Clash(),
|
|
11260
|
-
Base64Encoded(),
|
|
11261
|
-
SSD(),
|
|
11262
|
-
FullConfig(),
|
|
11263
|
-
fallbackBase64Encoded()
|
|
11264
|
-
];
|
|
11265
|
-
|
|
11266
11616
|
// src/index.js
|
|
11267
11617
|
var parsers = parsers_default;
|
|
11268
11618
|
var produce = producers_default;
|