sub-store-convert 2.39.6 → 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 +1322 -531
- package/package.json +9 -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
|
|
|
@@ -2557,15 +2966,16 @@ var grammars2 = String.raw`
|
|
|
2557
2966
|
function loonClientFingerprint(tlsProfile) {
|
|
2558
2967
|
switch (String(tlsProfile || "").trim()) {
|
|
2559
2968
|
case "chrome":
|
|
2969
|
+
case "chrome147":
|
|
2560
2970
|
return "chrome";
|
|
2561
|
-
case "ios18":
|
|
2562
|
-
case "
|
|
2971
|
+
case "safari-ios18":
|
|
2972
|
+
case "safari-ios-26":
|
|
2563
2973
|
return "ios";
|
|
2564
2974
|
}
|
|
2565
2975
|
}
|
|
2566
2976
|
}
|
|
2567
2977
|
|
|
2568
|
-
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) {
|
|
2569
2979
|
return proxy;
|
|
2570
2980
|
}
|
|
2571
2981
|
|
|
@@ -2586,17 +2996,17 @@ shadowsocks = tag equals "shadowsocks"i address method password (obfs_typev obfs
|
|
|
2586
2996
|
}
|
|
2587
2997
|
handleShadowTLS();
|
|
2588
2998
|
}
|
|
2589
|
-
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)* {
|
|
2590
3000
|
proxy.type = "vmess";
|
|
2591
3001
|
proxy.cipher = proxy.cipher || "auto";
|
|
2592
3002
|
proxy.alterId = proxy.alterId || 0;
|
|
2593
3003
|
handleTransport();
|
|
2594
3004
|
}
|
|
2595
|
-
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)* {
|
|
2596
3006
|
proxy.type = "vless";
|
|
2597
3007
|
handleTransport();
|
|
2598
3008
|
}
|
|
2599
|
-
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)* {
|
|
2600
3010
|
proxy.type = "trojan";
|
|
2601
3011
|
handleTransport();
|
|
2602
3012
|
}
|
|
@@ -2617,6 +3027,31 @@ http = tag equals "http"i address (username password)? (fast_open/udp_relay/ip_m
|
|
|
2617
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)* {
|
|
2618
3028
|
proxy.type = "socks5";
|
|
2619
3029
|
}
|
|
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); }
|
|
2620
3055
|
|
|
2621
3056
|
address = comma server:server comma port:port {
|
|
2622
3057
|
proxy.server = server;
|
|
@@ -2695,13 +3130,29 @@ obfs_ss = comma "obfs-name" equals type:("http"/"tls") { obfs.type = type; }
|
|
|
2695
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; }
|
|
2696
3131
|
obfs_ssr_param = comma "obfs-param" equals match:$[^,]+ { proxy["obfs-param"] = match; }
|
|
2697
3132
|
|
|
2698
|
-
obfs_host = comma "obfs-host" equals
|
|
2699
|
-
obfs_uri = comma "obfs-uri" equals
|
|
2700
|
-
|
|
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; }
|
|
2701
3140
|
|
|
2702
3141
|
transport = comma "transport" equals type:("tcp"/"ws"/"http") { transport.type = type; }
|
|
2703
|
-
transport_host = comma "host" equals
|
|
2704
|
-
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
|
+
}
|
|
2705
3156
|
|
|
2706
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; }
|
|
2707
3158
|
ssr_protocol_param = comma "protocol-param" equals param:$[^=,]+ { proxy["protocol-param"] = param; }
|
|
@@ -2725,7 +3176,7 @@ tls_profile = comma "tls-profile" equals match:[^,]+ {
|
|
|
2725
3176
|
const clientFingerprint = loonClientFingerprint(tlsProfile);
|
|
2726
3177
|
if (clientFingerprint) proxy["client-fingerprint"] = clientFingerprint;
|
|
2727
3178
|
}
|
|
2728
|
-
alpn = comma "alpn" equals
|
|
3179
|
+
alpn = comma "alpn" equals match:option_value {
|
|
2729
3180
|
const values = match
|
|
2730
3181
|
.split(",")
|
|
2731
3182
|
.map((item) => item.trim())
|
|
@@ -2735,7 +3186,7 @@ alpn = comma "alpn" equals '"' match:$[^"]* '"' {
|
|
|
2735
3186
|
|
|
2736
3187
|
flow = comma "flow" equals match:[^,]+ { proxy["flow"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
|
2737
3188
|
public_key = comma "public-key" equals match:[^,]+ { proxy["reality-opts"] = proxy["reality-opts"] || {}; proxy["reality-opts"]["public-key"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
|
2738
|
-
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; }
|
|
2739
3190
|
|
|
2740
3191
|
fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; }
|
|
2741
3192
|
udp_relay = comma "udp" equals flag:bool { proxy.udp = flag; }
|
|
@@ -2756,17 +3207,29 @@ max_stream_count = comma "max-stream-count" equals match:$[0-9]+ { proxy["max-st
|
|
|
2756
3207
|
|
|
2757
3208
|
udp_over_tcp = comma "udp-over-tcp" equals flag:bool { proxy["udp-over-tcp"] = true; proxy["udp-over-tcp-version"] = 2; }
|
|
2758
3209
|
|
|
3210
|
+
server_dns = comma "server-dns" equals value:(
|
|
3211
|
+
'"' match:$[^"]* '"' { return match; }
|
|
3212
|
+
/ $(!(comma [a-zA-Z0-9_-]+ equals) [^"])*
|
|
3213
|
+
) {
|
|
3214
|
+
proxy["server-dns"] = value.split(",").map((item) => item.trim()).filter(Boolean);
|
|
3215
|
+
}
|
|
3216
|
+
|
|
2759
3217
|
tag = match:[^=,]* { proxy.name = match.join("").trim(); }
|
|
3218
|
+
quoted_value = '"' match:$[^"]* '"' { return match; }
|
|
3219
|
+
option_value = quoted_value / match:$[^,"]* { return match.trim(); }
|
|
2760
3220
|
comma = _ "," _
|
|
2761
3221
|
equals = _ "=" _
|
|
2762
3222
|
_ = [ \r\t]*
|
|
2763
3223
|
bool = b:("true"/"false") { return b === "true" }
|
|
2764
|
-
others = comma [^=,]+ equals [^=,]+
|
|
3224
|
+
others = server_dns / (comma [^=,]+ equals [^=,]+)
|
|
2765
3225
|
`;
|
|
2766
3226
|
var parser2;
|
|
2767
3227
|
function getParser2() {
|
|
2768
3228
|
if (!parser2) {
|
|
2769
|
-
|
|
3229
|
+
const generated = peggy2.generate(grammars2);
|
|
3230
|
+
parser2 = {
|
|
3231
|
+
parse: (input) => generated.parse(input, { setLoonXhttpOption })
|
|
3232
|
+
};
|
|
2770
3233
|
}
|
|
2771
3234
|
return parser2;
|
|
2772
3235
|
}
|
|
@@ -2842,7 +3305,7 @@ var grammars3 = String.raw`
|
|
|
2842
3305
|
}
|
|
2843
3306
|
}
|
|
2844
3307
|
|
|
2845
|
-
start = (trojan/shadowsocks/vmess/vless/anytls/http/socks5) {
|
|
3308
|
+
start = (trojan/shadowsocks/vmess/vless/anytls/hysteria2/http/socks5) {
|
|
2846
3309
|
return proxy
|
|
2847
3310
|
}
|
|
2848
3311
|
|
|
@@ -2914,6 +3377,12 @@ anytls = "anytls" equals address
|
|
|
2914
3377
|
proxy.tls = true;
|
|
2915
3378
|
}
|
|
2916
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
|
+
|
|
2917
3386
|
http = "http" equals address
|
|
2918
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)*{
|
|
2919
3388
|
proxy.type = "http";
|
|
@@ -2973,6 +3442,22 @@ udp_relay = comma "udp-relay" equals flag:bool { proxy.udp = flag; }
|
|
|
2973
3442
|
udp_over_tcp = comma "udp-over-tcp" equals flag:bool { throw new Error("UDP over TCP is not supported"); }
|
|
2974
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"); } }
|
|
2975
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
|
+
|
|
2976
3461
|
fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; }
|
|
2977
3462
|
|
|
2978
3463
|
over_tls = comma "over-tls" equals flag:bool { proxy.tls = flag; }
|
|
@@ -3036,7 +3521,7 @@ reality_hex_shortid = comma "reality-hex-shortid" equals param:$[^=,]+ {
|
|
|
3036
3521
|
}
|
|
3037
3522
|
|
|
3038
3523
|
vless_flow = comma "vless-flow" equals param:$[^=,]+ { proxy["flow"] = param; }
|
|
3039
|
-
server_check_url = comma "server_check_url" equals param:$[
|
|
3524
|
+
server_check_url = comma "server_check_url" equals param:$[^,]+ { proxy["test-url"] = param.trim(); }
|
|
3040
3525
|
|
|
3041
3526
|
uri = $[^,]+
|
|
3042
3527
|
|
|
@@ -3254,7 +3739,7 @@ function parseTrojan(url) {
|
|
|
3254
3739
|
}
|
|
3255
3740
|
proxy["skip-cert-verify"] = toBool(params.allowInsecure);
|
|
3256
3741
|
proxy.sni = params.sni || params.peer;
|
|
3257
|
-
proxy["client-fingerprint"] = params.fp;
|
|
3742
|
+
proxy["client-fingerprint"] = params.fp ?? params["client-fingerprint"];
|
|
3258
3743
|
proxy["tls-fingerprint"] = params.pcs;
|
|
3259
3744
|
proxy._vcn = params.vcn?.split(",").map((name2) => name2.trim()).filter(Boolean);
|
|
3260
3745
|
proxy["name-cert-verify"] = proxy._vcn?.[0];
|
|
@@ -3452,245 +3937,29 @@ function stringify(content, options) {
|
|
|
3452
3937
|
return stringifyYaml(content, normalizeStringifyOptions(options));
|
|
3453
3938
|
}
|
|
3454
3939
|
function safeLoad(content, ...args) {
|
|
3455
|
-
return retry(parse, toSerializable(content), ...args);
|
|
3456
|
-
}
|
|
3457
|
-
function load(content, ...args) {
|
|
3458
|
-
return retry(parse, toSerializable(content), ...args);
|
|
3459
|
-
}
|
|
3460
|
-
function safeDump(content, ...args) {
|
|
3461
|
-
return stringify(toSerializable(content), ...args);
|
|
3462
|
-
}
|
|
3463
|
-
function dump(content, ...args) {
|
|
3464
|
-
return stringify(toSerializable(content), ...args);
|
|
3465
|
-
}
|
|
3466
|
-
var yaml_default = {
|
|
3467
|
-
safeLoad,
|
|
3468
|
-
load,
|
|
3469
|
-
safeDump,
|
|
3470
|
-
dump,
|
|
3471
|
-
parse: safeLoad,
|
|
3472
|
-
stringify: safeDump
|
|
3473
|
-
};
|
|
3474
|
-
|
|
3475
|
-
// src/vendors/Sub-Store/backend/src/core/proxy-utils/parsers/index.js
|
|
3476
|
-
import _ from "lodash";
|
|
3477
|
-
import { Base64 } from "js-base64";
|
|
3478
|
-
|
|
3479
|
-
// src/vendors/Sub-Store/backend/src/core/proxy-utils/xhttp-utils.js
|
|
3480
|
-
function parseNormalizedXhttpRangeBounds(value, { allowZeroLowerBound = true, allowZeroUpperBound = true } = {}) {
|
|
3481
|
-
if (typeof value !== "string" && typeof value !== "number") {
|
|
3482
|
-
return void 0;
|
|
3483
|
-
}
|
|
3484
|
-
const parseUnsignedIntegerToken = (token) => {
|
|
3485
|
-
const normalizedToken = token.trim();
|
|
3486
|
-
if (!/^\+?\d+$/.test(normalizedToken)) {
|
|
3487
|
-
return void 0;
|
|
3488
|
-
}
|
|
3489
|
-
const parsedInteger = parseInt(normalizedToken, 10);
|
|
3490
|
-
return Number.isSafeInteger(parsedInteger) ? parsedInteger : void 0;
|
|
3491
|
-
};
|
|
3492
|
-
const normalizedValue = `${value}`.trim();
|
|
3493
|
-
const rangeParts = normalizedValue.split("-");
|
|
3494
|
-
const minimumAllowedLowerBound = allowZeroLowerBound ? 0 : 1;
|
|
3495
|
-
const minimumAllowedUpperBound = allowZeroUpperBound ? 0 : 1;
|
|
3496
|
-
if (rangeParts.length === 1) {
|
|
3497
|
-
const normalizedInteger = parseUnsignedIntegerToken(rangeParts[0]);
|
|
3498
|
-
const minimumAllowedValue = Math.max(
|
|
3499
|
-
minimumAllowedLowerBound,
|
|
3500
|
-
minimumAllowedUpperBound
|
|
3501
|
-
);
|
|
3502
|
-
return normalizedInteger >= minimumAllowedValue ? {
|
|
3503
|
-
lowerBound: normalizedInteger,
|
|
3504
|
-
upperBound: normalizedInteger
|
|
3505
|
-
} : void 0;
|
|
3506
|
-
}
|
|
3507
|
-
if (rangeParts.length !== 2) {
|
|
3508
|
-
return void 0;
|
|
3509
|
-
}
|
|
3510
|
-
const lowerBound = parseUnsignedIntegerToken(rangeParts[0]);
|
|
3511
|
-
const upperBound = parseUnsignedIntegerToken(rangeParts[1]);
|
|
3512
|
-
if (lowerBound == null || upperBound == null) {
|
|
3513
|
-
return void 0;
|
|
3514
|
-
}
|
|
3515
|
-
return lowerBound >= minimumAllowedLowerBound && upperBound >= minimumAllowedUpperBound && upperBound >= lowerBound ? {
|
|
3516
|
-
lowerBound,
|
|
3517
|
-
upperBound
|
|
3518
|
-
} : void 0;
|
|
3519
|
-
}
|
|
3520
|
-
function parseNormalizedXhttpPositiveRangeBounds(value) {
|
|
3521
|
-
return parseNormalizedXhttpRangeBounds(value, {
|
|
3522
|
-
allowZeroUpperBound: false
|
|
3523
|
-
});
|
|
3524
|
-
}
|
|
3525
|
-
function parseNormalizedXhttpStrictPositiveRangeBounds(value) {
|
|
3526
|
-
return parseNormalizedXhttpRangeBounds(value, {
|
|
3527
|
-
allowZeroLowerBound: false,
|
|
3528
|
-
allowZeroUpperBound: false
|
|
3529
|
-
});
|
|
3530
|
-
}
|
|
3531
|
-
function normalizeXhttpPositiveRange(value) {
|
|
3532
|
-
const normalizedBounds = parseNormalizedXhttpPositiveRangeBounds(value);
|
|
3533
|
-
if (!normalizedBounds) {
|
|
3534
|
-
return void 0;
|
|
3535
|
-
}
|
|
3536
|
-
const { lowerBound, upperBound } = normalizedBounds;
|
|
3537
|
-
return lowerBound === upperBound ? upperBound : `${lowerBound}-${upperBound}`;
|
|
3538
|
-
}
|
|
3539
|
-
function normalizeXhttpStrictPositiveRangeString(value) {
|
|
3540
|
-
const normalizedBounds = parseNormalizedXhttpStrictPositiveRangeBounds(value);
|
|
3541
|
-
if (!normalizedBounds) {
|
|
3542
|
-
return void 0;
|
|
3543
|
-
}
|
|
3544
|
-
const { lowerBound, upperBound } = normalizedBounds;
|
|
3545
|
-
return lowerBound === upperBound ? `${upperBound}` : `${lowerBound}-${upperBound}`;
|
|
3546
|
-
}
|
|
3547
|
-
function normalizeXhttpStrictPositiveRangeValue(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 normalizeXhttpNonNegativeRange(value) {
|
|
3556
|
-
const normalizedBounds = parseNormalizedXhttpRangeBounds(value);
|
|
3557
|
-
if (!normalizedBounds) {
|
|
3558
|
-
return void 0;
|
|
3559
|
-
}
|
|
3560
|
-
const { lowerBound, upperBound } = normalizedBounds;
|
|
3561
|
-
return lowerBound === upperBound ? upperBound : `${lowerBound}-${upperBound}`;
|
|
3562
|
-
}
|
|
3563
|
-
function normalizeXhttpIntegerValue(value, { allowNegative = true } = {}) {
|
|
3564
|
-
if (typeof value === "number" && Number.isFinite(value) && Number.isSafeInteger(value)) {
|
|
3565
|
-
if (!allowNegative && value < 0) {
|
|
3566
|
-
return void 0;
|
|
3567
|
-
}
|
|
3568
|
-
return value;
|
|
3569
|
-
}
|
|
3570
|
-
if (typeof value !== "string") {
|
|
3571
|
-
return void 0;
|
|
3572
|
-
}
|
|
3573
|
-
const normalizedValue = value.trim();
|
|
3574
|
-
const integerPattern = allowNegative ? /^[+-]?\d+$/ : /^\+?\d+$/;
|
|
3575
|
-
if (!integerPattern.test(normalizedValue)) {
|
|
3576
|
-
return void 0;
|
|
3577
|
-
}
|
|
3578
|
-
const parsedInteger = parseInt(normalizedValue, 10);
|
|
3579
|
-
if (!Number.isSafeInteger(parsedInteger)) {
|
|
3580
|
-
return void 0;
|
|
3581
|
-
}
|
|
3582
|
-
if (!allowNegative && parsedInteger < 0) {
|
|
3583
|
-
return void 0;
|
|
3584
|
-
}
|
|
3585
|
-
return parsedInteger;
|
|
3586
|
-
}
|
|
3587
|
-
|
|
3588
|
-
// src/vendors/Sub-Store/backend/src/core/proxy-utils/ech-utils.js
|
|
3589
|
-
var ECH_DNS_FIELD = "_dns";
|
|
3590
|
-
var ECH_FORCE_QUERY_FIELD = "_force-query";
|
|
3591
|
-
var ECH_SOCKOPT_FIELD = "_sockopt";
|
|
3592
|
-
var DEFAULT_XRAY_ECH_DNS = "https://dns.alidns.com/dns-query";
|
|
3593
|
-
function parseXrayEchConfigList(echConfigList) {
|
|
3594
|
-
if (!isNotBlank(echConfigList)) {
|
|
3595
|
-
return void 0;
|
|
3596
|
-
}
|
|
3597
|
-
if (!echConfigList.includes("://")) {
|
|
3598
|
-
return {
|
|
3599
|
-
type: "config",
|
|
3600
|
-
config: echConfigList
|
|
3601
|
-
};
|
|
3602
|
-
}
|
|
3603
|
-
const parts = echConfigList.split("+");
|
|
3604
|
-
if (parts.length === 1 && isNotBlank(parts[0])) {
|
|
3605
|
-
return {
|
|
3606
|
-
type: "dns",
|
|
3607
|
-
dns: parts[0]
|
|
3608
|
-
};
|
|
3609
|
-
}
|
|
3610
|
-
if (parts.length === 2 && isNotBlank(parts[0]) && isNotBlank(parts[1])) {
|
|
3611
|
-
return {
|
|
3612
|
-
type: "dns",
|
|
3613
|
-
queryServerName: parts[0],
|
|
3614
|
-
dns: parts[1]
|
|
3615
|
-
};
|
|
3616
|
-
}
|
|
3617
|
-
return void 0;
|
|
3618
|
-
}
|
|
3619
|
-
function isSupportedXrayEchConfigList(echConfigList) {
|
|
3620
|
-
return parseXrayEchConfigList(echConfigList) != null;
|
|
3621
|
-
}
|
|
3622
|
-
function isSupportedXrayEchForceQuery(forceQuery) {
|
|
3623
|
-
return ["none", "half", "full"].includes(forceQuery);
|
|
3624
|
-
}
|
|
3625
|
-
function isMihomoEchEnabled(value) {
|
|
3626
|
-
if (typeof value === "boolean") {
|
|
3627
|
-
return value;
|
|
3628
|
-
}
|
|
3629
|
-
return typeof value === "number" && Number.isInteger(value) && value !== 0;
|
|
3630
|
-
}
|
|
3631
|
-
function buildMihomoEchOptsFromXrayFields({
|
|
3632
|
-
echConfigList,
|
|
3633
|
-
echForceQuery,
|
|
3634
|
-
echSockopt
|
|
3635
|
-
} = {}) {
|
|
3636
|
-
const parsedEchConfigList = parseXrayEchConfigList(echConfigList);
|
|
3637
|
-
if (!parsedEchConfigList) {
|
|
3638
|
-
return void 0;
|
|
3639
|
-
}
|
|
3640
|
-
const echOpts = {
|
|
3641
|
-
enable: true
|
|
3642
|
-
};
|
|
3643
|
-
if (parsedEchConfigList.type === "config") {
|
|
3644
|
-
echOpts.config = parsedEchConfigList.config;
|
|
3645
|
-
} else {
|
|
3646
|
-
echOpts[ECH_DNS_FIELD] = parsedEchConfigList.dns;
|
|
3647
|
-
if (parsedEchConfigList.queryServerName) {
|
|
3648
|
-
echOpts["query-server-name"] = parsedEchConfigList.queryServerName;
|
|
3649
|
-
}
|
|
3650
|
-
}
|
|
3651
|
-
if (isSupportedXrayEchForceQuery(echForceQuery)) {
|
|
3652
|
-
echOpts[ECH_FORCE_QUERY_FIELD] = echForceQuery;
|
|
3653
|
-
}
|
|
3654
|
-
if (isPlainObject(echSockopt)) {
|
|
3655
|
-
echOpts[ECH_SOCKOPT_FIELD] = echSockopt;
|
|
3656
|
-
}
|
|
3657
|
-
return echOpts;
|
|
3658
|
-
}
|
|
3659
|
-
function buildXrayEchFieldsFromMihomo(echOpts, fallbackEchConfigList, { dnsFieldPath = "ech-opts._dns", warnDefaultDns } = {}) {
|
|
3660
|
-
const fields = {};
|
|
3661
|
-
if (isPlainObject(echOpts)) {
|
|
3662
|
-
if (!isMihomoEchEnabled(echOpts.enable)) {
|
|
3663
|
-
return fields;
|
|
3664
|
-
}
|
|
3665
|
-
const queryServerName = echOpts["query-server-name"];
|
|
3666
|
-
if (isNotBlank(echOpts.config)) {
|
|
3667
|
-
fields.echConfigList = echOpts.config;
|
|
3668
|
-
} else if (isNotBlank(echOpts[ECH_DNS_FIELD])) {
|
|
3669
|
-
fields.echConfigList = isNotBlank(queryServerName) ? `${queryServerName}+${echOpts[ECH_DNS_FIELD]}` : echOpts[ECH_DNS_FIELD];
|
|
3670
|
-
} else if (isNotBlank(queryServerName)) {
|
|
3671
|
-
fields.echConfigList = `${queryServerName}+${DEFAULT_XRAY_ECH_DNS}`;
|
|
3672
|
-
warnDefaultDns?.({
|
|
3673
|
-
defaultDns: DEFAULT_XRAY_ECH_DNS,
|
|
3674
|
-
dnsFieldPath,
|
|
3675
|
-
queryServerName
|
|
3676
|
-
});
|
|
3677
|
-
}
|
|
3678
|
-
if (fields.echConfigList && isSupportedXrayEchForceQuery(echOpts[ECH_FORCE_QUERY_FIELD])) {
|
|
3679
|
-
fields.echForceQuery = echOpts[ECH_FORCE_QUERY_FIELD];
|
|
3680
|
-
}
|
|
3681
|
-
if (fields.echConfigList && isPlainObject(echOpts[ECH_SOCKOPT_FIELD])) {
|
|
3682
|
-
fields.echSockopt = echOpts[ECH_SOCKOPT_FIELD];
|
|
3683
|
-
}
|
|
3684
|
-
return fields;
|
|
3685
|
-
}
|
|
3686
|
-
if (isNotBlank(fallbackEchConfigList)) {
|
|
3687
|
-
fields.echConfigList = fallbackEchConfigList;
|
|
3688
|
-
}
|
|
3689
|
-
return fields;
|
|
3940
|
+
return retry(parse, toSerializable(content), ...args);
|
|
3690
3941
|
}
|
|
3691
|
-
function
|
|
3692
|
-
return
|
|
3942
|
+
function load(content, ...args) {
|
|
3943
|
+
return retry(parse, toSerializable(content), ...args);
|
|
3944
|
+
}
|
|
3945
|
+
function safeDump(content, ...args) {
|
|
3946
|
+
return stringify(toSerializable(content), ...args);
|
|
3693
3947
|
}
|
|
3948
|
+
function dump(content, ...args) {
|
|
3949
|
+
return stringify(toSerializable(content), ...args);
|
|
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";
|
|
3694
3963
|
|
|
3695
3964
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/vmess-security.js
|
|
3696
3965
|
var VMESS_SECURITY_AUTO = "auto";
|
|
@@ -3884,6 +4153,10 @@ function URI_PROXY() {
|
|
|
3884
4153
|
username: username != null ? decodeURIComponent(username) : void 0,
|
|
3885
4154
|
password: password != null ? decodeURIComponent(password) : void 0
|
|
3886
4155
|
};
|
|
4156
|
+
if (tls && query) {
|
|
4157
|
+
const fingerprint = getPathQueryParam(query, "fp") || getPathQueryParam(query, "client-fingerprint");
|
|
4158
|
+
if (fingerprint) proxy["client-fingerprint"] = fingerprint;
|
|
4159
|
+
}
|
|
3887
4160
|
return proxy;
|
|
3888
4161
|
};
|
|
3889
4162
|
return { name, test, parse: parse2 };
|
|
@@ -3978,7 +4251,7 @@ function URI_SS() {
|
|
|
3978
4251
|
proxy.alpn = params.alpn ? decodeURIComponent(params.alpn).split(",") : void 0;
|
|
3979
4252
|
if (params["ws"]) {
|
|
3980
4253
|
proxy.network = "ws";
|
|
3981
|
-
|
|
4254
|
+
_2.set(proxy, "ws-opts.path", params["wspath"]);
|
|
3982
4255
|
}
|
|
3983
4256
|
if (params["type"]) {
|
|
3984
4257
|
let httpupgrade;
|
|
@@ -4007,10 +4280,10 @@ function URI_SS() {
|
|
|
4007
4280
|
pathEarlyData = extracted.ed;
|
|
4008
4281
|
}
|
|
4009
4282
|
}
|
|
4010
|
-
|
|
4283
|
+
_2.set(proxy, proxy.network + "-opts.path", transportPath);
|
|
4011
4284
|
}
|
|
4012
4285
|
if (params["host"]) {
|
|
4013
|
-
|
|
4286
|
+
_2.set(
|
|
4014
4287
|
proxy,
|
|
4015
4288
|
proxy.network + "-opts.headers.Host",
|
|
4016
4289
|
decodeURIComponent(params["host"])
|
|
@@ -4018,30 +4291,30 @@ function URI_SS() {
|
|
|
4018
4291
|
}
|
|
4019
4292
|
if (httpupgrade) {
|
|
4020
4293
|
httpUpgradeEd = httpUpgradeEd || (isNumericEarlyData2(params.ed) ? `${params.ed}` : "");
|
|
4021
|
-
|
|
4294
|
+
_2.set(
|
|
4022
4295
|
proxy,
|
|
4023
4296
|
proxy.network + "-opts.v2ray-http-upgrade",
|
|
4024
4297
|
true
|
|
4025
4298
|
);
|
|
4026
4299
|
if (httpUpgradeEd !== "") {
|
|
4027
|
-
|
|
4300
|
+
_2.set(
|
|
4028
4301
|
proxy,
|
|
4029
4302
|
proxy.network + "-opts.v2ray-http-upgrade-fast-open",
|
|
4030
4303
|
true
|
|
4031
4304
|
);
|
|
4032
|
-
|
|
4305
|
+
_2.set(
|
|
4033
4306
|
proxy,
|
|
4034
4307
|
proxy.network + "-opts._v2ray-http-upgrade-ed",
|
|
4035
4308
|
httpUpgradeEd
|
|
4036
4309
|
);
|
|
4037
4310
|
}
|
|
4038
4311
|
} else if (proxy.network === "ws" && pathEarlyData !== "") {
|
|
4039
|
-
|
|
4312
|
+
_2.set(
|
|
4040
4313
|
proxy,
|
|
4041
4314
|
proxy.network + "-opts.max-early-data",
|
|
4042
4315
|
parseEarlyDataSize(pathEarlyData)
|
|
4043
4316
|
);
|
|
4044
|
-
|
|
4317
|
+
_2.set(
|
|
4045
4318
|
proxy,
|
|
4046
4319
|
proxy.network + "-opts.early-data-header-name",
|
|
4047
4320
|
"Sec-WebSocket-Protocol"
|
|
@@ -4062,15 +4335,17 @@ function URI_SS() {
|
|
|
4062
4335
|
if (params.mode) {
|
|
4063
4336
|
proxy._mode = params.mode;
|
|
4064
4337
|
}
|
|
4065
|
-
if (params.extra) {
|
|
4066
|
-
proxy._extra = params.extra;
|
|
4067
|
-
}
|
|
4068
4338
|
if (Object.keys(opts).length > 0) {
|
|
4069
|
-
|
|
4339
|
+
_2.set(proxy, params.security + "-opts", opts);
|
|
4070
4340
|
}
|
|
4071
4341
|
}
|
|
4342
|
+
if (params.extra && (proxy.network === "xhttp" || params.security === "reality")) {
|
|
4343
|
+
proxy._extra = params.extra;
|
|
4344
|
+
}
|
|
4072
4345
|
}
|
|
4073
|
-
proxy.udp =
|
|
4346
|
+
proxy.udp = ![false, 0, "0", "false", "off"].includes(
|
|
4347
|
+
typeof params["udp"] === "string" ? params["udp"].toLowerCase() : params["udp"]
|
|
4348
|
+
);
|
|
4074
4349
|
const serverAndPort = serverAndPortArray[1];
|
|
4075
4350
|
const portIdx = serverAndPort.lastIndexOf(":");
|
|
4076
4351
|
proxy.server = serverAndPort.substring(0, portIdx);
|
|
@@ -4463,7 +4738,7 @@ function URI_VMess() {
|
|
|
4463
4738
|
delete proxy.network;
|
|
4464
4739
|
}
|
|
4465
4740
|
}
|
|
4466
|
-
proxy["client-fingerprint"] = params.fp;
|
|
4741
|
+
proxy["client-fingerprint"] = params.fp ?? params["client-fingerprint"];
|
|
4467
4742
|
proxy.alpn = params.alpn ? params.alpn.split(",") : void 0;
|
|
4468
4743
|
if (isNotBlank(fragmentName)) {
|
|
4469
4744
|
proxy.name = fragmentName;
|
|
@@ -5192,7 +5467,7 @@ function URI_VLESS() {
|
|
|
5192
5467
|
let isShadowrocket;
|
|
5193
5468
|
let parsed = /^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
5194
5469
|
if (!parsed) {
|
|
5195
|
-
let [
|
|
5470
|
+
let [_5, base64, other] = /^(.*?)(\?.*?$)/.exec(line);
|
|
5196
5471
|
line = `${Base64.decode(base64)}${other}`;
|
|
5197
5472
|
parsed = /^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
5198
5473
|
isShadowrocket = true;
|
|
@@ -5238,9 +5513,9 @@ function URI_VLESS() {
|
|
|
5238
5513
|
proxy.flow = flow;
|
|
5239
5514
|
}
|
|
5240
5515
|
}
|
|
5241
|
-
proxy["client-fingerprint"] = params.fp;
|
|
5516
|
+
proxy["client-fingerprint"] = params.fp ?? params["client-fingerprint"];
|
|
5242
5517
|
proxy.alpn = params.alpn ? params.alpn.split(",") : void 0;
|
|
5243
|
-
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";
|
|
5244
5519
|
proxy._echConfigList = getIfPresent(params.ech);
|
|
5245
5520
|
const echOpts = buildMihomoEchOptsFromXrayFields({
|
|
5246
5521
|
echConfigList: params.ech
|
|
@@ -5300,6 +5575,8 @@ function URI_VLESS() {
|
|
|
5300
5575
|
}
|
|
5301
5576
|
if (["websocket"].includes(proxy.network)) {
|
|
5302
5577
|
proxy.network = "ws";
|
|
5578
|
+
} else if (protocol === "vless" && proxy.network === "splithttp") {
|
|
5579
|
+
proxy.network = "xhttp";
|
|
5303
5580
|
}
|
|
5304
5581
|
if (proxy.network && !["tcp", "none"].includes(proxy.network)) {
|
|
5305
5582
|
const opts = {};
|
|
@@ -5335,11 +5612,8 @@ function URI_VLESS() {
|
|
|
5335
5612
|
}
|
|
5336
5613
|
if (params.serviceName) {
|
|
5337
5614
|
opts[`${proxy.network}-service-name`] = params.serviceName;
|
|
5338
|
-
if (["grpc"].includes(proxy.network) && params.authority) {
|
|
5339
|
-
opts["_grpc-authority"] = params.authority;
|
|
5340
|
-
}
|
|
5341
5615
|
} else if (isShadowrocket && params.path) {
|
|
5342
|
-
if (!["ws", "http", "h2"].includes(proxy.network)) {
|
|
5616
|
+
if (!["ws", "http", "h2", "xhttp"].includes(proxy.network)) {
|
|
5343
5617
|
opts[`${proxy.network}-service-name`] = params.path;
|
|
5344
5618
|
delete params.path;
|
|
5345
5619
|
}
|
|
@@ -5360,6 +5634,9 @@ function URI_VLESS() {
|
|
|
5360
5634
|
}
|
|
5361
5635
|
if (["grpc"].includes(proxy.network)) {
|
|
5362
5636
|
opts["_grpc-type"] = params.mode || "gun";
|
|
5637
|
+
if (params.authority) {
|
|
5638
|
+
opts["_grpc-authority"] = params.authority;
|
|
5639
|
+
}
|
|
5363
5640
|
}
|
|
5364
5641
|
if (httpupgrade) {
|
|
5365
5642
|
opts["v2ray-http-upgrade"] = true;
|
|
@@ -5443,6 +5720,14 @@ function URI_VLESS() {
|
|
|
5443
5720
|
if (params.pqv) {
|
|
5444
5721
|
proxy._pqv = params.pqv;
|
|
5445
5722
|
}
|
|
5723
|
+
if (params.fm) {
|
|
5724
|
+
try {
|
|
5725
|
+
const finalmask = JSON.parse(params.fm);
|
|
5726
|
+
proxy._finalmask = isPlainObject(finalmask) ? finalmask : params.fm;
|
|
5727
|
+
} catch (e) {
|
|
5728
|
+
proxy._finalmask = params.fm;
|
|
5729
|
+
}
|
|
5730
|
+
}
|
|
5446
5731
|
return proxy;
|
|
5447
5732
|
};
|
|
5448
5733
|
return { name, test, parse: parse2 };
|
|
@@ -5456,7 +5741,6 @@ function URI_AnyTLS() {
|
|
|
5456
5741
|
const parsed = URI_VLESS().parse(line.replace("anytls", "vless"));
|
|
5457
5742
|
line = line.split(/anytls:\/\//)[1];
|
|
5458
5743
|
let [__, password, server, port, addons = "", name2] = /^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
5459
|
-
password = decodeURIComponent(password);
|
|
5460
5744
|
port = parseInt(`${port}`, 10);
|
|
5461
5745
|
if (isNaN(port)) {
|
|
5462
5746
|
port = 443;
|
|
@@ -5807,12 +6091,14 @@ function URI_Trojan() {
|
|
|
5807
6091
|
return /^trojan:\/\//.test(line);
|
|
5808
6092
|
};
|
|
5809
6093
|
const parse2 = (line) => {
|
|
5810
|
-
|
|
6094
|
+
let [newLine, name2] = line.split(/#(.+)/, 2);
|
|
6095
|
+
const matched = /^(trojan:\/\/.*?@.*?)(:(\d+))?\/?(\?.*?)?$/.exec(
|
|
6096
|
+
newLine
|
|
6097
|
+
);
|
|
5811
6098
|
const port = matched?.[2];
|
|
5812
6099
|
if (!port) {
|
|
5813
|
-
|
|
6100
|
+
newLine = newLine.replace(matched[1], `${matched[1]}:443`);
|
|
5814
6101
|
}
|
|
5815
|
-
let [newLine, name2] = line.split(/#(.+)/, 2);
|
|
5816
6102
|
const parser5 = getParser4();
|
|
5817
6103
|
const proxy = parser5.parse(newLine);
|
|
5818
6104
|
if (isNotBlank(name2)) {
|
|
@@ -5948,6 +6234,12 @@ function QX_AnyTLS() {
|
|
|
5948
6234
|
const parse2 = (line) => getParser3().parse(line);
|
|
5949
6235
|
return { name, test, parse: parse2 };
|
|
5950
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
|
+
}
|
|
5951
6243
|
function QX_Trojan() {
|
|
5952
6244
|
const name = "QX Trojan Parser";
|
|
5953
6245
|
const test = (line) => {
|
|
@@ -5988,11 +6280,10 @@ function Loon_SSR() {
|
|
|
5988
6280
|
const parse2 = (line) => getParser2().parse(line);
|
|
5989
6281
|
return { name, test, parse: parse2 };
|
|
5990
6282
|
}
|
|
6283
|
+
var LOON_VMESS = /^[^=,]*=\s*vmess\s*,[^,]*,[^,]*,[^,]*,\s*"/i;
|
|
5991
6284
|
function Loon_VMess() {
|
|
5992
6285
|
const name = "Loon VMess Parser";
|
|
5993
|
-
const test = (line) =>
|
|
5994
|
-
return /^.*=\s*vmess/i.test(line.split(",")[0]) && line.indexOf("username") === -1;
|
|
5995
|
-
};
|
|
6286
|
+
const test = (line) => LOON_VMESS.test(line);
|
|
5996
6287
|
const parse2 = (line) => getParser2().parse(line);
|
|
5997
6288
|
return { name, test, parse: parse2 };
|
|
5998
6289
|
}
|
|
@@ -6044,6 +6335,12 @@ function Loon_Socks5() {
|
|
|
6044
6335
|
const parse2 = (line) => getParser2().parse(line);
|
|
6045
6336
|
return { name, test, parse: parse2 };
|
|
6046
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
|
+
}
|
|
6047
6344
|
function Loon_WireGuard() {
|
|
6048
6345
|
const name = "Loon WireGuard Parser";
|
|
6049
6346
|
const test = (line) => {
|
|
@@ -6079,6 +6376,9 @@ function Loon_WireGuard() {
|
|
|
6079
6376
|
reserved = JSON.parse(reserved);
|
|
6080
6377
|
}
|
|
6081
6378
|
let dns;
|
|
6379
|
+
const serverDns = line.match(
|
|
6380
|
+
/(?:^|,)\s*server-dns\s*=\s*(?:"([^"]*)"|([^"]*?))(?=\s*(?:,\s*[\w-]+\s*=|$))/i
|
|
6381
|
+
);
|
|
6082
6382
|
let dnsv4 = line.match(/(,|^)\s*?dns\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2];
|
|
6083
6383
|
let dnsv6 = line.match(
|
|
6084
6384
|
/(,|^)\s*?dnsv6\s*?=\s*?"?(.+?)"?\s*?(,|$)/i
|
|
@@ -6122,6 +6422,7 @@ function Loon_WireGuard() {
|
|
|
6122
6422
|
"allowed-ips": allowedIps,
|
|
6123
6423
|
"preshared-key": preSharedKey,
|
|
6124
6424
|
dns,
|
|
6425
|
+
"server-dns": (serverDns?.[1] ?? serverDns?.[2])?.split(",").map((item) => item.trim()).filter(Boolean),
|
|
6125
6426
|
udp: true,
|
|
6126
6427
|
peers: [
|
|
6127
6428
|
{
|
|
@@ -6208,20 +6509,26 @@ function Surge_SS() {
|
|
|
6208
6509
|
function Surge_VMess() {
|
|
6209
6510
|
const name = "Surge VMess Parser";
|
|
6210
6511
|
const test = (line) => {
|
|
6211
|
-
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);
|
|
6212
6513
|
};
|
|
6213
6514
|
const parse2 = (line) => getParser().parse(line);
|
|
6214
6515
|
return { name, test, parse: parse2 };
|
|
6215
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
|
+
}
|
|
6216
6523
|
function Surge_Trojan() {
|
|
6217
6524
|
const name = "Surge Trojan Parser";
|
|
6218
6525
|
const test = (line) => {
|
|
6219
|
-
return /^.*=\s*trojan/.test(line.split(",")[0]);
|
|
6526
|
+
return /^.*=\s*trojan/.test(line.split(",")[0]) && !/^[^=,]*=\s*trojan\s*,[^,]*,[^,]*,\s*"/.test(line);
|
|
6220
6527
|
};
|
|
6221
6528
|
const parse2 = (line) => getParser().parse(line);
|
|
6222
6529
|
return { name, test, parse: parse2 };
|
|
6223
6530
|
}
|
|
6224
|
-
var LOON_ONLY_OPTIONS = /(^|,)\s*(fast-open|over-tls|tls-name|ip-mode|tls-cert-sha256|tls-pubkey-sha256)\s*=/i;
|
|
6531
|
+
var LOON_ONLY_OPTIONS = /(^|,)\s*(fast-open|over-tls|tls-name|ip-mode|tls-cert-sha256|tls-pubkey-sha256|server-dns)\s*=/i;
|
|
6225
6532
|
function Surge_Http() {
|
|
6226
6533
|
const name = "Surge HTTP Parser";
|
|
6227
6534
|
const test = (line) => {
|
|
@@ -6245,7 +6552,7 @@ function Surge_External() {
|
|
|
6245
6552
|
};
|
|
6246
6553
|
const parse2 = (line) => {
|
|
6247
6554
|
let parsed = /^\s*(.*?)\s*?=\s*?external\s*?,\s*(.*?)\s*$/.exec(line);
|
|
6248
|
-
let [
|
|
6555
|
+
let [_5, name2, other] = parsed;
|
|
6249
6556
|
line = other;
|
|
6250
6557
|
let exec = /(,|^)\s*?exec\s*?=\s*"(.*?)"\s*?(,|$)/.exec(line)?.[2];
|
|
6251
6558
|
if (!exec) {
|
|
@@ -6298,12 +6605,15 @@ function Surge_External() {
|
|
|
6298
6605
|
};
|
|
6299
6606
|
return { name, test, parse: parse2 };
|
|
6300
6607
|
}
|
|
6301
|
-
function
|
|
6302
|
-
const name = "
|
|
6303
|
-
const test = (line) =>
|
|
6304
|
-
|
|
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);
|
|
6305
6616
|
};
|
|
6306
|
-
const parse2 = (line) => getParser().parse(line);
|
|
6307
6617
|
return { name, test, parse: parse2 };
|
|
6308
6618
|
}
|
|
6309
6619
|
function Surge_Tuic() {
|
|
@@ -6365,9 +6675,10 @@ var parsers_default = [
|
|
|
6365
6675
|
Surge_SSH(),
|
|
6366
6676
|
Surge_SS(),
|
|
6367
6677
|
Surge_VMess(),
|
|
6678
|
+
Surge_VLESS(),
|
|
6368
6679
|
Surge_Trojan(),
|
|
6369
6680
|
Surge_Http(),
|
|
6370
|
-
|
|
6681
|
+
Snell(),
|
|
6371
6682
|
Surge_Tuic(),
|
|
6372
6683
|
Surge_WireGuard(),
|
|
6373
6684
|
Surge_Hysteria2(),
|
|
@@ -6383,45 +6694,100 @@ var parsers_default = [
|
|
|
6383
6694
|
Loon_Http(),
|
|
6384
6695
|
Loon_Socks5(),
|
|
6385
6696
|
Loon_WireGuard(),
|
|
6697
|
+
Loon_Tailscale(),
|
|
6386
6698
|
QX_SS(),
|
|
6387
6699
|
QX_SSR(),
|
|
6388
6700
|
QX_VMess(),
|
|
6389
6701
|
QX_VLESS(),
|
|
6390
6702
|
QX_AnyTLS(),
|
|
6703
|
+
QX_Hysteria2(),
|
|
6391
6704
|
QX_Trojan(),
|
|
6392
6705
|
QX_Http(),
|
|
6393
6706
|
QX_Socks5()
|
|
6394
6707
|
];
|
|
6395
6708
|
|
|
6709
|
+
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/surge.js
|
|
6710
|
+
import _4 from "lodash";
|
|
6711
|
+
|
|
6396
6712
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/utils.js
|
|
6397
|
-
import
|
|
6713
|
+
import _3 from "lodash";
|
|
6398
6714
|
|
|
6399
6715
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/preprocessors/index.js
|
|
6400
6716
|
import { Base64 as Base642 } from "js-base64";
|
|
6717
|
+
import { isAlias, isScalar, isSeq, parseDocument, visit } from "yaml";
|
|
6401
6718
|
function normalizeClashYaml(raw) {
|
|
6402
|
-
if (typeof raw !== "string" || !raw.includes("
|
|
6719
|
+
if (typeof raw !== "string" || !raw.includes("short-id")) {
|
|
6403
6720
|
return raw;
|
|
6404
6721
|
}
|
|
6722
|
+
let document;
|
|
6405
6723
|
try {
|
|
6406
|
-
|
|
6407
|
-
|
|
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
|
+
))
|
|
6408
6732
|
return raw;
|
|
6409
6733
|
} catch (e) {
|
|
6410
6734
|
return raw;
|
|
6411
6735
|
}
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
|
|
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
|
+
}
|
|
6416
6745
|
}
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
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
|
+
}
|
|
6423
6771
|
}
|
|
6424
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);
|
|
6425
6791
|
}
|
|
6426
6792
|
function HTML() {
|
|
6427
6793
|
const name = "HTML";
|
|
@@ -6585,9 +6951,18 @@ var Result = class {
|
|
|
6585
6951
|
}
|
|
6586
6952
|
};
|
|
6587
6953
|
function isPresent2(obj, attr) {
|
|
6588
|
-
const data =
|
|
6954
|
+
const data = _3.get(obj, attr);
|
|
6589
6955
|
return typeof data !== "undefined" && data !== null;
|
|
6590
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
|
+
}
|
|
6591
6966
|
function isShadowsocksOverTls(proxy) {
|
|
6592
6967
|
const normalizedNetwork = typeof proxy?.network === "string" ? proxy.network.trim().toLowerCase() : proxy?.network;
|
|
6593
6968
|
return proxy?.type === "ss" && proxy?.tls === true && !isPresent2(proxy, "plugin") && (!isPresent2(proxy, "network") || normalizedNetwork === "tcp");
|
|
@@ -6735,6 +7110,34 @@ function appendAlpn(result, proxy) {
|
|
|
6735
7110
|
const alpn = formatSurgeAlpn(proxy.alpn);
|
|
6736
7111
|
if (alpn) result.append(`,alpn="${alpn}"`);
|
|
6737
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
|
+
}
|
|
6738
7141
|
function getShadowTLSAlpn(proxy) {
|
|
6739
7142
|
return formatSurgeAlpn(proxy?.["plugin-opts"]?.alpn ?? proxy?.alpn);
|
|
6740
7143
|
}
|
|
@@ -6784,6 +7187,20 @@ function appendTlsProxyParams(result, proxy, enabled = true) {
|
|
|
6784
7187
|
if (isPresent2(proxy, "keystore-client-cert") || isPresent2(proxy, "client-cert")) {
|
|
6785
7188
|
result.append(`,client-cert=${quoteSurgeValue(clientCert)}`);
|
|
6786
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
|
+
}
|
|
6787
7204
|
}
|
|
6788
7205
|
function appendSshPrivateKey(result, proxy) {
|
|
6789
7206
|
const privateKey = isPresent2(proxy, "keystore-private-key") ? proxy["keystore-private-key"] : proxy["private-key"];
|
|
@@ -6807,12 +7224,11 @@ function isUnsupportedSnellV6Obfs(proxy) {
|
|
|
6807
7224
|
}
|
|
6808
7225
|
function Surge_Producer() {
|
|
6809
7226
|
const produce2 = (proxy, type, opts = {}) => {
|
|
6810
|
-
if (
|
|
7227
|
+
if (proxy.network === "ws" && proxy["ws-opts"]?.["v2ray-http-upgrade"] && !["vmess", "trojan", "vless"].includes(proxy.type)) {
|
|
6811
7228
|
throw unsupported(
|
|
6812
7229
|
`Platform ${targetPlatform} does not support network ${proxy.network} with http upgrade`
|
|
6813
7230
|
);
|
|
6814
7231
|
}
|
|
6815
|
-
proxy.name = proxy.name.replace(/=|,/g, "");
|
|
6816
7232
|
if (proxy.ports) {
|
|
6817
7233
|
proxy.ports = String(proxy.ports);
|
|
6818
7234
|
}
|
|
@@ -6822,7 +7238,8 @@ function Surge_Producer() {
|
|
|
6822
7238
|
case "trojan":
|
|
6823
7239
|
return trojan(proxy);
|
|
6824
7240
|
case "vmess":
|
|
6825
|
-
|
|
7241
|
+
case "vless":
|
|
7242
|
+
return v2ray(proxy, opts["include-unsupported-proxy"]);
|
|
6826
7243
|
case "http":
|
|
6827
7244
|
return http(proxy);
|
|
6828
7245
|
case "h2-connect":
|
|
@@ -7032,6 +7449,15 @@ function trusttunnel(proxy) {
|
|
|
7032
7449
|
result.append(`${proxy.name}=trust-tunnel,${proxy.server},${proxy.port}`);
|
|
7033
7450
|
result.appendIfPresent(`,username="${proxy.username}"`, "username");
|
|
7034
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
|
+
}
|
|
7035
7461
|
appendHeaders(result, proxy);
|
|
7036
7462
|
warnMaxStreamsIfNeeded(proxy);
|
|
7037
7463
|
result.appendIfPresent(
|
|
@@ -7169,13 +7595,16 @@ function h2Connect(proxy) {
|
|
|
7169
7595
|
);
|
|
7170
7596
|
return result.toString();
|
|
7171
7597
|
}
|
|
7172
|
-
function
|
|
7598
|
+
function v2ray(proxy, includeUnsupportedProxy) {
|
|
7599
|
+
const isVless = proxy.type === "vless";
|
|
7173
7600
|
const result = new Result(proxy);
|
|
7174
7601
|
result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`);
|
|
7175
7602
|
result.appendIfPresent(`,username=${proxy.uuid}`, "uuid");
|
|
7176
|
-
|
|
7177
|
-
|
|
7178
|
-
|
|
7603
|
+
if (!isVless) {
|
|
7604
|
+
const encryptMethod = formatSurgeVmessEncryptMethod(proxy.cipher);
|
|
7605
|
+
if (encryptMethod) {
|
|
7606
|
+
result.append(`,encrypt-method=${encryptMethod}`);
|
|
7607
|
+
}
|
|
7179
7608
|
}
|
|
7180
7609
|
const ip_version = ipVersions[proxy["ip-version"]] || proxy["ip-version"];
|
|
7181
7610
|
result.appendIfPresent(`,ip-version=${ip_version}`, "ip-version");
|
|
@@ -7183,14 +7612,15 @@ function vmess(proxy, includeUnsupportedProxy) {
|
|
|
7183
7612
|
`,no-error-alert=${proxy["no-error-alert"]}`,
|
|
7184
7613
|
"no-error-alert"
|
|
7185
7614
|
);
|
|
7186
|
-
|
|
7187
|
-
|
|
7188
|
-
result.append(`,vmess-aead=${proxy.aead}`);
|
|
7615
|
+
if (isVless) {
|
|
7616
|
+
appendVlessParams(result, proxy);
|
|
7189
7617
|
} else {
|
|
7190
|
-
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));
|
|
7191
7623
|
}
|
|
7192
|
-
result.appendIfPresent(`,tls=${proxy.tls}`, "tls");
|
|
7193
|
-
appendTlsProxyParams(result, proxy, Boolean(proxy.tls));
|
|
7194
7624
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
7195
7625
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
7196
7626
|
result.appendIfPresent(
|
|
@@ -7217,6 +7647,84 @@ function vmess(proxy, includeUnsupportedProxy) {
|
|
|
7217
7647
|
);
|
|
7218
7648
|
return result.toString();
|
|
7219
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
|
+
}
|
|
7220
7728
|
function ssh(proxy) {
|
|
7221
7729
|
const result = new Result(proxy);
|
|
7222
7730
|
result.append(`${proxy.name}=ssh,${proxy.server},${proxy.port}`);
|
|
@@ -7702,6 +8210,9 @@ function handleTransport(result, proxy, includeUnsupportedProxy) {
|
|
|
7702
8210
|
if (proxy.network === "ws") {
|
|
7703
8211
|
result.append(`,ws=true`);
|
|
7704
8212
|
if (isPresent2(proxy, "ws-opts")) {
|
|
8213
|
+
if (proxy["ws-opts"]["v2ray-http-upgrade"]) {
|
|
8214
|
+
result.append(",ws-http-upgrade=true");
|
|
8215
|
+
}
|
|
7705
8216
|
result.appendIfPresent(
|
|
7706
8217
|
`,ws-path=${proxy["ws-opts"].path}`,
|
|
7707
8218
|
"ws-opts.path"
|
|
@@ -7732,6 +8243,7 @@ function handleTransport(result, proxy, includeUnsupportedProxy) {
|
|
|
7732
8243
|
import { Base64 as Base643 } from "js-base64";
|
|
7733
8244
|
|
|
7734
8245
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/clashmeta.js
|
|
8246
|
+
var import_buffer2 = __toESM(require_buffer());
|
|
7735
8247
|
var ipVersions2 = {
|
|
7736
8248
|
dual: "dual",
|
|
7737
8249
|
"v4-only": "ipv4",
|
|
@@ -7763,6 +8275,9 @@ function ClashMeta_Producer() {
|
|
|
7763
8275
|
const type = "ALL";
|
|
7764
8276
|
const produce2 = (proxies, type2, opts = {}) => {
|
|
7765
8277
|
const list = proxies.filter((proxy) => {
|
|
8278
|
+
if (!supportsTrustTunnelClientRandomAuth(proxy, "Mihomo")) {
|
|
8279
|
+
return false;
|
|
8280
|
+
}
|
|
7766
8281
|
if (opts["include-unsupported-proxy"]) return true;
|
|
7767
8282
|
if (proxy.type === "h2-connect") {
|
|
7768
8283
|
app_default.error(
|
|
@@ -7784,7 +8299,7 @@ function ClashMeta_Producer() {
|
|
|
7784
8299
|
}
|
|
7785
8300
|
if (!supportsShadowsocksV2rayPluginMode(proxy, ["websocket"])) {
|
|
7786
8301
|
return false;
|
|
7787
|
-
} else if (proxy.type === "snell" && !
|
|
8302
|
+
} else if (proxy.type === "snell" && !supportsMihomoSnell(proxy)) {
|
|
7788
8303
|
return false;
|
|
7789
8304
|
} else if (hasMihomoShadowTls(proxy) && (![
|
|
7790
8305
|
"ss",
|
|
@@ -7902,8 +8417,6 @@ function ClashMeta_Producer() {
|
|
|
7902
8417
|
proxy["pre-shared-key"] = proxy["preshared-key"];
|
|
7903
8418
|
proxy.ip = getWireGuardAddressWithCIDR(proxy, "ipv4");
|
|
7904
8419
|
proxy.ipv6 = getWireGuardAddressWithCIDR(proxy, "ipv6");
|
|
7905
|
-
} else if (proxy.type === "snell" && proxy.version < 3) {
|
|
7906
|
-
delete proxy.udp;
|
|
7907
8420
|
} else if (proxy.type === "vless") {
|
|
7908
8421
|
if (isPresent2(proxy, "sni")) {
|
|
7909
8422
|
proxy.servername = proxy.sni;
|
|
@@ -7925,17 +8438,18 @@ function ClashMeta_Producer() {
|
|
|
7925
8438
|
);
|
|
7926
8439
|
}
|
|
7927
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;
|
|
7928
8447
|
const shadowTLSOpts = getMihomoShadowTlsOpts(proxy);
|
|
7929
8448
|
if (shadowTLSOpts) {
|
|
7930
8449
|
proxy["obfs-opts"] = {
|
|
7931
|
-
|
|
7932
|
-
|
|
7933
|
-
password: shadowTLSOpts.password,
|
|
7934
|
-
version: shadowTLSOpts.version
|
|
8450
|
+
...shadowTLSOpts,
|
|
8451
|
+
mode: "shadow-tls"
|
|
7935
8452
|
};
|
|
7936
|
-
if (shadowTLSOpts.alpn) {
|
|
7937
|
-
proxy["obfs-opts"].alpn = shadowTLSOpts.alpn;
|
|
7938
|
-
}
|
|
7939
8453
|
delete proxy.plugin;
|
|
7940
8454
|
delete proxy["plugin-opts"];
|
|
7941
8455
|
}
|
|
@@ -8049,6 +8563,33 @@ function isSupportedMihomoVersion(version, supportedVersions) {
|
|
|
8049
8563
|
const parsed = Number(normalized);
|
|
8050
8564
|
return Number.isInteger(parsed) && supportedVersions.includes(parsed);
|
|
8051
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
|
+
}
|
|
8052
8593
|
function hasMihomoShadowTls(proxy) {
|
|
8053
8594
|
return Boolean(getMihomoShadowTlsOpts(proxy));
|
|
8054
8595
|
}
|
|
@@ -8681,10 +9222,12 @@ function Loon_Producer() {
|
|
|
8681
9222
|
return shadowsocks2(proxy);
|
|
8682
9223
|
case "ssr":
|
|
8683
9224
|
return shadowsocksr(proxy);
|
|
9225
|
+
case "snell":
|
|
9226
|
+
return snell2(proxy);
|
|
8684
9227
|
case "trojan":
|
|
8685
9228
|
return trojan2(proxy);
|
|
8686
9229
|
case "vmess":
|
|
8687
|
-
return
|
|
9230
|
+
return vmess(proxy, opts["include-unsupported-proxy"]);
|
|
8688
9231
|
case "vless":
|
|
8689
9232
|
return vless(proxy, opts["include-unsupported-proxy"]);
|
|
8690
9233
|
case "http":
|
|
@@ -8693,6 +9236,8 @@ function Loon_Producer() {
|
|
|
8693
9236
|
return socks52(proxy);
|
|
8694
9237
|
case "wireguard":
|
|
8695
9238
|
return wireguard2(proxy);
|
|
9239
|
+
case "tailscale":
|
|
9240
|
+
return tailscale(proxy);
|
|
8696
9241
|
case "hysteria2":
|
|
8697
9242
|
return hysteria22(proxy);
|
|
8698
9243
|
}
|
|
@@ -8708,7 +9253,13 @@ function Loon_Producer() {
|
|
|
8708
9253
|
`Platform ${targetPlatform3} does not support proxy type: ${proxy.type}`
|
|
8709
9254
|
);
|
|
8710
9255
|
};
|
|
8711
|
-
return {
|
|
9256
|
+
return {
|
|
9257
|
+
produce: (proxy, type, opts = {}) => {
|
|
9258
|
+
const result = produce2(proxy, type, opts);
|
|
9259
|
+
const serverDns = proxy["server-dns"];
|
|
9260
|
+
return Array.isArray(serverDns) && serverDns.length > 0 ? `${result},server-dns="${serverDns.join(",")}"` : result;
|
|
9261
|
+
}
|
|
9262
|
+
};
|
|
8712
9263
|
}
|
|
8713
9264
|
function appendTlsProfile(result, proxy) {
|
|
8714
9265
|
const tlsProfile = getLoonTlsProfile(proxy);
|
|
@@ -8718,6 +9269,40 @@ function appendAlpn2(result, proxy) {
|
|
|
8718
9269
|
const alpn = getLoonAlpn(proxy);
|
|
8719
9270
|
if (alpn) result.append(`,alpn="${alpn}"`);
|
|
8720
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
|
+
}
|
|
8721
9306
|
function getLoonShadowTLSAlpn(proxy) {
|
|
8722
9307
|
const values = proxy?.["plugin-opts"]?.alpn ?? proxy?.alpn;
|
|
8723
9308
|
const normalized = Array.isArray(values) ? values : `${values || ""}`.split(",");
|
|
@@ -8759,14 +9344,26 @@ function getLoonAlpn(proxy) {
|
|
|
8759
9344
|
}
|
|
8760
9345
|
function getLoonTlsProfile(proxy) {
|
|
8761
9346
|
const tlsProfile = `${proxy._loon_tls_profile || ""}`.trim();
|
|
8762
|
-
if ([
|
|
9347
|
+
if ([
|
|
9348
|
+
"global",
|
|
9349
|
+
"default",
|
|
9350
|
+
"safari-ios18",
|
|
9351
|
+
"safari-ios-26",
|
|
9352
|
+
"chrome",
|
|
9353
|
+
"chrome147"
|
|
9354
|
+
].includes(tlsProfile)) {
|
|
8763
9355
|
return tlsProfile;
|
|
8764
9356
|
}
|
|
8765
|
-
|
|
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) {
|
|
8766
9362
|
case "chrome":
|
|
8767
9363
|
return "chrome";
|
|
9364
|
+
case "safari":
|
|
8768
9365
|
case "ios":
|
|
8769
|
-
return "
|
|
9366
|
+
return "safari-ios18";
|
|
8770
9367
|
}
|
|
8771
9368
|
}
|
|
8772
9369
|
function shadowsocks2(proxy) {
|
|
@@ -8870,8 +9467,46 @@ function shadowsocksr(proxy) {
|
|
|
8870
9467
|
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
8871
9468
|
return result.toString();
|
|
8872
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
|
+
}
|
|
8873
9507
|
function trojan2(proxy) {
|
|
8874
9508
|
const isReality = !!proxy["reality-opts"];
|
|
9509
|
+
const isXhttp = proxy.network === "xhttp";
|
|
8875
9510
|
const result = new Result(proxy);
|
|
8876
9511
|
result.append(
|
|
8877
9512
|
`${proxy.name}=trojan,${proxy.server},${proxy.port},"${proxy.password}"`
|
|
@@ -8890,6 +9525,8 @@ function trojan2(proxy) {
|
|
|
8890
9525
|
`,host=${proxy["ws-opts"]?.headers?.Host}`,
|
|
8891
9526
|
"ws-opts.headers.Host"
|
|
8892
9527
|
);
|
|
9528
|
+
} else if (isXhttp) {
|
|
9529
|
+
appendXhttp(result, proxy);
|
|
8893
9530
|
} else {
|
|
8894
9531
|
throw new Error(`network ${proxy.network} is unsupported`);
|
|
8895
9532
|
}
|
|
@@ -8903,7 +9540,10 @@ function trojan2(proxy) {
|
|
|
8903
9540
|
if (isReality) {
|
|
8904
9541
|
appendReality(result, proxy);
|
|
8905
9542
|
} else {
|
|
8906
|
-
result.appendIfPresent(
|
|
9543
|
+
result.appendIfPresent(
|
|
9544
|
+
`,${isXhttp ? "sni" : "tls-name"}=${proxy.sni}`,
|
|
9545
|
+
"sni"
|
|
9546
|
+
);
|
|
8907
9547
|
result.appendIfPresent(
|
|
8908
9548
|
`,tls-cert-sha256=${proxy["tls-fingerprint"]}`,
|
|
8909
9549
|
"tls-fingerprint"
|
|
@@ -8974,8 +9614,9 @@ function anytls2(proxy) {
|
|
|
8974
9614
|
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
8975
9615
|
return result.toString();
|
|
8976
9616
|
}
|
|
8977
|
-
function
|
|
9617
|
+
function vmess(proxy) {
|
|
8978
9618
|
const isReality = !!proxy["reality-opts"];
|
|
9619
|
+
const isXhttp = proxy.network === "xhttp";
|
|
8979
9620
|
const security = formatLoonVmessSecurity(proxy.cipher);
|
|
8980
9621
|
const result = new Result(proxy);
|
|
8981
9622
|
result.append(
|
|
@@ -9007,6 +9648,8 @@ function vmess2(proxy) {
|
|
|
9007
9648
|
`,host=${Array.isArray(httpHost) ? httpHost[0] : httpHost}`,
|
|
9008
9649
|
"http-opts.headers.Host"
|
|
9009
9650
|
);
|
|
9651
|
+
} else if (isXhttp) {
|
|
9652
|
+
appendXhttp(result, proxy);
|
|
9010
9653
|
} else {
|
|
9011
9654
|
throw new Error(`network ${proxy.network} is unsupported`);
|
|
9012
9655
|
}
|
|
@@ -9018,14 +9661,15 @@ function vmess2(proxy) {
|
|
|
9018
9661
|
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
9019
9662
|
"skip-cert-verify"
|
|
9020
9663
|
);
|
|
9021
|
-
if (proxy.tls || isReality)
|
|
9022
|
-
|
|
9023
|
-
appendAlpn2(result, proxy);
|
|
9024
|
-
}
|
|
9664
|
+
if (proxy.tls || isReality) appendTlsProfile(result, proxy);
|
|
9665
|
+
if (proxy.tls || isReality || isXhttp) appendAlpn2(result, proxy);
|
|
9025
9666
|
if (isReality) {
|
|
9026
9667
|
appendReality(result, proxy);
|
|
9027
9668
|
} else {
|
|
9028
|
-
result.appendIfPresent(
|
|
9669
|
+
result.appendIfPresent(
|
|
9670
|
+
`,${isXhttp ? "sni" : "tls-name"}=${proxy.sni}`,
|
|
9671
|
+
"sni"
|
|
9672
|
+
);
|
|
9029
9673
|
result.appendIfPresent(
|
|
9030
9674
|
`,tls-cert-sha256=${proxy["tls-fingerprint"]}`,
|
|
9031
9675
|
"tls-fingerprint"
|
|
@@ -9035,11 +9679,13 @@ function vmess2(proxy) {
|
|
|
9035
9679
|
"tls-pubkey-sha256"
|
|
9036
9680
|
);
|
|
9037
9681
|
}
|
|
9038
|
-
|
|
9039
|
-
|
|
9040
|
-
|
|
9041
|
-
|
|
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");
|
|
9042
9687
|
}
|
|
9688
|
+
result.append(`,alterId=${alterId}`);
|
|
9043
9689
|
result.appendIfPresent(`,fast-open=${proxy.tfo}`, "tfo");
|
|
9044
9690
|
if (proxy["block-quic"] === "on") {
|
|
9045
9691
|
result.append(",block-quic=true");
|
|
@@ -9058,7 +9704,10 @@ function vless(proxy) {
|
|
|
9058
9704
|
throw new Error(`VLESS encryption is not supported`);
|
|
9059
9705
|
let isXtls = false;
|
|
9060
9706
|
const isReality = !!proxy["reality-opts"];
|
|
9061
|
-
|
|
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") {
|
|
9062
9711
|
if (["xtls-rprx-vision"].includes(proxy.flow)) {
|
|
9063
9712
|
isXtls = true;
|
|
9064
9713
|
} else {
|
|
@@ -9095,6 +9744,8 @@ function vless(proxy) {
|
|
|
9095
9744
|
`,host=${Array.isArray(httpHost) ? httpHost[0] : httpHost}`,
|
|
9096
9745
|
"http-opts.headers.Host"
|
|
9097
9746
|
);
|
|
9747
|
+
} else if (isXhttp) {
|
|
9748
|
+
appendXhttp(result, proxy);
|
|
9098
9749
|
} else {
|
|
9099
9750
|
throw new Error(`network ${proxy.network} is unsupported`);
|
|
9100
9751
|
}
|
|
@@ -9106,17 +9757,18 @@ function vless(proxy) {
|
|
|
9106
9757
|
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
9107
9758
|
"skip-cert-verify"
|
|
9108
9759
|
);
|
|
9109
|
-
if (proxy.tls || isReality || isXtls)
|
|
9110
|
-
|
|
9111
|
-
appendAlpn2(result, proxy);
|
|
9112
|
-
}
|
|
9760
|
+
if (proxy.tls || isReality || isXtls) appendTlsProfile(result, proxy);
|
|
9761
|
+
if (proxy.tls || isReality || isXtls || isXhttp) appendAlpn2(result, proxy);
|
|
9113
9762
|
if (isXtls) {
|
|
9114
9763
|
result.appendIfPresent(`,flow=${proxy.flow}`, "flow");
|
|
9115
9764
|
}
|
|
9116
9765
|
if (isReality) {
|
|
9117
9766
|
appendReality(result, proxy);
|
|
9118
9767
|
} else {
|
|
9119
|
-
result.appendIfPresent(
|
|
9768
|
+
result.appendIfPresent(
|
|
9769
|
+
`,${isXhttp ? "sni" : "tls-name"}=${proxy.sni}`,
|
|
9770
|
+
"sni"
|
|
9771
|
+
);
|
|
9120
9772
|
result.appendIfPresent(
|
|
9121
9773
|
`,tls-cert-sha256=${proxy["tls-fingerprint"]}`,
|
|
9122
9774
|
"tls-fingerprint"
|
|
@@ -9192,6 +9844,42 @@ function socks52(proxy) {
|
|
|
9192
9844
|
result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
|
|
9193
9845
|
return result.toString();
|
|
9194
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
|
+
}
|
|
9195
9883
|
function wireguard2(proxy) {
|
|
9196
9884
|
if (Array.isArray(proxy.peers) && proxy.peers.length > 0) {
|
|
9197
9885
|
proxy.server = proxy.peers[0].server;
|
|
@@ -9678,17 +10366,17 @@ function mergeUnsupportedXhttpExtraObject(baseObject, unsupportedObject) {
|
|
|
9678
10366
|
}
|
|
9679
10367
|
return mergedExtra;
|
|
9680
10368
|
}
|
|
9681
|
-
function
|
|
9682
|
-
if (typeof
|
|
9683
|
-
return
|
|
10369
|
+
function serializeUriJsonValue(value) {
|
|
10370
|
+
if (typeof value === "string") {
|
|
10371
|
+
return value;
|
|
9684
10372
|
}
|
|
9685
|
-
if (isPlainObject(
|
|
9686
|
-
return JSON.stringify(
|
|
10373
|
+
if (isPlainObject(value)) {
|
|
10374
|
+
return JSON.stringify(value);
|
|
9687
10375
|
}
|
|
9688
10376
|
return void 0;
|
|
9689
10377
|
}
|
|
9690
10378
|
function buildVlessExtra(proxy) {
|
|
9691
|
-
const explicitExtraOverride =
|
|
10379
|
+
const explicitExtraOverride = serializeUriJsonValue(proxy._extra);
|
|
9692
10380
|
if (explicitExtraOverride != null) {
|
|
9693
10381
|
return explicitExtraOverride;
|
|
9694
10382
|
}
|
|
@@ -9785,6 +10473,11 @@ function vless2(proxy) {
|
|
|
9785
10473
|
if (extraPayload) {
|
|
9786
10474
|
extra = `&extra=${encodeURIComponent(extraPayload)}`;
|
|
9787
10475
|
}
|
|
10476
|
+
let fm = "";
|
|
10477
|
+
const finalmaskPayload = serializeUriJsonValue(proxy._finalmask);
|
|
10478
|
+
if (finalmaskPayload) {
|
|
10479
|
+
fm = `&fm=${encodeURIComponent(finalmaskPayload)}`;
|
|
10480
|
+
}
|
|
9788
10481
|
let mode = "";
|
|
9789
10482
|
if (["xhttp"].includes(proxy.network) && proxy[`${proxy.network}-opts`]?.mode) {
|
|
9790
10483
|
mode = `&mode=${encodeURIComponent(
|
|
@@ -9903,7 +10596,7 @@ function vless2(proxy) {
|
|
|
9903
10596
|
}
|
|
9904
10597
|
return `vless://${proxy.uuid}@${proxy.server}:${proxy.port}?security=${encodeURIComponent(
|
|
9905
10598
|
security
|
|
9906
|
-
)}${vlessTransport}${packetEncoding}${alpn}${allowInsecure}${pcs}${vcn}${ech}${h2}${sni}${fp}${flow}${sid}${spx}${pbk}${mode}${extra}${pqv}${encryption}#${encodeURIComponent(
|
|
10599
|
+
)}${vlessTransport}${packetEncoding}${alpn}${allowInsecure}${pcs}${vcn}${ech}${h2}${sni}${fp}${flow}${sid}${spx}${pbk}${mode}${extra}${fm}${pqv}${encryption}#${encodeURIComponent(
|
|
9907
10600
|
proxy.name
|
|
9908
10601
|
)}`;
|
|
9909
10602
|
}
|
|
@@ -9979,6 +10672,7 @@ function URI_Producer() {
|
|
|
9979
10672
|
if (proxy.tfo) {
|
|
9980
10673
|
query += "&tfo=1";
|
|
9981
10674
|
}
|
|
10675
|
+
query += `&udp=${proxy.udp ? 1 : 0}`;
|
|
9982
10676
|
let ssTransport = "";
|
|
9983
10677
|
if (proxy.network) {
|
|
9984
10678
|
let ssType = proxy.network;
|
|
@@ -10050,7 +10744,7 @@ function URI_Producer() {
|
|
|
10050
10744
|
let ssSpx = "";
|
|
10051
10745
|
let ssSecurity = proxy.tls ? "&security=tls" : "";
|
|
10052
10746
|
let ssMode = "";
|
|
10053
|
-
|
|
10747
|
+
const ssExtra = proxy._extra && (ssIsReality || proxy.network === "xhttp") ? `&extra=${encodeURIComponent(proxy._extra)}` : "";
|
|
10054
10748
|
if (ssIsReality) {
|
|
10055
10749
|
ssSecurity = `&security=reality`;
|
|
10056
10750
|
const publicKey = proxy["reality-opts"]?.["public-key"];
|
|
@@ -10065,9 +10759,6 @@ function URI_Producer() {
|
|
|
10065
10759
|
if (spiderX) {
|
|
10066
10760
|
ssSpx = `&spx=${encodeURIComponent(spiderX)}`;
|
|
10067
10761
|
}
|
|
10068
|
-
if (proxy._extra) {
|
|
10069
|
-
ssExtra = `&extra=${encodeURIComponent(proxy._extra)}`;
|
|
10070
|
-
}
|
|
10071
10762
|
if (proxy._mode) {
|
|
10072
10763
|
ssMode = `&mode=${encodeURIComponent(proxy._mode)}`;
|
|
10073
10764
|
}
|
|
@@ -10088,10 +10779,10 @@ function URI_Producer() {
|
|
|
10088
10779
|
result = "ssr://" + Base644.encode(result);
|
|
10089
10780
|
break;
|
|
10090
10781
|
case "vmess":
|
|
10091
|
-
if (proxy["reality-opts"]) {
|
|
10782
|
+
if (proxy["reality-opts"] || proxy._finalmask) {
|
|
10092
10783
|
if (proxy.aead === false || proxy.aead !== true && Number(proxy.alterId || 0) !== 0) {
|
|
10093
10784
|
throw new Error(
|
|
10094
|
-
"VMess
|
|
10785
|
+
"VMess query URI format cannot represent non-AEAD authentication (alterId must be 0)"
|
|
10095
10786
|
);
|
|
10096
10787
|
}
|
|
10097
10788
|
result = vless2({
|
|
@@ -10163,7 +10854,7 @@ function URI_Producer() {
|
|
|
10163
10854
|
result.path = vmessTransportPath;
|
|
10164
10855
|
}
|
|
10165
10856
|
if (vmessTransportHost) {
|
|
10166
|
-
result.host = Array.isArray(vmessTransportHost) ? vmessTransportHost[0] : vmessTransportHost;
|
|
10857
|
+
result.host = Array.isArray(vmessTransportHost) ? proxy.network === "h2" ? vmessTransportHost.join(",") : vmessTransportHost[0] : vmessTransportHost;
|
|
10167
10858
|
}
|
|
10168
10859
|
}
|
|
10169
10860
|
}
|
|
@@ -10279,7 +10970,9 @@ function URI_Producer() {
|
|
|
10279
10970
|
trojanMode = `&mode=${encodeURIComponent(proxy._mode)}`;
|
|
10280
10971
|
}
|
|
10281
10972
|
}
|
|
10282
|
-
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(
|
|
10283
10976
|
proxy.name
|
|
10284
10977
|
)}`;
|
|
10285
10978
|
break;
|
|
@@ -10440,7 +11133,8 @@ function URI_Producer() {
|
|
|
10440
11133
|
case "anytls":
|
|
10441
11134
|
result = vless2({
|
|
10442
11135
|
...proxy,
|
|
10443
|
-
uuid
|
|
11136
|
+
// vless() writes the uuid as is; a password may contain @, :, # etc.
|
|
11137
|
+
uuid: encodeURIComponent(proxy.password),
|
|
10444
11138
|
network: proxy.network || "tcp"
|
|
10445
11139
|
}).replace("vless", "anytls");
|
|
10446
11140
|
let anytlsParams = [];
|
|
@@ -10590,12 +11284,12 @@ Reason: ${err}`);
|
|
|
10590
11284
|
}
|
|
10591
11285
|
|
|
10592
11286
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/qx.js
|
|
10593
|
-
var
|
|
11287
|
+
var import_buffer3 = __toESM(require_buffer());
|
|
10594
11288
|
var targetPlatform4 = "QX";
|
|
10595
11289
|
function encodeQxAlpn(alpn) {
|
|
10596
11290
|
const protocols = (Array.isArray(alpn) ? alpn : `${alpn}`.split(",")).map((protocol) => `${protocol}`.trim()).filter(Boolean);
|
|
10597
11291
|
return protocols.map((protocol) => {
|
|
10598
|
-
const bytes =
|
|
11292
|
+
const bytes = import_buffer3.Buffer.from(protocol, "utf8");
|
|
10599
11293
|
if (bytes.length > 255) {
|
|
10600
11294
|
throw new Error("QX ALPN protocol exceeds 255 bytes");
|
|
10601
11295
|
}
|
|
@@ -10625,7 +11319,7 @@ function QX_Producer() {
|
|
|
10625
11319
|
case "trojan":
|
|
10626
11320
|
return trojan3(proxy);
|
|
10627
11321
|
case "vmess":
|
|
10628
|
-
return
|
|
11322
|
+
return vmess2(proxy);
|
|
10629
11323
|
case "http":
|
|
10630
11324
|
return http3(proxy);
|
|
10631
11325
|
case "socks5":
|
|
@@ -10634,6 +11328,8 @@ function QX_Producer() {
|
|
|
10634
11328
|
return vless3(proxy);
|
|
10635
11329
|
case "anytls":
|
|
10636
11330
|
return anytls3(proxy);
|
|
11331
|
+
case "hysteria2":
|
|
11332
|
+
return hysteria23(proxy);
|
|
10637
11333
|
}
|
|
10638
11334
|
throw new Error(
|
|
10639
11335
|
`Platform ${targetPlatform4} does not support proxy type: ${proxy.type}`
|
|
@@ -10743,7 +11439,7 @@ function shadowsocks3(proxy) {
|
|
|
10743
11439
|
"plugin-opts.path"
|
|
10744
11440
|
);
|
|
10745
11441
|
}
|
|
10746
|
-
if (needTls(proxy)) {
|
|
11442
|
+
if (needTls(proxy) || proxy.plugin === "v2ray-plugin" && proxy["plugin-opts"]?.tls) {
|
|
10747
11443
|
appendIfPresent(
|
|
10748
11444
|
`,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
|
|
10749
11445
|
"tls-pubkey-sha256"
|
|
@@ -10862,7 +11558,7 @@ function trojan3(proxy) {
|
|
|
10862
11558
|
append(`,tag=${proxy.name}`);
|
|
10863
11559
|
return result.toString();
|
|
10864
11560
|
}
|
|
10865
|
-
function
|
|
11561
|
+
function vmess2(proxy) {
|
|
10866
11562
|
const result = new Result(proxy);
|
|
10867
11563
|
const append = result.append.bind(result);
|
|
10868
11564
|
const appendIfPresent = result.appendIfPresent.bind(result);
|
|
@@ -11042,6 +11738,52 @@ function anytls3(proxy) {
|
|
|
11042
11738
|
append(`,tag=${proxy.name}`);
|
|
11043
11739
|
return result.toString();
|
|
11044
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
|
+
}
|
|
11045
11787
|
function http3(proxy) {
|
|
11046
11788
|
const result = new Result(proxy);
|
|
11047
11789
|
const append = result.append.bind(result);
|
|
@@ -11368,24 +12110,23 @@ function Surfboard_Producer() {
|
|
|
11368
12110
|
`Platform ${targetPlatform5} does not support network ${proxy.network} with http upgrade`
|
|
11369
12111
|
);
|
|
11370
12112
|
}
|
|
11371
|
-
proxy.name = proxy.name.replace(/=|,/g, "");
|
|
11372
12113
|
switch (proxy.type) {
|
|
11373
12114
|
case "ss":
|
|
11374
12115
|
return shadowsocks4(proxy);
|
|
11375
12116
|
case "trojan":
|
|
11376
12117
|
return trojan4(proxy);
|
|
11377
12118
|
case "vmess":
|
|
11378
|
-
return
|
|
12119
|
+
return vmess3(proxy);
|
|
11379
12120
|
case "http":
|
|
11380
12121
|
return http4(proxy);
|
|
11381
12122
|
case "snell":
|
|
11382
|
-
return
|
|
12123
|
+
return snell3(proxy);
|
|
11383
12124
|
case "tuic":
|
|
11384
12125
|
return tuic2(proxy);
|
|
11385
12126
|
case "socks5":
|
|
11386
12127
|
return socks54(proxy);
|
|
11387
12128
|
case "hysteria2":
|
|
11388
|
-
return
|
|
12129
|
+
return hysteria24(proxy);
|
|
11389
12130
|
case "wireguard-surge":
|
|
11390
12131
|
return wireguard3(proxy);
|
|
11391
12132
|
}
|
|
@@ -11430,7 +12171,7 @@ function tuic2(proxy) {
|
|
|
11430
12171
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
11431
12172
|
return result.toString();
|
|
11432
12173
|
}
|
|
11433
|
-
function
|
|
12174
|
+
function hysteria24(proxy) {
|
|
11434
12175
|
if (proxy.obfs && proxy.obfs !== "salamander" || proxy["obfs-password"] && proxy.obfs !== "salamander") {
|
|
11435
12176
|
throw new Error(`Surfboard Hysteria2 only supports salamander obfs`);
|
|
11436
12177
|
}
|
|
@@ -11468,7 +12209,7 @@ function anytls4(proxy) {
|
|
|
11468
12209
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
11469
12210
|
return result.toString();
|
|
11470
12211
|
}
|
|
11471
|
-
function
|
|
12212
|
+
function snell3(proxy) {
|
|
11472
12213
|
if (isPresent2(proxy, "version") && ![1, 2, 3, 4, 5].includes(Number(proxy.version))) {
|
|
11473
12214
|
throw new Error(
|
|
11474
12215
|
`Platform ${targetPlatform5} does not support snell version ${proxy.version}`
|
|
@@ -11559,7 +12300,7 @@ function trojan4(proxy) {
|
|
|
11559
12300
|
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
11560
12301
|
return result.toString();
|
|
11561
12302
|
}
|
|
11562
|
-
function
|
|
12303
|
+
function vmess3(proxy) {
|
|
11563
12304
|
const result = new Result(proxy);
|
|
11564
12305
|
result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`);
|
|
11565
12306
|
result.appendIfPresent(`,username=${proxy.uuid}`, "uuid");
|
|
@@ -11639,6 +12380,7 @@ function handleTransport2(result, proxy) {
|
|
|
11639
12380
|
}
|
|
11640
12381
|
|
|
11641
12382
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/sing-box.js
|
|
12383
|
+
var import_buffer4 = __toESM(require_buffer());
|
|
11642
12384
|
var ipVersions4 = {
|
|
11643
12385
|
ipv4: "ipv4_only",
|
|
11644
12386
|
ipv6: "ipv6_only",
|
|
@@ -11925,6 +12667,41 @@ var getSingBoxUtlsFingerprint = (value) => {
|
|
|
11925
12667
|
const fingerprint = `${value || ""}`.trim().toLowerCase();
|
|
11926
12668
|
if (singBoxUtlsFingerprints.includes(fingerprint)) return fingerprint;
|
|
11927
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
|
+
};
|
|
11928
12705
|
var tlsParser = (proxy, parsedProxy) => {
|
|
11929
12706
|
if (proxy.tls) parsedProxy.tls.enabled = true;
|
|
11930
12707
|
if (proxy.servername && proxy.servername !== "")
|
|
@@ -11938,9 +12715,6 @@ var tlsParser = (proxy, parsedProxy) => {
|
|
|
11938
12715
|
if (typeof proxy.alpn === "string") {
|
|
11939
12716
|
parsedProxy.tls.alpn = [proxy.alpn];
|
|
11940
12717
|
} else if (Array.isArray(proxy.alpn)) parsedProxy.tls.alpn = proxy.alpn;
|
|
11941
|
-
if (proxy.ca) parsedProxy.tls.certificate_path = `${proxy.ca}`;
|
|
11942
|
-
if (proxy.ca_str) parsedProxy.tls.certificate = [proxy.ca_str];
|
|
11943
|
-
if (proxy["ca-str"]) parsedProxy.tls.certificate = [proxy["ca-str"]];
|
|
11944
12718
|
if (proxy["reality-opts"]) {
|
|
11945
12719
|
parsedProxy.tls.reality = { enabled: true };
|
|
11946
12720
|
if (proxy["reality-opts"]["public-key"])
|
|
@@ -11984,12 +12758,6 @@ var tlsParser = (proxy, parsedProxy) => {
|
|
|
11984
12758
|
parsedProxy.tls.fragment_fallback_delay = proxy["_fragment_fallback_delay"];
|
|
11985
12759
|
if (proxy["_record_fragment"])
|
|
11986
12760
|
parsedProxy.tls.record_fragment = !!proxy["_record_fragment"];
|
|
11987
|
-
if (proxy["_certificate"])
|
|
11988
|
-
parsedProxy.tls.certificate = proxy["_certificate"];
|
|
11989
|
-
if (proxy["_certificate_path"])
|
|
11990
|
-
parsedProxy.tls.certificate_path = proxy["_certificate_path"];
|
|
11991
|
-
if (proxy["_certificate_public_key_sha256"])
|
|
11992
|
-
parsedProxy.tls.certificate_public_key_sha256 = proxy["_certificate_public_key_sha256"];
|
|
11993
12761
|
if (proxy["_client_certificate"])
|
|
11994
12762
|
parsedProxy.tls.client_certificate = proxy["_client_certificate"];
|
|
11995
12763
|
if (proxy["_client_certificate_path"])
|
|
@@ -11999,11 +12767,7 @@ var tlsParser = (proxy, parsedProxy) => {
|
|
|
11999
12767
|
parsedProxy.tls.client_key_path = proxy["_client_key_path"];
|
|
12000
12768
|
if (!parsedProxy.tls.enabled) {
|
|
12001
12769
|
delete parsedProxy.tls;
|
|
12002
|
-
} else
|
|
12003
|
-
app_default.warn(
|
|
12004
|
-
`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`
|
|
12005
|
-
);
|
|
12006
|
-
}
|
|
12770
|
+
} else tlsCertificateParser(proxy, parsedProxy);
|
|
12007
12771
|
};
|
|
12008
12772
|
var sshParser = (proxy = {}) => {
|
|
12009
12773
|
const parsedProxy = {
|
|
@@ -12016,9 +12780,10 @@ var sshParser = (proxy = {}) => {
|
|
|
12016
12780
|
throw "invalid port";
|
|
12017
12781
|
if (proxy.username) parsedProxy.user = proxy.username;
|
|
12018
12782
|
if (proxy.password) parsedProxy.password = proxy.password;
|
|
12019
|
-
|
|
12020
|
-
if (
|
|
12021
|
-
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
|
+
}
|
|
12022
12787
|
if (proxy["private-key-passphrase"])
|
|
12023
12788
|
parsedProxy.private_key_passphrase = proxy["private-key-passphrase"];
|
|
12024
12789
|
if (proxy["server-fingerprint"]) {
|
|
@@ -12164,6 +12929,7 @@ var shadowTLSOutboundParser = (proxy = {}, pluginOpts) => {
|
|
|
12164
12929
|
throw "\u7AEF\u53E3\u503C\u975E\u6CD5";
|
|
12165
12930
|
const alpn = normalizeALPN(pluginOpts.alpn) ?? normalizeALPN(proxy.alpn);
|
|
12166
12931
|
if (alpn) stPart.tls.alpn = alpn;
|
|
12932
|
+
tlsCertificateParser(proxy, stPart);
|
|
12167
12933
|
if (proxy["fast-open"] === true) stPart.udp_fragment = true;
|
|
12168
12934
|
tfoParser(proxy, stPart);
|
|
12169
12935
|
detourParser(proxy, stPart);
|
|
@@ -12307,7 +13073,8 @@ var snellParser = (proxy = {}, includeUnsupportedProxy = false) => {
|
|
|
12307
13073
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
12308
13074
|
throw "invalid port";
|
|
12309
13075
|
if (outputVersion != null) parsedProxy.version = outputVersion;
|
|
12310
|
-
if (proxy.
|
|
13076
|
+
if (proxy.userkey || proxy._userkey)
|
|
13077
|
+
parsedProxy.userkey = proxy.userkey || proxy._userkey;
|
|
12311
13078
|
if (outputVersion === 6) {
|
|
12312
13079
|
if (proxy.mode) parsedProxy.mode = proxy.mode;
|
|
12313
13080
|
if (includeUnsupportedProxy && proxy["quic-proxy-mode"])
|
|
@@ -12668,9 +13435,13 @@ var anytlsParser = (proxy = {}, includeUnsupportedProxy = false) => {
|
|
|
12668
13435
|
};
|
|
12669
13436
|
var tailscaleParser = (proxy = {}) => {
|
|
12670
13437
|
const useControlHTTPClient = hasControlHTTPClient(proxy);
|
|
13438
|
+
const listenPort = parseSafeIntegerValue(proxy._listen_port);
|
|
12671
13439
|
const parsedProxy = {
|
|
12672
13440
|
tag: proxy.name,
|
|
12673
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,
|
|
12674
13445
|
control_http_client: proxy["control-http-client"],
|
|
12675
13446
|
udp_timeout: proxy["udp-timeout"],
|
|
12676
13447
|
state_directory: proxy["state-dir"] || proxy["state-directory"],
|
|
@@ -12719,10 +13490,16 @@ var tailscaleParser = (proxy = {}) => {
|
|
|
12719
13490
|
};
|
|
12720
13491
|
var wireguardParser = (proxy = {}) => {
|
|
12721
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);
|
|
12722
13495
|
const parsedProxy = {
|
|
12723
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,
|
|
12724
13500
|
mtu: proxy.mtu ? parseInt(`${proxy.mtu}`, 10) : void 0,
|
|
12725
13501
|
udp_timeout: proxy["udp-timeout"],
|
|
13502
|
+
udp_nat_max: udpNatMax != null && udpNatMax <= 4294967295 ? udpNatMax : void 0,
|
|
12726
13503
|
workers: proxy["workers"] ? parseInt(`${proxy["workers"]}`, 10) : void 0,
|
|
12727
13504
|
tag: proxy.name,
|
|
12728
13505
|
type: "wireguard",
|
|
@@ -12734,6 +13511,15 @@ var wireguardParser = (proxy = {}) => {
|
|
|
12734
13511
|
pre_shared_key: proxy["pre-shared-key"],
|
|
12735
13512
|
reserved: []
|
|
12736
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
|
+
}
|
|
12737
13523
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
12738
13524
|
throw "invalid port";
|
|
12739
13525
|
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
@@ -12759,16 +13545,20 @@ var wireguardParser = (proxy = {}) => {
|
|
|
12759
13545
|
address2 = parsedProxy.server;
|
|
12760
13546
|
port = parseInt(`${parsedProxy.server_port}`, 10);
|
|
12761
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
|
+
}
|
|
12762
13555
|
const peer = {
|
|
12763
13556
|
address: address2,
|
|
12764
13557
|
port,
|
|
12765
13558
|
persistent_keepalive_interval: p["persistent-keepalive-interval"] ? parseInt(`${p["persistent-keepalive-interval"]}`, 10) : void 0,
|
|
12766
13559
|
public_key: p["public-key"] || p["public_key"] || parsedProxy.peer_public_key,
|
|
12767
13560
|
pre_shared_key: p["pre-shared-key"] || p["pre_shared_key"] || parsedProxy.pre_shared_key,
|
|
12768
|
-
allowed_ips:
|
|
12769
|
-
"0.0.0.0/0",
|
|
12770
|
-
...proxy.ipv6 ? ["::/0"] : []
|
|
12771
|
-
],
|
|
13561
|
+
allowed_ips: allowedIps,
|
|
12772
13562
|
reserved: []
|
|
12773
13563
|
};
|
|
12774
13564
|
if (typeof p.reserved === "string") {
|
|
@@ -13436,7 +14226,7 @@ function Egern_Producer() {
|
|
|
13436
14226
|
port: proxy.port,
|
|
13437
14227
|
private_key: proxy["private-key"],
|
|
13438
14228
|
peer_public_key: proxy["public-key"],
|
|
13439
|
-
preshared_key: proxy["preshared-key"],
|
|
14229
|
+
preshared_key: proxy["preshared-key"] ?? proxy["pre-shared-key"],
|
|
13440
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,
|
|
13441
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,
|
|
13442
14232
|
mtu: proxy.mtu,
|
|
@@ -13745,6 +14535,7 @@ var producers_default = {
|
|
|
13745
14535
|
SurgeMac: SurgeMac_Producer(),
|
|
13746
14536
|
Loon: Loon_Producer(),
|
|
13747
14537
|
Clash: Clash_Producer(),
|
|
14538
|
+
clash: Clash_Producer(),
|
|
13748
14539
|
meta: ClashMeta_Producer(),
|
|
13749
14540
|
clashmeta: ClashMeta_Producer(),
|
|
13750
14541
|
"clash.meta": ClashMeta_Producer(),
|