sub-store-convert 2.44.26 → 2.44.30

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.
Files changed (2) hide show
  1. package/index.js +502 -207
  2. package/package.json +1 -1
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 = Buffer6;
222
+ exports.Buffer = Buffer7;
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
- Buffer6.TYPED_ARRAY_SUPPORT = typedArraySupport();
228
- if (!Buffer6.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") {
227
+ Buffer7.TYPED_ARRAY_SUPPORT = typedArraySupport();
228
+ if (!Buffer7.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(Buffer6.prototype, "parent", {
246
+ Object.defineProperty(Buffer7.prototype, "parent", {
247
247
  enumerable: true,
248
248
  get: function() {
249
- if (!Buffer6.isBuffer(this)) return void 0;
249
+ if (!Buffer7.isBuffer(this)) return void 0;
250
250
  return this.buffer;
251
251
  }
252
252
  });
253
- Object.defineProperty(Buffer6.prototype, "offset", {
253
+ Object.defineProperty(Buffer7.prototype, "offset", {
254
254
  enumerable: true,
255
255
  get: function() {
256
- if (!Buffer6.isBuffer(this)) return void 0;
256
+ if (!Buffer7.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, Buffer6.prototype);
265
+ Object.setPrototypeOf(buf, Buffer7.prototype);
266
266
  return buf;
267
267
  }
268
- function Buffer6(arg, encodingOrOffset, length) {
268
+ function Buffer7(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
- Buffer6.poolSize = 8192;
279
+ Buffer7.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 Buffer6.from(valueOf, encodingOrOffset, length);
305
+ return Buffer7.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 Buffer6.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length);
310
+ return Buffer7.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
- Buffer6.from = function(value, encodingOrOffset, length) {
316
+ Buffer7.from = function(value, encodingOrOffset, length) {
317
317
  return from(value, encodingOrOffset, length);
318
318
  };
319
- Object.setPrototypeOf(Buffer6.prototype, Uint8Array.prototype);
320
- Object.setPrototypeOf(Buffer6, Uint8Array);
319
+ Object.setPrototypeOf(Buffer7.prototype, Uint8Array.prototype);
320
+ Object.setPrototypeOf(Buffer7, 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
- Buffer6.alloc = function(size, fill, encoding) {
338
+ Buffer7.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
- Buffer6.allocUnsafe = function(size) {
345
+ Buffer7.allocUnsafe = function(size) {
346
346
  return allocUnsafe(size);
347
347
  };
348
- Buffer6.allocUnsafeSlow = function(size) {
348
+ Buffer7.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 (!Buffer6.isEncoding(encoding)) {
355
+ if (!Buffer7.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, Buffer6.prototype);
396
+ Object.setPrototypeOf(buf, Buffer7.prototype);
397
397
  return buf;
398
398
  }
399
399
  function fromObject(obj) {
400
- if (Buffer6.isBuffer(obj)) {
400
+ if (Buffer7.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 Buffer6.alloc(+length);
429
+ return Buffer7.alloc(+length);
430
430
  }
431
- Buffer6.isBuffer = function isBuffer(b) {
432
- return b != null && b._isBuffer === true && b !== Buffer6.prototype;
431
+ Buffer7.isBuffer = function isBuffer(b) {
432
+ return b != null && b._isBuffer === true && b !== Buffer7.prototype;
433
433
  };
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)) {
434
+ Buffer7.compare = function compare(a, b) {
435
+ if (isInstance(a, Uint8Array)) a = Buffer7.from(a, a.offset, a.byteLength);
436
+ if (isInstance(b, Uint8Array)) b = Buffer7.from(b, b.offset, b.byteLength);
437
+ if (!Buffer7.isBuffer(a) || !Buffer7.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
- Buffer6.isEncoding = function isEncoding(encoding) {
456
+ Buffer7.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
- Buffer6.concat = function concat(list, length) {
474
+ Buffer7.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 Buffer6.alloc(0);
479
+ return Buffer7.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 = Buffer6.allocUnsafe(length);
488
+ const buffer = Buffer7.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 (!Buffer6.isBuffer(buf)) buf = Buffer6.from(buf);
494
+ if (!Buffer7.isBuffer(buf)) buf = Buffer7.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 (!Buffer6.isBuffer(buf)) {
503
+ } else if (!Buffer7.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 (Buffer6.isBuffer(string)) {
513
+ if (Buffer7.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
- Buffer6.byteLength = byteLength;
555
+ Buffer7.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
- Buffer6.prototype._isBuffer = true;
602
+ Buffer7.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
- Buffer6.prototype.swap16 = function swap16() {
608
+ Buffer7.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
- Buffer6.prototype.swap32 = function swap32() {
618
+ Buffer7.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
- Buffer6.prototype.swap64 = function swap64() {
629
+ Buffer7.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
- Buffer6.prototype.toString = function toString() {
642
+ Buffer7.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
- 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");
648
+ Buffer7.prototype.toLocaleString = Buffer7.prototype.toString;
649
+ Buffer7.prototype.equals = function equals(b) {
650
+ if (!Buffer7.isBuffer(b)) throw new TypeError("Argument must be a Buffer");
651
651
  if (this === b) return true;
652
- return Buffer6.compare(this, b) === 0;
652
+ return Buffer7.compare(this, b) === 0;
653
653
  };
654
- Buffer6.prototype.inspect = function inspect() {
654
+ Buffer7.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
- Buffer6.prototype[customInspectSymbol] = Buffer6.prototype.inspect;
662
+ Buffer7.prototype[customInspectSymbol] = Buffer7.prototype.inspect;
663
663
  }
664
- Buffer6.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
664
+ Buffer7.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
665
665
  if (isInstance(target, Uint8Array)) {
666
- target = Buffer6.from(target, target.offset, target.byteLength);
666
+ target = Buffer7.from(target, target.offset, target.byteLength);
667
667
  }
668
- if (!Buffer6.isBuffer(target)) {
668
+ if (!Buffer7.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 = Buffer6.from(val, encoding);
741
+ val = Buffer7.from(val, encoding);
742
742
  }
743
- if (Buffer6.isBuffer(val)) {
743
+ if (Buffer7.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
- Buffer6.prototype.includes = function includes(val, byteOffset, encoding) {
811
+ Buffer7.prototype.includes = function includes(val, byteOffset, encoding) {
812
812
  return this.indexOf(val, byteOffset, encoding) !== -1;
813
813
  };
814
- Buffer6.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
814
+ Buffer7.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
815
815
  return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
816
816
  };
817
- Buffer6.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
817
+ Buffer7.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
- Buffer6.prototype.write = function write(string, offset, length, encoding) {
855
+ Buffer7.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
- Buffer6.prototype.toJSON = function toJSON() {
910
+ Buffer7.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
- Buffer6.prototype.slice = function slice(start, end) {
1033
+ Buffer7.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, Buffer6.prototype);
1051
+ Object.setPrototypeOf(newBuf, Buffer7.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
- Buffer6.prototype.readUintLE = Buffer6.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) {
1058
+ Buffer7.prototype.readUintLE = Buffer7.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
- Buffer6.prototype.readUintBE = Buffer6.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) {
1070
+ Buffer7.prototype.readUintBE = Buffer7.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
- Buffer6.prototype.readUint8 = Buffer6.prototype.readUInt8 = function readUInt8(offset, noAssert) {
1083
+ Buffer7.prototype.readUint8 = Buffer7.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
- Buffer6.prototype.readUint16LE = Buffer6.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
1088
+ Buffer7.prototype.readUint16LE = Buffer7.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
- Buffer6.prototype.readUint16BE = Buffer6.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
1093
+ Buffer7.prototype.readUint16BE = Buffer7.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
- Buffer6.prototype.readUint32LE = Buffer6.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
1098
+ Buffer7.prototype.readUint32LE = Buffer7.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
- Buffer6.prototype.readUint32BE = Buffer6.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
1103
+ Buffer7.prototype.readUint32BE = Buffer7.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
- Buffer6.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE(offset) {
1108
+ Buffer7.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
- Buffer6.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE(offset) {
1120
+ Buffer7.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
- Buffer6.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) {
1132
+ Buffer7.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
- Buffer6.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) {
1146
+ Buffer7.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
- Buffer6.prototype.readInt8 = function readInt8(offset, noAssert) {
1160
+ Buffer7.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
- Buffer6.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
1166
+ Buffer7.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
- Buffer6.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
1172
+ Buffer7.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
- Buffer6.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
1178
+ Buffer7.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
- Buffer6.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
1183
+ Buffer7.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
- Buffer6.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE(offset) {
1188
+ Buffer7.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
- Buffer6.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE(offset) {
1199
+ Buffer7.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
- Buffer6.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
1211
+ Buffer7.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
- Buffer6.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
1216
+ Buffer7.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
- Buffer6.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
1221
+ Buffer7.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
- Buffer6.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
1226
+ Buffer7.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 (!Buffer6.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance');
1232
+ if (!Buffer7.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
- Buffer6.prototype.writeUintLE = Buffer6.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) {
1236
+ Buffer7.prototype.writeUintLE = Buffer7.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
- Buffer6.prototype.writeUintBE = Buffer6.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) {
1252
+ Buffer7.prototype.writeUintBE = Buffer7.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
- Buffer6.prototype.writeUint8 = Buffer6.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
1268
+ Buffer7.prototype.writeUint8 = Buffer7.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
- Buffer6.prototype.writeUint16LE = Buffer6.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
1275
+ Buffer7.prototype.writeUint16LE = Buffer7.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
- Buffer6.prototype.writeUint16BE = Buffer6.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
1283
+ Buffer7.prototype.writeUint16BE = Buffer7.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
- Buffer6.prototype.writeUint32LE = Buffer6.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
1291
+ Buffer7.prototype.writeUint32LE = Buffer7.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
- Buffer6.prototype.writeUint32BE = Buffer6.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
1301
+ Buffer7.prototype.writeUint32BE = Buffer7.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
- Buffer6.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) {
1351
+ Buffer7.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) {
1352
1352
  return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
1353
1353
  });
1354
- Buffer6.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) {
1354
+ Buffer7.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) {
1355
1355
  return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
1356
1356
  });
1357
- Buffer6.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) {
1357
+ Buffer7.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
- Buffer6.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) {
1376
+ Buffer7.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
- Buffer6.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
1395
+ Buffer7.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
- Buffer6.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
1403
+ Buffer7.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
- Buffer6.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
1411
+ Buffer7.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
- Buffer6.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
1419
+ Buffer7.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
- Buffer6.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
1429
+ Buffer7.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
- Buffer6.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) {
1440
+ Buffer7.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) {
1441
1441
  return wrtBigUInt64LE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
1442
1442
  });
1443
- Buffer6.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset = 0) {
1443
+ Buffer7.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
- Buffer6.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
1459
+ Buffer7.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
1460
1460
  return writeFloat(this, value, offset, true, noAssert);
1461
1461
  };
1462
- Buffer6.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
1462
+ Buffer7.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
- Buffer6.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
1474
+ Buffer7.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
1475
1475
  return writeDouble(this, value, offset, true, noAssert);
1476
1476
  };
1477
- Buffer6.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
1477
+ Buffer7.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
1478
1478
  return writeDouble(this, value, offset, false, noAssert);
1479
1479
  };
1480
- Buffer6.prototype.copy = function copy(target, targetStart, start, end) {
1481
- if (!Buffer6.isBuffer(target)) throw new TypeError("argument should be a Buffer");
1480
+ Buffer7.prototype.copy = function copy(target, targetStart, start, end) {
1481
+ if (!Buffer7.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
- Buffer6.prototype.fill = function fill(val, start, end, encoding) {
1510
+ Buffer7.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" && !Buffer6.isEncoding(encoding)) {
1523
+ if (typeof encoding === "string" && !Buffer7.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 = Buffer6.isBuffer(val) ? val : Buffer6.from(val, encoding);
1552
+ const bytes = Buffer7.isBuffer(val) ? val : Buffer7.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"');
@@ -2559,7 +2559,7 @@ start = (masque/anytls/shadowsocks/vmess/vless/trojan/h2_connect/https/http/snel
2559
2559
  return proxy;
2560
2560
  }
2561
2561
 
2562
- shadowsocks = tag equals "ss" address (method/passwordk/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/alpn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/udp_port/others)* {
2562
+ shadowsocks = tag equals "ss" address (method/passwordk/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/alpn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/ecn/udp_port/others)* {
2563
2563
  proxy.type = "ss";
2564
2564
  // handle obfs
2565
2565
  if (obfs.type == "http" || obfs.type === "tls") {
@@ -2570,7 +2570,7 @@ shadowsocks = tag equals "ss" address (method/passwordk/obfs/obfs_host/obfs_uri/
2570
2570
  }
2571
2571
  handleShadowTLS();
2572
2572
  }
2573
- 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)* {
2573
+ 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/ecn/others)* {
2574
2574
  proxy.type = "vmess";
2575
2575
  proxy.cipher = proxy.cipher || "auto";
2576
2576
  // Surfboard 与 Surge 默认不一致, 不管 Surfboard https://getsurfboard.com/docs/profile-format/proxy/external-proxy/vmess
@@ -2582,7 +2582,7 @@ vmess = tag equals "vmess" address (vmess_uuid/vmess_aead/ws/ws_http_upgrade/ws_
2582
2582
  handleWebsocket();
2583
2583
  handleShadowTLS();
2584
2584
  }
2585
- vless = tag equals vless_address (vless_username/vless_option/reality_option/ws/ws_http_upgrade/ws_path/ws_headers/grpc/grpc_service_name/grpc_mode/grpc_authority/xhttp/xhttp_headers/xhttp_option/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls/sni/cert_verify_name/alpn/tls_fingerprint/client_fingerprint/tls_verification/client_cert/ech_config/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
2585
+ vless = tag equals vless_address (vless_username/vless_option/reality_option/ws/ws_http_upgrade/ws_path/ws_headers/grpc/grpc_service_name/grpc_mode/grpc_authority/xhttp/xhttp_headers/xhttp_option/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls/sni/cert_verify_name/alpn/tls_fingerprint/client_fingerprint/tls_verification/client_cert/ech_config/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/ecn/others)* {
2586
2586
  proxy["packet-encoding"] = "xudp";
2587
2587
  if (proxy["reality-opts"] && proxy["reality-opts"]["public-key"]) proxy.tls = true;
2588
2588
  if (xhttpEnabled) {
@@ -2594,30 +2594,30 @@ vless = tag equals vless_address (vless_username/vless_option/reality_option/ws/
2594
2594
  handleShadowTLS();
2595
2595
  }
2596
2596
  vless_address = "vless" address { proxy.type = "vless"; }
2597
- trojan = tag equals "trojan" address (passwordk/ws/ws_http_upgrade/ws_path/ws_headers/tls/sni/cert_verify_name/alpn/tls_fingerprint/client_fingerprint/tls_verification/client_cert/ech_config/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
2597
+ trojan = tag equals "trojan" address (passwordk/ws/ws_http_upgrade/ws_path/ws_headers/tls/sni/cert_verify_name/alpn/tls_fingerprint/client_fingerprint/tls_verification/client_cert/ech_config/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/ecn/others)* {
2598
2598
  proxy.type = "trojan";
2599
2599
  handleWebsocket();
2600
2600
  handleShadowTLS();
2601
2601
  }
2602
- 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)* {
2602
+ 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/ecn/others)* {
2603
2603
  proxy.type = "http";
2604
2604
  proxy.tls = true;
2605
2605
  handleShadowTLS();
2606
2606
  }
2607
- 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)* {
2607
+ 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/ecn/others)* {
2608
2608
  proxy.type = "h2-connect";
2609
2609
  proxy.tls = true;
2610
2610
  handleShadowTLS();
2611
2611
  }
2612
- http = tag equals "http" address (username password)? (usernamek passwordk)? (headers/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)* {
2612
+ http = tag equals "http" address (username password)? (usernamek passwordk)? (headers/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/ecn/others)* {
2613
2613
  proxy.type = "http";
2614
2614
  handleShadowTLS();
2615
2615
  }
2616
- ssh = tag equals "ssh" address (username password)? (usernamek passwordk)? (server_fingerprint/idle_timeout/private_key/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)* {
2616
+ ssh = tag equals "ssh" address (username password)? (usernamek passwordk)? (server_fingerprint/idle_timeout/private_key/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/ecn/others)* {
2617
2617
  proxy.type = "ssh";
2618
2618
  handleShadowTLS();
2619
2619
  }
2620
- 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)* {
2620
+ 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/ecn/others)* {
2621
2621
  proxy.type = "snell";
2622
2622
  // handle obfs
2623
2623
  if (obfs.type == "http" || obfs.type === "tls") {
@@ -2636,7 +2636,7 @@ tuic_v5 = tag equals "tuic-v5" address (alpn/passwordk/uuidk/ip_version/underlyi
2636
2636
  proxy.version = 5;
2637
2637
  handleShadowTLS();
2638
2638
  }
2639
- wireguard = tag equals "wireguard" (section_name/no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
2639
+ wireguard = tag equals "wireguard" (section_name/no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/ecn/others)* {
2640
2640
  proxy.type = "wireguard-surge";
2641
2641
  handleShadowTLS();
2642
2642
  }
@@ -2644,20 +2644,20 @@ hysteria2 = tag equals "hysteria2" address (no_error_alert/ip_version/underlying
2644
2644
  proxy.type = "hysteria2";
2645
2645
  handleShadowTLS();
2646
2646
  }
2647
- socks5 = tag equals "socks5" 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/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
2647
+ socks5 = tag equals "socks5" 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/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/ecn/others)* {
2648
2648
  proxy.type = "socks5";
2649
2649
  handleShadowTLS();
2650
2650
  }
2651
- 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)* {
2651
+ 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/ecn/others)* {
2652
2652
  proxy.type = "socks5";
2653
2653
  proxy.tls = true;
2654
2654
  handleShadowTLS();
2655
2655
  }
2656
- 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)* {
2656
+ 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/ecn/others)* {
2657
2657
  proxy.type = "anytls";
2658
2658
  proxy.tls = true;
2659
2659
  }
2660
- 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)* {
2660
+ 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/ecn/others)* {
2661
2661
  proxy.type = "trusttunnel";
2662
2662
  proxy.tls = true;
2663
2663
  }
@@ -2815,7 +2815,7 @@ uri = $[^,]+
2815
2815
  udp_relay = comma "udp-relay" equals flag:bool { proxy.udp = flag; }
2816
2816
  fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; }
2817
2817
  reuse = comma "reuse" equals flag:bool { proxy.reuse = flag; }
2818
- ecn = comma "ecn" equals flag:bool { proxy.ecn = flag; }
2818
+ ecn = comma "ecn" equals mode:("auto" / "on" / "off" / bool) &(_ ("," / !.)) { proxy.ecn = mode; }
2819
2819
  tfo = comma "tfo" equals flag:bool { proxy.tfo = flag; }
2820
2820
  ip_version = comma "ip-version" equals match:[^,]+ { proxy["ip-version"] = match.join(""); }
2821
2821
  section_name = comma "section-name" equals match:[^,]+ { proxy["section-name"] = match.join(""); }
@@ -2881,6 +2881,45 @@ function getParser() {
2881
2881
  import peggy2 from "peggy";
2882
2882
 
2883
2883
  // src/vendors/Sub-Store/backend/src/core/proxy-utils/loon-xhttp.js
2884
+ import _2 from "lodash";
2885
+ var PADDING_FIELDS = {
2886
+ "padding-bytes": "x-padding-bytes",
2887
+ "padding-obfs-mode": "x-padding-obfs-mode",
2888
+ "padding-placement": "x-padding-placement",
2889
+ "padding-key": "x-padding-key",
2890
+ "padding-header": "x-padding-header",
2891
+ "padding-method": "x-padding-method"
2892
+ };
2893
+ var SESSION_FIELDS = {
2894
+ "session-id-placement": "session-placement",
2895
+ "session-id-key": "session-key"
2896
+ };
2897
+ var XMUX_FIELDS = {
2898
+ "xmux-max-concurrency": "reuse-settings.max-concurrency",
2899
+ "xmux-max-connections": "reuse-settings.max-connections",
2900
+ "xmux-max-reuse-times": "reuse-settings.c-max-reuse-times",
2901
+ "xmux-http-max-requests": "reuse-settings.h-max-request-times",
2902
+ "xmux-http-max-reusable-secs": "reuse-settings.h-max-reusable-secs",
2903
+ "xmux-http-keepalive-secs": "reuse-settings.h-keep-alive-period"
2904
+ };
2905
+ var DOWNLOAD_FIELDS = {
2906
+ server: "server",
2907
+ port: "port",
2908
+ host: "host",
2909
+ path: "path",
2910
+ alpn: "alpn",
2911
+ "over-tls": "tls",
2912
+ sni: "servername",
2913
+ "skip-cert-verify": "skip-cert-verify",
2914
+ "tls-profile": "_loon_tls_profile",
2915
+ "tls-cert-sha256": "fingerprint",
2916
+ "tls-pubkey-sha256": "tls-pubkey-sha256",
2917
+ "public-key": "reality-opts.public-key",
2918
+ "short-id": "reality-opts.short-id",
2919
+ ...XMUX_FIELDS,
2920
+ ...PADDING_FIELDS,
2921
+ ...SESSION_FIELDS
2922
+ };
2884
2923
  var LOON_XHTTP_FIELDS = {
2885
2924
  mode: "mode",
2886
2925
  "uplink-method": "uplink-http-method",
@@ -2889,25 +2928,66 @@ var LOON_XHTTP_FIELDS = {
2889
2928
  "uplink-data-placement": "uplink-data-placement",
2890
2929
  "uplink-data-key": "uplink-data-key",
2891
2930
  "uplink-chunk-size": "uplink-chunk-size",
2892
- "padding-bytes": "x-padding-bytes",
2893
- "padding-obfs-mode": "x-padding-obfs-mode",
2894
- "padding-placement": "x-padding-placement",
2895
- "padding-key": "x-padding-key",
2896
- "padding-header": "x-padding-header",
2897
- "padding-method": "x-padding-method",
2931
+ ...PADDING_FIELDS,
2898
2932
  "no-grpc-header": "no-grpc-header",
2899
- "session-id-placement": "session-placement",
2900
- "session-id-key": "session-key",
2933
+ ...SESSION_FIELDS,
2901
2934
  "session-id-table": "session-table",
2902
2935
  "session-id-length": "session-length",
2903
2936
  "seq-placement": "seq-placement",
2904
- "seq-key": "seq-key"
2937
+ "seq-key": "seq-key",
2938
+ ...XMUX_FIELDS,
2939
+ ...Object.fromEntries(
2940
+ Object.entries(DOWNLOAD_FIELDS).map(([key, path]) => [
2941
+ `download-${key}`,
2942
+ `download-settings.${path}`
2943
+ ])
2944
+ )
2905
2945
  };
2946
+ function validateLoonXhttpXmux(opts) {
2947
+ if (!opts) return;
2948
+ for (const prefix of ["", "download-"]) {
2949
+ const getOption = (key) => _2.get(opts, LOON_XHTTP_FIELDS[`${prefix}${key}`]);
2950
+ for (const key of Object.keys(XMUX_FIELDS)) {
2951
+ const value = getOption(key);
2952
+ if (value == null) continue;
2953
+ const isKeepalive = key === "xmux-http-keepalive-secs";
2954
+ const normalized = isKeepalive ? normalizeXhttpIntegerValue(value) : normalizeXhttpNonNegativeRange(value);
2955
+ if (normalized == null || isKeepalive && normalized < -1) {
2956
+ const expected = isKeepalive ? "an integer of at least -1" : "a non-negative integer or a valid non-negative integer range";
2957
+ throw new Error(
2958
+ `Loon xhttp-${prefix}${key} must be ${expected}`
2959
+ );
2960
+ }
2961
+ }
2962
+ const maxConcurrency = getOption("xmux-max-concurrency");
2963
+ const maxConnections = getOption("xmux-max-connections");
2964
+ if (normalizeXhttpPositiveRange(maxConcurrency) != null && normalizeXhttpPositiveRange(maxConnections) != null) {
2965
+ const optionPrefix = `xhttp-${prefix}xmux`;
2966
+ throw new Error(
2967
+ `Loon ${optionPrefix}-max-concurrency and ${optionPrefix}-max-connections cannot both be positive`
2968
+ );
2969
+ }
2970
+ }
2971
+ }
2906
2972
  function setLoonXhttpOption(opts, key, value) {
2973
+ if (key === "header" || key === "download-header") {
2974
+ const colon = value.indexOf(":");
2975
+ if (colon <= 0) return;
2976
+ const name = value.slice(0, colon).trim();
2977
+ if (!name || /^host$/i.test(name)) return;
2978
+ const target = key === "header" ? opts : opts["download-settings"] ??= {};
2979
+ target.headers = {
2980
+ ...target.headers,
2981
+ [name]: value.slice(colon + 1).trim()
2982
+ };
2983
+ return;
2984
+ }
2907
2985
  if (!Object.prototype.hasOwnProperty.call(LOON_XHTTP_FIELDS, key)) return;
2908
- switch (key) {
2986
+ switch (key.replace(/^download-/, "")) {
2909
2987
  case "padding-obfs-mode":
2910
2988
  case "no-grpc-header":
2989
+ case "over-tls":
2990
+ case "skip-cert-verify":
2911
2991
  if (value !== "true" && value !== "false") return;
2912
2992
  value = value === "true";
2913
2993
  break;
@@ -2916,8 +2996,15 @@ function setLoonXhttpOption(opts, key, value) {
2916
2996
  case "uplink-chunk-size":
2917
2997
  value = normalizeXhttpNonNegativeRange(value) ?? value;
2918
2998
  break;
2999
+ case "port":
3000
+ case "xmux-http-keepalive-secs":
3001
+ value = normalizeXhttpIntegerValue(value) ?? value;
3002
+ break;
3003
+ case "alpn":
3004
+ value = [value];
3005
+ break;
2919
3006
  }
2920
- opts[LOON_XHTTP_FIELDS[key]] = value;
3007
+ _2.set(opts, LOON_XHTTP_FIELDS[key], value);
2921
3008
  }
2922
3009
 
2923
3010
  // src/vendors/Sub-Store/backend/src/core/proxy-utils/parsers/peggy/loon.js
@@ -2942,7 +3029,7 @@ var grammars2 = String.raw`
2942
3029
  const obfs = {};
2943
3030
  const transport = {};
2944
3031
  const xhttpOpts = {};
2945
- const xhttpHeaders = [];
3032
+ const vlessEncryption = {};
2946
3033
  const shadowTLS = {};
2947
3034
  const $ = {};
2948
3035
 
@@ -2964,7 +3051,12 @@ var grammars2 = String.raw`
2964
3051
  proxy.udp ??= false;
2965
3052
  if (transport.path != null) xhttpOpts.path = transport.path;
2966
3053
  if (transport.host != null) xhttpOpts.host = transport.host;
2967
- if (xhttpHeaders.length) xhttpOpts.headers = Object.fromEntries(xhttpHeaders);
3054
+ const download = xhttpOpts["download-settings"];
3055
+ if (download) {
3056
+ download.tls ??= Boolean(download["reality-opts"]?.["public-key"]);
3057
+ const fingerprint = loonClientFingerprint(download._loon_tls_profile);
3058
+ if (fingerprint) download["client-fingerprint"] = fingerprint;
3059
+ }
2968
3060
  proxy["xhttp-opts"] = xhttpOpts;
2969
3061
  }
2970
3062
  }
@@ -3006,7 +3098,7 @@ var grammars2 = String.raw`
3006
3098
  }
3007
3099
  }
3008
3100
 
3009
- start = (shadowsocksr/shadowsocks/vmess/vless/trojan/https/http/socks5/hysteria2/anytls/tailscale/snell) {
3101
+ start = (shadowsocksr/shadowsocks/vmess/vless/trojan/https/http/socks5/hysteria2/anytls/tailscale/snell/mieru) {
3010
3102
  return proxy;
3011
3103
  }
3012
3104
 
@@ -3027,17 +3119,22 @@ shadowsocks = tag equals "shadowsocks"i address method password (obfs_typev obfs
3027
3119
  }
3028
3120
  handleShadowTLS();
3029
3121
  }
3030
- 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)* {
3122
+ vmess = tag equals "vmess"i address vmess_method uuid (xhttp_transport/transport/transport_host/transport_path/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)* {
3031
3123
  proxy.type = "vmess";
3032
3124
  proxy.cipher = proxy.cipher || "auto";
3033
3125
  proxy.alterId = proxy.alterId || 0;
3034
3126
  handleTransport();
3035
3127
  }
3036
- 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)* {
3128
+ vless = tag equals "vless"i address uuid (xhttp_transport/transport/transport_host/transport_path/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/vless_encryption/public_key/short_id/block_quic/others)* {
3037
3129
  proxy.type = "vless";
3130
+ const { mode, rtt, padding, "public-keys": publicKeys } = vlessEncryption;
3131
+ if (mode && mode !== "none") {
3132
+ if (!publicKeys) throw new Error("VLESS encryption requires public keys");
3133
+ proxy.encryption = ["mlkem768x25519plus", mode, rtt || "0rtt", padding, publicKeys].filter(Boolean).join(".");
3134
+ }
3038
3135
  handleTransport();
3039
3136
  }
3040
- 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)* {
3137
+ trojan = tag equals "trojan"i address password (xhttp_transport/transport/transport_host/transport_path/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)* {
3041
3138
  proxy.type = "trojan";
3042
3139
  handleTransport();
3043
3140
  }
@@ -3072,6 +3169,13 @@ snell = tag equals ("snell"i/"opensnell"i) address snell_positional_psk? (snell_
3072
3169
  proxy["obfs-opts"] = { mode: obfs.type, host: obfs.host, path: obfs.path };
3073
3170
  }
3074
3171
  }
3172
+ mieru = tag equals "mieru"i address comma user:option_value comma pass:option_value (udp_relay/ip_mode/block_quic/others)* {
3173
+ proxy.type = "mieru";
3174
+ proxy.transport = "TCP";
3175
+ proxy.username = user;
3176
+ proxy.password = pass;
3177
+ proxy.udp ??= false;
3178
+ }
3075
3179
 
3076
3180
  tailscale_string = comma key:("auth-key"/"control-url"/"hostname"/"exit-node"/"path-mode"/"ip-mode") equals value:(
3077
3181
  '"' match:$[^"]* '"' { return match; }
@@ -3174,13 +3278,6 @@ transport_host = comma "host" equals value:option_value { transport.host = value
3174
3278
  transport_path = comma "path" equals value:option_value { transport.path = value; }
3175
3279
 
3176
3280
  xhttp_transport = comma "transport" equals "xhttp" { transport.type = "xhttp"; }
3177
- xhttp_header = comma "xhttp-header" equals value:option_value {
3178
- const colon = value.indexOf(":");
3179
- const name = value.slice(0, colon).trim();
3180
- if (colon > 0 && name && !/^host$/i.test(name)) {
3181
- xhttpHeaders.push([name, value.slice(colon + 1).trim()]);
3182
- }
3183
- }
3184
3281
  xhttp_option = comma "xhttp-" key:$[a-z0-9-]+ equals value:option_value {
3185
3282
  options.setLoonXhttpOption(xhttpOpts, key, value);
3186
3283
  }
@@ -3216,6 +3313,9 @@ alpn = comma "alpn" equals match:option_value {
3216
3313
  }
3217
3314
 
3218
3315
  flow = comma "flow" equals match:[^,]+ { proxy["flow"] = match.join("").replace(/^"(.*)"$/, '$1'); }
3316
+ vless_encryption = comma "encryption-" key:("mode"/"rtt"/"public-keys"/"padding") equals value:option_value {
3317
+ vlessEncryption[key] = value;
3318
+ }
3219
3319
  public_key = comma "public-key" equals match:[^,]+ { proxy["reality-opts"] = proxy["reality-opts"] || {}; proxy["reality-opts"]["public-key"] = match.join("").replace(/^"(.*)"$/, '$1'); }
3220
3320
  short_id = comma "short-id" equals value:option_value { proxy["reality-opts"] = proxy["reality-opts"] || {}; proxy["reality-opts"]["short-id"] = value; }
3221
3321
 
@@ -4013,7 +4113,7 @@ var yaml_default = {
4013
4113
  };
4014
4114
 
4015
4115
  // src/vendors/Sub-Store/backend/src/core/proxy-utils/parsers/index.js
4016
- import _2 from "lodash";
4116
+ import _3 from "lodash";
4017
4117
  import { Base64 } from "js-base64";
4018
4118
 
4019
4119
  // src/vendors/Sub-Store/backend/src/core/proxy-utils/vmess-security.js
@@ -4306,7 +4406,7 @@ function URI_SS() {
4306
4406
  proxy.alpn = params.alpn ? decodeURIComponent(params.alpn).split(",") : void 0;
4307
4407
  if (params["ws"]) {
4308
4408
  proxy.network = "ws";
4309
- _2.set(proxy, "ws-opts.path", params["wspath"]);
4409
+ _3.set(proxy, "ws-opts.path", params["wspath"]);
4310
4410
  }
4311
4411
  if (params["type"]) {
4312
4412
  let httpupgrade;
@@ -4335,10 +4435,10 @@ function URI_SS() {
4335
4435
  pathEarlyData = extracted.ed;
4336
4436
  }
4337
4437
  }
4338
- _2.set(proxy, proxy.network + "-opts.path", transportPath);
4438
+ _3.set(proxy, proxy.network + "-opts.path", transportPath);
4339
4439
  }
4340
4440
  if (params["host"]) {
4341
- _2.set(
4441
+ _3.set(
4342
4442
  proxy,
4343
4443
  proxy.network + "-opts.headers.Host",
4344
4444
  decodeURIComponent(params["host"])
@@ -4346,30 +4446,30 @@ function URI_SS() {
4346
4446
  }
4347
4447
  if (httpupgrade) {
4348
4448
  httpUpgradeEd = httpUpgradeEd || (isNumericEarlyData2(params.ed) ? `${params.ed}` : "");
4349
- _2.set(
4449
+ _3.set(
4350
4450
  proxy,
4351
4451
  proxy.network + "-opts.v2ray-http-upgrade",
4352
4452
  true
4353
4453
  );
4354
4454
  if (httpUpgradeEd !== "") {
4355
- _2.set(
4455
+ _3.set(
4356
4456
  proxy,
4357
4457
  proxy.network + "-opts.v2ray-http-upgrade-fast-open",
4358
4458
  true
4359
4459
  );
4360
- _2.set(
4460
+ _3.set(
4361
4461
  proxy,
4362
4462
  proxy.network + "-opts._v2ray-http-upgrade-ed",
4363
4463
  httpUpgradeEd
4364
4464
  );
4365
4465
  }
4366
4466
  } else if (proxy.network === "ws" && pathEarlyData !== "") {
4367
- _2.set(
4467
+ _3.set(
4368
4468
  proxy,
4369
4469
  proxy.network + "-opts.max-early-data",
4370
4470
  parseEarlyDataSize(pathEarlyData)
4371
4471
  );
4372
- _2.set(
4472
+ _3.set(
4373
4473
  proxy,
4374
4474
  proxy.network + "-opts.early-data-header-name",
4375
4475
  "Sec-WebSocket-Protocol"
@@ -4391,7 +4491,7 @@ function URI_SS() {
4391
4491
  proxy._mode = params.mode;
4392
4492
  }
4393
4493
  if (Object.keys(opts).length > 0) {
4394
- _2.set(proxy, params.security + "-opts", opts);
4494
+ _3.set(proxy, params.security + "-opts", opts);
4395
4495
  }
4396
4496
  }
4397
4497
  if (params.extra && (proxy.network === "xhttp" || params.security === "reality")) {
@@ -5522,7 +5622,7 @@ function URI_VLESS() {
5522
5622
  let isShadowrocket;
5523
5623
  let parsed = /^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(line);
5524
5624
  if (!parsed) {
5525
- let [_6, base64, other] = /^(.*?)(\?.*?$)/.exec(line);
5625
+ let [_8, base64, other] = /^(.*?)(\?.*?$)/.exec(line);
5526
5626
  line = `${Base64.decode(base64)}${other}`;
5527
5627
  parsed = /^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(line);
5528
5628
  isShadowrocket = true;
@@ -6458,6 +6558,12 @@ function Loon_Tailscale() {
6458
6558
  const parse2 = (line) => getParser2().parse(line);
6459
6559
  return { name, test, parse: parse2 };
6460
6560
  }
6561
+ function Loon_Mieru() {
6562
+ const name = "Loon Mieru Parser";
6563
+ const test = (line) => /^[^=,]*=\s*mieru\s*,/i.test(line);
6564
+ const parse2 = (line) => getParser2().parse(line);
6565
+ return { name, test, parse: parse2 };
6566
+ }
6461
6567
  function Loon_WireGuard() {
6462
6568
  const name = "Loon WireGuard Parser";
6463
6569
  const test = (line) => {
@@ -6669,7 +6775,7 @@ function Surge_External() {
6669
6775
  };
6670
6776
  const parse2 = (line) => {
6671
6777
  let parsed = /^\s*(.*?)\s*?=\s*?external\s*?,\s*(.*?)\s*$/.exec(line);
6672
- let [_6, name2, other] = parsed;
6778
+ let [_8, name2, other] = parsed;
6673
6779
  line = other;
6674
6780
  let exec = /(,|^)\s*?exec\s*?=\s*"(.*?)"\s*?(,|$)/.exec(line)?.[2];
6675
6781
  if (!exec) {
@@ -6813,6 +6919,7 @@ var parsers_default = [
6813
6919
  Loon_Socks5(),
6814
6920
  Loon_WireGuard(),
6815
6921
  Loon_Tailscale(),
6922
+ Loon_Mieru(),
6816
6923
  QX_SS(),
6817
6924
  QX_SSR(),
6818
6925
  QX_VMess(),
@@ -6826,10 +6933,10 @@ var parsers_default = [
6826
6933
  ];
6827
6934
 
6828
6935
  // src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/surge.js
6829
- import _4 from "lodash";
6936
+ import _5 from "lodash";
6830
6937
 
6831
6938
  // src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/utils.js
6832
- import _3 from "lodash";
6939
+ import _4 from "lodash";
6833
6940
 
6834
6941
  // src/vendors/Sub-Store/backend/src/core/proxy-utils/preprocessors/index.js
6835
6942
  import { Base64 as Base642 } from "js-base64";
@@ -6851,7 +6958,7 @@ function normalizeClashYamlDocument(raw, document, content) {
6851
6958
  const anchors = /* @__PURE__ */ new Map();
6852
6959
  const aliases = /* @__PURE__ */ new Map();
6853
6960
  visit(document, {
6854
- Node(_6, node) {
6961
+ Node(_8, node) {
6855
6962
  if (isAlias(node)) {
6856
6963
  aliases.set(node.range[0], anchors.get(node.source));
6857
6964
  } else if (node.anchor) {
@@ -6863,7 +6970,7 @@ function normalizeClashYamlDocument(raw, document, content) {
6863
6970
  const needsQuotes = (node) => isScalar(node) && typeof node.value !== "string" && node.value !== null && !node.tag && node.source;
6864
6971
  const realityConfigs = /* @__PURE__ */ new Set();
6865
6972
  visit(document, {
6866
- Pair(_6, { key, value }) {
6973
+ Pair(_8, { key, value }) {
6867
6974
  const name = resolveAlias(key)?.value;
6868
6975
  if (["reality-opts", "reality-config"].includes(name)) {
6869
6976
  realityConfigs.add(value);
@@ -6873,10 +6980,10 @@ function normalizeClashYamlDocument(raw, document, content) {
6873
6980
  const shortIds = /* @__PURE__ */ new Set();
6874
6981
  for (const config of realityConfigs) {
6875
6982
  visit(config, {
6876
- Alias(_6, alias) {
6983
+ Alias(_8, alias) {
6877
6984
  realityConfigs.add(resolveAlias(alias));
6878
6985
  },
6879
- Pair(_6, { key, value }) {
6986
+ Pair(_8, { key, value }) {
6880
6987
  if (resolveAlias(key)?.value === "short-id") {
6881
6988
  shortIds.add(value);
6882
6989
  }
@@ -7092,7 +7199,7 @@ var Result = class {
7092
7199
  }
7093
7200
  };
7094
7201
  function isPresent2(obj, attr) {
7095
- const data = _3.get(obj, attr);
7202
+ const data = _4.get(obj, attr);
7096
7203
  return typeof data !== "undefined" && data !== null;
7097
7204
  }
7098
7205
  function supportsVlessTransportSecurity(proxy) {
@@ -7203,6 +7310,12 @@ function getWireGuardAddressWithCIDR(proxy = {}, family = "ipv4") {
7203
7310
  return `${parsed.address}/${normalizedCIDR ?? parsed.cidr ?? config.defaultCIDR}`;
7204
7311
  }
7205
7312
  function produceProxyListOutput(list, type, opts = {}) {
7313
+ list = list.map((proxy) => {
7314
+ if (!Object.hasOwn(proxy, "ecn")) return proxy;
7315
+ const config = { ...proxy };
7316
+ delete config.ecn;
7317
+ return config;
7318
+ });
7206
7319
  if (type === "internal") return list;
7207
7320
  if (opts.prettyYaml || opts["pretty-yaml"]) {
7208
7321
  return normalizeClashYaml(
@@ -7513,6 +7626,7 @@ function shadowsocks(proxy) {
7513
7626
  result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
7514
7627
  appendShadowTLS(result, proxy, true);
7515
7628
  result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
7629
+ result.appendIfPresent(`,ecn=${proxy.ecn}`, "ecn");
7516
7630
  result.appendIfPresent(
7517
7631
  `,underlying-proxy=${proxy["underlying-proxy"]}`,
7518
7632
  "underlying-proxy"
@@ -7552,6 +7666,7 @@ function trojan(proxy) {
7552
7666
  result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
7553
7667
  appendShadowTLS(result, proxy);
7554
7668
  result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
7669
+ result.appendIfPresent(`,ecn=${proxy.ecn}`, "ecn");
7555
7670
  result.appendIfPresent(
7556
7671
  `,underlying-proxy=${proxy["underlying-proxy"]}`,
7557
7672
  "underlying-proxy"
@@ -7588,6 +7703,7 @@ function anytls(proxy) {
7588
7703
  );
7589
7704
  result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
7590
7705
  result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
7706
+ result.appendIfPresent(`,ecn=${proxy.ecn}`, "ecn");
7591
7707
  result.appendIfPresent(
7592
7708
  `,underlying-proxy=${proxy["underlying-proxy"]}`,
7593
7709
  "underlying-proxy"
@@ -7642,6 +7758,7 @@ function trusttunnel(proxy) {
7642
7758
  );
7643
7759
  result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
7644
7760
  result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
7761
+ result.appendIfPresent(`,ecn=${proxy.ecn}`, "ecn");
7645
7762
  result.appendIfPresent(
7646
7763
  `,underlying-proxy=${proxy["underlying-proxy"]}`,
7647
7764
  "underlying-proxy"
@@ -7740,6 +7857,7 @@ function h2Connect(proxy) {
7740
7857
  result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
7741
7858
  appendShadowTLS(result, proxy);
7742
7859
  result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
7860
+ result.appendIfPresent(`,ecn=${proxy.ecn}`, "ecn");
7743
7861
  result.appendIfPresent(
7744
7862
  `,underlying-proxy=${proxy["underlying-proxy"]}`,
7745
7863
  "underlying-proxy"
@@ -7792,6 +7910,7 @@ function v2ray(proxy, includeUnsupportedProxy) {
7792
7910
  result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
7793
7911
  appendShadowTLS(result, proxy);
7794
7912
  result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
7913
+ result.appendIfPresent(`,ecn=${proxy.ecn}`, "ecn");
7795
7914
  result.appendIfPresent(
7796
7915
  `,underlying-proxy=${proxy["underlying-proxy"]}`,
7797
7916
  "underlying-proxy"
@@ -7852,7 +7971,7 @@ function appendXhttpParams(result, proxy) {
7852
7971
  const headers = isPlainObject(xhttp?.headers) ? Object.entries(xhttp.headers) : [];
7853
7972
  const host = xhttp?.host ?? headers.find(([key]) => /^host$/i.test(key))?.[1];
7854
7973
  for (const [key, field] of Object.entries(SURGE_XHTTP_FIELDS)) {
7855
- const rawValue = key === "host" ? host : _4.get(xhttp, field);
7974
+ const rawValue = key === "host" ? host : _5.get(xhttp, field);
7856
7975
  if (rawValue == null) continue;
7857
7976
  const rawText = String(rawValue);
7858
7977
  const value2 = stripSurgeQuotes(rawText);
@@ -7913,6 +8032,7 @@ function ssh(proxy) {
7913
8032
  );
7914
8033
  result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
7915
8034
  result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
8035
+ result.appendIfPresent(`,ecn=${proxy.ecn}`, "ecn");
7916
8036
  result.appendIfPresent(
7917
8037
  `,underlying-proxy=${proxy["underlying-proxy"]}`,
7918
8038
  "underlying-proxy"
@@ -7953,6 +8073,7 @@ function http(proxy) {
7953
8073
  result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
7954
8074
  appendShadowTLS(result, proxy);
7955
8075
  result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
8076
+ result.appendIfPresent(`,ecn=${proxy.ecn}`, "ecn");
7956
8077
  result.appendIfPresent(
7957
8078
  `,underlying-proxy=${proxy["underlying-proxy"]}`,
7958
8079
  "underlying-proxy"
@@ -8030,6 +8151,7 @@ function socks5(proxy) {
8030
8151
  result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
8031
8152
  appendShadowTLS(result, proxy);
8032
8153
  result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
8154
+ result.appendIfPresent(`,ecn=${proxy.ecn}`, "ecn");
8033
8155
  result.appendIfPresent(
8034
8156
  `,underlying-proxy=${proxy["underlying-proxy"]}`,
8035
8157
  "underlying-proxy"
@@ -8103,6 +8225,7 @@ function snell(proxy) {
8103
8225
  result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
8104
8226
  appendShadowTLS(result, proxy);
8105
8227
  result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
8228
+ result.appendIfPresent(`,ecn=${proxy.ecn}`, "ecn");
8106
8229
  result.appendIfPresent(
8107
8230
  `,underlying-proxy=${proxy["underlying-proxy"]}`,
8108
8231
  "underlying-proxy"
@@ -8210,6 +8333,7 @@ function wireguard(proxy) {
8210
8333
  result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
8211
8334
  appendShadowTLS(result, proxy);
8212
8335
  result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
8336
+ result.appendIfPresent(`,ecn=${proxy.ecn}`, "ecn");
8213
8337
  result.appendIfPresent(
8214
8338
  `,underlying-proxy=${proxy["underlying-proxy"]}`,
8215
8339
  "underlying-proxy"
@@ -8284,6 +8408,7 @@ function wireguard_surge(proxy) {
8284
8408
  result.appendIfPresent(`,interface=${proxy["interface"]}`, "interface");
8285
8409
  appendShadowTLS(result, proxy);
8286
8410
  result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
8411
+ result.appendIfPresent(`,ecn=${proxy.ecn}`, "ecn");
8287
8412
  result.appendIfPresent(
8288
8413
  `,underlying-proxy=${proxy["underlying-proxy"]}`,
8289
8414
  "underlying-proxy"
@@ -9351,6 +9476,8 @@ function Stash_Producer() {
9351
9476
  }
9352
9477
 
9353
9478
  // src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/loon.js
9479
+ var import_buffer3 = __toESM(require_buffer());
9480
+ import _6 from "lodash";
9354
9481
  var targetPlatform3 = "Loon";
9355
9482
  var ipVersions3 = {
9356
9483
  dual: "dual",
@@ -9389,6 +9516,8 @@ function Loon_Producer() {
9389
9516
  return tailscale(proxy);
9390
9517
  case "hysteria2":
9391
9518
  return hysteria22(proxy);
9519
+ case "mieru":
9520
+ return mieru(proxy);
9392
9521
  }
9393
9522
  if (proxy.type === "anytls") {
9394
9523
  if (proxy.network && !["tcp"].includes(proxy.network)) {
@@ -9414,8 +9543,8 @@ function appendTlsProfile(result, proxy) {
9414
9543
  const tlsProfile = getLoonTlsProfile(proxy);
9415
9544
  if (tlsProfile) result.append(`,tls-profile=${tlsProfile}`);
9416
9545
  }
9417
- function appendAlpn2(result, proxy) {
9418
- const alpn = getLoonAlpn(proxy);
9546
+ function appendAlpn2(result, proxy, isXhttp = false) {
9547
+ const alpn = isXhttp ? getLoonXhttpAlpn(proxy) : getLoonAlpn(proxy);
9419
9548
  if (alpn) result.append(`,alpn="${alpn}"`);
9420
9549
  }
9421
9550
  function formatLoonValue(value, quoted = false) {
@@ -9427,31 +9556,95 @@ function formatLoonValue(value, quoted = false) {
9427
9556
  }
9428
9557
  function appendXhttp(result, proxy) {
9429
9558
  const xhttp = proxy["xhttp-opts"];
9430
- if (xhttp?.["download-settings"]) {
9431
- throw new Error("Loon XHTTP does not support download-settings");
9559
+ const download = xhttp?.["download-settings"];
9560
+ if (download?.plugin || download?.["shadow-tls-opts"]) {
9561
+ throw new Error("Loon XHTTP download-settings do not support plugins");
9562
+ }
9563
+ validateLoonXhttpXmux(xhttp);
9564
+ let options = xhttp;
9565
+ if (download) {
9566
+ const server = getIfNotBlank(download.server) ?? getIfNotBlank(proxy.server);
9567
+ if (server == null) {
9568
+ throw new Error(
9569
+ "Loon xhttp-download-server requires a server address"
9570
+ );
9571
+ }
9572
+ const port = normalizeXhttpIntegerValue(download.port ?? proxy.port);
9573
+ if (port == null || port < 1 || port > 65535) {
9574
+ throw new Error(
9575
+ "Loon xhttp-download-port must be an integer from 1 to 65535"
9576
+ );
9577
+ }
9578
+ const reality = download["reality-opts"];
9579
+ const hasReality = Boolean(getIfNotBlank(reality?.["public-key"]));
9580
+ if (reality && !hasReality) {
9581
+ throw new Error(
9582
+ "Loon XHTTP download REALITY requires a non-blank public-key"
9583
+ );
9584
+ }
9585
+ if (hasReality && [false, "false"].includes(download.tls)) {
9586
+ throw new Error(
9587
+ "Loon XHTTP download REALITY conflicts with xhttp-download-over-tls=false"
9588
+ );
9589
+ }
9590
+ const alpn = getLoonXhttpAlpn(download, true);
9591
+ const fingerprint = download.fingerprint ?? download["tls-fingerprint"];
9592
+ const pubkeyFingerprint = download["tls-pubkey-sha256"];
9593
+ const skipCertVerify = download["skip-cert-verify"];
9594
+ if (hasReality && (fingerprint || pubkeyFingerprint || [true, "true"].includes(skipCertVerify))) {
9595
+ throw new Error(
9596
+ "Loon XHTTP download REALITY conflicts with skip-cert-verify=true or TLS certificate fingerprints"
9597
+ );
9598
+ }
9599
+ options = {
9600
+ ...xhttp,
9601
+ "download-settings": {
9602
+ ...download,
9603
+ server: server.trim(),
9604
+ port,
9605
+ host: getXhttpHost(download),
9606
+ alpn: alpn || void 0,
9607
+ servername: download.servername ?? download.sni,
9608
+ fingerprint: hasReality ? void 0 : fingerprint,
9609
+ "tls-pubkey-sha256": hasReality ? void 0 : pubkeyFingerprint,
9610
+ "skip-cert-verify": hasReality ? void 0 : skipCertVerify,
9611
+ _loon_tls_profile: getLoonTlsProfile(download)
9612
+ }
9613
+ };
9432
9614
  }
9433
- const headers = isPlainObject(xhttp?.headers) ? Object.entries(xhttp.headers) : [];
9434
- const host = xhttp?.host ?? headers.find(([key]) => /^host$/i.test(key))?.[1];
9435
9615
  result.append(",transport=xhttp");
9436
9616
  for (const [key, value] of [
9437
9617
  ["path", xhttp?.path],
9438
- ["host", host]
9618
+ ["host", getXhttpHost(xhttp)]
9439
9619
  ]) {
9440
9620
  if (value != null) result.append(`,${key}=${formatLoonValue(value)}`);
9441
9621
  }
9442
9622
  for (const [key, field] of Object.entries(LOON_XHTTP_FIELDS)) {
9443
- const value = xhttp?.[field];
9623
+ const value = _6.get(options, field);
9444
9624
  if (value != null)
9445
9625
  result.append(`,xhttp-${key}=${formatLoonValue(value)}`);
9446
9626
  }
9447
- for (const [key, value] of headers) {
9448
- if (!/^host$/i.test(key) && value != null) {
9627
+ for (const [option, headers] of [
9628
+ ["xhttp-header", xhttp?.headers],
9629
+ ["xhttp-download-header", download?.headers]
9630
+ ]) {
9631
+ if (!isPlainObject(headers)) continue;
9632
+ for (const [key, value] of Object.entries(headers)) {
9633
+ if (/^host$/i.test(key) || value == null) continue;
9449
9634
  result.append(
9450
- `,xhttp-header=${formatLoonValue(`${key}: ${value}`, true)}`
9635
+ `,${option}=${formatLoonValue(`${key}: ${value}`, true)}`
9451
9636
  );
9452
9637
  }
9453
9638
  }
9454
9639
  }
9640
+ function getXhttpHost(opts) {
9641
+ if (opts?.host != null) return opts.host;
9642
+ if (isPlainObject(opts?.headers)) {
9643
+ return Object.entries(opts.headers).find(
9644
+ ([key]) => /^host$/i.test(key)
9645
+ )?.[1];
9646
+ }
9647
+ }
9455
9648
  function getLoonShadowTLSAlpn(proxy) {
9456
9649
  const values = proxy?.["plugin-opts"]?.alpn ?? proxy?.alpn;
9457
9650
  const normalized = Array.isArray(values) ? values : `${values || ""}`.split(",");
@@ -9491,6 +9684,26 @@ function getLoonAlpn(proxy) {
9491
9684
  const values = Array.isArray(proxy.alpn) ? proxy.alpn : `${proxy.alpn || ""}`.split(",");
9492
9685
  return values.map((item) => `${item}`.trim()).filter((item) => item !== "").join(",");
9493
9686
  }
9687
+ function getLoonXhttpAlpn(endpoint, isDownload = false) {
9688
+ const alpn = getLoonAlpn(endpoint);
9689
+ if (!alpn) return alpn;
9690
+ if (alpn.includes(",")) {
9691
+ const scope = isDownload ? " download" : "";
9692
+ throw new Error(`Loon XHTTP${scope} supports only a single ALPN`);
9693
+ }
9694
+ const hasReality = Boolean(endpoint["reality-opts"]?.["public-key"]);
9695
+ const hasTls = !isDownload && endpoint.type === "trojan" || [true, "true"].includes(endpoint.tls);
9696
+ const allowed = hasReality ? ["h2"] : hasTls ? ["http/1.1", "h2", "h3"] : ["http/1.1"];
9697
+ if (!allowed.includes(alpn)) {
9698
+ const field = isDownload ? "xhttp-download-alpn" : "XHTTP alpn";
9699
+ throw new Error(
9700
+ `Loon ${field} must be ${allowed.join(
9701
+ " or "
9702
+ )} for the configured security`
9703
+ );
9704
+ }
9705
+ return alpn;
9706
+ }
9494
9707
  function getLoonTlsProfile(proxy) {
9495
9708
  const tlsProfile = `${proxy._loon_tls_profile || ""}`.trim();
9496
9709
  if ([
@@ -9685,7 +9898,7 @@ function trojan2(proxy) {
9685
9898
  "skip-cert-verify"
9686
9899
  );
9687
9900
  appendTlsProfile(result, proxy);
9688
- appendAlpn2(result, proxy);
9901
+ appendAlpn2(result, proxy, isXhttp);
9689
9902
  if (isReality) {
9690
9903
  appendReality(result, proxy);
9691
9904
  } else {
@@ -9811,7 +10024,7 @@ function vmess(proxy) {
9811
10024
  "skip-cert-verify"
9812
10025
  );
9813
10026
  if (proxy.tls || isReality) appendTlsProfile(result, proxy);
9814
- if (proxy.tls || isReality || isXhttp) appendAlpn2(result, proxy);
10027
+ if (proxy.tls || isReality || isXhttp) appendAlpn2(result, proxy, isXhttp);
9815
10028
  if (isReality) {
9816
10029
  appendReality(result, proxy);
9817
10030
  } else {
@@ -9848,20 +10061,55 @@ function vmess(proxy) {
9848
10061
  result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
9849
10062
  return result.toString();
9850
10063
  }
10064
+ function appendVlessEncryption(result, encryption) {
10065
+ if (!encryption || encryption === "none") return;
10066
+ const [method, mode, rtt, ...settings] = encryption.split(".");
10067
+ const paddingGroup = /^(-?\d+)-(-?\d+)-(-?\d+)$/;
10068
+ const keyIndex = settings.findIndex((part) => !paddingGroup.test(part));
10069
+ if (method !== "mlkem768x25519plus" || !["native", "xorpub", "random"].includes(mode) || !["0rtt", "1rtt"].includes(rtt) || !settings[keyIndex]) {
10070
+ throw new Error("Unsupported VLESS encryption format");
10071
+ }
10072
+ const padding = settings.slice(0, keyIndex);
10073
+ for (const [index, group] of padding.entries()) {
10074
+ const [, probability, min, max] = paddingGroup.exec(group).map(Number);
10075
+ if (index === 0 && (probability !== 100 || min < 35 || max < 35)) {
10076
+ throw new Error(
10077
+ "Loon VLESS encryption-padding first group requires probability 100 and lengths of at least 35"
10078
+ );
10079
+ }
10080
+ if (probability < 0 || probability > 100 || min < 0 || min > max || !Number.isSafeInteger(max)) {
10081
+ throw new Error(
10082
+ "Loon VLESS encryption-padding requires probabilities from 0 to 100 and ordered non-negative integer bounds"
10083
+ );
10084
+ }
10085
+ }
10086
+ const publicKeys = settings.slice(keyIndex).join(".");
10087
+ result.append(`,encryption-mode=${mode},encryption-rtt=${rtt}`);
10088
+ result.append(`,encryption-public-keys=${formatLoonValue(publicKeys)}`);
10089
+ if (padding.length) {
10090
+ result.append(
10091
+ `,encryption-padding=${formatLoonValue(padding.join("."))}`
10092
+ );
10093
+ }
10094
+ }
9851
10095
  function vless(proxy) {
9852
- if (proxy.encryption && proxy.encryption !== "none")
9853
- throw new Error(`VLESS encryption is not supported`);
9854
- let isXtls = false;
9855
- const isReality = !!proxy["reality-opts"];
10096
+ const isXtls = !!proxy.flow;
10097
+ const reality = proxy["reality-opts"];
10098
+ const isReality = Boolean(getIfNotBlank(reality?.["public-key"]));
9856
10099
  const isXhttp = proxy.network === "xhttp";
9857
- if (isXhttp && proxy.flow)
9858
- throw new Error("VLESS XHTTP does not support flow");
9859
- if (!isXhttp && typeof proxy.flow !== "undefined") {
9860
- if (["xtls-rprx-vision"].includes(proxy.flow)) {
9861
- isXtls = true;
9862
- } else {
9863
- throw new Error(`VLESS flow(${proxy.flow}) is not supported`);
9864
- }
10100
+ const isTcp = (proxy.network ?? "tcp") === "tcp";
10101
+ const isSecure = isReality || [true, "true"].includes(proxy.tls);
10102
+ const encryptionEnabled = proxy.encryption && proxy.encryption !== "none";
10103
+ if (reality && !isReality) {
10104
+ throw new Error("Loon VLESS REALITY requires a non-blank public-key");
10105
+ }
10106
+ if (isXtls && !["xtls-rprx-vision", "xtls-rprx-vision-udp443"].includes(proxy.flow)) {
10107
+ throw new Error(`VLESS flow(${proxy.flow}) is not supported`);
10108
+ }
10109
+ if (isXtls && !encryptionEnabled && (!isTcp || !isSecure)) {
10110
+ throw new Error(
10111
+ "Loon VLESS Vision without encryption requires TCP with TLS or REALITY"
10112
+ );
9865
10113
  }
9866
10114
  const result = new Result(proxy);
9867
10115
  result.append(
@@ -9907,10 +10155,10 @@ function vless(proxy) {
9907
10155
  "skip-cert-verify"
9908
10156
  );
9909
10157
  if (proxy.tls || isReality || isXtls) appendTlsProfile(result, proxy);
9910
- if (proxy.tls || isReality || isXtls || isXhttp) appendAlpn2(result, proxy);
9911
- if (isXtls) {
9912
- result.appendIfPresent(`,flow=${proxy.flow}`, "flow");
9913
- }
10158
+ if (proxy.tls || isReality || isXtls || isXhttp)
10159
+ appendAlpn2(result, proxy, isXhttp);
10160
+ appendVlessEncryption(result, proxy.encryption);
10161
+ if (isXtls) result.append(`,flow=${proxy.flow}`);
9914
10162
  if (isReality) {
9915
10163
  appendReality(result, proxy);
9916
10164
  } else {
@@ -10087,6 +10335,49 @@ function wireguard2(proxy) {
10087
10335
  }
10088
10336
  return result.toString();
10089
10337
  }
10338
+ function mieru(proxy) {
10339
+ if (proxy.transport && String(proxy.transport).toUpperCase() !== "TCP") {
10340
+ throw new Error("Loon Mieru requires TCP transport");
10341
+ }
10342
+ if (proxy.tls || proxy["reality-opts"]) {
10343
+ throw new Error("Loon Mieru does not support TLS or REALITY");
10344
+ }
10345
+ const server = getIfNotBlank(proxy.server)?.trim();
10346
+ if (!server) throw new Error("Loon Mieru requires a server");
10347
+ const portText = String(proxy.port ?? "").trim();
10348
+ const port = Number(portText);
10349
+ if (!/^\d+$/.test(portText) || port < 1 || port > 65535) {
10350
+ throw new Error("Loon Mieru port must be an integer from 1 to 65535");
10351
+ }
10352
+ const credentials = [proxy.username, proxy.password].map(
10353
+ (value) => String(value ?? "")
10354
+ );
10355
+ if (credentials.some(
10356
+ (value) => !value || import_buffer3.Buffer.byteLength(value, "utf8") > 64
10357
+ )) {
10358
+ throw new Error(
10359
+ "Loon Mieru username and password must each be 1-64 UTF-8 bytes"
10360
+ );
10361
+ }
10362
+ const result = new Result(proxy);
10363
+ const address = isIPv6(server) ? `[${server}]` : server;
10364
+ const [username, password] = credentials.map(
10365
+ (value) => formatLoonValue(value, true)
10366
+ );
10367
+ result.append(
10368
+ `${proxy.name}=mieru,${address},${port},${username},${password}`
10369
+ );
10370
+ if (proxy.udp) result.append(",udp=true");
10371
+ const blockQuic = proxy["block-quic"];
10372
+ if (["on", "off", true, false].includes(blockQuic)) {
10373
+ result.append(
10374
+ `,block-quic=${blockQuic === "on" || blockQuic === true}`
10375
+ );
10376
+ }
10377
+ const ipVersion = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
10378
+ result.appendIfPresent(`,ip-mode=${ipVersion}`, "ip-version");
10379
+ return result.toString();
10380
+ }
10090
10381
  function hysteria22(proxy) {
10091
10382
  if (proxy["obfs-password"] && proxy.obfs != "salamander") {
10092
10383
  throw new Error(`only salamander obfs is supported`);
@@ -10131,7 +10422,11 @@ function hysteria22(proxy) {
10131
10422
  `,download-bandwidth=${`${proxy["down"]}`.match(/\d+/)?.[0] || 0}`,
10132
10423
  "down"
10133
10424
  );
10134
- result.appendIfPresent(`,ecn=${proxy.ecn}`, "ecn");
10425
+ if ([true, "true", "on"].includes(proxy.ecn)) {
10426
+ result.append(",ecn=true");
10427
+ } else if ([false, "false", "off"].includes(proxy.ecn)) {
10428
+ result.append(",ecn=false");
10429
+ }
10135
10430
  const ip_version = ipVersions3[proxy["ip-version"]] || proxy["ip-version"];
10136
10431
  result.appendIfPresent(`,ip-mode=${ip_version}`, "ip-version");
10137
10432
  return result.toString();
@@ -11458,12 +11753,12 @@ Reason: ${err}`);
11458
11753
  }
11459
11754
 
11460
11755
  // src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/qx.js
11461
- var import_buffer3 = __toESM(require_buffer());
11756
+ var import_buffer4 = __toESM(require_buffer());
11462
11757
  var targetPlatform4 = "QX";
11463
11758
  function encodeQxAlpn(alpn) {
11464
11759
  const protocols = (Array.isArray(alpn) ? alpn : `${alpn}`.split(",")).map((protocol) => `${protocol}`.trim()).filter(Boolean);
11465
11760
  return protocols.map((protocol) => {
11466
- const bytes = import_buffer3.Buffer.from(protocol, "utf8");
11761
+ const bytes = import_buffer4.Buffer.from(protocol, "utf8");
11467
11762
  if (bytes.length > 255) {
11468
11763
  throw new Error("QX ALPN protocol exceeds 255 bytes");
11469
11764
  }
@@ -11505,7 +11800,7 @@ function QX_Producer() {
11505
11800
  case "hysteria2":
11506
11801
  return hysteria23(proxy);
11507
11802
  case "mieru":
11508
- return mieru(proxy);
11803
+ return mieru2(proxy);
11509
11804
  }
11510
11805
  throw new Error(
11511
11806
  `Platform ${targetPlatform4} does not support proxy type: ${proxy.type}`
@@ -11932,7 +12227,7 @@ function hysteria23(proxy) {
11932
12227
  }
11933
12228
  if (isPresent2(proxy, "obfs-password")) {
11934
12229
  const obfsPassword = String(proxy["obfs-password"]);
11935
- if (import_buffer3.Buffer.byteLength(obfsPassword, "utf8") < 4) {
12230
+ if (import_buffer4.Buffer.byteLength(obfsPassword, "utf8") < 4) {
11936
12231
  throw new Error(
11937
12232
  `QX Hysteria 2 ${obfs}-password must be at least 4 bytes`
11938
12233
  );
@@ -12054,7 +12349,7 @@ function socks53(proxy) {
12054
12349
  append(`,tag=${proxy.name}`);
12055
12350
  return result.toString();
12056
12351
  }
12057
- function mieru(proxy) {
12352
+ function mieru2(proxy) {
12058
12353
  const result = new Result(proxy);
12059
12354
  result.append(`mieru=${proxy.server}:${proxy.port}`);
12060
12355
  result.appendIfPresent(`,username=${proxy.username}`, "username");
@@ -12315,7 +12610,7 @@ function hasShadowrocketSnellShadowTlsObfsConflict(proxy) {
12315
12610
  }
12316
12611
 
12317
12612
  // src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/surfboard.js
12318
- import _5 from "lodash";
12613
+ import _7 from "lodash";
12319
12614
  var targetPlatform5 = "Surfboard";
12320
12615
  function hasNonBlankValue2(value) {
12321
12616
  return value != null && `${value}`.trim().length > 0;
@@ -12593,7 +12888,7 @@ function vless4(proxy) {
12593
12888
  const headers = Object.entries(xhttp?.headers ?? {});
12594
12889
  const host = xhttp?.host ?? headers.find(([key]) => /^host$/i.test(key))?.[1];
12595
12890
  for (const [key, field] of Object.entries(SURGE_XHTTP_FIELDS)) {
12596
- append(`xhttp-${key}`, key === "host" ? host : _5.get(xhttp, field));
12891
+ append(`xhttp-${key}`, key === "host" ? host : _7.get(xhttp, field));
12597
12892
  }
12598
12893
  append(
12599
12894
  "xhttp-headers",
@@ -12704,7 +12999,7 @@ function handleTransport2(result, proxy) {
12704
12999
  }
12705
13000
 
12706
13001
  // src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/sing-box.js
12707
- var import_buffer4 = __toESM(require_buffer());
13002
+ var import_buffer5 = __toESM(require_buffer());
12708
13003
  var ipVersions4 = {
12709
13004
  ipv4: "ipv4_only",
12710
13005
  ipv6: "ipv6_only",
@@ -13018,7 +13313,7 @@ var tlsCertificateParser = (proxy, parsedProxy) => {
13018
13313
  `Platform sing-box: invalid SHA-256 certificate fingerprint for proxy ${proxy.name}`
13019
13314
  );
13020
13315
  }
13021
- tls.certificate_sha256 = [import_buffer4.Buffer.from(hex, "hex").toString("base64")];
13316
+ tls.certificate_sha256 = [import_buffer5.Buffer.from(hex, "hex").toString("base64")];
13022
13317
  }
13023
13318
  if (hasCertificate && (tls.certificate_sha256?.length || tls.certificate_public_key_sha256?.length)) {
13024
13319
  throw new Error(