sub-store-convert 2.44.16 → 2.44.20
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 +1295 -535
- package/package.json +4 -4
package/index.js
CHANGED
|
@@ -219,13 +219,13 @@ var require_buffer = __commonJS({
|
|
|
219
219
|
var base64 = require_base64_js();
|
|
220
220
|
var ieee754 = require_ieee754();
|
|
221
221
|
var customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null;
|
|
222
|
-
exports.Buffer =
|
|
222
|
+
exports.Buffer = Buffer6;
|
|
223
223
|
exports.SlowBuffer = SlowBuffer;
|
|
224
224
|
exports.INSPECT_MAX_BYTES = 50;
|
|
225
225
|
var K_MAX_LENGTH = 2147483647;
|
|
226
226
|
exports.kMaxLength = K_MAX_LENGTH;
|
|
227
|
-
|
|
228
|
-
if (!
|
|
227
|
+
Buffer6.TYPED_ARRAY_SUPPORT = typedArraySupport();
|
|
228
|
+
if (!Buffer6.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") {
|
|
229
229
|
console.error(
|
|
230
230
|
"This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."
|
|
231
231
|
);
|
|
@@ -243,17 +243,17 @@ var require_buffer = __commonJS({
|
|
|
243
243
|
return false;
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
|
-
Object.defineProperty(
|
|
246
|
+
Object.defineProperty(Buffer6.prototype, "parent", {
|
|
247
247
|
enumerable: true,
|
|
248
248
|
get: function() {
|
|
249
|
-
if (!
|
|
249
|
+
if (!Buffer6.isBuffer(this)) return void 0;
|
|
250
250
|
return this.buffer;
|
|
251
251
|
}
|
|
252
252
|
});
|
|
253
|
-
Object.defineProperty(
|
|
253
|
+
Object.defineProperty(Buffer6.prototype, "offset", {
|
|
254
254
|
enumerable: true,
|
|
255
255
|
get: function() {
|
|
256
|
-
if (!
|
|
256
|
+
if (!Buffer6.isBuffer(this)) return void 0;
|
|
257
257
|
return this.byteOffset;
|
|
258
258
|
}
|
|
259
259
|
});
|
|
@@ -262,10 +262,10 @@ var require_buffer = __commonJS({
|
|
|
262
262
|
throw new RangeError('The value "' + length + '" is invalid for option "size"');
|
|
263
263
|
}
|
|
264
264
|
const buf = new Uint8Array(length);
|
|
265
|
-
Object.setPrototypeOf(buf,
|
|
265
|
+
Object.setPrototypeOf(buf, Buffer6.prototype);
|
|
266
266
|
return buf;
|
|
267
267
|
}
|
|
268
|
-
function
|
|
268
|
+
function Buffer6(arg, encodingOrOffset, length) {
|
|
269
269
|
if (typeof arg === "number") {
|
|
270
270
|
if (typeof encodingOrOffset === "string") {
|
|
271
271
|
throw new TypeError(
|
|
@@ -276,7 +276,7 @@ var require_buffer = __commonJS({
|
|
|
276
276
|
}
|
|
277
277
|
return from(arg, encodingOrOffset, length);
|
|
278
278
|
}
|
|
279
|
-
|
|
279
|
+
Buffer6.poolSize = 8192;
|
|
280
280
|
function from(value, encodingOrOffset, length) {
|
|
281
281
|
if (typeof value === "string") {
|
|
282
282
|
return fromString(value, encodingOrOffset);
|
|
@@ -302,22 +302,22 @@ var require_buffer = __commonJS({
|
|
|
302
302
|
}
|
|
303
303
|
const valueOf = value.valueOf && value.valueOf();
|
|
304
304
|
if (valueOf != null && valueOf !== value) {
|
|
305
|
-
return
|
|
305
|
+
return Buffer6.from(valueOf, encodingOrOffset, length);
|
|
306
306
|
}
|
|
307
307
|
const b = fromObject(value);
|
|
308
308
|
if (b) return b;
|
|
309
309
|
if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") {
|
|
310
|
-
return
|
|
310
|
+
return Buffer6.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length);
|
|
311
311
|
}
|
|
312
312
|
throw new TypeError(
|
|
313
313
|
"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value
|
|
314
314
|
);
|
|
315
315
|
}
|
|
316
|
-
|
|
316
|
+
Buffer6.from = function(value, encodingOrOffset, length) {
|
|
317
317
|
return from(value, encodingOrOffset, length);
|
|
318
318
|
};
|
|
319
|
-
Object.setPrototypeOf(
|
|
320
|
-
Object.setPrototypeOf(
|
|
319
|
+
Object.setPrototypeOf(Buffer6.prototype, Uint8Array.prototype);
|
|
320
|
+
Object.setPrototypeOf(Buffer6, Uint8Array);
|
|
321
321
|
function assertSize(size) {
|
|
322
322
|
if (typeof size !== "number") {
|
|
323
323
|
throw new TypeError('"size" argument must be of type number');
|
|
@@ -335,24 +335,24 @@ var require_buffer = __commonJS({
|
|
|
335
335
|
}
|
|
336
336
|
return createBuffer(size);
|
|
337
337
|
}
|
|
338
|
-
|
|
338
|
+
Buffer6.alloc = function(size, fill, encoding) {
|
|
339
339
|
return alloc(size, fill, encoding);
|
|
340
340
|
};
|
|
341
341
|
function allocUnsafe(size) {
|
|
342
342
|
assertSize(size);
|
|
343
343
|
return createBuffer(size < 0 ? 0 : checked(size) | 0);
|
|
344
344
|
}
|
|
345
|
-
|
|
345
|
+
Buffer6.allocUnsafe = function(size) {
|
|
346
346
|
return allocUnsafe(size);
|
|
347
347
|
};
|
|
348
|
-
|
|
348
|
+
Buffer6.allocUnsafeSlow = function(size) {
|
|
349
349
|
return allocUnsafe(size);
|
|
350
350
|
};
|
|
351
351
|
function fromString(string, encoding) {
|
|
352
352
|
if (typeof encoding !== "string" || encoding === "") {
|
|
353
353
|
encoding = "utf8";
|
|
354
354
|
}
|
|
355
|
-
if (!
|
|
355
|
+
if (!Buffer6.isEncoding(encoding)) {
|
|
356
356
|
throw new TypeError("Unknown encoding: " + encoding);
|
|
357
357
|
}
|
|
358
358
|
const length = byteLength(string, encoding) | 0;
|
|
@@ -393,11 +393,11 @@ var require_buffer = __commonJS({
|
|
|
393
393
|
} else {
|
|
394
394
|
buf = new Uint8Array(array, byteOffset, length);
|
|
395
395
|
}
|
|
396
|
-
Object.setPrototypeOf(buf,
|
|
396
|
+
Object.setPrototypeOf(buf, Buffer6.prototype);
|
|
397
397
|
return buf;
|
|
398
398
|
}
|
|
399
399
|
function fromObject(obj) {
|
|
400
|
-
if (
|
|
400
|
+
if (Buffer6.isBuffer(obj)) {
|
|
401
401
|
const len = checked(obj.length) | 0;
|
|
402
402
|
const buf = createBuffer(len);
|
|
403
403
|
if (buf.length === 0) {
|
|
@@ -426,15 +426,15 @@ var require_buffer = __commonJS({
|
|
|
426
426
|
if (+length != length) {
|
|
427
427
|
length = 0;
|
|
428
428
|
}
|
|
429
|
-
return
|
|
429
|
+
return Buffer6.alloc(+length);
|
|
430
430
|
}
|
|
431
|
-
|
|
432
|
-
return b != null && b._isBuffer === true && b !==
|
|
431
|
+
Buffer6.isBuffer = function isBuffer(b) {
|
|
432
|
+
return b != null && b._isBuffer === true && b !== Buffer6.prototype;
|
|
433
433
|
};
|
|
434
|
-
|
|
435
|
-
if (isInstance(a, Uint8Array)) a =
|
|
436
|
-
if (isInstance(b, Uint8Array)) b =
|
|
437
|
-
if (!
|
|
434
|
+
Buffer6.compare = function compare(a, b) {
|
|
435
|
+
if (isInstance(a, Uint8Array)) a = Buffer6.from(a, a.offset, a.byteLength);
|
|
436
|
+
if (isInstance(b, Uint8Array)) b = Buffer6.from(b, b.offset, b.byteLength);
|
|
437
|
+
if (!Buffer6.isBuffer(a) || !Buffer6.isBuffer(b)) {
|
|
438
438
|
throw new TypeError(
|
|
439
439
|
'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
|
|
440
440
|
);
|
|
@@ -453,7 +453,7 @@ var require_buffer = __commonJS({
|
|
|
453
453
|
if (y < x) return 1;
|
|
454
454
|
return 0;
|
|
455
455
|
};
|
|
456
|
-
|
|
456
|
+
Buffer6.isEncoding = function isEncoding(encoding) {
|
|
457
457
|
switch (String(encoding).toLowerCase()) {
|
|
458
458
|
case "hex":
|
|
459
459
|
case "utf8":
|
|
@@ -471,12 +471,12 @@ var require_buffer = __commonJS({
|
|
|
471
471
|
return false;
|
|
472
472
|
}
|
|
473
473
|
};
|
|
474
|
-
|
|
474
|
+
Buffer6.concat = function concat(list, length) {
|
|
475
475
|
if (!Array.isArray(list)) {
|
|
476
476
|
throw new TypeError('"list" argument must be an Array of Buffers');
|
|
477
477
|
}
|
|
478
478
|
if (list.length === 0) {
|
|
479
|
-
return
|
|
479
|
+
return Buffer6.alloc(0);
|
|
480
480
|
}
|
|
481
481
|
let i;
|
|
482
482
|
if (length === void 0) {
|
|
@@ -485,13 +485,13 @@ var require_buffer = __commonJS({
|
|
|
485
485
|
length += list[i].length;
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
|
-
const buffer =
|
|
488
|
+
const buffer = Buffer6.allocUnsafe(length);
|
|
489
489
|
let pos = 0;
|
|
490
490
|
for (i = 0; i < list.length; ++i) {
|
|
491
491
|
let buf = list[i];
|
|
492
492
|
if (isInstance(buf, Uint8Array)) {
|
|
493
493
|
if (pos + buf.length > buffer.length) {
|
|
494
|
-
if (!
|
|
494
|
+
if (!Buffer6.isBuffer(buf)) buf = Buffer6.from(buf);
|
|
495
495
|
buf.copy(buffer, pos);
|
|
496
496
|
} else {
|
|
497
497
|
Uint8Array.prototype.set.call(
|
|
@@ -500,7 +500,7 @@ var require_buffer = __commonJS({
|
|
|
500
500
|
pos
|
|
501
501
|
);
|
|
502
502
|
}
|
|
503
|
-
} else if (!
|
|
503
|
+
} else if (!Buffer6.isBuffer(buf)) {
|
|
504
504
|
throw new TypeError('"list" argument must be an Array of Buffers');
|
|
505
505
|
} else {
|
|
506
506
|
buf.copy(buffer, pos);
|
|
@@ -510,7 +510,7 @@ var require_buffer = __commonJS({
|
|
|
510
510
|
return buffer;
|
|
511
511
|
};
|
|
512
512
|
function byteLength(string, encoding) {
|
|
513
|
-
if (
|
|
513
|
+
if (Buffer6.isBuffer(string)) {
|
|
514
514
|
return string.length;
|
|
515
515
|
}
|
|
516
516
|
if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
|
|
@@ -552,7 +552,7 @@ var require_buffer = __commonJS({
|
|
|
552
552
|
}
|
|
553
553
|
}
|
|
554
554
|
}
|
|
555
|
-
|
|
555
|
+
Buffer6.byteLength = byteLength;
|
|
556
556
|
function slowToString(encoding, start, end) {
|
|
557
557
|
let loweredCase = false;
|
|
558
558
|
if (start === void 0 || start < 0) {
|
|
@@ -599,13 +599,13 @@ var require_buffer = __commonJS({
|
|
|
599
599
|
}
|
|
600
600
|
}
|
|
601
601
|
}
|
|
602
|
-
|
|
602
|
+
Buffer6.prototype._isBuffer = true;
|
|
603
603
|
function swap(b, n, m) {
|
|
604
604
|
const i = b[n];
|
|
605
605
|
b[n] = b[m];
|
|
606
606
|
b[m] = i;
|
|
607
607
|
}
|
|
608
|
-
|
|
608
|
+
Buffer6.prototype.swap16 = function swap16() {
|
|
609
609
|
const len = this.length;
|
|
610
610
|
if (len % 2 !== 0) {
|
|
611
611
|
throw new RangeError("Buffer size must be a multiple of 16-bits");
|
|
@@ -615,7 +615,7 @@ var require_buffer = __commonJS({
|
|
|
615
615
|
}
|
|
616
616
|
return this;
|
|
617
617
|
};
|
|
618
|
-
|
|
618
|
+
Buffer6.prototype.swap32 = function swap32() {
|
|
619
619
|
const len = this.length;
|
|
620
620
|
if (len % 4 !== 0) {
|
|
621
621
|
throw new RangeError("Buffer size must be a multiple of 32-bits");
|
|
@@ -626,7 +626,7 @@ var require_buffer = __commonJS({
|
|
|
626
626
|
}
|
|
627
627
|
return this;
|
|
628
628
|
};
|
|
629
|
-
|
|
629
|
+
Buffer6.prototype.swap64 = function swap64() {
|
|
630
630
|
const len = this.length;
|
|
631
631
|
if (len % 8 !== 0) {
|
|
632
632
|
throw new RangeError("Buffer size must be a multiple of 64-bits");
|
|
@@ -639,19 +639,19 @@ var require_buffer = __commonJS({
|
|
|
639
639
|
}
|
|
640
640
|
return this;
|
|
641
641
|
};
|
|
642
|
-
|
|
642
|
+
Buffer6.prototype.toString = function toString() {
|
|
643
643
|
const length = this.length;
|
|
644
644
|
if (length === 0) return "";
|
|
645
645
|
if (arguments.length === 0) return utf8Slice(this, 0, length);
|
|
646
646
|
return slowToString.apply(this, arguments);
|
|
647
647
|
};
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
if (!
|
|
648
|
+
Buffer6.prototype.toLocaleString = Buffer6.prototype.toString;
|
|
649
|
+
Buffer6.prototype.equals = function equals(b) {
|
|
650
|
+
if (!Buffer6.isBuffer(b)) throw new TypeError("Argument must be a Buffer");
|
|
651
651
|
if (this === b) return true;
|
|
652
|
-
return
|
|
652
|
+
return Buffer6.compare(this, b) === 0;
|
|
653
653
|
};
|
|
654
|
-
|
|
654
|
+
Buffer6.prototype.inspect = function inspect() {
|
|
655
655
|
let str = "";
|
|
656
656
|
const max = exports.INSPECT_MAX_BYTES;
|
|
657
657
|
str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim();
|
|
@@ -659,13 +659,13 @@ var require_buffer = __commonJS({
|
|
|
659
659
|
return "<Buffer " + str + ">";
|
|
660
660
|
};
|
|
661
661
|
if (customInspectSymbol) {
|
|
662
|
-
|
|
662
|
+
Buffer6.prototype[customInspectSymbol] = Buffer6.prototype.inspect;
|
|
663
663
|
}
|
|
664
|
-
|
|
664
|
+
Buffer6.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
|
|
665
665
|
if (isInstance(target, Uint8Array)) {
|
|
666
|
-
target =
|
|
666
|
+
target = Buffer6.from(target, target.offset, target.byteLength);
|
|
667
667
|
}
|
|
668
|
-
if (!
|
|
668
|
+
if (!Buffer6.isBuffer(target)) {
|
|
669
669
|
throw new TypeError(
|
|
670
670
|
'The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target
|
|
671
671
|
);
|
|
@@ -738,9 +738,9 @@ var require_buffer = __commonJS({
|
|
|
738
738
|
else return -1;
|
|
739
739
|
}
|
|
740
740
|
if (typeof val === "string") {
|
|
741
|
-
val =
|
|
741
|
+
val = Buffer6.from(val, encoding);
|
|
742
742
|
}
|
|
743
|
-
if (
|
|
743
|
+
if (Buffer6.isBuffer(val)) {
|
|
744
744
|
if (val.length === 0) {
|
|
745
745
|
return -1;
|
|
746
746
|
}
|
|
@@ -808,13 +808,13 @@ var require_buffer = __commonJS({
|
|
|
808
808
|
}
|
|
809
809
|
return -1;
|
|
810
810
|
}
|
|
811
|
-
|
|
811
|
+
Buffer6.prototype.includes = function includes(val, byteOffset, encoding) {
|
|
812
812
|
return this.indexOf(val, byteOffset, encoding) !== -1;
|
|
813
813
|
};
|
|
814
|
-
|
|
814
|
+
Buffer6.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
|
|
815
815
|
return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
|
|
816
816
|
};
|
|
817
|
-
|
|
817
|
+
Buffer6.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
|
|
818
818
|
return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
|
|
819
819
|
};
|
|
820
820
|
function hexWrite(buf, string, offset, length) {
|
|
@@ -852,7 +852,7 @@ var require_buffer = __commonJS({
|
|
|
852
852
|
function ucs2Write(buf, string, offset, length) {
|
|
853
853
|
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
|
|
854
854
|
}
|
|
855
|
-
|
|
855
|
+
Buffer6.prototype.write = function write(string, offset, length, encoding) {
|
|
856
856
|
if (offset === void 0) {
|
|
857
857
|
encoding = "utf8";
|
|
858
858
|
length = this.length;
|
|
@@ -907,7 +907,7 @@ var require_buffer = __commonJS({
|
|
|
907
907
|
}
|
|
908
908
|
}
|
|
909
909
|
};
|
|
910
|
-
|
|
910
|
+
Buffer6.prototype.toJSON = function toJSON() {
|
|
911
911
|
return {
|
|
912
912
|
type: "Buffer",
|
|
913
913
|
data: Array.prototype.slice.call(this._arr || this, 0)
|
|
@@ -1030,7 +1030,7 @@ var require_buffer = __commonJS({
|
|
|
1030
1030
|
}
|
|
1031
1031
|
return res;
|
|
1032
1032
|
}
|
|
1033
|
-
|
|
1033
|
+
Buffer6.prototype.slice = function slice(start, end) {
|
|
1034
1034
|
const len = this.length;
|
|
1035
1035
|
start = ~~start;
|
|
1036
1036
|
end = end === void 0 ? len : ~~end;
|
|
@@ -1048,14 +1048,14 @@ var require_buffer = __commonJS({
|
|
|
1048
1048
|
}
|
|
1049
1049
|
if (end < start) end = start;
|
|
1050
1050
|
const newBuf = this.subarray(start, end);
|
|
1051
|
-
Object.setPrototypeOf(newBuf,
|
|
1051
|
+
Object.setPrototypeOf(newBuf, Buffer6.prototype);
|
|
1052
1052
|
return newBuf;
|
|
1053
1053
|
};
|
|
1054
1054
|
function checkOffset(offset, ext, length) {
|
|
1055
1055
|
if (offset % 1 !== 0 || offset < 0) throw new RangeError("offset is not uint");
|
|
1056
1056
|
if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length");
|
|
1057
1057
|
}
|
|
1058
|
-
|
|
1058
|
+
Buffer6.prototype.readUintLE = Buffer6.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) {
|
|
1059
1059
|
offset = offset >>> 0;
|
|
1060
1060
|
byteLength2 = byteLength2 >>> 0;
|
|
1061
1061
|
if (!noAssert) checkOffset(offset, byteLength2, this.length);
|
|
@@ -1067,7 +1067,7 @@ var require_buffer = __commonJS({
|
|
|
1067
1067
|
}
|
|
1068
1068
|
return val;
|
|
1069
1069
|
};
|
|
1070
|
-
|
|
1070
|
+
Buffer6.prototype.readUintBE = Buffer6.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) {
|
|
1071
1071
|
offset = offset >>> 0;
|
|
1072
1072
|
byteLength2 = byteLength2 >>> 0;
|
|
1073
1073
|
if (!noAssert) {
|
|
@@ -1080,32 +1080,32 @@ var require_buffer = __commonJS({
|
|
|
1080
1080
|
}
|
|
1081
1081
|
return val;
|
|
1082
1082
|
};
|
|
1083
|
-
|
|
1083
|
+
Buffer6.prototype.readUint8 = Buffer6.prototype.readUInt8 = function readUInt8(offset, noAssert) {
|
|
1084
1084
|
offset = offset >>> 0;
|
|
1085
1085
|
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
1086
1086
|
return this[offset];
|
|
1087
1087
|
};
|
|
1088
|
-
|
|
1088
|
+
Buffer6.prototype.readUint16LE = Buffer6.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
|
|
1089
1089
|
offset = offset >>> 0;
|
|
1090
1090
|
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1091
1091
|
return this[offset] | this[offset + 1] << 8;
|
|
1092
1092
|
};
|
|
1093
|
-
|
|
1093
|
+
Buffer6.prototype.readUint16BE = Buffer6.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
|
|
1094
1094
|
offset = offset >>> 0;
|
|
1095
1095
|
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1096
1096
|
return this[offset] << 8 | this[offset + 1];
|
|
1097
1097
|
};
|
|
1098
|
-
|
|
1098
|
+
Buffer6.prototype.readUint32LE = Buffer6.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
|
|
1099
1099
|
offset = offset >>> 0;
|
|
1100
1100
|
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1101
1101
|
return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
|
|
1102
1102
|
};
|
|
1103
|
-
|
|
1103
|
+
Buffer6.prototype.readUint32BE = Buffer6.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
|
|
1104
1104
|
offset = offset >>> 0;
|
|
1105
1105
|
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1106
1106
|
return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
|
|
1107
1107
|
};
|
|
1108
|
-
|
|
1108
|
+
Buffer6.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE(offset) {
|
|
1109
1109
|
offset = offset >>> 0;
|
|
1110
1110
|
validateNumber(offset, "offset");
|
|
1111
1111
|
const first = this[offset];
|
|
@@ -1117,7 +1117,7 @@ var require_buffer = __commonJS({
|
|
|
1117
1117
|
const hi = this[++offset] + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + last * 2 ** 24;
|
|
1118
1118
|
return BigInt(lo) + (BigInt(hi) << BigInt(32));
|
|
1119
1119
|
});
|
|
1120
|
-
|
|
1120
|
+
Buffer6.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE(offset) {
|
|
1121
1121
|
offset = offset >>> 0;
|
|
1122
1122
|
validateNumber(offset, "offset");
|
|
1123
1123
|
const first = this[offset];
|
|
@@ -1129,7 +1129,7 @@ var require_buffer = __commonJS({
|
|
|
1129
1129
|
const lo = this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last;
|
|
1130
1130
|
return (BigInt(hi) << BigInt(32)) + BigInt(lo);
|
|
1131
1131
|
});
|
|
1132
|
-
|
|
1132
|
+
Buffer6.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) {
|
|
1133
1133
|
offset = offset >>> 0;
|
|
1134
1134
|
byteLength2 = byteLength2 >>> 0;
|
|
1135
1135
|
if (!noAssert) checkOffset(offset, byteLength2, this.length);
|
|
@@ -1143,7 +1143,7 @@ var require_buffer = __commonJS({
|
|
|
1143
1143
|
if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
|
|
1144
1144
|
return val;
|
|
1145
1145
|
};
|
|
1146
|
-
|
|
1146
|
+
Buffer6.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) {
|
|
1147
1147
|
offset = offset >>> 0;
|
|
1148
1148
|
byteLength2 = byteLength2 >>> 0;
|
|
1149
1149
|
if (!noAssert) checkOffset(offset, byteLength2, this.length);
|
|
@@ -1157,35 +1157,35 @@ var require_buffer = __commonJS({
|
|
|
1157
1157
|
if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
|
|
1158
1158
|
return val;
|
|
1159
1159
|
};
|
|
1160
|
-
|
|
1160
|
+
Buffer6.prototype.readInt8 = function readInt8(offset, noAssert) {
|
|
1161
1161
|
offset = offset >>> 0;
|
|
1162
1162
|
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
1163
1163
|
if (!(this[offset] & 128)) return this[offset];
|
|
1164
1164
|
return (255 - this[offset] + 1) * -1;
|
|
1165
1165
|
};
|
|
1166
|
-
|
|
1166
|
+
Buffer6.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
|
|
1167
1167
|
offset = offset >>> 0;
|
|
1168
1168
|
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1169
1169
|
const val = this[offset] | this[offset + 1] << 8;
|
|
1170
1170
|
return val & 32768 ? val | 4294901760 : val;
|
|
1171
1171
|
};
|
|
1172
|
-
|
|
1172
|
+
Buffer6.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
|
|
1173
1173
|
offset = offset >>> 0;
|
|
1174
1174
|
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1175
1175
|
const val = this[offset + 1] | this[offset] << 8;
|
|
1176
1176
|
return val & 32768 ? val | 4294901760 : val;
|
|
1177
1177
|
};
|
|
1178
|
-
|
|
1178
|
+
Buffer6.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
|
|
1179
1179
|
offset = offset >>> 0;
|
|
1180
1180
|
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1181
1181
|
return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
|
|
1182
1182
|
};
|
|
1183
|
-
|
|
1183
|
+
Buffer6.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
|
|
1184
1184
|
offset = offset >>> 0;
|
|
1185
1185
|
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1186
1186
|
return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
|
|
1187
1187
|
};
|
|
1188
|
-
|
|
1188
|
+
Buffer6.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE(offset) {
|
|
1189
1189
|
offset = offset >>> 0;
|
|
1190
1190
|
validateNumber(offset, "offset");
|
|
1191
1191
|
const first = this[offset];
|
|
@@ -1196,7 +1196,7 @@ var require_buffer = __commonJS({
|
|
|
1196
1196
|
const val = this[offset + 4] + this[offset + 5] * 2 ** 8 + this[offset + 6] * 2 ** 16 + (last << 24);
|
|
1197
1197
|
return (BigInt(val) << BigInt(32)) + BigInt(first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24);
|
|
1198
1198
|
});
|
|
1199
|
-
|
|
1199
|
+
Buffer6.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE(offset) {
|
|
1200
1200
|
offset = offset >>> 0;
|
|
1201
1201
|
validateNumber(offset, "offset");
|
|
1202
1202
|
const first = this[offset];
|
|
@@ -1208,32 +1208,32 @@ var require_buffer = __commonJS({
|
|
|
1208
1208
|
this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
|
|
1209
1209
|
return (BigInt(val) << BigInt(32)) + BigInt(this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last);
|
|
1210
1210
|
});
|
|
1211
|
-
|
|
1211
|
+
Buffer6.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
|
|
1212
1212
|
offset = offset >>> 0;
|
|
1213
1213
|
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1214
1214
|
return ieee754.read(this, offset, true, 23, 4);
|
|
1215
1215
|
};
|
|
1216
|
-
|
|
1216
|
+
Buffer6.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
|
|
1217
1217
|
offset = offset >>> 0;
|
|
1218
1218
|
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1219
1219
|
return ieee754.read(this, offset, false, 23, 4);
|
|
1220
1220
|
};
|
|
1221
|
-
|
|
1221
|
+
Buffer6.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
|
|
1222
1222
|
offset = offset >>> 0;
|
|
1223
1223
|
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
1224
1224
|
return ieee754.read(this, offset, true, 52, 8);
|
|
1225
1225
|
};
|
|
1226
|
-
|
|
1226
|
+
Buffer6.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
|
|
1227
1227
|
offset = offset >>> 0;
|
|
1228
1228
|
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
1229
1229
|
return ieee754.read(this, offset, false, 52, 8);
|
|
1230
1230
|
};
|
|
1231
1231
|
function checkInt(buf, value, offset, ext, max, min) {
|
|
1232
|
-
if (!
|
|
1232
|
+
if (!Buffer6.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance');
|
|
1233
1233
|
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds');
|
|
1234
1234
|
if (offset + ext > buf.length) throw new RangeError("Index out of range");
|
|
1235
1235
|
}
|
|
1236
|
-
|
|
1236
|
+
Buffer6.prototype.writeUintLE = Buffer6.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) {
|
|
1237
1237
|
value = +value;
|
|
1238
1238
|
offset = offset >>> 0;
|
|
1239
1239
|
byteLength2 = byteLength2 >>> 0;
|
|
@@ -1249,7 +1249,7 @@ var require_buffer = __commonJS({
|
|
|
1249
1249
|
}
|
|
1250
1250
|
return offset + byteLength2;
|
|
1251
1251
|
};
|
|
1252
|
-
|
|
1252
|
+
Buffer6.prototype.writeUintBE = Buffer6.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) {
|
|
1253
1253
|
value = +value;
|
|
1254
1254
|
offset = offset >>> 0;
|
|
1255
1255
|
byteLength2 = byteLength2 >>> 0;
|
|
@@ -1265,14 +1265,14 @@ var require_buffer = __commonJS({
|
|
|
1265
1265
|
}
|
|
1266
1266
|
return offset + byteLength2;
|
|
1267
1267
|
};
|
|
1268
|
-
|
|
1268
|
+
Buffer6.prototype.writeUint8 = Buffer6.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
|
|
1269
1269
|
value = +value;
|
|
1270
1270
|
offset = offset >>> 0;
|
|
1271
1271
|
if (!noAssert) checkInt(this, value, offset, 1, 255, 0);
|
|
1272
1272
|
this[offset] = value & 255;
|
|
1273
1273
|
return offset + 1;
|
|
1274
1274
|
};
|
|
1275
|
-
|
|
1275
|
+
Buffer6.prototype.writeUint16LE = Buffer6.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
|
|
1276
1276
|
value = +value;
|
|
1277
1277
|
offset = offset >>> 0;
|
|
1278
1278
|
if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
|
|
@@ -1280,7 +1280,7 @@ var require_buffer = __commonJS({
|
|
|
1280
1280
|
this[offset + 1] = value >>> 8;
|
|
1281
1281
|
return offset + 2;
|
|
1282
1282
|
};
|
|
1283
|
-
|
|
1283
|
+
Buffer6.prototype.writeUint16BE = Buffer6.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
|
|
1284
1284
|
value = +value;
|
|
1285
1285
|
offset = offset >>> 0;
|
|
1286
1286
|
if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
|
|
@@ -1288,7 +1288,7 @@ var require_buffer = __commonJS({
|
|
|
1288
1288
|
this[offset + 1] = value & 255;
|
|
1289
1289
|
return offset + 2;
|
|
1290
1290
|
};
|
|
1291
|
-
|
|
1291
|
+
Buffer6.prototype.writeUint32LE = Buffer6.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
|
|
1292
1292
|
value = +value;
|
|
1293
1293
|
offset = offset >>> 0;
|
|
1294
1294
|
if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
|
|
@@ -1298,7 +1298,7 @@ var require_buffer = __commonJS({
|
|
|
1298
1298
|
this[offset] = value & 255;
|
|
1299
1299
|
return offset + 4;
|
|
1300
1300
|
};
|
|
1301
|
-
|
|
1301
|
+
Buffer6.prototype.writeUint32BE = Buffer6.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
|
|
1302
1302
|
value = +value;
|
|
1303
1303
|
offset = offset >>> 0;
|
|
1304
1304
|
if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
|
|
@@ -1348,13 +1348,13 @@ var require_buffer = __commonJS({
|
|
|
1348
1348
|
buf[offset] = hi;
|
|
1349
1349
|
return offset + 8;
|
|
1350
1350
|
}
|
|
1351
|
-
|
|
1351
|
+
Buffer6.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) {
|
|
1352
1352
|
return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
|
|
1353
1353
|
});
|
|
1354
|
-
|
|
1354
|
+
Buffer6.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) {
|
|
1355
1355
|
return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
|
|
1356
1356
|
});
|
|
1357
|
-
|
|
1357
|
+
Buffer6.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) {
|
|
1358
1358
|
value = +value;
|
|
1359
1359
|
offset = offset >>> 0;
|
|
1360
1360
|
if (!noAssert) {
|
|
@@ -1373,7 +1373,7 @@ var require_buffer = __commonJS({
|
|
|
1373
1373
|
}
|
|
1374
1374
|
return offset + byteLength2;
|
|
1375
1375
|
};
|
|
1376
|
-
|
|
1376
|
+
Buffer6.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) {
|
|
1377
1377
|
value = +value;
|
|
1378
1378
|
offset = offset >>> 0;
|
|
1379
1379
|
if (!noAssert) {
|
|
@@ -1392,7 +1392,7 @@ var require_buffer = __commonJS({
|
|
|
1392
1392
|
}
|
|
1393
1393
|
return offset + byteLength2;
|
|
1394
1394
|
};
|
|
1395
|
-
|
|
1395
|
+
Buffer6.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
|
|
1396
1396
|
value = +value;
|
|
1397
1397
|
offset = offset >>> 0;
|
|
1398
1398
|
if (!noAssert) checkInt(this, value, offset, 1, 127, -128);
|
|
@@ -1400,7 +1400,7 @@ var require_buffer = __commonJS({
|
|
|
1400
1400
|
this[offset] = value & 255;
|
|
1401
1401
|
return offset + 1;
|
|
1402
1402
|
};
|
|
1403
|
-
|
|
1403
|
+
Buffer6.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
|
|
1404
1404
|
value = +value;
|
|
1405
1405
|
offset = offset >>> 0;
|
|
1406
1406
|
if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
|
|
@@ -1408,7 +1408,7 @@ var require_buffer = __commonJS({
|
|
|
1408
1408
|
this[offset + 1] = value >>> 8;
|
|
1409
1409
|
return offset + 2;
|
|
1410
1410
|
};
|
|
1411
|
-
|
|
1411
|
+
Buffer6.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
|
|
1412
1412
|
value = +value;
|
|
1413
1413
|
offset = offset >>> 0;
|
|
1414
1414
|
if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
|
|
@@ -1416,7 +1416,7 @@ var require_buffer = __commonJS({
|
|
|
1416
1416
|
this[offset + 1] = value & 255;
|
|
1417
1417
|
return offset + 2;
|
|
1418
1418
|
};
|
|
1419
|
-
|
|
1419
|
+
Buffer6.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
|
|
1420
1420
|
value = +value;
|
|
1421
1421
|
offset = offset >>> 0;
|
|
1422
1422
|
if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
|
|
@@ -1426,7 +1426,7 @@ var require_buffer = __commonJS({
|
|
|
1426
1426
|
this[offset + 3] = value >>> 24;
|
|
1427
1427
|
return offset + 4;
|
|
1428
1428
|
};
|
|
1429
|
-
|
|
1429
|
+
Buffer6.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
|
|
1430
1430
|
value = +value;
|
|
1431
1431
|
offset = offset >>> 0;
|
|
1432
1432
|
if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
|
|
@@ -1437,10 +1437,10 @@ var require_buffer = __commonJS({
|
|
|
1437
1437
|
this[offset + 3] = value & 255;
|
|
1438
1438
|
return offset + 4;
|
|
1439
1439
|
};
|
|
1440
|
-
|
|
1440
|
+
Buffer6.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) {
|
|
1441
1441
|
return wrtBigUInt64LE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
|
|
1442
1442
|
});
|
|
1443
|
-
|
|
1443
|
+
Buffer6.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset = 0) {
|
|
1444
1444
|
return wrtBigUInt64BE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
|
|
1445
1445
|
});
|
|
1446
1446
|
function checkIEEE754(buf, value, offset, ext, max, min) {
|
|
@@ -1456,10 +1456,10 @@ var require_buffer = __commonJS({
|
|
|
1456
1456
|
ieee754.write(buf, value, offset, littleEndian, 23, 4);
|
|
1457
1457
|
return offset + 4;
|
|
1458
1458
|
}
|
|
1459
|
-
|
|
1459
|
+
Buffer6.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
|
|
1460
1460
|
return writeFloat(this, value, offset, true, noAssert);
|
|
1461
1461
|
};
|
|
1462
|
-
|
|
1462
|
+
Buffer6.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
|
|
1463
1463
|
return writeFloat(this, value, offset, false, noAssert);
|
|
1464
1464
|
};
|
|
1465
1465
|
function writeDouble(buf, value, offset, littleEndian, noAssert) {
|
|
@@ -1471,14 +1471,14 @@ var require_buffer = __commonJS({
|
|
|
1471
1471
|
ieee754.write(buf, value, offset, littleEndian, 52, 8);
|
|
1472
1472
|
return offset + 8;
|
|
1473
1473
|
}
|
|
1474
|
-
|
|
1474
|
+
Buffer6.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
|
|
1475
1475
|
return writeDouble(this, value, offset, true, noAssert);
|
|
1476
1476
|
};
|
|
1477
|
-
|
|
1477
|
+
Buffer6.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
|
|
1478
1478
|
return writeDouble(this, value, offset, false, noAssert);
|
|
1479
1479
|
};
|
|
1480
|
-
|
|
1481
|
-
if (!
|
|
1480
|
+
Buffer6.prototype.copy = function copy(target, targetStart, start, end) {
|
|
1481
|
+
if (!Buffer6.isBuffer(target)) throw new TypeError("argument should be a Buffer");
|
|
1482
1482
|
if (!start) start = 0;
|
|
1483
1483
|
if (!end && end !== 0) end = this.length;
|
|
1484
1484
|
if (targetStart >= target.length) targetStart = target.length;
|
|
@@ -1507,7 +1507,7 @@ var require_buffer = __commonJS({
|
|
|
1507
1507
|
}
|
|
1508
1508
|
return len;
|
|
1509
1509
|
};
|
|
1510
|
-
|
|
1510
|
+
Buffer6.prototype.fill = function fill(val, start, end, encoding) {
|
|
1511
1511
|
if (typeof val === "string") {
|
|
1512
1512
|
if (typeof start === "string") {
|
|
1513
1513
|
encoding = start;
|
|
@@ -1520,7 +1520,7 @@ var require_buffer = __commonJS({
|
|
|
1520
1520
|
if (encoding !== void 0 && typeof encoding !== "string") {
|
|
1521
1521
|
throw new TypeError("encoding must be a string");
|
|
1522
1522
|
}
|
|
1523
|
-
if (typeof encoding === "string" && !
|
|
1523
|
+
if (typeof encoding === "string" && !Buffer6.isEncoding(encoding)) {
|
|
1524
1524
|
throw new TypeError("Unknown encoding: " + encoding);
|
|
1525
1525
|
}
|
|
1526
1526
|
if (val.length === 1) {
|
|
@@ -1549,7 +1549,7 @@ var require_buffer = __commonJS({
|
|
|
1549
1549
|
this[i] = val;
|
|
1550
1550
|
}
|
|
1551
1551
|
} else {
|
|
1552
|
-
const bytes =
|
|
1552
|
+
const bytes = Buffer6.isBuffer(val) ? val : Buffer6.from(val, encoding);
|
|
1553
1553
|
const len = bytes.length;
|
|
1554
1554
|
if (len === 0) {
|
|
1555
1555
|
throw new TypeError('The value "' + val + '" is invalid for argument "value"');
|
|
@@ -1846,6 +1846,297 @@ function isPlainObject(obj) {
|
|
|
1846
1846
|
|
|
1847
1847
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/parsers/peggy/surge.js
|
|
1848
1848
|
import peggy from "peggy";
|
|
1849
|
+
|
|
1850
|
+
// src/vendors/Sub-Store/backend/src/core/proxy-utils/ech-utils.js
|
|
1851
|
+
var ECH_DNS_FIELD = "_dns";
|
|
1852
|
+
var ECH_FORCE_QUERY_FIELD = "_force-query";
|
|
1853
|
+
var ECH_SOCKOPT_FIELD = "_sockopt";
|
|
1854
|
+
var DEFAULT_XRAY_ECH_DNS = "https://dns.alidns.com/dns-query";
|
|
1855
|
+
function normalizeInlineEchConfigList(value) {
|
|
1856
|
+
if (typeof value !== "string") return void 0;
|
|
1857
|
+
const match = /^([A-Za-z0-9+/]+|[A-Za-z0-9_-]+)(={0,2})$/.exec(
|
|
1858
|
+
value.trim()
|
|
1859
|
+
);
|
|
1860
|
+
if (!match) return void 0;
|
|
1861
|
+
const [, config, padding] = match;
|
|
1862
|
+
const paddingLength = (4 - config.length % 4) % 4;
|
|
1863
|
+
if (paddingLength === 3 || padding && padding.length !== paddingLength) {
|
|
1864
|
+
return void 0;
|
|
1865
|
+
}
|
|
1866
|
+
return config.replace(/-/g, "+").replace(/_/g, "/") + "=".repeat(paddingLength);
|
|
1867
|
+
}
|
|
1868
|
+
function parseXrayEchConfigList(echConfigList) {
|
|
1869
|
+
if (!isNotBlank(echConfigList)) {
|
|
1870
|
+
return void 0;
|
|
1871
|
+
}
|
|
1872
|
+
if (!echConfigList.includes("://")) {
|
|
1873
|
+
return {
|
|
1874
|
+
type: "config",
|
|
1875
|
+
config: echConfigList
|
|
1876
|
+
};
|
|
1877
|
+
}
|
|
1878
|
+
const parts = echConfigList.split("+");
|
|
1879
|
+
if (parts.length === 1 && isNotBlank(parts[0])) {
|
|
1880
|
+
return {
|
|
1881
|
+
type: "dns",
|
|
1882
|
+
dns: parts[0]
|
|
1883
|
+
};
|
|
1884
|
+
}
|
|
1885
|
+
if (parts.length === 2 && isNotBlank(parts[0]) && isNotBlank(parts[1])) {
|
|
1886
|
+
return {
|
|
1887
|
+
type: "dns",
|
|
1888
|
+
queryServerName: parts[0],
|
|
1889
|
+
dns: parts[1]
|
|
1890
|
+
};
|
|
1891
|
+
}
|
|
1892
|
+
return void 0;
|
|
1893
|
+
}
|
|
1894
|
+
function isSupportedXrayEchConfigList(echConfigList) {
|
|
1895
|
+
return parseXrayEchConfigList(echConfigList) != null;
|
|
1896
|
+
}
|
|
1897
|
+
function isSupportedXrayEchForceQuery(forceQuery) {
|
|
1898
|
+
return ["none", "half", "full"].includes(forceQuery);
|
|
1899
|
+
}
|
|
1900
|
+
function isMihomoEchEnabled(value) {
|
|
1901
|
+
if (typeof value === "boolean") {
|
|
1902
|
+
return value;
|
|
1903
|
+
}
|
|
1904
|
+
return typeof value === "number" && Number.isInteger(value) && value !== 0;
|
|
1905
|
+
}
|
|
1906
|
+
function buildMihomoEchOptsFromXrayFields({
|
|
1907
|
+
echConfigList,
|
|
1908
|
+
echForceQuery,
|
|
1909
|
+
echSockopt
|
|
1910
|
+
} = {}) {
|
|
1911
|
+
const parsedEchConfigList = parseXrayEchConfigList(echConfigList);
|
|
1912
|
+
if (!parsedEchConfigList) {
|
|
1913
|
+
return void 0;
|
|
1914
|
+
}
|
|
1915
|
+
const echOpts = {
|
|
1916
|
+
enable: true
|
|
1917
|
+
};
|
|
1918
|
+
if (parsedEchConfigList.type === "config") {
|
|
1919
|
+
echOpts.config = parsedEchConfigList.config;
|
|
1920
|
+
} else {
|
|
1921
|
+
echOpts[ECH_DNS_FIELD] = parsedEchConfigList.dns;
|
|
1922
|
+
if (parsedEchConfigList.queryServerName) {
|
|
1923
|
+
echOpts["query-server-name"] = parsedEchConfigList.queryServerName;
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
if (isSupportedXrayEchForceQuery(echForceQuery)) {
|
|
1927
|
+
echOpts[ECH_FORCE_QUERY_FIELD] = echForceQuery;
|
|
1928
|
+
}
|
|
1929
|
+
if (isPlainObject(echSockopt)) {
|
|
1930
|
+
echOpts[ECH_SOCKOPT_FIELD] = echSockopt;
|
|
1931
|
+
}
|
|
1932
|
+
return echOpts;
|
|
1933
|
+
}
|
|
1934
|
+
function buildXrayEchFieldsFromMihomo(echOpts, fallbackEchConfigList, { dnsFieldPath = "ech-opts._dns", warnDefaultDns } = {}) {
|
|
1935
|
+
const fields = {};
|
|
1936
|
+
if (isPlainObject(echOpts)) {
|
|
1937
|
+
if (!isMihomoEchEnabled(echOpts.enable)) {
|
|
1938
|
+
return fields;
|
|
1939
|
+
}
|
|
1940
|
+
const queryServerName = echOpts["query-server-name"];
|
|
1941
|
+
if (isNotBlank(echOpts.config)) {
|
|
1942
|
+
fields.echConfigList = echOpts.config;
|
|
1943
|
+
} else if (isNotBlank(echOpts[ECH_DNS_FIELD])) {
|
|
1944
|
+
fields.echConfigList = isNotBlank(queryServerName) ? `${queryServerName}+${echOpts[ECH_DNS_FIELD]}` : echOpts[ECH_DNS_FIELD];
|
|
1945
|
+
} else if (isNotBlank(queryServerName)) {
|
|
1946
|
+
fields.echConfigList = `${queryServerName}+${DEFAULT_XRAY_ECH_DNS}`;
|
|
1947
|
+
warnDefaultDns?.({
|
|
1948
|
+
defaultDns: DEFAULT_XRAY_ECH_DNS,
|
|
1949
|
+
dnsFieldPath,
|
|
1950
|
+
queryServerName
|
|
1951
|
+
});
|
|
1952
|
+
}
|
|
1953
|
+
if (fields.echConfigList && isSupportedXrayEchForceQuery(echOpts[ECH_FORCE_QUERY_FIELD])) {
|
|
1954
|
+
fields.echForceQuery = echOpts[ECH_FORCE_QUERY_FIELD];
|
|
1955
|
+
}
|
|
1956
|
+
if (fields.echConfigList && isPlainObject(echOpts[ECH_SOCKOPT_FIELD])) {
|
|
1957
|
+
fields.echSockopt = echOpts[ECH_SOCKOPT_FIELD];
|
|
1958
|
+
}
|
|
1959
|
+
return fields;
|
|
1960
|
+
}
|
|
1961
|
+
if (isNotBlank(fallbackEchConfigList)) {
|
|
1962
|
+
fields.echConfigList = fallbackEchConfigList;
|
|
1963
|
+
}
|
|
1964
|
+
return fields;
|
|
1965
|
+
}
|
|
1966
|
+
function buildXrayEchConfigListFromMihomo(echOpts, fallbackEchConfigList, options) {
|
|
1967
|
+
return buildXrayEchFieldsFromMihomo(echOpts, fallbackEchConfigList, options).echConfigList;
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
// src/vendors/Sub-Store/backend/src/core/proxy-utils/surge-xhttp.js
|
|
1971
|
+
import _ from "lodash";
|
|
1972
|
+
|
|
1973
|
+
// src/vendors/Sub-Store/backend/src/core/proxy-utils/xhttp-utils.js
|
|
1974
|
+
function parseNormalizedXhttpRangeBounds(value, { allowZeroLowerBound = true, allowZeroUpperBound = true } = {}) {
|
|
1975
|
+
if (typeof value !== "string" && typeof value !== "number") {
|
|
1976
|
+
return void 0;
|
|
1977
|
+
}
|
|
1978
|
+
const parseUnsignedIntegerToken = (token) => {
|
|
1979
|
+
const normalizedToken = token.trim();
|
|
1980
|
+
if (!/^\+?\d+$/.test(normalizedToken)) {
|
|
1981
|
+
return void 0;
|
|
1982
|
+
}
|
|
1983
|
+
const parsedInteger = parseInt(normalizedToken, 10);
|
|
1984
|
+
return Number.isSafeInteger(parsedInteger) ? parsedInteger : void 0;
|
|
1985
|
+
};
|
|
1986
|
+
const normalizedValue = `${value}`.trim();
|
|
1987
|
+
const rangeParts = normalizedValue.split("-");
|
|
1988
|
+
const minimumAllowedLowerBound = allowZeroLowerBound ? 0 : 1;
|
|
1989
|
+
const minimumAllowedUpperBound = allowZeroUpperBound ? 0 : 1;
|
|
1990
|
+
if (rangeParts.length === 1) {
|
|
1991
|
+
const normalizedInteger = parseUnsignedIntegerToken(rangeParts[0]);
|
|
1992
|
+
const minimumAllowedValue = Math.max(
|
|
1993
|
+
minimumAllowedLowerBound,
|
|
1994
|
+
minimumAllowedUpperBound
|
|
1995
|
+
);
|
|
1996
|
+
return normalizedInteger >= minimumAllowedValue ? {
|
|
1997
|
+
lowerBound: normalizedInteger,
|
|
1998
|
+
upperBound: normalizedInteger
|
|
1999
|
+
} : void 0;
|
|
2000
|
+
}
|
|
2001
|
+
if (rangeParts.length !== 2) {
|
|
2002
|
+
return void 0;
|
|
2003
|
+
}
|
|
2004
|
+
const lowerBound = parseUnsignedIntegerToken(rangeParts[0]);
|
|
2005
|
+
const upperBound = parseUnsignedIntegerToken(rangeParts[1]);
|
|
2006
|
+
if (lowerBound == null || upperBound == null) {
|
|
2007
|
+
return void 0;
|
|
2008
|
+
}
|
|
2009
|
+
return lowerBound >= minimumAllowedLowerBound && upperBound >= minimumAllowedUpperBound && upperBound >= lowerBound ? {
|
|
2010
|
+
lowerBound,
|
|
2011
|
+
upperBound
|
|
2012
|
+
} : void 0;
|
|
2013
|
+
}
|
|
2014
|
+
function parseNormalizedXhttpPositiveRangeBounds(value) {
|
|
2015
|
+
return parseNormalizedXhttpRangeBounds(value, {
|
|
2016
|
+
allowZeroUpperBound: false
|
|
2017
|
+
});
|
|
2018
|
+
}
|
|
2019
|
+
function parseNormalizedXhttpStrictPositiveRangeBounds(value) {
|
|
2020
|
+
return parseNormalizedXhttpRangeBounds(value, {
|
|
2021
|
+
allowZeroLowerBound: false,
|
|
2022
|
+
allowZeroUpperBound: false
|
|
2023
|
+
});
|
|
2024
|
+
}
|
|
2025
|
+
function normalizeXhttpPositiveRange(value) {
|
|
2026
|
+
const normalizedBounds = parseNormalizedXhttpPositiveRangeBounds(value);
|
|
2027
|
+
if (!normalizedBounds) {
|
|
2028
|
+
return void 0;
|
|
2029
|
+
}
|
|
2030
|
+
const { lowerBound, upperBound } = normalizedBounds;
|
|
2031
|
+
return lowerBound === upperBound ? upperBound : `${lowerBound}-${upperBound}`;
|
|
2032
|
+
}
|
|
2033
|
+
function normalizeXhttpStrictPositiveRangeString(value) {
|
|
2034
|
+
const normalizedBounds = parseNormalizedXhttpStrictPositiveRangeBounds(value);
|
|
2035
|
+
if (!normalizedBounds) {
|
|
2036
|
+
return void 0;
|
|
2037
|
+
}
|
|
2038
|
+
const { lowerBound, upperBound } = normalizedBounds;
|
|
2039
|
+
return lowerBound === upperBound ? `${upperBound}` : `${lowerBound}-${upperBound}`;
|
|
2040
|
+
}
|
|
2041
|
+
function normalizeXhttpStrictPositiveRangeValue(value) {
|
|
2042
|
+
const normalizedBounds = parseNormalizedXhttpStrictPositiveRangeBounds(value);
|
|
2043
|
+
if (!normalizedBounds) {
|
|
2044
|
+
return void 0;
|
|
2045
|
+
}
|
|
2046
|
+
const { lowerBound, upperBound } = normalizedBounds;
|
|
2047
|
+
return lowerBound === upperBound ? upperBound : `${lowerBound}-${upperBound}`;
|
|
2048
|
+
}
|
|
2049
|
+
function normalizeXhttpNonNegativeRange(value) {
|
|
2050
|
+
const normalizedBounds = parseNormalizedXhttpRangeBounds(value);
|
|
2051
|
+
if (!normalizedBounds) {
|
|
2052
|
+
return void 0;
|
|
2053
|
+
}
|
|
2054
|
+
const { lowerBound, upperBound } = normalizedBounds;
|
|
2055
|
+
return lowerBound === upperBound ? upperBound : `${lowerBound}-${upperBound}`;
|
|
2056
|
+
}
|
|
2057
|
+
function normalizeXhttpIntegerValue(value, { allowNegative = true } = {}) {
|
|
2058
|
+
if (typeof value === "number" && Number.isFinite(value) && Number.isSafeInteger(value)) {
|
|
2059
|
+
if (!allowNegative && value < 0) {
|
|
2060
|
+
return void 0;
|
|
2061
|
+
}
|
|
2062
|
+
return value;
|
|
2063
|
+
}
|
|
2064
|
+
if (typeof value !== "string") {
|
|
2065
|
+
return void 0;
|
|
2066
|
+
}
|
|
2067
|
+
const normalizedValue = value.trim();
|
|
2068
|
+
const integerPattern = allowNegative ? /^[+-]?\d+$/ : /^\+?\d+$/;
|
|
2069
|
+
if (!integerPattern.test(normalizedValue)) {
|
|
2070
|
+
return void 0;
|
|
2071
|
+
}
|
|
2072
|
+
const parsedInteger = parseInt(normalizedValue, 10);
|
|
2073
|
+
if (!Number.isSafeInteger(parsedInteger)) {
|
|
2074
|
+
return void 0;
|
|
2075
|
+
}
|
|
2076
|
+
if (!allowNegative && parsedInteger < 0) {
|
|
2077
|
+
return void 0;
|
|
2078
|
+
}
|
|
2079
|
+
return parsedInteger;
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
// src/vendors/Sub-Store/backend/src/core/proxy-utils/surge-xhttp.js
|
|
2083
|
+
var SURGE_XHTTP_FIELDS = {
|
|
2084
|
+
path: "path",
|
|
2085
|
+
host: "host",
|
|
2086
|
+
mode: "mode",
|
|
2087
|
+
"padding-bytes": "x-padding-bytes",
|
|
2088
|
+
"padding-obfs": "x-padding-obfs-mode",
|
|
2089
|
+
"padding-key": "x-padding-key",
|
|
2090
|
+
"padding-header": "x-padding-header",
|
|
2091
|
+
"padding-placement": "x-padding-placement",
|
|
2092
|
+
"padding-method": "x-padding-method",
|
|
2093
|
+
"uplink-method": "uplink-http-method",
|
|
2094
|
+
"session-placement": "session-placement",
|
|
2095
|
+
"session-key": "session-key",
|
|
2096
|
+
"session-table": "session-table",
|
|
2097
|
+
"session-length": "session-length",
|
|
2098
|
+
"seq-placement": "seq-placement",
|
|
2099
|
+
"seq-key": "seq-key",
|
|
2100
|
+
"uplink-data-placement": "uplink-data-placement",
|
|
2101
|
+
"uplink-data-key": "uplink-data-key",
|
|
2102
|
+
"uplink-chunk-size": "uplink-chunk-size",
|
|
2103
|
+
"no-grpc-header": "no-grpc-header",
|
|
2104
|
+
"max-each-post-bytes": "sc-max-each-post-bytes",
|
|
2105
|
+
"min-posts-interval": "sc-min-posts-interval-ms",
|
|
2106
|
+
"xmux-max-concurrency": "reuse-settings.max-concurrency",
|
|
2107
|
+
"xmux-max-connections": "reuse-settings.max-connections",
|
|
2108
|
+
"xmux-max-reuse-times": "reuse-settings.c-max-reuse-times",
|
|
2109
|
+
"xmux-max-request-times": "reuse-settings.h-max-request-times",
|
|
2110
|
+
"xmux-max-reusable-secs": "reuse-settings.h-max-reusable-secs",
|
|
2111
|
+
"xmux-keep-alive": "reuse-settings.h-keep-alive-period"
|
|
2112
|
+
};
|
|
2113
|
+
function setSurgeXhttpOption(opts, key, rawValue) {
|
|
2114
|
+
if (!Object.prototype.hasOwnProperty.call(SURGE_XHTTP_FIELDS, key)) return;
|
|
2115
|
+
const field = SURGE_XHTTP_FIELDS[key];
|
|
2116
|
+
let value = rawValue;
|
|
2117
|
+
switch (key) {
|
|
2118
|
+
case "padding-obfs":
|
|
2119
|
+
case "no-grpc-header":
|
|
2120
|
+
if (rawValue !== "true" && rawValue !== "false") return;
|
|
2121
|
+
value = rawValue === "true";
|
|
2122
|
+
break;
|
|
2123
|
+
case "uplink-chunk-size":
|
|
2124
|
+
value = normalizeXhttpNonNegativeRange(rawValue) ?? rawValue;
|
|
2125
|
+
break;
|
|
2126
|
+
case "max-each-post-bytes":
|
|
2127
|
+
value = normalizeXhttpStrictPositiveRangeValue(rawValue) ?? rawValue;
|
|
2128
|
+
break;
|
|
2129
|
+
case "min-posts-interval":
|
|
2130
|
+
value = normalizeXhttpPositiveRange(rawValue) ?? rawValue;
|
|
2131
|
+
break;
|
|
2132
|
+
case "xmux-keep-alive":
|
|
2133
|
+
value = normalizeXhttpIntegerValue(rawValue) ?? rawValue;
|
|
2134
|
+
break;
|
|
2135
|
+
}
|
|
2136
|
+
_.set(opts, field, value);
|
|
2137
|
+
}
|
|
2138
|
+
|
|
2139
|
+
// src/vendors/Sub-Store/backend/src/core/proxy-utils/parsers/peggy/surge.js
|
|
1849
2140
|
var grammars = String.raw`
|
|
1850
2141
|
// global initializer
|
|
1851
2142
|
{{
|
|
@@ -1866,6 +2157,10 @@ var grammars = String.raw`
|
|
|
1866
2157
|
const proxy = {};
|
|
1867
2158
|
const obfs = {};
|
|
1868
2159
|
const shadowTLS = {};
|
|
2160
|
+
const xhttpOpts = { mode: "auto" };
|
|
2161
|
+
let xhttpEnabled = false;
|
|
2162
|
+
let clientFingerprint;
|
|
2163
|
+
let echConfig;
|
|
1869
2164
|
const $ = {};
|
|
1870
2165
|
|
|
1871
2166
|
function handleWebsocket() {
|
|
@@ -1873,6 +2168,7 @@ var grammars = String.raw`
|
|
|
1873
2168
|
proxy.network = "ws";
|
|
1874
2169
|
$set(proxy, "ws-opts.path", obfs.path);
|
|
1875
2170
|
$set(proxy, "ws-opts.headers", obfs['ws-headers']);
|
|
2171
|
+
if (obfs.httpUpgrade) $set(proxy, "ws-opts.v2ray-http-upgrade", true);
|
|
1876
2172
|
if (proxy['ws-opts'] && proxy['ws-opts']['headers'] && proxy['ws-opts']['headers'].Host) {
|
|
1877
2173
|
proxy['ws-opts']['headers'].Host = proxy['ws-opts']['headers'].Host.replace(/^"(.*)"$/, '$1')
|
|
1878
2174
|
}
|
|
@@ -2216,7 +2512,25 @@ var grammars = String.raw`
|
|
|
2216
2512
|
}
|
|
2217
2513
|
}
|
|
2218
2514
|
|
|
2219
|
-
start = (masque/anytls/shadowsocks/vmess/trojan/h2_connect/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2/ssh/trust_tunnel/direct) {
|
|
2515
|
+
start = (masque/anytls/shadowsocks/vmess/vless/trojan/h2_connect/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2/ssh/trust_tunnel/direct) {
|
|
2516
|
+
if (
|
|
2517
|
+
["auto", "none", "apple-26", "chromium-155"].includes(clientFingerprint) &&
|
|
2518
|
+
proxy.network !== "h3" &&
|
|
2519
|
+
(proxy.tls || proxy.type === "trojan")
|
|
2520
|
+
) {
|
|
2521
|
+
proxy._surge_client_fingerprint = clientFingerprint;
|
|
2522
|
+
if (clientFingerprint === "apple-26") proxy["client-fingerprint"] = "ios";
|
|
2523
|
+
if (clientFingerprint === "chromium-155") proxy["client-fingerprint"] = "chrome";
|
|
2524
|
+
}
|
|
2525
|
+
if (
|
|
2526
|
+
echConfig !== undefined &&
|
|
2527
|
+
(proxy.tls || ["trojan", "tuic", "hysteria2"].includes(proxy.type))
|
|
2528
|
+
) {
|
|
2529
|
+
if (proxy["reality-opts"]) error("ECH cannot be combined with REALITY");
|
|
2530
|
+
// Preserve malformed ECH for export validation so another parser cannot discard it.
|
|
2531
|
+
const config = options.normalizeInlineEchConfigList(echConfig) ?? echConfig;
|
|
2532
|
+
proxy["ech-opts"] = { enable: true, config };
|
|
2533
|
+
}
|
|
2220
2534
|
return proxy;
|
|
2221
2535
|
}
|
|
2222
2536
|
|
|
@@ -2231,7 +2545,7 @@ shadowsocks = tag equals "ss" address (method/passwordk/obfs/obfs_host/obfs_uri/
|
|
|
2231
2545
|
}
|
|
2232
2546
|
handleShadowTLS();
|
|
2233
2547
|
}
|
|
2234
|
-
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/cert_verify_name/alpn/tls_fingerprint/tls_verification/client_cert/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
2548
|
+
vmess = tag equals "vmess" address (vmess_uuid/vmess_aead/ws/ws_http_upgrade/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/cert_verify_name/alpn/tls_fingerprint/client_fingerprint/tls_verification/client_cert/ech_config/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
2235
2549
|
proxy.type = "vmess";
|
|
2236
2550
|
proxy.cipher = proxy.cipher || "auto";
|
|
2237
2551
|
// Surfboard 与 Surge 默认不一致, 不管 Surfboard https://getsurfboard.com/docs/profile-format/proxy/external-proxy/vmess
|
|
@@ -2243,17 +2557,29 @@ vmess = tag equals "vmess" address (vmess_uuid/vmess_aead/ws/ws_path/ws_headers/
|
|
|
2243
2557
|
handleWebsocket();
|
|
2244
2558
|
handleShadowTLS();
|
|
2245
2559
|
}
|
|
2246
|
-
|
|
2560
|
+
vless = tag equals "vless" address (vless_username/vless_option/reality_option/ws/ws_http_upgrade/ws_path/ws_headers/grpc/grpc_service_name/grpc_mode/grpc_authority/xhttp/xhttp_headers/xhttp_option/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls/sni/cert_verify_name/alpn/tls_fingerprint/client_fingerprint/tls_verification/client_cert/ech_config/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
2561
|
+
proxy.type = "vless";
|
|
2562
|
+
proxy["packet-encoding"] = "xudp";
|
|
2563
|
+
if (proxy["reality-opts"] && proxy["reality-opts"]["public-key"]) proxy.tls = true;
|
|
2564
|
+
if (xhttpEnabled) {
|
|
2565
|
+
proxy.network = "xhttp";
|
|
2566
|
+
proxy["xhttp-opts"] = xhttpOpts;
|
|
2567
|
+
} else {
|
|
2568
|
+
handleWebsocket();
|
|
2569
|
+
}
|
|
2570
|
+
handleShadowTLS();
|
|
2571
|
+
}
|
|
2572
|
+
trojan = tag equals "trojan" address (passwordk/ws/ws_http_upgrade/ws_path/ws_headers/tls/sni/cert_verify_name/alpn/tls_fingerprint/client_fingerprint/tls_verification/client_cert/ech_config/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
2247
2573
|
proxy.type = "trojan";
|
|
2248
2574
|
handleWebsocket();
|
|
2249
2575
|
handleShadowTLS();
|
|
2250
2576
|
}
|
|
2251
|
-
https = tag equals "https" address (username password)? (usernamek passwordk)? (headers/sni/cert_verify_name/alpn/tls_fingerprint/tls_verification/client_cert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
2577
|
+
https = tag equals "https" address (username password)? (usernamek passwordk)? (headers/sni/cert_verify_name/alpn/tls_fingerprint/client_fingerprint/tls_verification/client_cert/ech_config/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
2252
2578
|
proxy.type = "http";
|
|
2253
2579
|
proxy.tls = true;
|
|
2254
2580
|
handleShadowTLS();
|
|
2255
2581
|
}
|
|
2256
|
-
h2_connect = tag equals "h2-connect" address (username password)? (usernamek passwordk)? (headers/max_streams/sni/cert_verify_name/alpn/tls_fingerprint/tls_verification/client_cert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
2582
|
+
h2_connect = tag equals "h2-connect" address (username password)? (usernamek passwordk)? (headers/max_streams/sni/cert_verify_name/alpn/tls_fingerprint/client_fingerprint/tls_verification/client_cert/ech_config/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
2257
2583
|
proxy.type = "h2-connect";
|
|
2258
2584
|
proxy.tls = true;
|
|
2259
2585
|
handleShadowTLS();
|
|
@@ -2266,7 +2592,7 @@ ssh = tag equals "ssh" address (username password)? (usernamek passwordk)? (serv
|
|
|
2266
2592
|
proxy.type = "ssh";
|
|
2267
2593
|
handleShadowTLS();
|
|
2268
2594
|
}
|
|
2269
|
-
snell = tag equals "snell" address (snell_version/snell_mode/snell_psk/obfs/obfs_host/obfs_uri/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/reuse/alpn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
2595
|
+
snell = tag equals ("snell"i/"opensnell"i) address (snell_version/snell_mode/snell_psk/obfs/obfs_host/obfs_uri/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/reuse/alpn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
2270
2596
|
proxy.type = "snell";
|
|
2271
2597
|
// handle obfs
|
|
2272
2598
|
if (obfs.type == "http" || obfs.type === "tls") {
|
|
@@ -2276,11 +2602,11 @@ snell = tag equals "snell" address (snell_version/snell_mode/snell_psk/obfs/obfs
|
|
|
2276
2602
|
}
|
|
2277
2603
|
handleShadowTLS();
|
|
2278
2604
|
}
|
|
2279
|
-
tuic = tag equals "tuic" address (alpn/token/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/client_cert/sni/cert_verify_name/fast_open/tfo/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* {
|
|
2605
|
+
tuic = tag equals "tuic" address (alpn/token/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/client_cert/ech_config/sni/cert_verify_name/fast_open/tfo/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* {
|
|
2280
2606
|
proxy.type = "tuic";
|
|
2281
2607
|
handleShadowTLS();
|
|
2282
2608
|
}
|
|
2283
|
-
tuic_v5 = tag equals "tuic-v5" address (alpn/passwordk/uuidk/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/client_cert/sni/cert_verify_name/fast_open/tfo/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* {
|
|
2609
|
+
tuic_v5 = tag equals "tuic-v5" address (alpn/passwordk/uuidk/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/client_cert/ech_config/sni/cert_verify_name/fast_open/tfo/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* {
|
|
2284
2610
|
proxy.type = "tuic";
|
|
2285
2611
|
proxy.version = 5;
|
|
2286
2612
|
handleShadowTLS();
|
|
@@ -2289,7 +2615,7 @@ wireguard = tag equals "wireguard" (section_name/no_error_alert/ip_version/under
|
|
|
2289
2615
|
proxy.type = "wireguard-surge";
|
|
2290
2616
|
handleShadowTLS();
|
|
2291
2617
|
}
|
|
2292
|
-
hysteria2 = tag equals "hysteria2" address (no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/sni/cert_verify_name/alpn/tls_verification/client_cert/passwordk/tls_fingerprint/download_bandwidth/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/salamander_password/gecko_password/others)* {
|
|
2618
|
+
hysteria2 = tag equals "hysteria2" address (no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/sni/cert_verify_name/alpn/tls_verification/client_cert/ech_config/passwordk/tls_fingerprint/download_bandwidth/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/salamander_password/gecko_password/others)* {
|
|
2293
2619
|
proxy.type = "hysteria2";
|
|
2294
2620
|
handleShadowTLS();
|
|
2295
2621
|
}
|
|
@@ -2297,20 +2623,20 @@ socks5 = tag equals "socks5" address (username password)? (usernamek passwordk)?
|
|
|
2297
2623
|
proxy.type = "socks5";
|
|
2298
2624
|
handleShadowTLS();
|
|
2299
2625
|
}
|
|
2300
|
-
socks5_tls = tag equals "socks5-tls" address (username password)? (usernamek passwordk)? (udp_relay/no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/sni/cert_verify_name/alpn/tls_fingerprint/tls_verification/client_cert/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
2626
|
+
socks5_tls = tag equals "socks5-tls" address (username password)? (usernamek passwordk)? (udp_relay/no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/sni/cert_verify_name/alpn/tls_fingerprint/client_fingerprint/tls_verification/client_cert/ech_config/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
2301
2627
|
proxy.type = "socks5";
|
|
2302
2628
|
proxy.tls = true;
|
|
2303
2629
|
handleShadowTLS();
|
|
2304
2630
|
}
|
|
2305
|
-
anytls = tag equals "anytls" address (passwordk/reuse/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/client_cert/sni/cert_verify_name/alpn/fast_open/tfo/block_quic/others)* {
|
|
2631
|
+
anytls = tag equals "anytls" address (passwordk/reuse/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/client_fingerprint/tls_verification/client_cert/ech_config/sni/cert_verify_name/alpn/fast_open/tfo/block_quic/others)* {
|
|
2306
2632
|
proxy.type = "anytls";
|
|
2307
2633
|
proxy.tls = true;
|
|
2308
2634
|
}
|
|
2309
|
-
trust_tunnel = tag equals "trust-tunnel" address (usernamek/passwordk/headers/max_streams/reuse/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/client_cert/sni/cert_verify_name/alpn/h3/fast_open/tfo/block_quic/others)* {
|
|
2635
|
+
trust_tunnel = tag equals "trust-tunnel" address (usernamek/passwordk/client_random_auth_key/headers/max_streams/reuse/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/client_fingerprint/tls_verification/client_cert/ech_config/sni/cert_verify_name/alpn/h3/fast_open/tfo/block_quic/others)* {
|
|
2310
2636
|
proxy.type = "trusttunnel";
|
|
2311
2637
|
proxy.tls = true;
|
|
2312
2638
|
}
|
|
2313
|
-
masque = tag equals "masque" address (usernamek/passwordk/port_hopping_interval/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/client_cert/sni/cert_verify_name/alpn/fast_open/tfo/udp_relay/ecn/block_quic/others)* {
|
|
2639
|
+
masque = tag equals "masque" address (usernamek/passwordk/port_hopping_interval/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/client_cert/ech_config/sni/cert_verify_name/alpn/fast_open/tfo/udp_relay/ecn/block_quic/others)* {
|
|
2314
2640
|
proxy.type = "masque-surge";
|
|
2315
2641
|
proxy.tls = true;
|
|
2316
2642
|
}
|
|
@@ -2390,9 +2716,11 @@ sni = comma "sni" equals match:[^,]+ {
|
|
|
2390
2716
|
cert_verify_name = comma "server-cert-verify-name" equals match:[^,]+ { proxy["name-cert-verify"] = stripQuotes(match.join("")); }
|
|
2391
2717
|
tls_verification = comma "skip-cert-verify" equals flag:bool { proxy["skip-cert-verify"] = flag; }
|
|
2392
2718
|
tls_fingerprint = comma "server-cert-fingerprint-sha256" equals tls_fingerprint:$[^,]+ { proxy["tls-fingerprint"] = tls_fingerprint.trim(); }
|
|
2719
|
+
client_fingerprint = comma "client-fingerprint" equals value:quoted_value { clientFingerprint = value.trim().toLowerCase(); }
|
|
2393
2720
|
client_cert = comma "client-cert" equals match:[^,]+ { proxy["keystore-client-cert"] = stripQuotes(match.join("")); }
|
|
2721
|
+
ech_config = comma "ech-config" equals value:quoted_value { echConfig = value; }
|
|
2394
2722
|
|
|
2395
|
-
snell_psk = comma "psk" equals
|
|
2723
|
+
snell_psk = comma "psk" equals value:quoted_value { proxy.psk = value; }
|
|
2396
2724
|
snell_version = comma "version" equals match:$[0-9]+ { proxy.version = parseInt(match.trim()); }
|
|
2397
2725
|
snell_mode = comma "mode" equals match:[^,]+ {
|
|
2398
2726
|
const mode = stripQuotes(match.join("")).trim();
|
|
@@ -2405,6 +2733,11 @@ usernamek = comma "username" equals match:[^,]+ { proxy.username = match.join(""
|
|
|
2405
2733
|
passwordk = comma "password" equals match:[^,]+ { proxy.password = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
|
2406
2734
|
vmess_uuid = comma "username" equals match:[^,]+ { proxy.uuid = match.join(""); }
|
|
2407
2735
|
vmess_aead = comma "vmess-aead" equals flag:bool { proxy.aead = flag; }
|
|
2736
|
+
// shortcut: keep text IDs as given, convert them to UUIDv5 when a target requires it.
|
|
2737
|
+
vless_username = comma "username" equals value:quoted_value { proxy.uuid = value.trim(); }
|
|
2738
|
+
vless_option = comma key:("flow"/"encryption") equals value:quoted_value { proxy[key] = value.trim(); }
|
|
2739
|
+
reality_option = comma "reality-" key:("public-key"/"short-id") equals value:quoted_value { $set(proxy, "reality-opts." + key, value.trim()); }
|
|
2740
|
+
client_random_auth_key = comma "client-random-auth-key" equals value:$[^,]* { proxy["client-random-auth-key"] = stripQuotes(value); }
|
|
2408
2741
|
|
|
2409
2742
|
method = comma "encrypt-method" equals cipher:cipher {
|
|
2410
2743
|
proxy.cipher = cipher;
|
|
@@ -2414,16 +2747,32 @@ vmess_method = comma "encrypt-method" equals cipher:$[^,]+ {
|
|
|
2414
2747
|
}
|
|
2415
2748
|
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");
|
|
2416
2749
|
|
|
2417
|
-
ws = comma "ws" equals flag:bool { obfs.type = "ws"; }
|
|
2418
|
-
|
|
2750
|
+
ws = comma "ws" equals flag:bool { if (flag) obfs.type = "ws"; }
|
|
2751
|
+
ws_http_upgrade = comma "ws-http-upgrade" equals flag:bool { obfs.httpUpgrade = flag; }
|
|
2752
|
+
ws_headers = comma "ws-headers" equals value:pipe_headers { obfs["ws-headers"] = value; }
|
|
2753
|
+
pipe_headers = & {
|
|
2419
2754
|
const start = peg$currPos;
|
|
2420
2755
|
const index = readHeadersEnd(input, start, "|");
|
|
2421
2756
|
|
|
2422
2757
|
$.headers = input.substring(start, index);
|
|
2423
2758
|
peg$currPos = index;
|
|
2424
2759
|
return $.headers.trim().length > 0;
|
|
2425
|
-
} {
|
|
2760
|
+
} { return parseHeaders($.headers, "|"); }
|
|
2426
2761
|
ws_path = comma "ws-path" equals path:uri { obfs.path = path.trim().replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
|
2762
|
+
grpc = comma "grpc" equals flag:bool { if (flag) proxy.network = "grpc"; }
|
|
2763
|
+
grpc_service_name = comma "grpc-service-name" equals value:quoted_value { $set(proxy, "grpc-opts.grpc-service-name", value.trim()); }
|
|
2764
|
+
grpc_mode = comma "grpc-mode" equals value:quoted_value { $set(proxy, "grpc-opts._grpc-type", value.trim()); }
|
|
2765
|
+
grpc_authority = comma "grpc-authority" equals value:quoted_value { $set(proxy, "grpc-opts._grpc-authority", value.trim()); }
|
|
2766
|
+
xhttp = comma "xhttp" equals flag:bool { xhttpEnabled = flag; }
|
|
2767
|
+
xhttp_headers = comma "xhttp-headers" equals value:pipe_headers {
|
|
2768
|
+
for (const key of Object.keys(value)) {
|
|
2769
|
+
if (/^host$/i.test(key)) delete value[key];
|
|
2770
|
+
}
|
|
2771
|
+
xhttpOpts.headers = value;
|
|
2772
|
+
}
|
|
2773
|
+
xhttp_option = comma "xhttp-" key:$[a-z0-9-]+ equals value:quoted_value {
|
|
2774
|
+
options.setSurgeXhttpOption(xhttpOpts, key, value.trim());
|
|
2775
|
+
}
|
|
2427
2776
|
headers = comma "headers" equals & {
|
|
2428
2777
|
const start = peg$currPos;
|
|
2429
2778
|
const index = readHeadersEnd(input, start, ";");
|
|
@@ -2486,13 +2835,61 @@ others = comma [^=,]+ equals [^=,]+
|
|
|
2486
2835
|
var parser;
|
|
2487
2836
|
function getParser() {
|
|
2488
2837
|
if (!parser) {
|
|
2489
|
-
|
|
2838
|
+
const generated = peggy.generate(grammars);
|
|
2839
|
+
parser = {
|
|
2840
|
+
parse: (input) => generated.parse(input, {
|
|
2841
|
+
normalizeInlineEchConfigList,
|
|
2842
|
+
setSurgeXhttpOption
|
|
2843
|
+
})
|
|
2844
|
+
};
|
|
2490
2845
|
}
|
|
2491
2846
|
return parser;
|
|
2492
2847
|
}
|
|
2493
2848
|
|
|
2494
2849
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/parsers/peggy/loon.js
|
|
2495
2850
|
import peggy2 from "peggy";
|
|
2851
|
+
|
|
2852
|
+
// src/vendors/Sub-Store/backend/src/core/proxy-utils/loon-xhttp.js
|
|
2853
|
+
var LOON_XHTTP_FIELDS = {
|
|
2854
|
+
mode: "mode",
|
|
2855
|
+
"uplink-method": "uplink-http-method",
|
|
2856
|
+
"min-post-interval-ms": "sc-min-posts-interval-ms",
|
|
2857
|
+
"max-post-bytes": "sc-max-each-post-bytes",
|
|
2858
|
+
"uplink-data-placement": "uplink-data-placement",
|
|
2859
|
+
"uplink-data-key": "uplink-data-key",
|
|
2860
|
+
"uplink-chunk-size": "uplink-chunk-size",
|
|
2861
|
+
"padding-bytes": "x-padding-bytes",
|
|
2862
|
+
"padding-obfs-mode": "x-padding-obfs-mode",
|
|
2863
|
+
"padding-placement": "x-padding-placement",
|
|
2864
|
+
"padding-key": "x-padding-key",
|
|
2865
|
+
"padding-header": "x-padding-header",
|
|
2866
|
+
"padding-method": "x-padding-method",
|
|
2867
|
+
"no-grpc-header": "no-grpc-header",
|
|
2868
|
+
"session-id-placement": "session-placement",
|
|
2869
|
+
"session-id-key": "session-key",
|
|
2870
|
+
"session-id-table": "session-table",
|
|
2871
|
+
"session-id-length": "session-length",
|
|
2872
|
+
"seq-placement": "seq-placement",
|
|
2873
|
+
"seq-key": "seq-key"
|
|
2874
|
+
};
|
|
2875
|
+
function setLoonXhttpOption(opts, key, value) {
|
|
2876
|
+
if (!Object.prototype.hasOwnProperty.call(LOON_XHTTP_FIELDS, key)) return;
|
|
2877
|
+
switch (key) {
|
|
2878
|
+
case "padding-obfs-mode":
|
|
2879
|
+
case "no-grpc-header":
|
|
2880
|
+
if (value !== "true" && value !== "false") return;
|
|
2881
|
+
value = value === "true";
|
|
2882
|
+
break;
|
|
2883
|
+
case "min-post-interval-ms":
|
|
2884
|
+
case "max-post-bytes":
|
|
2885
|
+
case "uplink-chunk-size":
|
|
2886
|
+
value = normalizeXhttpNonNegativeRange(value) ?? value;
|
|
2887
|
+
break;
|
|
2888
|
+
}
|
|
2889
|
+
opts[LOON_XHTTP_FIELDS[key]] = value;
|
|
2890
|
+
}
|
|
2891
|
+
|
|
2892
|
+
// src/vendors/Sub-Store/backend/src/core/proxy-utils/parsers/peggy/loon.js
|
|
2496
2893
|
var grammars2 = String.raw`
|
|
2497
2894
|
// global initializer
|
|
2498
2895
|
{{
|
|
@@ -2513,6 +2910,8 @@ var grammars2 = String.raw`
|
|
|
2513
2910
|
const proxy = {};
|
|
2514
2911
|
const obfs = {};
|
|
2515
2912
|
const transport = {};
|
|
2913
|
+
const xhttpOpts = {};
|
|
2914
|
+
const xhttpHeaders = [];
|
|
2516
2915
|
const shadowTLS = {};
|
|
2517
2916
|
const $ = {};
|
|
2518
2917
|
|
|
@@ -2526,6 +2925,16 @@ var grammars2 = String.raw`
|
|
|
2526
2925
|
proxy.network = "http";
|
|
2527
2926
|
$set(proxy, "http-opts.path", transport.path);
|
|
2528
2927
|
$set(proxy, "http-opts.headers.Host", transport.host);
|
|
2928
|
+
} else if (transport.type === "xhttp") {
|
|
2929
|
+
if (proxy.type === "vmess" && proxy.alterId !== 0) {
|
|
2930
|
+
throw new Error("VMess XHTTP requires AEAD");
|
|
2931
|
+
}
|
|
2932
|
+
proxy.network = "xhttp";
|
|
2933
|
+
proxy.udp ??= false;
|
|
2934
|
+
if (transport.path != null) xhttpOpts.path = transport.path;
|
|
2935
|
+
if (transport.host != null) xhttpOpts.host = transport.host;
|
|
2936
|
+
if (xhttpHeaders.length) xhttpOpts.headers = Object.fromEntries(xhttpHeaders);
|
|
2937
|
+
proxy["xhttp-opts"] = xhttpOpts;
|
|
2529
2938
|
}
|
|
2530
2939
|
}
|
|
2531
2940
|
|
|
@@ -2559,14 +2968,14 @@ var grammars2 = String.raw`
|
|
|
2559
2968
|
case "chrome":
|
|
2560
2969
|
case "chrome147":
|
|
2561
2970
|
return "chrome";
|
|
2562
|
-
case "ios18":
|
|
2563
|
-
case "
|
|
2971
|
+
case "safari-ios18":
|
|
2972
|
+
case "safari-ios-26":
|
|
2564
2973
|
return "ios";
|
|
2565
2974
|
}
|
|
2566
2975
|
}
|
|
2567
2976
|
}
|
|
2568
2977
|
|
|
2569
|
-
start = (shadowsocksr/shadowsocks/vmess/vless/trojan/https/http/socks5/hysteria2/anytls) {
|
|
2978
|
+
start = (shadowsocksr/shadowsocks/vmess/vless/trojan/https/http/socks5/hysteria2/anytls/tailscale/snell) {
|
|
2570
2979
|
return proxy;
|
|
2571
2980
|
}
|
|
2572
2981
|
|
|
@@ -2587,17 +2996,17 @@ shadowsocks = tag equals "shadowsocks"i address method password (obfs_typev obfs
|
|
|
2587
2996
|
}
|
|
2588
2997
|
handleShadowTLS();
|
|
2589
2998
|
}
|
|
2590
|
-
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)* {
|
|
2999
|
+
vmess = tag equals "vmess"i address vmess_method uuid (xhttp_transport/transport/transport_host/transport_path/xhttp_header/xhttp_option/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)* {
|
|
2591
3000
|
proxy.type = "vmess";
|
|
2592
3001
|
proxy.cipher = proxy.cipher || "auto";
|
|
2593
3002
|
proxy.alterId = proxy.alterId || 0;
|
|
2594
3003
|
handleTransport();
|
|
2595
3004
|
}
|
|
2596
|
-
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)* {
|
|
3005
|
+
vless = tag equals "vless"i address uuid (xhttp_transport/transport/transport_host/transport_path/xhttp_header/xhttp_option/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)* {
|
|
2597
3006
|
proxy.type = "vless";
|
|
2598
3007
|
handleTransport();
|
|
2599
3008
|
}
|
|
2600
|
-
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/public_key/short_id/block_quic/others)* {
|
|
3009
|
+
trojan = tag equals "trojan"i address password (xhttp_transport/transport/transport_host/transport_path/xhttp_header/xhttp_option/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/fast_open/udp_relay/ip_mode/public_key/short_id/block_quic/others)* {
|
|
2601
3010
|
proxy.type = "trojan";
|
|
2602
3011
|
handleTransport();
|
|
2603
3012
|
}
|
|
@@ -2618,9 +3027,34 @@ http = tag equals "http"i address (username password)? (fast_open/udp_relay/ip_m
|
|
|
2618
3027
|
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)* {
|
|
2619
3028
|
proxy.type = "socks5";
|
|
2620
3029
|
}
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
proxy
|
|
3030
|
+
tailscale = tag equals "tailscale"i (tailscale_string/tailscale_bool/tailscale_mtu/idle_session_timeout/udp_relay/block_quic/others)* {
|
|
3031
|
+
proxy.type = "tailscale";
|
|
3032
|
+
if (proxy["exit-node"] === "auto") proxy["exit-node"] = "auto:any";
|
|
3033
|
+
if (proxy["exit-node"] === "none") proxy["exit-node"] = "";
|
|
3034
|
+
}
|
|
3035
|
+
snell = tag equals ("snell"i/"opensnell"i) address snell_positional_psk? (snell_psk/snell_version/snell_obfs/obfs_host/obfs_uri/udp_relay/ip_mode/block_quic/others)* {
|
|
3036
|
+
if (!proxy.psk) throw new Error("Missing Snell PSK");
|
|
3037
|
+
proxy.type = "snell";
|
|
3038
|
+
proxy.version ??= 4;
|
|
3039
|
+
proxy.udp ??= false;
|
|
3040
|
+
if (obfs.type === "http") {
|
|
3041
|
+
proxy["obfs-opts"] = { mode: obfs.type, host: obfs.host, path: obfs.path };
|
|
3042
|
+
}
|
|
3043
|
+
}
|
|
3044
|
+
|
|
3045
|
+
tailscale_string = comma key:("auth-key"/"control-url"/"hostname"/"exit-node"/"path-mode"/"ip-mode") equals value:(
|
|
3046
|
+
'"' match:$[^"]* '"' { return match; }
|
|
3047
|
+
/ match:$[^,"]* { return match.trim(); }
|
|
3048
|
+
) {
|
|
3049
|
+
if (value !== "" || key === "exit-node") {
|
|
3050
|
+
proxy[key === "ip-mode" ? "ip-version" : key] = value;
|
|
3051
|
+
}
|
|
3052
|
+
}
|
|
3053
|
+
tailscale_bool = comma key:("accept-routes"/"accept-dns"/"magic-dns") equals flag:bool { proxy[key] = flag; }
|
|
3054
|
+
tailscale_mtu = comma "mtu" equals match:$[0-9]+ { proxy.mtu = Number(match); }
|
|
3055
|
+
|
|
3056
|
+
address = comma server:server comma port:port {
|
|
3057
|
+
proxy.server = server;
|
|
2624
3058
|
proxy.port = port;
|
|
2625
3059
|
}
|
|
2626
3060
|
|
|
@@ -2696,13 +3130,29 @@ obfs_ss = comma "obfs-name" equals type:("http"/"tls") { obfs.type = type; }
|
|
|
2696
3130
|
obfs_ssr = comma "obfs" equals type:("plain"/"http_simple"/"http_post"/"random_head"/"tls1.2_ticket_auth"/"tls1.2_ticket_fastauth") { obfs.type = type; }
|
|
2697
3131
|
obfs_ssr_param = comma "obfs-param" equals match:$[^,]+ { proxy["obfs-param"] = match; }
|
|
2698
3132
|
|
|
2699
|
-
obfs_host = comma "obfs-host" equals
|
|
2700
|
-
obfs_uri = comma "obfs-uri" equals
|
|
2701
|
-
|
|
3133
|
+
obfs_host = comma "obfs-host" equals value:option_value { obfs.host = value; }
|
|
3134
|
+
obfs_uri = comma "obfs-uri" equals value:option_value { obfs.path = value; }
|
|
3135
|
+
|
|
3136
|
+
snell_positional_psk = comma psk:quoted_value { proxy.psk = psk; }
|
|
3137
|
+
snell_psk = comma "psk" equals psk:option_value { proxy.psk = psk; }
|
|
3138
|
+
snell_version = comma "version" equals version:$[0-9]+ { proxy.version = Number(version); }
|
|
3139
|
+
snell_obfs = comma ("obfs-name"/"obfs") equals type:("none"/"http") { obfs.type = type; }
|
|
2702
3140
|
|
|
2703
3141
|
transport = comma "transport" equals type:("tcp"/"ws"/"http") { transport.type = type; }
|
|
2704
|
-
transport_host = comma "host" equals
|
|
2705
|
-
transport_path = comma "path" equals
|
|
3142
|
+
transport_host = comma "host" equals value:option_value { transport.host = value; }
|
|
3143
|
+
transport_path = comma "path" equals value:option_value { transport.path = value; }
|
|
3144
|
+
|
|
3145
|
+
xhttp_transport = comma "transport" equals "xhttp" { transport.type = "xhttp"; }
|
|
3146
|
+
xhttp_header = comma "xhttp-header" equals value:option_value {
|
|
3147
|
+
const colon = value.indexOf(":");
|
|
3148
|
+
const name = value.slice(0, colon).trim();
|
|
3149
|
+
if (colon > 0 && name && !/^host$/i.test(name)) {
|
|
3150
|
+
xhttpHeaders.push([name, value.slice(colon + 1).trim()]);
|
|
3151
|
+
}
|
|
3152
|
+
}
|
|
3153
|
+
xhttp_option = comma "xhttp-" key:$[a-z0-9-]+ equals value:option_value {
|
|
3154
|
+
options.setLoonXhttpOption(xhttpOpts, key, value);
|
|
3155
|
+
}
|
|
2706
3156
|
|
|
2707
3157
|
ssr_protocol = comma "protocol" equals protocol:("origin"/"auth_sha1_v4"/"auth_aes128_md5"/"auth_aes128_sha1"/"auth_chain_a"/"auth_chain_b") { proxy.protocol = protocol; }
|
|
2708
3158
|
ssr_protocol_param = comma "protocol-param" equals param:$[^=,]+ { proxy["protocol-param"] = param; }
|
|
@@ -2726,7 +3176,7 @@ tls_profile = comma "tls-profile" equals match:[^,]+ {
|
|
|
2726
3176
|
const clientFingerprint = loonClientFingerprint(tlsProfile);
|
|
2727
3177
|
if (clientFingerprint) proxy["client-fingerprint"] = clientFingerprint;
|
|
2728
3178
|
}
|
|
2729
|
-
alpn = comma "alpn" equals
|
|
3179
|
+
alpn = comma "alpn" equals match:option_value {
|
|
2730
3180
|
const values = match
|
|
2731
3181
|
.split(",")
|
|
2732
3182
|
.map((item) => item.trim())
|
|
@@ -2736,7 +3186,7 @@ alpn = comma "alpn" equals '"' match:$[^"]* '"' {
|
|
|
2736
3186
|
|
|
2737
3187
|
flow = comma "flow" equals match:[^,]+ { proxy["flow"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
|
2738
3188
|
public_key = comma "public-key" equals match:[^,]+ { proxy["reality-opts"] = proxy["reality-opts"] || {}; proxy["reality-opts"]["public-key"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
|
2739
|
-
short_id = comma "short-id" equals
|
|
3189
|
+
short_id = comma "short-id" equals value:option_value { proxy["reality-opts"] = proxy["reality-opts"] || {}; proxy["reality-opts"]["short-id"] = value; }
|
|
2740
3190
|
|
|
2741
3191
|
fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; }
|
|
2742
3192
|
udp_relay = comma "udp" equals flag:bool { proxy.udp = flag; }
|
|
@@ -2765,6 +3215,8 @@ server_dns = comma "server-dns" equals value:(
|
|
|
2765
3215
|
}
|
|
2766
3216
|
|
|
2767
3217
|
tag = match:[^=,]* { proxy.name = match.join("").trim(); }
|
|
3218
|
+
quoted_value = '"' match:$[^"]* '"' { return match; }
|
|
3219
|
+
option_value = quoted_value / match:$[^,"]* { return match.trim(); }
|
|
2768
3220
|
comma = _ "," _
|
|
2769
3221
|
equals = _ "=" _
|
|
2770
3222
|
_ = [ \r\t]*
|
|
@@ -2774,7 +3226,10 @@ others = server_dns / (comma [^=,]+ equals [^=,]+)
|
|
|
2774
3226
|
var parser2;
|
|
2775
3227
|
function getParser2() {
|
|
2776
3228
|
if (!parser2) {
|
|
2777
|
-
|
|
3229
|
+
const generated = peggy2.generate(grammars2);
|
|
3230
|
+
parser2 = {
|
|
3231
|
+
parse: (input) => generated.parse(input, { setLoonXhttpOption })
|
|
3232
|
+
};
|
|
2778
3233
|
}
|
|
2779
3234
|
return parser2;
|
|
2780
3235
|
}
|
|
@@ -2850,7 +3305,7 @@ var grammars3 = String.raw`
|
|
|
2850
3305
|
}
|
|
2851
3306
|
}
|
|
2852
3307
|
|
|
2853
|
-
start = (trojan/shadowsocks/vmess/vless/anytls/http/socks5) {
|
|
3308
|
+
start = (trojan/shadowsocks/vmess/vless/anytls/hysteria2/http/socks5) {
|
|
2854
3309
|
return proxy
|
|
2855
3310
|
}
|
|
2856
3311
|
|
|
@@ -2922,6 +3377,12 @@ anytls = "anytls" equals address
|
|
|
2922
3377
|
proxy.tls = true;
|
|
2923
3378
|
}
|
|
2924
3379
|
|
|
3380
|
+
hysteria2 = "hysteria2" equals address
|
|
3381
|
+
(password/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/udp_relay/download_bandwidth/salamander_password/port_hopping/port_hopping_interval/server_check_url/tag/others)* {
|
|
3382
|
+
proxy.type = "hysteria2";
|
|
3383
|
+
proxy.tls = true;
|
|
3384
|
+
}
|
|
3385
|
+
|
|
2925
3386
|
http = "http" equals address
|
|
2926
3387
|
(username/password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/fast_open/udp_relay/udp_over_tcp/server_check_url/reality_base64_pubkey/reality_hex_shortid/others)*{
|
|
2927
3388
|
proxy.type = "http";
|
|
@@ -2981,6 +3442,22 @@ udp_relay = comma "udp-relay" equals flag:bool { proxy.udp = flag; }
|
|
|
2981
3442
|
udp_over_tcp = comma "udp-over-tcp" equals flag:bool { throw new Error("UDP over TCP is not supported"); }
|
|
2982
3443
|
udp_over_tcp_new = comma "udp-over-tcp" equals param:$[^=,]+ { if (param === "sp.v1") { proxy["udp-over-tcp"] = true; proxy["udp-over-tcp-version"] = 1; } else if (param === "sp.v2") { proxy["udp-over-tcp"] = true; proxy["udp-over-tcp-version"] = 2; } else if (param === "true") { proxy["_ssr_python_uot"] = true; } else { throw new Error("Invalid value for udp-over-tcp"); } }
|
|
2983
3444
|
|
|
3445
|
+
download_bandwidth = comma "download-bandwidth" equals value:$[^,]+ { proxy.down = value.trim(); }
|
|
3446
|
+
salamander_password = comma "salamander-password" equals value:$((!next_parameter .)+) {
|
|
3447
|
+
proxy.obfs = "salamander";
|
|
3448
|
+
proxy["obfs-password"] = value.trim();
|
|
3449
|
+
}
|
|
3450
|
+
port_hopping = comma "port-hopping" equals ports:$(hopping_port (comma hopping_port)*) {
|
|
3451
|
+
proxy.ports = ports.replace(/\s/g, "");
|
|
3452
|
+
}
|
|
3453
|
+
hopping_port = [0-9]+ (_ "-" _ [0-9]+)?
|
|
3454
|
+
port_hopping_interval = comma "port-hopping-interval" equals interval:$[0-9]+ {
|
|
3455
|
+
const seconds = Number(interval);
|
|
3456
|
+
if (seconds >= 5 && seconds <= 3600) {
|
|
3457
|
+
proxy["hop-interval"] = seconds;
|
|
3458
|
+
}
|
|
3459
|
+
}
|
|
3460
|
+
|
|
2984
3461
|
fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; }
|
|
2985
3462
|
|
|
2986
3463
|
over_tls = comma "over-tls" equals flag:bool { proxy.tls = flag; }
|
|
@@ -3044,7 +3521,7 @@ reality_hex_shortid = comma "reality-hex-shortid" equals param:$[^=,]+ {
|
|
|
3044
3521
|
}
|
|
3045
3522
|
|
|
3046
3523
|
vless_flow = comma "vless-flow" equals param:$[^=,]+ { proxy["flow"] = param; }
|
|
3047
|
-
server_check_url = comma "server_check_url" equals param:$[
|
|
3524
|
+
server_check_url = comma "server_check_url" equals param:$[^,]+ { proxy["test-url"] = param.trim(); }
|
|
3048
3525
|
|
|
3049
3526
|
uri = $[^,]+
|
|
3050
3527
|
|
|
@@ -3262,7 +3739,7 @@ function parseTrojan(url) {
|
|
|
3262
3739
|
}
|
|
3263
3740
|
proxy["skip-cert-verify"] = toBool(params.allowInsecure);
|
|
3264
3741
|
proxy.sni = params.sni || params.peer;
|
|
3265
|
-
proxy["client-fingerprint"] = params.fp;
|
|
3742
|
+
proxy["client-fingerprint"] = params.fp ?? params["client-fingerprint"];
|
|
3266
3743
|
proxy["tls-fingerprint"] = params.pcs;
|
|
3267
3744
|
proxy._vcn = params.vcn?.split(",").map((name2) => name2.trim()).filter(Boolean);
|
|
3268
3745
|
proxy["name-cert-verify"] = proxy._vcn?.[0];
|
|
@@ -3448,257 +3925,41 @@ function normalizeStringifyOptions(options = {}) {
|
|
|
3448
3925
|
} else if (quotingType === '"') {
|
|
3449
3926
|
normalized.singleQuote = false;
|
|
3450
3927
|
}
|
|
3451
|
-
if (forceQuotes) {
|
|
3452
|
-
normalized.defaultStringType = quotingType === "'" ? "QUOTE_SINGLE" : "QUOTE_DOUBLE";
|
|
3453
|
-
}
|
|
3454
|
-
return normalized;
|
|
3455
|
-
}
|
|
3456
|
-
function parse(content, options) {
|
|
3457
|
-
return parseYaml(content, normalizeParseOptions(options));
|
|
3458
|
-
}
|
|
3459
|
-
function stringify(content, options) {
|
|
3460
|
-
return stringifyYaml(content, normalizeStringifyOptions(options));
|
|
3461
|
-
}
|
|
3462
|
-
function safeLoad(content, ...args) {
|
|
3463
|
-
return retry(parse, toSerializable(content), ...args);
|
|
3464
|
-
}
|
|
3465
|
-
function load(content, ...args) {
|
|
3466
|
-
return retry(parse, toSerializable(content), ...args);
|
|
3467
|
-
}
|
|
3468
|
-
function safeDump(content, ...args) {
|
|
3469
|
-
return stringify(toSerializable(content), ...args);
|
|
3470
|
-
}
|
|
3471
|
-
function dump(content, ...args) {
|
|
3472
|
-
return stringify(toSerializable(content), ...args);
|
|
3473
|
-
}
|
|
3474
|
-
var yaml_default = {
|
|
3475
|
-
safeLoad,
|
|
3476
|
-
load,
|
|
3477
|
-
safeDump,
|
|
3478
|
-
dump,
|
|
3479
|
-
parse: safeLoad,
|
|
3480
|
-
stringify: safeDump
|
|
3481
|
-
};
|
|
3482
|
-
|
|
3483
|
-
// src/vendors/Sub-Store/backend/src/core/proxy-utils/parsers/index.js
|
|
3484
|
-
import _ from "lodash";
|
|
3485
|
-
import { Base64 } from "js-base64";
|
|
3486
|
-
|
|
3487
|
-
// src/vendors/Sub-Store/backend/src/core/proxy-utils/xhttp-utils.js
|
|
3488
|
-
function parseNormalizedXhttpRangeBounds(value, { allowZeroLowerBound = true, allowZeroUpperBound = true } = {}) {
|
|
3489
|
-
if (typeof value !== "string" && typeof value !== "number") {
|
|
3490
|
-
return void 0;
|
|
3491
|
-
}
|
|
3492
|
-
const parseUnsignedIntegerToken = (token) => {
|
|
3493
|
-
const normalizedToken = token.trim();
|
|
3494
|
-
if (!/^\+?\d+$/.test(normalizedToken)) {
|
|
3495
|
-
return void 0;
|
|
3496
|
-
}
|
|
3497
|
-
const parsedInteger = parseInt(normalizedToken, 10);
|
|
3498
|
-
return Number.isSafeInteger(parsedInteger) ? parsedInteger : void 0;
|
|
3499
|
-
};
|
|
3500
|
-
const normalizedValue = `${value}`.trim();
|
|
3501
|
-
const rangeParts = normalizedValue.split("-");
|
|
3502
|
-
const minimumAllowedLowerBound = allowZeroLowerBound ? 0 : 1;
|
|
3503
|
-
const minimumAllowedUpperBound = allowZeroUpperBound ? 0 : 1;
|
|
3504
|
-
if (rangeParts.length === 1) {
|
|
3505
|
-
const normalizedInteger = parseUnsignedIntegerToken(rangeParts[0]);
|
|
3506
|
-
const minimumAllowedValue = Math.max(
|
|
3507
|
-
minimumAllowedLowerBound,
|
|
3508
|
-
minimumAllowedUpperBound
|
|
3509
|
-
);
|
|
3510
|
-
return normalizedInteger >= minimumAllowedValue ? {
|
|
3511
|
-
lowerBound: normalizedInteger,
|
|
3512
|
-
upperBound: normalizedInteger
|
|
3513
|
-
} : void 0;
|
|
3514
|
-
}
|
|
3515
|
-
if (rangeParts.length !== 2) {
|
|
3516
|
-
return void 0;
|
|
3517
|
-
}
|
|
3518
|
-
const lowerBound = parseUnsignedIntegerToken(rangeParts[0]);
|
|
3519
|
-
const upperBound = parseUnsignedIntegerToken(rangeParts[1]);
|
|
3520
|
-
if (lowerBound == null || upperBound == null) {
|
|
3521
|
-
return void 0;
|
|
3522
|
-
}
|
|
3523
|
-
return lowerBound >= minimumAllowedLowerBound && upperBound >= minimumAllowedUpperBound && upperBound >= lowerBound ? {
|
|
3524
|
-
lowerBound,
|
|
3525
|
-
upperBound
|
|
3526
|
-
} : void 0;
|
|
3527
|
-
}
|
|
3528
|
-
function parseNormalizedXhttpPositiveRangeBounds(value) {
|
|
3529
|
-
return parseNormalizedXhttpRangeBounds(value, {
|
|
3530
|
-
allowZeroUpperBound: false
|
|
3531
|
-
});
|
|
3532
|
-
}
|
|
3533
|
-
function parseNormalizedXhttpStrictPositiveRangeBounds(value) {
|
|
3534
|
-
return parseNormalizedXhttpRangeBounds(value, {
|
|
3535
|
-
allowZeroLowerBound: false,
|
|
3536
|
-
allowZeroUpperBound: false
|
|
3537
|
-
});
|
|
3538
|
-
}
|
|
3539
|
-
function normalizeXhttpPositiveRange(value) {
|
|
3540
|
-
const normalizedBounds = parseNormalizedXhttpPositiveRangeBounds(value);
|
|
3541
|
-
if (!normalizedBounds) {
|
|
3542
|
-
return void 0;
|
|
3543
|
-
}
|
|
3544
|
-
const { lowerBound, upperBound } = normalizedBounds;
|
|
3545
|
-
return lowerBound === upperBound ? upperBound : `${lowerBound}-${upperBound}`;
|
|
3546
|
-
}
|
|
3547
|
-
function normalizeXhttpStrictPositiveRangeString(value) {
|
|
3548
|
-
const normalizedBounds = parseNormalizedXhttpStrictPositiveRangeBounds(value);
|
|
3549
|
-
if (!normalizedBounds) {
|
|
3550
|
-
return void 0;
|
|
3551
|
-
}
|
|
3552
|
-
const { lowerBound, upperBound } = normalizedBounds;
|
|
3553
|
-
return lowerBound === upperBound ? `${upperBound}` : `${lowerBound}-${upperBound}`;
|
|
3554
|
-
}
|
|
3555
|
-
function normalizeXhttpStrictPositiveRangeValue(value) {
|
|
3556
|
-
const normalizedBounds = parseNormalizedXhttpStrictPositiveRangeBounds(value);
|
|
3557
|
-
if (!normalizedBounds) {
|
|
3558
|
-
return void 0;
|
|
3559
|
-
}
|
|
3560
|
-
const { lowerBound, upperBound } = normalizedBounds;
|
|
3561
|
-
return lowerBound === upperBound ? upperBound : `${lowerBound}-${upperBound}`;
|
|
3562
|
-
}
|
|
3563
|
-
function normalizeXhttpNonNegativeRange(value) {
|
|
3564
|
-
const normalizedBounds = parseNormalizedXhttpRangeBounds(value);
|
|
3565
|
-
if (!normalizedBounds) {
|
|
3566
|
-
return void 0;
|
|
3567
|
-
}
|
|
3568
|
-
const { lowerBound, upperBound } = normalizedBounds;
|
|
3569
|
-
return lowerBound === upperBound ? upperBound : `${lowerBound}-${upperBound}`;
|
|
3570
|
-
}
|
|
3571
|
-
function normalizeXhttpIntegerValue(value, { allowNegative = true } = {}) {
|
|
3572
|
-
if (typeof value === "number" && Number.isFinite(value) && Number.isSafeInteger(value)) {
|
|
3573
|
-
if (!allowNegative && value < 0) {
|
|
3574
|
-
return void 0;
|
|
3575
|
-
}
|
|
3576
|
-
return value;
|
|
3577
|
-
}
|
|
3578
|
-
if (typeof value !== "string") {
|
|
3579
|
-
return void 0;
|
|
3580
|
-
}
|
|
3581
|
-
const normalizedValue = value.trim();
|
|
3582
|
-
const integerPattern = allowNegative ? /^[+-]?\d+$/ : /^\+?\d+$/;
|
|
3583
|
-
if (!integerPattern.test(normalizedValue)) {
|
|
3584
|
-
return void 0;
|
|
3585
|
-
}
|
|
3586
|
-
const parsedInteger = parseInt(normalizedValue, 10);
|
|
3587
|
-
if (!Number.isSafeInteger(parsedInteger)) {
|
|
3588
|
-
return void 0;
|
|
3589
|
-
}
|
|
3590
|
-
if (!allowNegative && parsedInteger < 0) {
|
|
3591
|
-
return void 0;
|
|
3592
|
-
}
|
|
3593
|
-
return parsedInteger;
|
|
3594
|
-
}
|
|
3595
|
-
|
|
3596
|
-
// src/vendors/Sub-Store/backend/src/core/proxy-utils/ech-utils.js
|
|
3597
|
-
var ECH_DNS_FIELD = "_dns";
|
|
3598
|
-
var ECH_FORCE_QUERY_FIELD = "_force-query";
|
|
3599
|
-
var ECH_SOCKOPT_FIELD = "_sockopt";
|
|
3600
|
-
var DEFAULT_XRAY_ECH_DNS = "https://dns.alidns.com/dns-query";
|
|
3601
|
-
function parseXrayEchConfigList(echConfigList) {
|
|
3602
|
-
if (!isNotBlank(echConfigList)) {
|
|
3603
|
-
return void 0;
|
|
3604
|
-
}
|
|
3605
|
-
if (!echConfigList.includes("://")) {
|
|
3606
|
-
return {
|
|
3607
|
-
type: "config",
|
|
3608
|
-
config: echConfigList
|
|
3609
|
-
};
|
|
3610
|
-
}
|
|
3611
|
-
const parts = echConfigList.split("+");
|
|
3612
|
-
if (parts.length === 1 && isNotBlank(parts[0])) {
|
|
3613
|
-
return {
|
|
3614
|
-
type: "dns",
|
|
3615
|
-
dns: parts[0]
|
|
3616
|
-
};
|
|
3617
|
-
}
|
|
3618
|
-
if (parts.length === 2 && isNotBlank(parts[0]) && isNotBlank(parts[1])) {
|
|
3619
|
-
return {
|
|
3620
|
-
type: "dns",
|
|
3621
|
-
queryServerName: parts[0],
|
|
3622
|
-
dns: parts[1]
|
|
3623
|
-
};
|
|
3624
|
-
}
|
|
3625
|
-
return void 0;
|
|
3626
|
-
}
|
|
3627
|
-
function isSupportedXrayEchConfigList(echConfigList) {
|
|
3628
|
-
return parseXrayEchConfigList(echConfigList) != null;
|
|
3629
|
-
}
|
|
3630
|
-
function isSupportedXrayEchForceQuery(forceQuery) {
|
|
3631
|
-
return ["none", "half", "full"].includes(forceQuery);
|
|
3632
|
-
}
|
|
3633
|
-
function isMihomoEchEnabled(value) {
|
|
3634
|
-
if (typeof value === "boolean") {
|
|
3635
|
-
return value;
|
|
3636
|
-
}
|
|
3637
|
-
return typeof value === "number" && Number.isInteger(value) && value !== 0;
|
|
3638
|
-
}
|
|
3639
|
-
function buildMihomoEchOptsFromXrayFields({
|
|
3640
|
-
echConfigList,
|
|
3641
|
-
echForceQuery,
|
|
3642
|
-
echSockopt
|
|
3643
|
-
} = {}) {
|
|
3644
|
-
const parsedEchConfigList = parseXrayEchConfigList(echConfigList);
|
|
3645
|
-
if (!parsedEchConfigList) {
|
|
3646
|
-
return void 0;
|
|
3647
|
-
}
|
|
3648
|
-
const echOpts = {
|
|
3649
|
-
enable: true
|
|
3650
|
-
};
|
|
3651
|
-
if (parsedEchConfigList.type === "config") {
|
|
3652
|
-
echOpts.config = parsedEchConfigList.config;
|
|
3653
|
-
} else {
|
|
3654
|
-
echOpts[ECH_DNS_FIELD] = parsedEchConfigList.dns;
|
|
3655
|
-
if (parsedEchConfigList.queryServerName) {
|
|
3656
|
-
echOpts["query-server-name"] = parsedEchConfigList.queryServerName;
|
|
3657
|
-
}
|
|
3658
|
-
}
|
|
3659
|
-
if (isSupportedXrayEchForceQuery(echForceQuery)) {
|
|
3660
|
-
echOpts[ECH_FORCE_QUERY_FIELD] = echForceQuery;
|
|
3661
|
-
}
|
|
3662
|
-
if (isPlainObject(echSockopt)) {
|
|
3663
|
-
echOpts[ECH_SOCKOPT_FIELD] = echSockopt;
|
|
3664
|
-
}
|
|
3665
|
-
return echOpts;
|
|
3666
|
-
}
|
|
3667
|
-
function buildXrayEchFieldsFromMihomo(echOpts, fallbackEchConfigList, { dnsFieldPath = "ech-opts._dns", warnDefaultDns } = {}) {
|
|
3668
|
-
const fields = {};
|
|
3669
|
-
if (isPlainObject(echOpts)) {
|
|
3670
|
-
if (!isMihomoEchEnabled(echOpts.enable)) {
|
|
3671
|
-
return fields;
|
|
3672
|
-
}
|
|
3673
|
-
const queryServerName = echOpts["query-server-name"];
|
|
3674
|
-
if (isNotBlank(echOpts.config)) {
|
|
3675
|
-
fields.echConfigList = echOpts.config;
|
|
3676
|
-
} else if (isNotBlank(echOpts[ECH_DNS_FIELD])) {
|
|
3677
|
-
fields.echConfigList = isNotBlank(queryServerName) ? `${queryServerName}+${echOpts[ECH_DNS_FIELD]}` : echOpts[ECH_DNS_FIELD];
|
|
3678
|
-
} else if (isNotBlank(queryServerName)) {
|
|
3679
|
-
fields.echConfigList = `${queryServerName}+${DEFAULT_XRAY_ECH_DNS}`;
|
|
3680
|
-
warnDefaultDns?.({
|
|
3681
|
-
defaultDns: DEFAULT_XRAY_ECH_DNS,
|
|
3682
|
-
dnsFieldPath,
|
|
3683
|
-
queryServerName
|
|
3684
|
-
});
|
|
3685
|
-
}
|
|
3686
|
-
if (fields.echConfigList && isSupportedXrayEchForceQuery(echOpts[ECH_FORCE_QUERY_FIELD])) {
|
|
3687
|
-
fields.echForceQuery = echOpts[ECH_FORCE_QUERY_FIELD];
|
|
3688
|
-
}
|
|
3689
|
-
if (fields.echConfigList && isPlainObject(echOpts[ECH_SOCKOPT_FIELD])) {
|
|
3690
|
-
fields.echSockopt = echOpts[ECH_SOCKOPT_FIELD];
|
|
3691
|
-
}
|
|
3692
|
-
return fields;
|
|
3693
|
-
}
|
|
3694
|
-
if (isNotBlank(fallbackEchConfigList)) {
|
|
3695
|
-
fields.echConfigList = fallbackEchConfigList;
|
|
3696
|
-
}
|
|
3697
|
-
return fields;
|
|
3928
|
+
if (forceQuotes) {
|
|
3929
|
+
normalized.defaultStringType = quotingType === "'" ? "QUOTE_SINGLE" : "QUOTE_DOUBLE";
|
|
3930
|
+
}
|
|
3931
|
+
return normalized;
|
|
3698
3932
|
}
|
|
3699
|
-
function
|
|
3700
|
-
return
|
|
3933
|
+
function parse(content, options) {
|
|
3934
|
+
return parseYaml(content, normalizeParseOptions(options));
|
|
3935
|
+
}
|
|
3936
|
+
function stringify(content, options) {
|
|
3937
|
+
return stringifyYaml(content, normalizeStringifyOptions(options));
|
|
3938
|
+
}
|
|
3939
|
+
function safeLoad(content, ...args) {
|
|
3940
|
+
return retry(parse, toSerializable(content), ...args);
|
|
3941
|
+
}
|
|
3942
|
+
function load(content, ...args) {
|
|
3943
|
+
return retry(parse, toSerializable(content), ...args);
|
|
3944
|
+
}
|
|
3945
|
+
function safeDump(content, ...args) {
|
|
3946
|
+
return stringify(toSerializable(content), ...args);
|
|
3947
|
+
}
|
|
3948
|
+
function dump(content, ...args) {
|
|
3949
|
+
return stringify(toSerializable(content), ...args);
|
|
3701
3950
|
}
|
|
3951
|
+
var yaml_default = {
|
|
3952
|
+
safeLoad,
|
|
3953
|
+
load,
|
|
3954
|
+
safeDump,
|
|
3955
|
+
dump,
|
|
3956
|
+
parse: safeLoad,
|
|
3957
|
+
stringify: safeDump
|
|
3958
|
+
};
|
|
3959
|
+
|
|
3960
|
+
// src/vendors/Sub-Store/backend/src/core/proxy-utils/parsers/index.js
|
|
3961
|
+
import _2 from "lodash";
|
|
3962
|
+
import { Base64 } from "js-base64";
|
|
3702
3963
|
|
|
3703
3964
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/vmess-security.js
|
|
3704
3965
|
var VMESS_SECURITY_AUTO = "auto";
|
|
@@ -3892,6 +4153,10 @@ function URI_PROXY() {
|
|
|
3892
4153
|
username: username != null ? decodeURIComponent(username) : void 0,
|
|
3893
4154
|
password: password != null ? decodeURIComponent(password) : void 0
|
|
3894
4155
|
};
|
|
4156
|
+
if (tls && query) {
|
|
4157
|
+
const fingerprint = getPathQueryParam(query, "fp") || getPathQueryParam(query, "client-fingerprint");
|
|
4158
|
+
if (fingerprint) proxy["client-fingerprint"] = fingerprint;
|
|
4159
|
+
}
|
|
3895
4160
|
return proxy;
|
|
3896
4161
|
};
|
|
3897
4162
|
return { name, test, parse: parse2 };
|
|
@@ -3986,7 +4251,7 @@ function URI_SS() {
|
|
|
3986
4251
|
proxy.alpn = params.alpn ? decodeURIComponent(params.alpn).split(",") : void 0;
|
|
3987
4252
|
if (params["ws"]) {
|
|
3988
4253
|
proxy.network = "ws";
|
|
3989
|
-
|
|
4254
|
+
_2.set(proxy, "ws-opts.path", params["wspath"]);
|
|
3990
4255
|
}
|
|
3991
4256
|
if (params["type"]) {
|
|
3992
4257
|
let httpupgrade;
|
|
@@ -4015,10 +4280,10 @@ function URI_SS() {
|
|
|
4015
4280
|
pathEarlyData = extracted.ed;
|
|
4016
4281
|
}
|
|
4017
4282
|
}
|
|
4018
|
-
|
|
4283
|
+
_2.set(proxy, proxy.network + "-opts.path", transportPath);
|
|
4019
4284
|
}
|
|
4020
4285
|
if (params["host"]) {
|
|
4021
|
-
|
|
4286
|
+
_2.set(
|
|
4022
4287
|
proxy,
|
|
4023
4288
|
proxy.network + "-opts.headers.Host",
|
|
4024
4289
|
decodeURIComponent(params["host"])
|
|
@@ -4026,30 +4291,30 @@ function URI_SS() {
|
|
|
4026
4291
|
}
|
|
4027
4292
|
if (httpupgrade) {
|
|
4028
4293
|
httpUpgradeEd = httpUpgradeEd || (isNumericEarlyData2(params.ed) ? `${params.ed}` : "");
|
|
4029
|
-
|
|
4294
|
+
_2.set(
|
|
4030
4295
|
proxy,
|
|
4031
4296
|
proxy.network + "-opts.v2ray-http-upgrade",
|
|
4032
4297
|
true
|
|
4033
4298
|
);
|
|
4034
4299
|
if (httpUpgradeEd !== "") {
|
|
4035
|
-
|
|
4300
|
+
_2.set(
|
|
4036
4301
|
proxy,
|
|
4037
4302
|
proxy.network + "-opts.v2ray-http-upgrade-fast-open",
|
|
4038
4303
|
true
|
|
4039
4304
|
);
|
|
4040
|
-
|
|
4305
|
+
_2.set(
|
|
4041
4306
|
proxy,
|
|
4042
4307
|
proxy.network + "-opts._v2ray-http-upgrade-ed",
|
|
4043
4308
|
httpUpgradeEd
|
|
4044
4309
|
);
|
|
4045
4310
|
}
|
|
4046
4311
|
} else if (proxy.network === "ws" && pathEarlyData !== "") {
|
|
4047
|
-
|
|
4312
|
+
_2.set(
|
|
4048
4313
|
proxy,
|
|
4049
4314
|
proxy.network + "-opts.max-early-data",
|
|
4050
4315
|
parseEarlyDataSize(pathEarlyData)
|
|
4051
4316
|
);
|
|
4052
|
-
|
|
4317
|
+
_2.set(
|
|
4053
4318
|
proxy,
|
|
4054
4319
|
proxy.network + "-opts.early-data-header-name",
|
|
4055
4320
|
"Sec-WebSocket-Protocol"
|
|
@@ -4070,15 +4335,17 @@ function URI_SS() {
|
|
|
4070
4335
|
if (params.mode) {
|
|
4071
4336
|
proxy._mode = params.mode;
|
|
4072
4337
|
}
|
|
4073
|
-
if (params.extra) {
|
|
4074
|
-
proxy._extra = params.extra;
|
|
4075
|
-
}
|
|
4076
4338
|
if (Object.keys(opts).length > 0) {
|
|
4077
|
-
|
|
4339
|
+
_2.set(proxy, params.security + "-opts", opts);
|
|
4078
4340
|
}
|
|
4079
4341
|
}
|
|
4342
|
+
if (params.extra && (proxy.network === "xhttp" || params.security === "reality")) {
|
|
4343
|
+
proxy._extra = params.extra;
|
|
4344
|
+
}
|
|
4080
4345
|
}
|
|
4081
|
-
proxy.udp =
|
|
4346
|
+
proxy.udp = ![false, 0, "0", "false", "off"].includes(
|
|
4347
|
+
typeof params["udp"] === "string" ? params["udp"].toLowerCase() : params["udp"]
|
|
4348
|
+
);
|
|
4082
4349
|
const serverAndPort = serverAndPortArray[1];
|
|
4083
4350
|
const portIdx = serverAndPort.lastIndexOf(":");
|
|
4084
4351
|
proxy.server = serverAndPort.substring(0, portIdx);
|
|
@@ -4471,7 +4738,7 @@ function URI_VMess() {
|
|
|
4471
4738
|
delete proxy.network;
|
|
4472
4739
|
}
|
|
4473
4740
|
}
|
|
4474
|
-
proxy["client-fingerprint"] = params.fp;
|
|
4741
|
+
proxy["client-fingerprint"] = params.fp ?? params["client-fingerprint"];
|
|
4475
4742
|
proxy.alpn = params.alpn ? params.alpn.split(",") : void 0;
|
|
4476
4743
|
if (isNotBlank(fragmentName)) {
|
|
4477
4744
|
proxy.name = fragmentName;
|
|
@@ -5200,7 +5467,7 @@ function URI_VLESS() {
|
|
|
5200
5467
|
let isShadowrocket;
|
|
5201
5468
|
let parsed = /^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
5202
5469
|
if (!parsed) {
|
|
5203
|
-
let [
|
|
5470
|
+
let [_5, base64, other] = /^(.*?)(\?.*?$)/.exec(line);
|
|
5204
5471
|
line = `${Base64.decode(base64)}${other}`;
|
|
5205
5472
|
parsed = /^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
5206
5473
|
isShadowrocket = true;
|
|
@@ -5246,9 +5513,9 @@ function URI_VLESS() {
|
|
|
5246
5513
|
proxy.flow = flow;
|
|
5247
5514
|
}
|
|
5248
5515
|
}
|
|
5249
|
-
proxy["client-fingerprint"] = params.fp;
|
|
5516
|
+
proxy["client-fingerprint"] = params.fp ?? params["client-fingerprint"];
|
|
5250
5517
|
proxy.alpn = params.alpn ? params.alpn.split(",") : void 0;
|
|
5251
|
-
proxy["skip-cert-verify"] = /(TRUE)|1/i.test(params.allowInsecure);
|
|
5518
|
+
proxy["skip-cert-verify"] = /(TRUE)|1/i.test(params.allowInsecure) || protocol === "vless" && params.allowInsecure == null && params.insecure === "1";
|
|
5252
5519
|
proxy._echConfigList = getIfPresent(params.ech);
|
|
5253
5520
|
const echOpts = buildMihomoEchOptsFromXrayFields({
|
|
5254
5521
|
echConfigList: params.ech
|
|
@@ -5308,6 +5575,8 @@ function URI_VLESS() {
|
|
|
5308
5575
|
}
|
|
5309
5576
|
if (["websocket"].includes(proxy.network)) {
|
|
5310
5577
|
proxy.network = "ws";
|
|
5578
|
+
} else if (protocol === "vless" && proxy.network === "splithttp") {
|
|
5579
|
+
proxy.network = "xhttp";
|
|
5311
5580
|
}
|
|
5312
5581
|
if (proxy.network && !["tcp", "none"].includes(proxy.network)) {
|
|
5313
5582
|
const opts = {};
|
|
@@ -5343,11 +5612,8 @@ function URI_VLESS() {
|
|
|
5343
5612
|
}
|
|
5344
5613
|
if (params.serviceName) {
|
|
5345
5614
|
opts[`${proxy.network}-service-name`] = params.serviceName;
|
|
5346
|
-
if (["grpc"].includes(proxy.network) && params.authority) {
|
|
5347
|
-
opts["_grpc-authority"] = params.authority;
|
|
5348
|
-
}
|
|
5349
5615
|
} else if (isShadowrocket && params.path) {
|
|
5350
|
-
if (!["ws", "http", "h2"].includes(proxy.network)) {
|
|
5616
|
+
if (!["ws", "http", "h2", "xhttp"].includes(proxy.network)) {
|
|
5351
5617
|
opts[`${proxy.network}-service-name`] = params.path;
|
|
5352
5618
|
delete params.path;
|
|
5353
5619
|
}
|
|
@@ -5368,6 +5634,9 @@ function URI_VLESS() {
|
|
|
5368
5634
|
}
|
|
5369
5635
|
if (["grpc"].includes(proxy.network)) {
|
|
5370
5636
|
opts["_grpc-type"] = params.mode || "gun";
|
|
5637
|
+
if (params.authority) {
|
|
5638
|
+
opts["_grpc-authority"] = params.authority;
|
|
5639
|
+
}
|
|
5371
5640
|
}
|
|
5372
5641
|
if (httpupgrade) {
|
|
5373
5642
|
opts["v2ray-http-upgrade"] = true;
|
|
@@ -5472,7 +5741,6 @@ function URI_AnyTLS() {
|
|
|
5472
5741
|
const parsed = URI_VLESS().parse(line.replace("anytls", "vless"));
|
|
5473
5742
|
line = line.split(/anytls:\/\//)[1];
|
|
5474
5743
|
let [__, password, server, port, addons = "", name2] = /^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
5475
|
-
password = decodeURIComponent(password);
|
|
5476
5744
|
port = parseInt(`${port}`, 10);
|
|
5477
5745
|
if (isNaN(port)) {
|
|
5478
5746
|
port = 443;
|
|
@@ -5823,12 +6091,14 @@ function URI_Trojan() {
|
|
|
5823
6091
|
return /^trojan:\/\//.test(line);
|
|
5824
6092
|
};
|
|
5825
6093
|
const parse2 = (line) => {
|
|
5826
|
-
|
|
6094
|
+
let [newLine, name2] = line.split(/#(.+)/, 2);
|
|
6095
|
+
const matched = /^(trojan:\/\/.*?@.*?)(:(\d+))?\/?(\?.*?)?$/.exec(
|
|
6096
|
+
newLine
|
|
6097
|
+
);
|
|
5827
6098
|
const port = matched?.[2];
|
|
5828
6099
|
if (!port) {
|
|
5829
|
-
|
|
6100
|
+
newLine = newLine.replace(matched[1], `${matched[1]}:443`);
|
|
5830
6101
|
}
|
|
5831
|
-
let [newLine, name2] = line.split(/#(.+)/, 2);
|
|
5832
6102
|
const parser5 = getParser4();
|
|
5833
6103
|
const proxy = parser5.parse(newLine);
|
|
5834
6104
|
if (isNotBlank(name2)) {
|
|
@@ -5964,6 +6234,12 @@ function QX_AnyTLS() {
|
|
|
5964
6234
|
const parse2 = (line) => getParser3().parse(line);
|
|
5965
6235
|
return { name, test, parse: parse2 };
|
|
5966
6236
|
}
|
|
6237
|
+
function QX_Hysteria2() {
|
|
6238
|
+
const name = "QX Hysteria2 Parser";
|
|
6239
|
+
const test = (line) => /^hysteria2\s*=/.test(line);
|
|
6240
|
+
const parse2 = (line) => getParser3().parse(line);
|
|
6241
|
+
return { name, test, parse: parse2 };
|
|
6242
|
+
}
|
|
5967
6243
|
function QX_Trojan() {
|
|
5968
6244
|
const name = "QX Trojan Parser";
|
|
5969
6245
|
const test = (line) => {
|
|
@@ -6004,11 +6280,10 @@ function Loon_SSR() {
|
|
|
6004
6280
|
const parse2 = (line) => getParser2().parse(line);
|
|
6005
6281
|
return { name, test, parse: parse2 };
|
|
6006
6282
|
}
|
|
6283
|
+
var LOON_VMESS = /^[^=,]*=\s*vmess\s*,[^,]*,[^,]*,[^,]*,\s*"/i;
|
|
6007
6284
|
function Loon_VMess() {
|
|
6008
6285
|
const name = "Loon VMess Parser";
|
|
6009
|
-
const test = (line) =>
|
|
6010
|
-
return /^.*=\s*vmess/i.test(line.split(",")[0]) && line.indexOf("username") === -1;
|
|
6011
|
-
};
|
|
6286
|
+
const test = (line) => LOON_VMESS.test(line);
|
|
6012
6287
|
const parse2 = (line) => getParser2().parse(line);
|
|
6013
6288
|
return { name, test, parse: parse2 };
|
|
6014
6289
|
}
|
|
@@ -6060,6 +6335,12 @@ function Loon_Socks5() {
|
|
|
6060
6335
|
const parse2 = (line) => getParser2().parse(line);
|
|
6061
6336
|
return { name, test, parse: parse2 };
|
|
6062
6337
|
}
|
|
6338
|
+
function Loon_Tailscale() {
|
|
6339
|
+
const name = "Loon Tailscale Parser";
|
|
6340
|
+
const test = (line) => /^[^=,]*=\s*tailscale\s*(?:,|$)/i.test(line);
|
|
6341
|
+
const parse2 = (line) => getParser2().parse(line);
|
|
6342
|
+
return { name, test, parse: parse2 };
|
|
6343
|
+
}
|
|
6063
6344
|
function Loon_WireGuard() {
|
|
6064
6345
|
const name = "Loon WireGuard Parser";
|
|
6065
6346
|
const test = (line) => {
|
|
@@ -6228,15 +6509,21 @@ function Surge_SS() {
|
|
|
6228
6509
|
function Surge_VMess() {
|
|
6229
6510
|
const name = "Surge VMess Parser";
|
|
6230
6511
|
const test = (line) => {
|
|
6231
|
-
return /^.*=\s*vmess/.test(line.split(",")[0]) && line.indexOf("username") !== -1;
|
|
6512
|
+
return /^.*=\s*vmess/.test(line.split(",")[0]) && line.indexOf("username") !== -1 && !LOON_VMESS.test(line);
|
|
6232
6513
|
};
|
|
6233
6514
|
const parse2 = (line) => getParser().parse(line);
|
|
6234
6515
|
return { name, test, parse: parse2 };
|
|
6235
6516
|
}
|
|
6517
|
+
function Surge_VLESS() {
|
|
6518
|
+
const name = "Surge VLESS Parser";
|
|
6519
|
+
const test = (line) => /^.*=\s*vless\s*$/.test(line.split(",")[0]) && /,\s*username\s*=/.test(line);
|
|
6520
|
+
const parse2 = (line) => getParser().parse(line);
|
|
6521
|
+
return { name, test, parse: parse2 };
|
|
6522
|
+
}
|
|
6236
6523
|
function Surge_Trojan() {
|
|
6237
6524
|
const name = "Surge Trojan Parser";
|
|
6238
6525
|
const test = (line) => {
|
|
6239
|
-
return /^.*=\s*trojan/.test(line.split(",")[0]);
|
|
6526
|
+
return /^.*=\s*trojan/.test(line.split(",")[0]) && !/^[^=,]*=\s*trojan\s*,[^,]*,[^,]*,\s*"/.test(line);
|
|
6240
6527
|
};
|
|
6241
6528
|
const parse2 = (line) => getParser().parse(line);
|
|
6242
6529
|
return { name, test, parse: parse2 };
|
|
@@ -6265,7 +6552,7 @@ function Surge_External() {
|
|
|
6265
6552
|
};
|
|
6266
6553
|
const parse2 = (line) => {
|
|
6267
6554
|
let parsed = /^\s*(.*?)\s*?=\s*?external\s*?,\s*(.*?)\s*$/.exec(line);
|
|
6268
|
-
let [
|
|
6555
|
+
let [_5, name2, other] = parsed;
|
|
6269
6556
|
line = other;
|
|
6270
6557
|
let exec = /(,|^)\s*?exec\s*?=\s*"(.*?)"\s*?(,|$)/.exec(line)?.[2];
|
|
6271
6558
|
if (!exec) {
|
|
@@ -6318,12 +6605,15 @@ function Surge_External() {
|
|
|
6318
6605
|
};
|
|
6319
6606
|
return { name, test, parse: parse2 };
|
|
6320
6607
|
}
|
|
6321
|
-
function
|
|
6322
|
-
const name = "
|
|
6323
|
-
const test = (line) =>
|
|
6324
|
-
|
|
6608
|
+
function Snell() {
|
|
6609
|
+
const name = "Snell Parser";
|
|
6610
|
+
const test = (line) => /^[^=,]*=\s*(?:snell|opensnell)\s*,/i.test(line);
|
|
6611
|
+
const parse2 = (line) => {
|
|
6612
|
+
const fields = line.match(/(?:[^",]+|"[^"]*")+/g).slice(3);
|
|
6613
|
+
const loonOption = /^(?:(?:udp|obfs-name|ip-mode|server-dns)\s*=|block-quic\s*=\s*(?:true|false)$)/;
|
|
6614
|
+
const isLoon = fields[0]?.trim().startsWith('"') || fields.some((field) => loonOption.test(field.trim()));
|
|
6615
|
+
return (isLoon ? getParser2() : getParser()).parse(line);
|
|
6325
6616
|
};
|
|
6326
|
-
const parse2 = (line) => getParser().parse(line);
|
|
6327
6617
|
return { name, test, parse: parse2 };
|
|
6328
6618
|
}
|
|
6329
6619
|
function Surge_Tuic() {
|
|
@@ -6385,9 +6675,10 @@ var parsers_default = [
|
|
|
6385
6675
|
Surge_SSH(),
|
|
6386
6676
|
Surge_SS(),
|
|
6387
6677
|
Surge_VMess(),
|
|
6678
|
+
Surge_VLESS(),
|
|
6388
6679
|
Surge_Trojan(),
|
|
6389
6680
|
Surge_Http(),
|
|
6390
|
-
|
|
6681
|
+
Snell(),
|
|
6391
6682
|
Surge_Tuic(),
|
|
6392
6683
|
Surge_WireGuard(),
|
|
6393
6684
|
Surge_Hysteria2(),
|
|
@@ -6403,45 +6694,100 @@ var parsers_default = [
|
|
|
6403
6694
|
Loon_Http(),
|
|
6404
6695
|
Loon_Socks5(),
|
|
6405
6696
|
Loon_WireGuard(),
|
|
6697
|
+
Loon_Tailscale(),
|
|
6406
6698
|
QX_SS(),
|
|
6407
6699
|
QX_SSR(),
|
|
6408
6700
|
QX_VMess(),
|
|
6409
6701
|
QX_VLESS(),
|
|
6410
6702
|
QX_AnyTLS(),
|
|
6703
|
+
QX_Hysteria2(),
|
|
6411
6704
|
QX_Trojan(),
|
|
6412
6705
|
QX_Http(),
|
|
6413
6706
|
QX_Socks5()
|
|
6414
6707
|
];
|
|
6415
6708
|
|
|
6709
|
+
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/surge.js
|
|
6710
|
+
import _4 from "lodash";
|
|
6711
|
+
|
|
6416
6712
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/utils.js
|
|
6417
|
-
import
|
|
6713
|
+
import _3 from "lodash";
|
|
6418
6714
|
|
|
6419
6715
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/preprocessors/index.js
|
|
6420
6716
|
import { Base64 as Base642 } from "js-base64";
|
|
6717
|
+
import { isAlias, isScalar, isSeq, parseDocument, visit } from "yaml";
|
|
6421
6718
|
function normalizeClashYaml(raw) {
|
|
6422
|
-
if (typeof raw !== "string" || !raw.includes("
|
|
6719
|
+
if (typeof raw !== "string" || !raw.includes("short-id")) {
|
|
6423
6720
|
return raw;
|
|
6424
6721
|
}
|
|
6722
|
+
let document;
|
|
6425
6723
|
try {
|
|
6426
|
-
|
|
6427
|
-
|
|
6724
|
+
document = parseDocument(raw, {
|
|
6725
|
+
merge: true,
|
|
6726
|
+
logLevel: "error"
|
|
6727
|
+
});
|
|
6728
|
+
const content = document.errors.length > 0 ? safeLoad(raw) : document.toJS();
|
|
6729
|
+
if (![content.proxies, content.listeners].some(
|
|
6730
|
+
(items) => Array.isArray(items) && items.length > 0
|
|
6731
|
+
))
|
|
6428
6732
|
return raw;
|
|
6429
6733
|
} catch (e) {
|
|
6430
6734
|
return raw;
|
|
6431
6735
|
}
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6736
|
+
const anchors = /* @__PURE__ */ new Map();
|
|
6737
|
+
const aliases = /* @__PURE__ */ new Map();
|
|
6738
|
+
visit(document, {
|
|
6739
|
+
Node(_5, node) {
|
|
6740
|
+
if (isAlias(node)) {
|
|
6741
|
+
aliases.set(node.range[0], anchors.get(node.source));
|
|
6742
|
+
} else if (node.anchor) {
|
|
6743
|
+
anchors.set(node.anchor, node);
|
|
6744
|
+
}
|
|
6436
6745
|
}
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6746
|
+
});
|
|
6747
|
+
const resolveAlias = (node) => isAlias(node) ? aliases.get(node.range[0]) : node;
|
|
6748
|
+
const needsQuotes = (node) => isScalar(node) && typeof node.value !== "string" && node.value !== null && !node.tag && node.source;
|
|
6749
|
+
const realityConfigs = /* @__PURE__ */ new Set();
|
|
6750
|
+
visit(document, {
|
|
6751
|
+
Pair(_5, { key, value }) {
|
|
6752
|
+
const name = resolveAlias(key)?.value;
|
|
6753
|
+
if (["reality-opts", "reality-config"].includes(name)) {
|
|
6754
|
+
realityConfigs.add(value);
|
|
6755
|
+
}
|
|
6756
|
+
}
|
|
6757
|
+
});
|
|
6758
|
+
for (const config of realityConfigs) {
|
|
6759
|
+
visit(config, {
|
|
6760
|
+
Alias(_5, alias) {
|
|
6761
|
+
realityConfigs.add(resolveAlias(alias));
|
|
6762
|
+
}
|
|
6763
|
+
});
|
|
6764
|
+
}
|
|
6765
|
+
const shortIds = /* @__PURE__ */ new Set();
|
|
6766
|
+
visit(document, {
|
|
6767
|
+
Pair(_5, { key, value }, path) {
|
|
6768
|
+
if (resolveAlias(key)?.value === "short-id" && path.some((node) => realityConfigs.has(node))) {
|
|
6769
|
+
shortIds.add(value);
|
|
6770
|
+
}
|
|
6443
6771
|
}
|
|
6444
6772
|
});
|
|
6773
|
+
const replacements = /* @__PURE__ */ new Map();
|
|
6774
|
+
for (const value of shortIds) {
|
|
6775
|
+
const node = resolveAlias(value);
|
|
6776
|
+
if (isSeq(node)) {
|
|
6777
|
+
for (const item of node.items) shortIds.add(item);
|
|
6778
|
+
} else if (needsQuotes(node)) {
|
|
6779
|
+
replacements.set(node, JSON.stringify(node.source));
|
|
6780
|
+
}
|
|
6781
|
+
}
|
|
6782
|
+
const chunks = [];
|
|
6783
|
+
let offset = 0;
|
|
6784
|
+
for (const [node, content] of [...replacements].sort(
|
|
6785
|
+
([left], [right]) => left.range[0] - right.range[0]
|
|
6786
|
+
)) {
|
|
6787
|
+
chunks.push(raw.slice(offset, node.range[0]), content);
|
|
6788
|
+
offset = node.range[1];
|
|
6789
|
+
}
|
|
6790
|
+
return chunks.join("") + raw.slice(offset);
|
|
6445
6791
|
}
|
|
6446
6792
|
function HTML() {
|
|
6447
6793
|
const name = "HTML";
|
|
@@ -6605,9 +6951,18 @@ var Result = class {
|
|
|
6605
6951
|
}
|
|
6606
6952
|
};
|
|
6607
6953
|
function isPresent2(obj, attr) {
|
|
6608
|
-
const data =
|
|
6954
|
+
const data = _3.get(obj, attr);
|
|
6609
6955
|
return typeof data !== "undefined" && data !== null;
|
|
6610
6956
|
}
|
|
6957
|
+
function supportsTrustTunnelClientRandomAuth(proxy, targetPlatform6) {
|
|
6958
|
+
if (proxy.type !== "trusttunnel" || !isPresent2(proxy, "client-random-auth-key") || ["surge", "surgemac", "json"].includes(targetPlatform6.toLowerCase())) {
|
|
6959
|
+
return true;
|
|
6960
|
+
}
|
|
6961
|
+
app_default.error(
|
|
6962
|
+
`Target platform ${targetPlatform6} does not support client-random-auth-key for TrustTunnel proxy ${proxy.name || `${proxy.server}:${proxy.port}`}. Proxy has been filtered.`
|
|
6963
|
+
);
|
|
6964
|
+
return false;
|
|
6965
|
+
}
|
|
6611
6966
|
function isShadowsocksOverTls(proxy) {
|
|
6612
6967
|
const normalizedNetwork = typeof proxy?.network === "string" ? proxy.network.trim().toLowerCase() : proxy?.network;
|
|
6613
6968
|
return proxy?.type === "ss" && proxy?.tls === true && !isPresent2(proxy, "plugin") && (!isPresent2(proxy, "network") || normalizedNetwork === "tcp");
|
|
@@ -6755,6 +7110,34 @@ function appendAlpn(result, proxy) {
|
|
|
6755
7110
|
const alpn = formatSurgeAlpn(proxy.alpn);
|
|
6756
7111
|
if (alpn) result.append(`,alpn="${alpn}"`);
|
|
6757
7112
|
}
|
|
7113
|
+
function appendClientFingerprint(result, proxy) {
|
|
7114
|
+
if (proxy.network === "h3" || ["tuic", "hysteria2", "masque-surge"].includes(proxy.type)) {
|
|
7115
|
+
return;
|
|
7116
|
+
}
|
|
7117
|
+
const value = proxy._surge_client_fingerprint ?? proxy["client-fingerprint"];
|
|
7118
|
+
if (typeof value !== "string") return;
|
|
7119
|
+
let fingerprint = value.trim().toLowerCase();
|
|
7120
|
+
if (!["auto", "none", "apple-26", "chromium-155"].includes(fingerprint)) {
|
|
7121
|
+
const family = fingerprint.replace(/^hello/, "").split(/[-_]/, 1)[0].replace(/([a-z])\d+$/, "$1");
|
|
7122
|
+
if (["chrome", "edge", "android", "360", "qq"].includes(family)) {
|
|
7123
|
+
fingerprint = "chromium-155";
|
|
7124
|
+
} else if (["safari", "ios"].includes(family)) {
|
|
7125
|
+
fingerprint = "apple-26";
|
|
7126
|
+
} else if ([
|
|
7127
|
+
"firefox",
|
|
7128
|
+
"golang",
|
|
7129
|
+
"random",
|
|
7130
|
+
"randomized",
|
|
7131
|
+
"randomizedalpn",
|
|
7132
|
+
"randomizednoalpn"
|
|
7133
|
+
].includes(family)) {
|
|
7134
|
+
fingerprint = "auto";
|
|
7135
|
+
} else {
|
|
7136
|
+
return;
|
|
7137
|
+
}
|
|
7138
|
+
}
|
|
7139
|
+
result.append(`,client-fingerprint=${fingerprint}`);
|
|
7140
|
+
}
|
|
6758
7141
|
function getShadowTLSAlpn(proxy) {
|
|
6759
7142
|
return formatSurgeAlpn(proxy?.["plugin-opts"]?.alpn ?? proxy?.alpn);
|
|
6760
7143
|
}
|
|
@@ -6804,6 +7187,20 @@ function appendTlsProxyParams(result, proxy, enabled = true) {
|
|
|
6804
7187
|
if (isPresent2(proxy, "keystore-client-cert") || isPresent2(proxy, "client-cert")) {
|
|
6805
7188
|
result.append(`,client-cert=${quoteSurgeValue(clientCert)}`);
|
|
6806
7189
|
}
|
|
7190
|
+
appendClientFingerprint(result, proxy);
|
|
7191
|
+
const echOpts = isPlainObject(proxy["ech-opts"]) ? proxy["ech-opts"] : void 0;
|
|
7192
|
+
const echEnabled = echOpts ? isMihomoEchEnabled(echOpts.enable) : isNotBlank(proxy._echConfigList);
|
|
7193
|
+
if (echEnabled && !proxy["reality-opts"]) {
|
|
7194
|
+
const config = normalizeInlineEchConfigList(
|
|
7195
|
+
echOpts ? echOpts.config : proxy._echConfigList
|
|
7196
|
+
);
|
|
7197
|
+
if (!config) {
|
|
7198
|
+
throw unsupported(
|
|
7199
|
+
"Surge ECH requires an inline ECHConfigList in base64 or base64url"
|
|
7200
|
+
);
|
|
7201
|
+
}
|
|
7202
|
+
result.append(`,ech-config=${config}`);
|
|
7203
|
+
}
|
|
6807
7204
|
}
|
|
6808
7205
|
function appendSshPrivateKey(result, proxy) {
|
|
6809
7206
|
const privateKey = isPresent2(proxy, "keystore-private-key") ? proxy["keystore-private-key"] : proxy["private-key"];
|
|
@@ -6827,12 +7224,11 @@ function isUnsupportedSnellV6Obfs(proxy) {
|
|
|
6827
7224
|
}
|
|
6828
7225
|
function Surge_Producer() {
|
|
6829
7226
|
const produce2 = (proxy, type, opts = {}) => {
|
|
6830
|
-
if (
|
|
7227
|
+
if (proxy.network === "ws" && proxy["ws-opts"]?.["v2ray-http-upgrade"] && !["vmess", "trojan", "vless"].includes(proxy.type)) {
|
|
6831
7228
|
throw unsupported(
|
|
6832
7229
|
`Platform ${targetPlatform} does not support network ${proxy.network} with http upgrade`
|
|
6833
7230
|
);
|
|
6834
7231
|
}
|
|
6835
|
-
proxy.name = proxy.name.replace(/=|,/g, "");
|
|
6836
7232
|
if (proxy.ports) {
|
|
6837
7233
|
proxy.ports = String(proxy.ports);
|
|
6838
7234
|
}
|
|
@@ -6842,7 +7238,8 @@ function Surge_Producer() {
|
|
|
6842
7238
|
case "trojan":
|
|
6843
7239
|
return trojan(proxy);
|
|
6844
7240
|
case "vmess":
|
|
6845
|
-
|
|
7241
|
+
case "vless":
|
|
7242
|
+
return v2ray(proxy, opts["include-unsupported-proxy"]);
|
|
6846
7243
|
case "http":
|
|
6847
7244
|
return http(proxy);
|
|
6848
7245
|
case "h2-connect":
|
|
@@ -7052,6 +7449,15 @@ function trusttunnel(proxy) {
|
|
|
7052
7449
|
result.append(`${proxy.name}=trust-tunnel,${proxy.server},${proxy.port}`);
|
|
7053
7450
|
result.appendIfPresent(`,username="${proxy.username}"`, "username");
|
|
7054
7451
|
result.appendIfPresent(`,password="${proxy.password}"`, "password");
|
|
7452
|
+
if (isPresent2(proxy, "client-random-auth-key")) {
|
|
7453
|
+
const key = stripSurgeQuotes(proxy["client-random-auth-key"]);
|
|
7454
|
+
if (typeof key !== "string" || !/^[0-9a-f]+$/i.test(key)) {
|
|
7455
|
+
throw new Error(
|
|
7456
|
+
"TrustTunnel client-random-auth-key must be a hex string"
|
|
7457
|
+
);
|
|
7458
|
+
}
|
|
7459
|
+
result.append(`,client-random-auth-key=${key}`);
|
|
7460
|
+
}
|
|
7055
7461
|
appendHeaders(result, proxy);
|
|
7056
7462
|
warnMaxStreamsIfNeeded(proxy);
|
|
7057
7463
|
result.appendIfPresent(
|
|
@@ -7189,13 +7595,16 @@ function h2Connect(proxy) {
|
|
|
7189
7595
|
);
|
|
7190
7596
|
return result.toString();
|
|
7191
7597
|
}
|
|
7192
|
-
function
|
|
7598
|
+
function v2ray(proxy, includeUnsupportedProxy) {
|
|
7599
|
+
const isVless = proxy.type === "vless";
|
|
7193
7600
|
const result = new Result(proxy);
|
|
7194
7601
|
result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`);
|
|
7195
7602
|
result.appendIfPresent(`,username=${proxy.uuid}`, "uuid");
|
|
7196
|
-
|
|
7197
|
-
|
|
7198
|
-
|
|
7603
|
+
if (!isVless) {
|
|
7604
|
+
const encryptMethod = formatSurgeVmessEncryptMethod(proxy.cipher);
|
|
7605
|
+
if (encryptMethod) {
|
|
7606
|
+
result.append(`,encrypt-method=${encryptMethod}`);
|
|
7607
|
+
}
|
|
7199
7608
|
}
|
|
7200
7609
|
const ip_version = ipVersions[proxy["ip-version"]] || proxy["ip-version"];
|
|
7201
7610
|
result.appendIfPresent(`,ip-version=${ip_version}`, "ip-version");
|
|
@@ -7203,14 +7612,15 @@ function vmess(proxy, includeUnsupportedProxy) {
|
|
|
7203
7612
|
`,no-error-alert=${proxy["no-error-alert"]}`,
|
|
7204
7613
|
"no-error-alert"
|
|
7205
7614
|
);
|
|
7206
|
-
|
|
7207
|
-
|
|
7208
|
-
result.append(`,vmess-aead=${proxy.aead}`);
|
|
7615
|
+
if (isVless) {
|
|
7616
|
+
appendVlessParams(result, proxy);
|
|
7209
7617
|
} else {
|
|
7210
|
-
result
|
|
7618
|
+
handleTransport(result, proxy, includeUnsupportedProxy);
|
|
7619
|
+
const aead = isPresent2(proxy, "aead") ? proxy.aead : proxy.alterId === 0;
|
|
7620
|
+
result.append(`,vmess-aead=${aead}`);
|
|
7621
|
+
result.appendIfPresent(`,tls=${proxy.tls}`, "tls");
|
|
7622
|
+
appendTlsProxyParams(result, proxy, Boolean(proxy.tls));
|
|
7211
7623
|
}
|
|
7212
|
-
result.appendIfPresent(`,tls=${proxy.tls}`, "tls");
|
|
7213
|
-
appendTlsProxyParams(result, proxy, Boolean(proxy.tls));
|
|
7214
7624
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
7215
7625
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
7216
7626
|
result.appendIfPresent(
|
|
@@ -7237,6 +7647,84 @@ function vmess(proxy, includeUnsupportedProxy) {
|
|
|
7237
7647
|
);
|
|
7238
7648
|
return result.toString();
|
|
7239
7649
|
}
|
|
7650
|
+
function appendVlessParams(result, proxy) {
|
|
7651
|
+
const network = proxy.network ?? "tcp";
|
|
7652
|
+
const reality = proxy["reality-opts"];
|
|
7653
|
+
const tls = proxy.tls || reality;
|
|
7654
|
+
const encrypted = isNotBlank(proxy.encryption) && proxy.encryption.trim() !== "none";
|
|
7655
|
+
if (!["tcp", "raw", "none", "ws", "grpc", "xhttp"].includes(network)) {
|
|
7656
|
+
throw unsupported(`VLESS network ${network} is unsupported`);
|
|
7657
|
+
}
|
|
7658
|
+
if (proxy.encryption && /[,\r\n"']/.test(proxy.encryption)) {
|
|
7659
|
+
throw unsupported("VLESS encryption contains unsupported characters");
|
|
7660
|
+
}
|
|
7661
|
+
const supportsVision = network !== "grpc" && (encrypted || tls && network !== "ws" && network !== "xhttp");
|
|
7662
|
+
if (network === "ws" && reality || network === "grpc" && !tls || proxy.flow && !supportsVision) {
|
|
7663
|
+
throw unsupported(
|
|
7664
|
+
"Unsupported VLESS transport, TLS or flow combination"
|
|
7665
|
+
);
|
|
7666
|
+
}
|
|
7667
|
+
if (network === "ws") {
|
|
7668
|
+
handleTransport(result, proxy);
|
|
7669
|
+
} else if (network === "grpc") {
|
|
7670
|
+
result.append(",grpc=true");
|
|
7671
|
+
const grpc = proxy["grpc-opts"];
|
|
7672
|
+
for (const [key, value] of [
|
|
7673
|
+
["grpc-service-name", grpc?.["grpc-service-name"]],
|
|
7674
|
+
["grpc-mode", grpc?.["_grpc-type"]],
|
|
7675
|
+
["grpc-authority", grpc?.["_grpc-authority"]]
|
|
7676
|
+
]) {
|
|
7677
|
+
if (value) result.append(`,${key}=${value}`);
|
|
7678
|
+
}
|
|
7679
|
+
} else if (network === "xhttp") {
|
|
7680
|
+
appendXhttpParams(result, proxy);
|
|
7681
|
+
}
|
|
7682
|
+
if (proxy.flow) result.append(`,flow=${proxy.flow}`);
|
|
7683
|
+
if (proxy.encryption) result.append(`,encryption=${proxy.encryption}`);
|
|
7684
|
+
if (reality) {
|
|
7685
|
+
result.append(`,reality-public-key=${reality["public-key"]}`);
|
|
7686
|
+
if (reality["short-id"]) {
|
|
7687
|
+
result.append(`,reality-short-id=${reality["short-id"]}`);
|
|
7688
|
+
}
|
|
7689
|
+
result.appendIfPresent(`,sni="${proxy.sni}"`, "sni");
|
|
7690
|
+
appendAlpn(result, proxy);
|
|
7691
|
+
appendClientFingerprint(result, proxy);
|
|
7692
|
+
} else {
|
|
7693
|
+
result.appendIfPresent(`,tls=${proxy.tls}`, "tls");
|
|
7694
|
+
appendTlsProxyParams(result, proxy, Boolean(tls));
|
|
7695
|
+
}
|
|
7696
|
+
}
|
|
7697
|
+
function appendXhttpParams(result, proxy) {
|
|
7698
|
+
const xhttp = proxy["xhttp-opts"];
|
|
7699
|
+
if (xhttp?.["download-settings"]) {
|
|
7700
|
+
throw unsupported("VLESS XHTTP download-settings are unsupported");
|
|
7701
|
+
}
|
|
7702
|
+
result.append(",xhttp=true");
|
|
7703
|
+
const headers = isPlainObject(xhttp?.headers) ? Object.entries(xhttp.headers) : [];
|
|
7704
|
+
const host = xhttp?.host ?? headers.find(([key]) => /^host$/i.test(key))?.[1];
|
|
7705
|
+
for (const [key, field] of Object.entries(SURGE_XHTTP_FIELDS)) {
|
|
7706
|
+
const rawValue = key === "host" ? host : _4.get(xhttp, field);
|
|
7707
|
+
if (rawValue == null) continue;
|
|
7708
|
+
const rawText = String(rawValue);
|
|
7709
|
+
const value2 = stripSurgeQuotes(rawText);
|
|
7710
|
+
if (!value2 && key !== "session-table") continue;
|
|
7711
|
+
if (/[\r\n]/.test(rawText) || value2.includes('"')) {
|
|
7712
|
+
throw unsupported(
|
|
7713
|
+
`VLESS xhttp-${key} contains unsupported characters`
|
|
7714
|
+
);
|
|
7715
|
+
}
|
|
7716
|
+
const parameter = !value2 || /[,'\s]/.test(value2) ? quoteSurgeValue(value2) : value2;
|
|
7717
|
+
result.append(`,xhttp-${key}=${parameter}`);
|
|
7718
|
+
}
|
|
7719
|
+
const extraHeaders = headers.filter(([key]) => !/^host$/i.test(key));
|
|
7720
|
+
if (extraHeaders.some(
|
|
7721
|
+
([key, value2]) => /[,="':|\r\n]/.test(key) || /[\r\n]/.test(String(value2))
|
|
7722
|
+
)) {
|
|
7723
|
+
throw unsupported("VLESS xhttp-headers contain unsupported characters");
|
|
7724
|
+
}
|
|
7725
|
+
const value = formatHeaderMap(Object.fromEntries(extraHeaders), "|");
|
|
7726
|
+
if (value) result.append(`,xhttp-headers=${quoteSurgeValue(value)}`);
|
|
7727
|
+
}
|
|
7240
7728
|
function ssh(proxy) {
|
|
7241
7729
|
const result = new Result(proxy);
|
|
7242
7730
|
result.append(`${proxy.name}=ssh,${proxy.server},${proxy.port}`);
|
|
@@ -7722,6 +8210,9 @@ function handleTransport(result, proxy, includeUnsupportedProxy) {
|
|
|
7722
8210
|
if (proxy.network === "ws") {
|
|
7723
8211
|
result.append(`,ws=true`);
|
|
7724
8212
|
if (isPresent2(proxy, "ws-opts")) {
|
|
8213
|
+
if (proxy["ws-opts"]["v2ray-http-upgrade"]) {
|
|
8214
|
+
result.append(",ws-http-upgrade=true");
|
|
8215
|
+
}
|
|
7725
8216
|
result.appendIfPresent(
|
|
7726
8217
|
`,ws-path=${proxy["ws-opts"].path}`,
|
|
7727
8218
|
"ws-opts.path"
|
|
@@ -7752,6 +8243,7 @@ function handleTransport(result, proxy, includeUnsupportedProxy) {
|
|
|
7752
8243
|
import { Base64 as Base643 } from "js-base64";
|
|
7753
8244
|
|
|
7754
8245
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/clashmeta.js
|
|
8246
|
+
var import_buffer2 = __toESM(require_buffer());
|
|
7755
8247
|
var ipVersions2 = {
|
|
7756
8248
|
dual: "dual",
|
|
7757
8249
|
"v4-only": "ipv4",
|
|
@@ -7783,6 +8275,9 @@ function ClashMeta_Producer() {
|
|
|
7783
8275
|
const type = "ALL";
|
|
7784
8276
|
const produce2 = (proxies, type2, opts = {}) => {
|
|
7785
8277
|
const list = proxies.filter((proxy) => {
|
|
8278
|
+
if (!supportsTrustTunnelClientRandomAuth(proxy, "Mihomo")) {
|
|
8279
|
+
return false;
|
|
8280
|
+
}
|
|
7786
8281
|
if (opts["include-unsupported-proxy"]) return true;
|
|
7787
8282
|
if (proxy.type === "h2-connect") {
|
|
7788
8283
|
app_default.error(
|
|
@@ -7804,7 +8299,7 @@ function ClashMeta_Producer() {
|
|
|
7804
8299
|
}
|
|
7805
8300
|
if (!supportsShadowsocksV2rayPluginMode(proxy, ["websocket"])) {
|
|
7806
8301
|
return false;
|
|
7807
|
-
} else if (proxy.type === "snell" && !
|
|
8302
|
+
} else if (proxy.type === "snell" && !supportsMihomoSnell(proxy)) {
|
|
7808
8303
|
return false;
|
|
7809
8304
|
} else if (hasMihomoShadowTls(proxy) && (![
|
|
7810
8305
|
"ss",
|
|
@@ -7922,8 +8417,6 @@ function ClashMeta_Producer() {
|
|
|
7922
8417
|
proxy["pre-shared-key"] = proxy["preshared-key"];
|
|
7923
8418
|
proxy.ip = getWireGuardAddressWithCIDR(proxy, "ipv4");
|
|
7924
8419
|
proxy.ipv6 = getWireGuardAddressWithCIDR(proxy, "ipv6");
|
|
7925
|
-
} else if (proxy.type === "snell" && proxy.version < 3) {
|
|
7926
|
-
delete proxy.udp;
|
|
7927
8420
|
} else if (proxy.type === "vless") {
|
|
7928
8421
|
if (isPresent2(proxy, "sni")) {
|
|
7929
8422
|
proxy.servername = proxy.sni;
|
|
@@ -7945,17 +8438,18 @@ function ClashMeta_Producer() {
|
|
|
7945
8438
|
);
|
|
7946
8439
|
}
|
|
7947
8440
|
if (proxy.type === "snell") {
|
|
8441
|
+
const version = Number(proxy.version ?? 1);
|
|
8442
|
+
if (proxy.version != null && Number.isInteger(version)) {
|
|
8443
|
+
proxy.version = version;
|
|
8444
|
+
}
|
|
8445
|
+
if (version < 3) delete proxy.udp;
|
|
8446
|
+
if (version < 6) delete proxy.mode;
|
|
7948
8447
|
const shadowTLSOpts = getMihomoShadowTlsOpts(proxy);
|
|
7949
8448
|
if (shadowTLSOpts) {
|
|
7950
8449
|
proxy["obfs-opts"] = {
|
|
7951
|
-
|
|
7952
|
-
|
|
7953
|
-
password: shadowTLSOpts.password,
|
|
7954
|
-
version: shadowTLSOpts.version
|
|
8450
|
+
...shadowTLSOpts,
|
|
8451
|
+
mode: "shadow-tls"
|
|
7955
8452
|
};
|
|
7956
|
-
if (shadowTLSOpts.alpn) {
|
|
7957
|
-
proxy["obfs-opts"].alpn = shadowTLSOpts.alpn;
|
|
7958
|
-
}
|
|
7959
8453
|
delete proxy.plugin;
|
|
7960
8454
|
delete proxy["plugin-opts"];
|
|
7961
8455
|
}
|
|
@@ -8069,6 +8563,33 @@ function isSupportedMihomoVersion(version, supportedVersions) {
|
|
|
8069
8563
|
const parsed = Number(normalized);
|
|
8070
8564
|
return Number.isInteger(parsed) && supportedVersions.includes(parsed);
|
|
8071
8565
|
}
|
|
8566
|
+
function supportsMihomoSnell(proxy) {
|
|
8567
|
+
if (!isSupportedMihomoVersion(proxy.version, [0, 1, 2, 3, 4, 5, 6])) {
|
|
8568
|
+
return false;
|
|
8569
|
+
}
|
|
8570
|
+
const isV6 = Number(proxy.version) === 6;
|
|
8571
|
+
const { psk, mode, "obfs-opts": obfsOpts } = proxy;
|
|
8572
|
+
const obfsModes = ["", "shadow-tls", "restls", "jls"];
|
|
8573
|
+
if (!isV6) obfsModes.push("http", "tls");
|
|
8574
|
+
let reason;
|
|
8575
|
+
if (typeof psk !== "string" && !Number.isFinite(psk)) {
|
|
8576
|
+
reason = "missing or invalid PSK";
|
|
8577
|
+
} else if (obfsOpts != null && !isPlainObject(obfsOpts)) {
|
|
8578
|
+
reason = "obfs-opts must be a mapping";
|
|
8579
|
+
} else if (!obfsModes.includes(obfsOpts?.mode ?? "")) {
|
|
8580
|
+
reason = "unsupported obfs-opts.mode";
|
|
8581
|
+
} else if (isV6) {
|
|
8582
|
+
const pskLength = import_buffer2.Buffer.byteLength(String(psk), "utf8");
|
|
8583
|
+
if (pskLength < 12 || pskLength > 255) {
|
|
8584
|
+
reason = "PSK must be 12 to 255 UTF-8 bytes";
|
|
8585
|
+
} else if (!["", "default", "unshaped", "unsafe-raw"].includes(mode ?? "")) {
|
|
8586
|
+
reason = "unsupported mode";
|
|
8587
|
+
}
|
|
8588
|
+
}
|
|
8589
|
+
if (!reason) return true;
|
|
8590
|
+
app_default.error(`Mihomo Snell proxy ${proxy.name} has been filtered. ${reason}.`);
|
|
8591
|
+
return false;
|
|
8592
|
+
}
|
|
8072
8593
|
function hasMihomoShadowTls(proxy) {
|
|
8073
8594
|
return Boolean(getMihomoShadowTlsOpts(proxy));
|
|
8074
8595
|
}
|
|
@@ -8701,10 +9222,12 @@ function Loon_Producer() {
|
|
|
8701
9222
|
return shadowsocks2(proxy);
|
|
8702
9223
|
case "ssr":
|
|
8703
9224
|
return shadowsocksr(proxy);
|
|
9225
|
+
case "snell":
|
|
9226
|
+
return snell2(proxy);
|
|
8704
9227
|
case "trojan":
|
|
8705
9228
|
return trojan2(proxy);
|
|
8706
9229
|
case "vmess":
|
|
8707
|
-
return
|
|
9230
|
+
return vmess(proxy, opts["include-unsupported-proxy"]);
|
|
8708
9231
|
case "vless":
|
|
8709
9232
|
return vless(proxy, opts["include-unsupported-proxy"]);
|
|
8710
9233
|
case "http":
|
|
@@ -8713,6 +9236,8 @@ function Loon_Producer() {
|
|
|
8713
9236
|
return socks52(proxy);
|
|
8714
9237
|
case "wireguard":
|
|
8715
9238
|
return wireguard2(proxy);
|
|
9239
|
+
case "tailscale":
|
|
9240
|
+
return tailscale(proxy);
|
|
8716
9241
|
case "hysteria2":
|
|
8717
9242
|
return hysteria22(proxy);
|
|
8718
9243
|
}
|
|
@@ -8744,6 +9269,40 @@ function appendAlpn2(result, proxy) {
|
|
|
8744
9269
|
const alpn = getLoonAlpn(proxy);
|
|
8745
9270
|
if (alpn) result.append(`,alpn="${alpn}"`);
|
|
8746
9271
|
}
|
|
9272
|
+
function formatLoonValue(value, quoted = false) {
|
|
9273
|
+
const text = String(value);
|
|
9274
|
+
if (/["\r\n]/.test(text)) {
|
|
9275
|
+
throw new Error("Unsupported characters in Loon option");
|
|
9276
|
+
}
|
|
9277
|
+
return quoted || !text || /[,\s]/.test(text) ? `"${text}"` : text;
|
|
9278
|
+
}
|
|
9279
|
+
function appendXhttp(result, proxy) {
|
|
9280
|
+
const xhttp = proxy["xhttp-opts"];
|
|
9281
|
+
if (xhttp?.["download-settings"]) {
|
|
9282
|
+
throw new Error("Loon XHTTP does not support download-settings");
|
|
9283
|
+
}
|
|
9284
|
+
const headers = isPlainObject(xhttp?.headers) ? Object.entries(xhttp.headers) : [];
|
|
9285
|
+
const host = xhttp?.host ?? headers.find(([key]) => /^host$/i.test(key))?.[1];
|
|
9286
|
+
result.append(",transport=xhttp");
|
|
9287
|
+
for (const [key, value] of [
|
|
9288
|
+
["path", xhttp?.path],
|
|
9289
|
+
["host", host]
|
|
9290
|
+
]) {
|
|
9291
|
+
if (value != null) result.append(`,${key}=${formatLoonValue(value)}`);
|
|
9292
|
+
}
|
|
9293
|
+
for (const [key, field] of Object.entries(LOON_XHTTP_FIELDS)) {
|
|
9294
|
+
const value = xhttp?.[field];
|
|
9295
|
+
if (value != null)
|
|
9296
|
+
result.append(`,xhttp-${key}=${formatLoonValue(value)}`);
|
|
9297
|
+
}
|
|
9298
|
+
for (const [key, value] of headers) {
|
|
9299
|
+
if (!/^host$/i.test(key) && value != null) {
|
|
9300
|
+
result.append(
|
|
9301
|
+
`,xhttp-header=${formatLoonValue(`${key}: ${value}`, true)}`
|
|
9302
|
+
);
|
|
9303
|
+
}
|
|
9304
|
+
}
|
|
9305
|
+
}
|
|
8747
9306
|
function getLoonShadowTLSAlpn(proxy) {
|
|
8748
9307
|
const values = proxy?.["plugin-opts"]?.alpn ?? proxy?.alpn;
|
|
8749
9308
|
const normalized = Array.isArray(values) ? values : `${values || ""}`.split(",");
|
|
@@ -8785,14 +9344,26 @@ function getLoonAlpn(proxy) {
|
|
|
8785
9344
|
}
|
|
8786
9345
|
function getLoonTlsProfile(proxy) {
|
|
8787
9346
|
const tlsProfile = `${proxy._loon_tls_profile || ""}`.trim();
|
|
8788
|
-
if ([
|
|
9347
|
+
if ([
|
|
9348
|
+
"global",
|
|
9349
|
+
"default",
|
|
9350
|
+
"safari-ios18",
|
|
9351
|
+
"safari-ios-26",
|
|
9352
|
+
"chrome",
|
|
9353
|
+
"chrome147"
|
|
9354
|
+
].includes(tlsProfile)) {
|
|
8789
9355
|
return tlsProfile;
|
|
8790
9356
|
}
|
|
8791
|
-
|
|
9357
|
+
const fingerprint = `${proxy["client-fingerprint"] || ""}`.trim();
|
|
9358
|
+
if (proxy["reality-opts"]?.["support-x25519mlkem768"]) {
|
|
9359
|
+
return ["safari", "ios"].includes(fingerprint) ? "safari-ios-26" : "chrome147";
|
|
9360
|
+
}
|
|
9361
|
+
switch (fingerprint) {
|
|
8792
9362
|
case "chrome":
|
|
8793
|
-
return "
|
|
9363
|
+
return "chrome";
|
|
9364
|
+
case "safari":
|
|
8794
9365
|
case "ios":
|
|
8795
|
-
return "
|
|
9366
|
+
return "safari-ios18";
|
|
8796
9367
|
}
|
|
8797
9368
|
}
|
|
8798
9369
|
function shadowsocks2(proxy) {
|
|
@@ -8896,8 +9467,46 @@ function shadowsocksr(proxy) {
|
|
|
8896
9467
|
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
8897
9468
|
return result.toString();
|
|
8898
9469
|
}
|
|
9470
|
+
function snell2(proxy) {
|
|
9471
|
+
const version = Number(proxy.version);
|
|
9472
|
+
if (![4, 5].includes(version)) {
|
|
9473
|
+
throw new Error(
|
|
9474
|
+
`Loon does not support Snell version ${proxy.version ?? 1}`
|
|
9475
|
+
);
|
|
9476
|
+
}
|
|
9477
|
+
if (proxy.psk == null || proxy.psk === "") {
|
|
9478
|
+
throw new Error("Missing Snell PSK");
|
|
9479
|
+
}
|
|
9480
|
+
const obfs = proxy["obfs-opts"];
|
|
9481
|
+
if (proxy.plugin || obfs?.mode && !["none", "http"].includes(obfs.mode)) {
|
|
9482
|
+
throw new Error("Loon Snell only supports HTTP obfs");
|
|
9483
|
+
}
|
|
9484
|
+
const result = new Result(proxy);
|
|
9485
|
+
result.append(
|
|
9486
|
+
`${proxy.name}=snell,${proxy.server},${proxy.port},${formatLoonValue(
|
|
9487
|
+
proxy.psk,
|
|
9488
|
+
true
|
|
9489
|
+
)},version=${version}`
|
|
9490
|
+
);
|
|
9491
|
+
if (obfs?.mode === "http") {
|
|
9492
|
+
result.append(",obfs=http");
|
|
9493
|
+
if (obfs.host != null)
|
|
9494
|
+
result.append(`,obfs-host=${formatLoonValue(obfs.host)}`);
|
|
9495
|
+
if (obfs.path != null)
|
|
9496
|
+
result.append(`,obfs-uri=${formatLoonValue(obfs.path)}`);
|
|
9497
|
+
}
|
|
9498
|
+
result.appendIfPresent(`,udp=${proxy.udp}`, "udp");
|
|
9499
|
+
const blockQuic = proxy["block-quic"];
|
|
9500
|
+
if (blockQuic === "on" || blockQuic === "off") {
|
|
9501
|
+
result.append(`,block-quic=${blockQuic === "on"}`);
|
|
9502
|
+
}
|
|
9503
|
+
const ipVersion = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
9504
|
+
result.appendIfPresent(`,ip-mode=${ipVersion}`, "ip-version");
|
|
9505
|
+
return result.toString();
|
|
9506
|
+
}
|
|
8899
9507
|
function trojan2(proxy) {
|
|
8900
9508
|
const isReality = !!proxy["reality-opts"];
|
|
9509
|
+
const isXhttp = proxy.network === "xhttp";
|
|
8901
9510
|
const result = new Result(proxy);
|
|
8902
9511
|
result.append(
|
|
8903
9512
|
`${proxy.name}=trojan,${proxy.server},${proxy.port},"${proxy.password}"`
|
|
@@ -8916,6 +9525,8 @@ function trojan2(proxy) {
|
|
|
8916
9525
|
`,host=${proxy["ws-opts"]?.headers?.Host}`,
|
|
8917
9526
|
"ws-opts.headers.Host"
|
|
8918
9527
|
);
|
|
9528
|
+
} else if (isXhttp) {
|
|
9529
|
+
appendXhttp(result, proxy);
|
|
8919
9530
|
} else {
|
|
8920
9531
|
throw new Error(`network ${proxy.network} is unsupported`);
|
|
8921
9532
|
}
|
|
@@ -8929,7 +9540,10 @@ function trojan2(proxy) {
|
|
|
8929
9540
|
if (isReality) {
|
|
8930
9541
|
appendReality(result, proxy);
|
|
8931
9542
|
} else {
|
|
8932
|
-
result.appendIfPresent(
|
|
9543
|
+
result.appendIfPresent(
|
|
9544
|
+
`,${isXhttp ? "sni" : "tls-name"}=${proxy.sni}`,
|
|
9545
|
+
"sni"
|
|
9546
|
+
);
|
|
8933
9547
|
result.appendIfPresent(
|
|
8934
9548
|
`,tls-cert-sha256=${proxy["tls-fingerprint"]}`,
|
|
8935
9549
|
"tls-fingerprint"
|
|
@@ -9000,8 +9614,9 @@ function anytls2(proxy) {
|
|
|
9000
9614
|
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
9001
9615
|
return result.toString();
|
|
9002
9616
|
}
|
|
9003
|
-
function
|
|
9617
|
+
function vmess(proxy) {
|
|
9004
9618
|
const isReality = !!proxy["reality-opts"];
|
|
9619
|
+
const isXhttp = proxy.network === "xhttp";
|
|
9005
9620
|
const security = formatLoonVmessSecurity(proxy.cipher);
|
|
9006
9621
|
const result = new Result(proxy);
|
|
9007
9622
|
result.append(
|
|
@@ -9033,6 +9648,8 @@ function vmess2(proxy) {
|
|
|
9033
9648
|
`,host=${Array.isArray(httpHost) ? httpHost[0] : httpHost}`,
|
|
9034
9649
|
"http-opts.headers.Host"
|
|
9035
9650
|
);
|
|
9651
|
+
} else if (isXhttp) {
|
|
9652
|
+
appendXhttp(result, proxy);
|
|
9036
9653
|
} else {
|
|
9037
9654
|
throw new Error(`network ${proxy.network} is unsupported`);
|
|
9038
9655
|
}
|
|
@@ -9044,14 +9661,15 @@ function vmess2(proxy) {
|
|
|
9044
9661
|
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
9045
9662
|
"skip-cert-verify"
|
|
9046
9663
|
);
|
|
9047
|
-
if (proxy.tls || isReality)
|
|
9048
|
-
|
|
9049
|
-
appendAlpn2(result, proxy);
|
|
9050
|
-
}
|
|
9664
|
+
if (proxy.tls || isReality) appendTlsProfile(result, proxy);
|
|
9665
|
+
if (proxy.tls || isReality || isXhttp) appendAlpn2(result, proxy);
|
|
9051
9666
|
if (isReality) {
|
|
9052
9667
|
appendReality(result, proxy);
|
|
9053
9668
|
} else {
|
|
9054
|
-
result.appendIfPresent(
|
|
9669
|
+
result.appendIfPresent(
|
|
9670
|
+
`,${isXhttp ? "sni" : "tls-name"}=${proxy.sni}`,
|
|
9671
|
+
"sni"
|
|
9672
|
+
);
|
|
9055
9673
|
result.appendIfPresent(
|
|
9056
9674
|
`,tls-cert-sha256=${proxy["tls-fingerprint"]}`,
|
|
9057
9675
|
"tls-fingerprint"
|
|
@@ -9061,11 +9679,13 @@ function vmess2(proxy) {
|
|
|
9061
9679
|
"tls-pubkey-sha256"
|
|
9062
9680
|
);
|
|
9063
9681
|
}
|
|
9064
|
-
|
|
9065
|
-
|
|
9066
|
-
|
|
9067
|
-
|
|
9682
|
+
let alterId = proxy.alterId;
|
|
9683
|
+
if (isPresent2(proxy, "aead")) alterId = proxy.aead ? 0 : 1;
|
|
9684
|
+
if (isXhttp) {
|
|
9685
|
+
alterId ??= 0;
|
|
9686
|
+
if (Number(alterId) !== 0) throw new Error("VMess XHTTP requires AEAD");
|
|
9068
9687
|
}
|
|
9688
|
+
result.append(`,alterId=${alterId}`);
|
|
9069
9689
|
result.appendIfPresent(`,fast-open=${proxy.tfo}`, "tfo");
|
|
9070
9690
|
if (proxy["block-quic"] === "on") {
|
|
9071
9691
|
result.append(",block-quic=true");
|
|
@@ -9084,7 +9704,10 @@ function vless(proxy) {
|
|
|
9084
9704
|
throw new Error(`VLESS encryption is not supported`);
|
|
9085
9705
|
let isXtls = false;
|
|
9086
9706
|
const isReality = !!proxy["reality-opts"];
|
|
9087
|
-
|
|
9707
|
+
const isXhttp = proxy.network === "xhttp";
|
|
9708
|
+
if (isXhttp && proxy.flow)
|
|
9709
|
+
throw new Error("VLESS XHTTP does not support flow");
|
|
9710
|
+
if (!isXhttp && typeof proxy.flow !== "undefined") {
|
|
9088
9711
|
if (["xtls-rprx-vision"].includes(proxy.flow)) {
|
|
9089
9712
|
isXtls = true;
|
|
9090
9713
|
} else {
|
|
@@ -9121,6 +9744,8 @@ function vless(proxy) {
|
|
|
9121
9744
|
`,host=${Array.isArray(httpHost) ? httpHost[0] : httpHost}`,
|
|
9122
9745
|
"http-opts.headers.Host"
|
|
9123
9746
|
);
|
|
9747
|
+
} else if (isXhttp) {
|
|
9748
|
+
appendXhttp(result, proxy);
|
|
9124
9749
|
} else {
|
|
9125
9750
|
throw new Error(`network ${proxy.network} is unsupported`);
|
|
9126
9751
|
}
|
|
@@ -9132,17 +9757,18 @@ function vless(proxy) {
|
|
|
9132
9757
|
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
9133
9758
|
"skip-cert-verify"
|
|
9134
9759
|
);
|
|
9135
|
-
if (proxy.tls || isReality || isXtls)
|
|
9136
|
-
|
|
9137
|
-
appendAlpn2(result, proxy);
|
|
9138
|
-
}
|
|
9760
|
+
if (proxy.tls || isReality || isXtls) appendTlsProfile(result, proxy);
|
|
9761
|
+
if (proxy.tls || isReality || isXtls || isXhttp) appendAlpn2(result, proxy);
|
|
9139
9762
|
if (isXtls) {
|
|
9140
9763
|
result.appendIfPresent(`,flow=${proxy.flow}`, "flow");
|
|
9141
9764
|
}
|
|
9142
9765
|
if (isReality) {
|
|
9143
9766
|
appendReality(result, proxy);
|
|
9144
9767
|
} else {
|
|
9145
|
-
result.appendIfPresent(
|
|
9768
|
+
result.appendIfPresent(
|
|
9769
|
+
`,${isXhttp ? "sni" : "tls-name"}=${proxy.sni}`,
|
|
9770
|
+
"sni"
|
|
9771
|
+
);
|
|
9146
9772
|
result.appendIfPresent(
|
|
9147
9773
|
`,tls-cert-sha256=${proxy["tls-fingerprint"]}`,
|
|
9148
9774
|
"tls-fingerprint"
|
|
@@ -9218,6 +9844,42 @@ function socks52(proxy) {
|
|
|
9218
9844
|
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
9219
9845
|
return result.toString();
|
|
9220
9846
|
}
|
|
9847
|
+
function tailscale(proxy) {
|
|
9848
|
+
const result = new Result(proxy);
|
|
9849
|
+
result.append(`${proxy.name}=tailscale`);
|
|
9850
|
+
let exitNode = proxy["exit-node"];
|
|
9851
|
+
if (exitNode === "auto:any") exitNode = "auto";
|
|
9852
|
+
if (exitNode === "") exitNode = "none";
|
|
9853
|
+
const stringOptions = {
|
|
9854
|
+
"control-url": proxy["control-url"],
|
|
9855
|
+
"auth-key": proxy["auth-key"],
|
|
9856
|
+
hostname: proxy.hostname,
|
|
9857
|
+
"exit-node": exitNode
|
|
9858
|
+
};
|
|
9859
|
+
for (const [key, value] of Object.entries(stringOptions)) {
|
|
9860
|
+
if (!value) continue;
|
|
9861
|
+
const quoted = key === "control-url" || key === "auth-key" || /[,\s]/.test(value);
|
|
9862
|
+
result.append(`,${key}=${quoted ? `"${value}"` : value}`);
|
|
9863
|
+
}
|
|
9864
|
+
for (const key of [
|
|
9865
|
+
"accept-routes",
|
|
9866
|
+
"accept-dns",
|
|
9867
|
+
"magic-dns",
|
|
9868
|
+
"path-mode",
|
|
9869
|
+
"mtu",
|
|
9870
|
+
"idle-session-timeout",
|
|
9871
|
+
"udp"
|
|
9872
|
+
]) {
|
|
9873
|
+
result.appendIfPresent(`,${key}=${proxy[key]}`, key);
|
|
9874
|
+
}
|
|
9875
|
+
const ipVersion = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
|
|
9876
|
+
result.appendIfPresent(`,ip-mode=${ipVersion}`, "ip-version");
|
|
9877
|
+
const blockQuic = proxy["block-quic"];
|
|
9878
|
+
if (blockQuic === "on" || blockQuic === "off") {
|
|
9879
|
+
result.append(`,block-quic=${blockQuic === "on"}`);
|
|
9880
|
+
}
|
|
9881
|
+
return result.toString();
|
|
9882
|
+
}
|
|
9221
9883
|
function wireguard2(proxy) {
|
|
9222
9884
|
if (Array.isArray(proxy.peers) && proxy.peers.length > 0) {
|
|
9223
9885
|
proxy.server = proxy.peers[0].server;
|
|
@@ -10010,6 +10672,7 @@ function URI_Producer() {
|
|
|
10010
10672
|
if (proxy.tfo) {
|
|
10011
10673
|
query += "&tfo=1";
|
|
10012
10674
|
}
|
|
10675
|
+
query += `&udp=${proxy.udp ? 1 : 0}`;
|
|
10013
10676
|
let ssTransport = "";
|
|
10014
10677
|
if (proxy.network) {
|
|
10015
10678
|
let ssType = proxy.network;
|
|
@@ -10081,7 +10744,7 @@ function URI_Producer() {
|
|
|
10081
10744
|
let ssSpx = "";
|
|
10082
10745
|
let ssSecurity = proxy.tls ? "&security=tls" : "";
|
|
10083
10746
|
let ssMode = "";
|
|
10084
|
-
|
|
10747
|
+
const ssExtra = proxy._extra && (ssIsReality || proxy.network === "xhttp") ? `&extra=${encodeURIComponent(proxy._extra)}` : "";
|
|
10085
10748
|
if (ssIsReality) {
|
|
10086
10749
|
ssSecurity = `&security=reality`;
|
|
10087
10750
|
const publicKey = proxy["reality-opts"]?.["public-key"];
|
|
@@ -10096,9 +10759,6 @@ function URI_Producer() {
|
|
|
10096
10759
|
if (spiderX) {
|
|
10097
10760
|
ssSpx = `&spx=${encodeURIComponent(spiderX)}`;
|
|
10098
10761
|
}
|
|
10099
|
-
if (proxy._extra) {
|
|
10100
|
-
ssExtra = `&extra=${encodeURIComponent(proxy._extra)}`;
|
|
10101
|
-
}
|
|
10102
10762
|
if (proxy._mode) {
|
|
10103
10763
|
ssMode = `&mode=${encodeURIComponent(proxy._mode)}`;
|
|
10104
10764
|
}
|
|
@@ -10194,7 +10854,7 @@ function URI_Producer() {
|
|
|
10194
10854
|
result.path = vmessTransportPath;
|
|
10195
10855
|
}
|
|
10196
10856
|
if (vmessTransportHost) {
|
|
10197
|
-
result.host = Array.isArray(vmessTransportHost) ? vmessTransportHost[0] : vmessTransportHost;
|
|
10857
|
+
result.host = Array.isArray(vmessTransportHost) ? proxy.network === "h2" ? vmessTransportHost.join(",") : vmessTransportHost[0] : vmessTransportHost;
|
|
10198
10858
|
}
|
|
10199
10859
|
}
|
|
10200
10860
|
}
|
|
@@ -10310,7 +10970,9 @@ function URI_Producer() {
|
|
|
10310
10970
|
trojanMode = `&mode=${encodeURIComponent(proxy._mode)}`;
|
|
10311
10971
|
}
|
|
10312
10972
|
}
|
|
10313
|
-
result = `trojan://${proxy.password}@${proxy.server}:${proxy.port}?sni=${encodeURIComponent(
|
|
10973
|
+
result = `trojan://${encodeURIComponent(proxy.password)}@${proxy.server}:${proxy.port}?sni=${encodeURIComponent(
|
|
10974
|
+
proxy.sni || proxy.server
|
|
10975
|
+
)}${proxy["skip-cert-verify"] ? "&allowInsecure=1" : ""}${trojanTransport}${trojanAlpn}${trojanFp}${trojanPcs}${trojanVcn}${trojanSecurity}${trojanSid}${trojanPbk}${trojanSpx}${trojanMode}${trojanExtra}#${encodeURIComponent(
|
|
10314
10976
|
proxy.name
|
|
10315
10977
|
)}`;
|
|
10316
10978
|
break;
|
|
@@ -10471,7 +11133,8 @@ function URI_Producer() {
|
|
|
10471
11133
|
case "anytls":
|
|
10472
11134
|
result = vless2({
|
|
10473
11135
|
...proxy,
|
|
10474
|
-
uuid
|
|
11136
|
+
// vless() writes the uuid as is; a password may contain @, :, # etc.
|
|
11137
|
+
uuid: encodeURIComponent(proxy.password),
|
|
10475
11138
|
network: proxy.network || "tcp"
|
|
10476
11139
|
}).replace("vless", "anytls");
|
|
10477
11140
|
let anytlsParams = [];
|
|
@@ -10621,12 +11284,12 @@ Reason: ${err}`);
|
|
|
10621
11284
|
}
|
|
10622
11285
|
|
|
10623
11286
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/qx.js
|
|
10624
|
-
var
|
|
11287
|
+
var import_buffer3 = __toESM(require_buffer());
|
|
10625
11288
|
var targetPlatform4 = "QX";
|
|
10626
11289
|
function encodeQxAlpn(alpn) {
|
|
10627
11290
|
const protocols = (Array.isArray(alpn) ? alpn : `${alpn}`.split(",")).map((protocol) => `${protocol}`.trim()).filter(Boolean);
|
|
10628
11291
|
return protocols.map((protocol) => {
|
|
10629
|
-
const bytes =
|
|
11292
|
+
const bytes = import_buffer3.Buffer.from(protocol, "utf8");
|
|
10630
11293
|
if (bytes.length > 255) {
|
|
10631
11294
|
throw new Error("QX ALPN protocol exceeds 255 bytes");
|
|
10632
11295
|
}
|
|
@@ -10656,7 +11319,7 @@ function QX_Producer() {
|
|
|
10656
11319
|
case "trojan":
|
|
10657
11320
|
return trojan3(proxy);
|
|
10658
11321
|
case "vmess":
|
|
10659
|
-
return
|
|
11322
|
+
return vmess2(proxy);
|
|
10660
11323
|
case "http":
|
|
10661
11324
|
return http3(proxy);
|
|
10662
11325
|
case "socks5":
|
|
@@ -10665,6 +11328,8 @@ function QX_Producer() {
|
|
|
10665
11328
|
return vless3(proxy);
|
|
10666
11329
|
case "anytls":
|
|
10667
11330
|
return anytls3(proxy);
|
|
11331
|
+
case "hysteria2":
|
|
11332
|
+
return hysteria23(proxy);
|
|
10668
11333
|
}
|
|
10669
11334
|
throw new Error(
|
|
10670
11335
|
`Platform ${targetPlatform4} does not support proxy type: ${proxy.type}`
|
|
@@ -10774,7 +11439,7 @@ function shadowsocks3(proxy) {
|
|
|
10774
11439
|
"plugin-opts.path"
|
|
10775
11440
|
);
|
|
10776
11441
|
}
|
|
10777
|
-
if (needTls(proxy)) {
|
|
11442
|
+
if (needTls(proxy) || proxy.plugin === "v2ray-plugin" && proxy["plugin-opts"]?.tls) {
|
|
10778
11443
|
appendIfPresent(
|
|
10779
11444
|
`,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
|
|
10780
11445
|
"tls-pubkey-sha256"
|
|
@@ -10893,7 +11558,7 @@ function trojan3(proxy) {
|
|
|
10893
11558
|
append(`,tag=${proxy.name}`);
|
|
10894
11559
|
return result.toString();
|
|
10895
11560
|
}
|
|
10896
|
-
function
|
|
11561
|
+
function vmess2(proxy) {
|
|
10897
11562
|
const result = new Result(proxy);
|
|
10898
11563
|
const append = result.append.bind(result);
|
|
10899
11564
|
const appendIfPresent = result.appendIfPresent.bind(result);
|
|
@@ -11073,6 +11738,52 @@ function anytls3(proxy) {
|
|
|
11073
11738
|
append(`,tag=${proxy.name}`);
|
|
11074
11739
|
return result.toString();
|
|
11075
11740
|
}
|
|
11741
|
+
function hysteria23(proxy) {
|
|
11742
|
+
if (proxy.obfs && proxy.obfs !== "salamander") {
|
|
11743
|
+
throw new Error("QX Hysteria 2 only supports Salamander obfuscation");
|
|
11744
|
+
}
|
|
11745
|
+
const result = new Result(proxy);
|
|
11746
|
+
result.append(`hysteria2=${proxy.server}:${proxy.port}`);
|
|
11747
|
+
result.appendIfPresent(`,password=${proxy.password}`, "password");
|
|
11748
|
+
const ports = String(proxy.ports || "").trim();
|
|
11749
|
+
if (ports) result.append(`,port-hopping=${ports.replace(/;/g, ",")}`);
|
|
11750
|
+
const interval = Number(proxy["hop-interval"]);
|
|
11751
|
+
if (Number.isInteger(interval) && interval >= 5 && interval <= 3600) {
|
|
11752
|
+
result.append(`,port-hopping-interval=${interval}`);
|
|
11753
|
+
}
|
|
11754
|
+
result.appendIfPresent(
|
|
11755
|
+
`,salamander-password=${proxy["obfs-password"]}`,
|
|
11756
|
+
"obfs-password"
|
|
11757
|
+
);
|
|
11758
|
+
result.appendIfPresent(`,tls-host=${proxy.sni}`, "sni");
|
|
11759
|
+
result.appendIfPresent(
|
|
11760
|
+
`,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
|
|
11761
|
+
"tls-pubkey-sha256"
|
|
11762
|
+
);
|
|
11763
|
+
appendTlsAlpn(result, proxy);
|
|
11764
|
+
result.appendIfPresent(
|
|
11765
|
+
`,tls-no-session-ticket=${proxy["tls-no-session-ticket"]}`,
|
|
11766
|
+
"tls-no-session-ticket"
|
|
11767
|
+
);
|
|
11768
|
+
result.appendIfPresent(
|
|
11769
|
+
`,tls-no-session-reuse=${proxy["tls-no-session-reuse"]}`,
|
|
11770
|
+
"tls-no-session-reuse"
|
|
11771
|
+
);
|
|
11772
|
+
result.appendIfPresent(
|
|
11773
|
+
`,tls-cert-sha256=${proxy["tls-fingerprint"]}`,
|
|
11774
|
+
"tls-fingerprint"
|
|
11775
|
+
);
|
|
11776
|
+
appendTlsVerification(result, proxy);
|
|
11777
|
+
const bandwidth = String(proxy.down).match(/^\s*(\d+)/)?.[1];
|
|
11778
|
+
if (bandwidth) result.append(`,download-bandwidth=${bandwidth}`);
|
|
11779
|
+
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
11780
|
+
result.appendIfPresent(
|
|
11781
|
+
`,server_check_url=${proxy["test-url"]}`,
|
|
11782
|
+
"test-url"
|
|
11783
|
+
);
|
|
11784
|
+
result.append(`,tag=${proxy.name}`);
|
|
11785
|
+
return result.toString();
|
|
11786
|
+
}
|
|
11076
11787
|
function http3(proxy) {
|
|
11077
11788
|
const result = new Result(proxy);
|
|
11078
11789
|
const append = result.append.bind(result);
|
|
@@ -11399,24 +12110,23 @@ function Surfboard_Producer() {
|
|
|
11399
12110
|
`Platform ${targetPlatform5} does not support network ${proxy.network} with http upgrade`
|
|
11400
12111
|
);
|
|
11401
12112
|
}
|
|
11402
|
-
proxy.name = proxy.name.replace(/=|,/g, "");
|
|
11403
12113
|
switch (proxy.type) {
|
|
11404
12114
|
case "ss":
|
|
11405
12115
|
return shadowsocks4(proxy);
|
|
11406
12116
|
case "trojan":
|
|
11407
12117
|
return trojan4(proxy);
|
|
11408
12118
|
case "vmess":
|
|
11409
|
-
return
|
|
12119
|
+
return vmess3(proxy);
|
|
11410
12120
|
case "http":
|
|
11411
12121
|
return http4(proxy);
|
|
11412
12122
|
case "snell":
|
|
11413
|
-
return
|
|
12123
|
+
return snell3(proxy);
|
|
11414
12124
|
case "tuic":
|
|
11415
12125
|
return tuic2(proxy);
|
|
11416
12126
|
case "socks5":
|
|
11417
12127
|
return socks54(proxy);
|
|
11418
12128
|
case "hysteria2":
|
|
11419
|
-
return
|
|
12129
|
+
return hysteria24(proxy);
|
|
11420
12130
|
case "wireguard-surge":
|
|
11421
12131
|
return wireguard3(proxy);
|
|
11422
12132
|
}
|
|
@@ -11461,7 +12171,7 @@ function tuic2(proxy) {
|
|
|
11461
12171
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
11462
12172
|
return result.toString();
|
|
11463
12173
|
}
|
|
11464
|
-
function
|
|
12174
|
+
function hysteria24(proxy) {
|
|
11465
12175
|
if (proxy.obfs && proxy.obfs !== "salamander" || proxy["obfs-password"] && proxy.obfs !== "salamander") {
|
|
11466
12176
|
throw new Error(`Surfboard Hysteria2 only supports salamander obfs`);
|
|
11467
12177
|
}
|
|
@@ -11499,7 +12209,7 @@ function anytls4(proxy) {
|
|
|
11499
12209
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
11500
12210
|
return result.toString();
|
|
11501
12211
|
}
|
|
11502
|
-
function
|
|
12212
|
+
function snell3(proxy) {
|
|
11503
12213
|
if (isPresent2(proxy, "version") && ![1, 2, 3, 4, 5].includes(Number(proxy.version))) {
|
|
11504
12214
|
throw new Error(
|
|
11505
12215
|
`Platform ${targetPlatform5} does not support snell version ${proxy.version}`
|
|
@@ -11590,7 +12300,7 @@ function trojan4(proxy) {
|
|
|
11590
12300
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
11591
12301
|
return result.toString();
|
|
11592
12302
|
}
|
|
11593
|
-
function
|
|
12303
|
+
function vmess3(proxy) {
|
|
11594
12304
|
const result = new Result(proxy);
|
|
11595
12305
|
result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`);
|
|
11596
12306
|
result.appendIfPresent(`,username=${proxy.uuid}`, "uuid");
|
|
@@ -11670,6 +12380,7 @@ function handleTransport2(result, proxy) {
|
|
|
11670
12380
|
}
|
|
11671
12381
|
|
|
11672
12382
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/sing-box.js
|
|
12383
|
+
var import_buffer4 = __toESM(require_buffer());
|
|
11673
12384
|
var ipVersions4 = {
|
|
11674
12385
|
ipv4: "ipv4_only",
|
|
11675
12386
|
ipv6: "ipv6_only",
|
|
@@ -11956,6 +12667,41 @@ var getSingBoxUtlsFingerprint = (value) => {
|
|
|
11956
12667
|
const fingerprint = `${value || ""}`.trim().toLowerCase();
|
|
11957
12668
|
if (singBoxUtlsFingerprints.includes(fingerprint)) return fingerprint;
|
|
11958
12669
|
};
|
|
12670
|
+
var tlsCertificateParser = (proxy, parsedProxy) => {
|
|
12671
|
+
const tls = parsedProxy.tls;
|
|
12672
|
+
if (proxy.ca) tls.certificate_path = `${proxy.ca}`;
|
|
12673
|
+
if (proxy.ca_str) tls.certificate = [proxy.ca_str];
|
|
12674
|
+
if (proxy["ca-str"]) tls.certificate = [proxy["ca-str"]];
|
|
12675
|
+
if (proxy._certificate) tls.certificate = proxy._certificate;
|
|
12676
|
+
if (proxy._certificate_path) tls.certificate_path = proxy._certificate_path;
|
|
12677
|
+
if (tls.reality?.enabled) {
|
|
12678
|
+
if (proxy._certificate_sha256?.length || proxy._certificate_public_key_sha256?.length) {
|
|
12679
|
+
app_default.warn(
|
|
12680
|
+
`Platform sing-box: certificate_sha256 and certificate_public_key_sha256 are ignored by Reality for proxy ${proxy.name}`
|
|
12681
|
+
);
|
|
12682
|
+
}
|
|
12683
|
+
return;
|
|
12684
|
+
}
|
|
12685
|
+
if (proxy._certificate_public_key_sha256)
|
|
12686
|
+
tls.certificate_public_key_sha256 = proxy._certificate_public_key_sha256;
|
|
12687
|
+
const hasCertificate = tls.certificate?.length || tls.certificate_path;
|
|
12688
|
+
if (proxy._certificate_sha256 != null) {
|
|
12689
|
+
tls.certificate_sha256 = proxy._certificate_sha256;
|
|
12690
|
+
} else if ((proxy.fingerprint || proxy["tls-fingerprint"]) && !hasCertificate && !tls.certificate_public_key_sha256?.length) {
|
|
12691
|
+
const hex = `${proxy.fingerprint || proxy["tls-fingerprint"]}`.trim().replace(/:/g, "");
|
|
12692
|
+
if (!/^[0-9a-f]{64}$/i.test(hex)) {
|
|
12693
|
+
throw new Error(
|
|
12694
|
+
`Platform sing-box: invalid SHA-256 certificate fingerprint for proxy ${proxy.name}`
|
|
12695
|
+
);
|
|
12696
|
+
}
|
|
12697
|
+
tls.certificate_sha256 = [import_buffer4.Buffer.from(hex, "hex").toString("base64")];
|
|
12698
|
+
}
|
|
12699
|
+
if (hasCertificate && (tls.certificate_sha256?.length || tls.certificate_public_key_sha256?.length)) {
|
|
12700
|
+
throw new Error(
|
|
12701
|
+
`Platform sing-box: certificate_sha256 or certificate_public_key_sha256 conflicts with certificate or certificate_path for proxy ${proxy.name}`
|
|
12702
|
+
);
|
|
12703
|
+
}
|
|
12704
|
+
};
|
|
11959
12705
|
var tlsParser = (proxy, parsedProxy) => {
|
|
11960
12706
|
if (proxy.tls) parsedProxy.tls.enabled = true;
|
|
11961
12707
|
if (proxy.servername && proxy.servername !== "")
|
|
@@ -11969,9 +12715,6 @@ var tlsParser = (proxy, parsedProxy) => {
|
|
|
11969
12715
|
if (typeof proxy.alpn === "string") {
|
|
11970
12716
|
parsedProxy.tls.alpn = [proxy.alpn];
|
|
11971
12717
|
} else if (Array.isArray(proxy.alpn)) parsedProxy.tls.alpn = proxy.alpn;
|
|
11972
|
-
if (proxy.ca) parsedProxy.tls.certificate_path = `${proxy.ca}`;
|
|
11973
|
-
if (proxy.ca_str) parsedProxy.tls.certificate = [proxy.ca_str];
|
|
11974
|
-
if (proxy["ca-str"]) parsedProxy.tls.certificate = [proxy["ca-str"]];
|
|
11975
12718
|
if (proxy["reality-opts"]) {
|
|
11976
12719
|
parsedProxy.tls.reality = { enabled: true };
|
|
11977
12720
|
if (proxy["reality-opts"]["public-key"])
|
|
@@ -12015,12 +12758,6 @@ var tlsParser = (proxy, parsedProxy) => {
|
|
|
12015
12758
|
parsedProxy.tls.fragment_fallback_delay = proxy["_fragment_fallback_delay"];
|
|
12016
12759
|
if (proxy["_record_fragment"])
|
|
12017
12760
|
parsedProxy.tls.record_fragment = !!proxy["_record_fragment"];
|
|
12018
|
-
if (proxy["_certificate"])
|
|
12019
|
-
parsedProxy.tls.certificate = proxy["_certificate"];
|
|
12020
|
-
if (proxy["_certificate_path"])
|
|
12021
|
-
parsedProxy.tls.certificate_path = proxy["_certificate_path"];
|
|
12022
|
-
if (proxy["_certificate_public_key_sha256"])
|
|
12023
|
-
parsedProxy.tls.certificate_public_key_sha256 = proxy["_certificate_public_key_sha256"];
|
|
12024
12761
|
if (proxy["_client_certificate"])
|
|
12025
12762
|
parsedProxy.tls.client_certificate = proxy["_client_certificate"];
|
|
12026
12763
|
if (proxy["_client_certificate_path"])
|
|
@@ -12030,11 +12767,7 @@ var tlsParser = (proxy, parsedProxy) => {
|
|
|
12030
12767
|
parsedProxy.tls.client_key_path = proxy["_client_key_path"];
|
|
12031
12768
|
if (!parsedProxy.tls.enabled) {
|
|
12032
12769
|
delete parsedProxy.tls;
|
|
12033
|
-
} else
|
|
12034
|
-
app_default.warn(
|
|
12035
|
-
`Platform sing-box does not support certificate fingerprint pinning, it is dropped for proxy ${proxy.name}. Set _certificate_public_key_sha256 to pin the certificate public key instead`
|
|
12036
|
-
);
|
|
12037
|
-
}
|
|
12770
|
+
} else tlsCertificateParser(proxy, parsedProxy);
|
|
12038
12771
|
};
|
|
12039
12772
|
var sshParser = (proxy = {}) => {
|
|
12040
12773
|
const parsedProxy = {
|
|
@@ -12047,9 +12780,10 @@ var sshParser = (proxy = {}) => {
|
|
|
12047
12780
|
throw "invalid port";
|
|
12048
12781
|
if (proxy.username) parsedProxy.user = proxy.username;
|
|
12049
12782
|
if (proxy.password) parsedProxy.password = proxy.password;
|
|
12050
|
-
|
|
12051
|
-
if (
|
|
12052
|
-
parsedProxy.
|
|
12783
|
+
const privateKey = proxy["private-key"] || proxy.privateKey;
|
|
12784
|
+
if (privateKey) {
|
|
12785
|
+
parsedProxy[privateKey.includes("PRIVATE KEY") ? "private_key" : "private_key_path"] = privateKey;
|
|
12786
|
+
}
|
|
12053
12787
|
if (proxy["private-key-passphrase"])
|
|
12054
12788
|
parsedProxy.private_key_passphrase = proxy["private-key-passphrase"];
|
|
12055
12789
|
if (proxy["server-fingerprint"]) {
|
|
@@ -12195,6 +12929,7 @@ var shadowTLSOutboundParser = (proxy = {}, pluginOpts) => {
|
|
|
12195
12929
|
throw "\u7AEF\u53E3\u503C\u975E\u6CD5";
|
|
12196
12930
|
const alpn = normalizeALPN(pluginOpts.alpn) ?? normalizeALPN(proxy.alpn);
|
|
12197
12931
|
if (alpn) stPart.tls.alpn = alpn;
|
|
12932
|
+
tlsCertificateParser(proxy, stPart);
|
|
12198
12933
|
if (proxy["fast-open"] === true) stPart.udp_fragment = true;
|
|
12199
12934
|
tfoParser(proxy, stPart);
|
|
12200
12935
|
detourParser(proxy, stPart);
|
|
@@ -12338,7 +13073,8 @@ var snellParser = (proxy = {}, includeUnsupportedProxy = false) => {
|
|
|
12338
13073
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
12339
13074
|
throw "invalid port";
|
|
12340
13075
|
if (outputVersion != null) parsedProxy.version = outputVersion;
|
|
12341
|
-
if (proxy.
|
|
13076
|
+
if (proxy.userkey || proxy._userkey)
|
|
13077
|
+
parsedProxy.userkey = proxy.userkey || proxy._userkey;
|
|
12342
13078
|
if (outputVersion === 6) {
|
|
12343
13079
|
if (proxy.mode) parsedProxy.mode = proxy.mode;
|
|
12344
13080
|
if (includeUnsupportedProxy && proxy["quic-proxy-mode"])
|
|
@@ -12699,9 +13435,13 @@ var anytlsParser = (proxy = {}, includeUnsupportedProxy = false) => {
|
|
|
12699
13435
|
};
|
|
12700
13436
|
var tailscaleParser = (proxy = {}) => {
|
|
12701
13437
|
const useControlHTTPClient = hasControlHTTPClient(proxy);
|
|
13438
|
+
const listenPort = parseSafeIntegerValue(proxy._listen_port);
|
|
12702
13439
|
const parsedProxy = {
|
|
12703
13440
|
tag: proxy.name,
|
|
12704
13441
|
type: "tailscale",
|
|
13442
|
+
listen_port: listenPort != null && listenPort <= 65535 ? listenPort : void 0,
|
|
13443
|
+
taildrop_directory: typeof proxy._taildrop_directory === "string" ? proxy._taildrop_directory : void 0,
|
|
13444
|
+
on_demand: typeof proxy._on_demand === "boolean" ? proxy._on_demand : void 0,
|
|
12705
13445
|
control_http_client: proxy["control-http-client"],
|
|
12706
13446
|
udp_timeout: proxy["udp-timeout"],
|
|
12707
13447
|
state_directory: proxy["state-dir"] || proxy["state-directory"],
|
|
@@ -12750,10 +13490,16 @@ var tailscaleParser = (proxy = {}) => {
|
|
|
12750
13490
|
};
|
|
12751
13491
|
var wireguardParser = (proxy = {}) => {
|
|
12752
13492
|
const address = ["ipv4", "ipv6"].map((family) => getWireGuardAddressWithCIDR(proxy, family)).filter((i) => i);
|
|
13493
|
+
const listenPort = parseSafeIntegerValue(proxy._listen_port);
|
|
13494
|
+
const udpNatMax = parseSafeIntegerValue(proxy._udp_nat_max);
|
|
12753
13495
|
const parsedProxy = {
|
|
12754
13496
|
system: !!proxy.system,
|
|
13497
|
+
name: typeof proxy._name === "string" ? proxy._name : void 0,
|
|
13498
|
+
listen_port: listenPort != null && listenPort <= 65535 ? listenPort : void 0,
|
|
13499
|
+
on_demand: typeof proxy._on_demand === "boolean" ? proxy._on_demand : void 0,
|
|
12755
13500
|
mtu: proxy.mtu ? parseInt(`${proxy.mtu}`, 10) : void 0,
|
|
12756
13501
|
udp_timeout: proxy["udp-timeout"],
|
|
13502
|
+
udp_nat_max: udpNatMax != null && udpNatMax <= 4294967295 ? udpNatMax : void 0,
|
|
12757
13503
|
workers: proxy["workers"] ? parseInt(`${proxy["workers"]}`, 10) : void 0,
|
|
12758
13504
|
tag: proxy.name,
|
|
12759
13505
|
type: "wireguard",
|
|
@@ -12765,6 +13511,15 @@ var wireguardParser = (proxy = {}) => {
|
|
|
12765
13511
|
pre_shared_key: proxy["pre-shared-key"],
|
|
12766
13512
|
reserved: []
|
|
12767
13513
|
};
|
|
13514
|
+
for (const field of ["udp_mapping", "udp_filtering"]) {
|
|
13515
|
+
if ([
|
|
13516
|
+
"endpoint_independent",
|
|
13517
|
+
"address_dependent",
|
|
13518
|
+
"address_and_port_dependent"
|
|
13519
|
+
].includes(proxy[`_${field}`])) {
|
|
13520
|
+
parsedProxy[field] = proxy[`_${field}`];
|
|
13521
|
+
}
|
|
13522
|
+
}
|
|
12768
13523
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
12769
13524
|
throw "invalid port";
|
|
12770
13525
|
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
@@ -12790,16 +13545,20 @@ var wireguardParser = (proxy = {}) => {
|
|
|
12790
13545
|
address2 = parsedProxy.server;
|
|
12791
13546
|
port = parseInt(`${parsedProxy.server_port}`, 10);
|
|
12792
13547
|
}
|
|
13548
|
+
let allowedIps = p["allowed-ips"] || p.allowed_ips || proxy["allowed-ips"] || proxy.allowed_ips;
|
|
13549
|
+
if (typeof allowedIps === "string") {
|
|
13550
|
+
allowedIps = allowedIps.split(",").map((i) => i.trim()).filter(Boolean);
|
|
13551
|
+
}
|
|
13552
|
+
if (!Array.isArray(allowedIps) || allowedIps.length === 0) {
|
|
13553
|
+
allowedIps = ["0.0.0.0/0", ...proxy.ipv6 ? ["::/0"] : []];
|
|
13554
|
+
}
|
|
12793
13555
|
const peer = {
|
|
12794
13556
|
address: address2,
|
|
12795
13557
|
port,
|
|
12796
13558
|
persistent_keepalive_interval: p["persistent-keepalive-interval"] ? parseInt(`${p["persistent-keepalive-interval"]}`, 10) : void 0,
|
|
12797
13559
|
public_key: p["public-key"] || p["public_key"] || parsedProxy.peer_public_key,
|
|
12798
13560
|
pre_shared_key: p["pre-shared-key"] || p["pre_shared_key"] || parsedProxy.pre_shared_key,
|
|
12799
|
-
allowed_ips:
|
|
12800
|
-
"0.0.0.0/0",
|
|
12801
|
-
...proxy.ipv6 ? ["::/0"] : []
|
|
12802
|
-
],
|
|
13561
|
+
allowed_ips: allowedIps,
|
|
12803
13562
|
reserved: []
|
|
12804
13563
|
};
|
|
12805
13564
|
if (typeof p.reserved === "string") {
|
|
@@ -13467,7 +14226,7 @@ function Egern_Producer() {
|
|
|
13467
14226
|
port: proxy.port,
|
|
13468
14227
|
private_key: proxy["private-key"],
|
|
13469
14228
|
peer_public_key: proxy["public-key"],
|
|
13470
|
-
preshared_key: proxy["preshared-key"],
|
|
14229
|
+
preshared_key: proxy["preshared-key"] ?? proxy["pre-shared-key"],
|
|
13471
14230
|
reserved: proxy.reserved ? Array.isArray(proxy.reserved) ? proxy.reserved : proxy.reserved.split(/\s*\/\s*/).map((item) => item.trim()).filter((item) => item.length > 0) : void 0,
|
|
13472
14231
|
dns_servers: proxy.dns ? Array.isArray(proxy.dns) ? proxy.dns : proxy.dns.split(/\s*,\s*/).map((item) => item.trim()).filter((item) => item.length > 0) : void 0,
|
|
13473
14232
|
mtu: proxy.mtu,
|
|
@@ -13776,6 +14535,7 @@ var producers_default = {
|
|
|
13776
14535
|
SurgeMac: SurgeMac_Producer(),
|
|
13777
14536
|
Loon: Loon_Producer(),
|
|
13778
14537
|
Clash: Clash_Producer(),
|
|
14538
|
+
clash: Clash_Producer(),
|
|
13779
14539
|
meta: ClashMeta_Producer(),
|
|
13780
14540
|
clashmeta: ClashMeta_Producer(),
|
|
13781
14541
|
"clash.meta": ClashMeta_Producer(),
|