sub-store-convert 2.36.33 → 2.44.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +2343 -460
- package/package.json +6 -1
package/index.js
CHANGED
|
@@ -1,3 +1,1809 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
try {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
} catch (e) {
|
|
11
|
+
throw mod = 0, e;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
+
mod
|
|
29
|
+
));
|
|
30
|
+
|
|
31
|
+
// ../../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js
|
|
32
|
+
var require_base64_js = __commonJS({
|
|
33
|
+
"../../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js"(exports) {
|
|
34
|
+
"use strict";
|
|
35
|
+
exports.byteLength = byteLength;
|
|
36
|
+
exports.toByteArray = toByteArray;
|
|
37
|
+
exports.fromByteArray = fromByteArray;
|
|
38
|
+
var lookup = [];
|
|
39
|
+
var revLookup = [];
|
|
40
|
+
var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
|
|
41
|
+
var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
42
|
+
for (i = 0, len = code.length; i < len; ++i) {
|
|
43
|
+
lookup[i] = code[i];
|
|
44
|
+
revLookup[code.charCodeAt(i)] = i;
|
|
45
|
+
}
|
|
46
|
+
var i;
|
|
47
|
+
var len;
|
|
48
|
+
revLookup["-".charCodeAt(0)] = 62;
|
|
49
|
+
revLookup["_".charCodeAt(0)] = 63;
|
|
50
|
+
function getLens(b64) {
|
|
51
|
+
var len2 = b64.length;
|
|
52
|
+
if (len2 % 4 > 0) {
|
|
53
|
+
throw new Error("Invalid string. Length must be a multiple of 4");
|
|
54
|
+
}
|
|
55
|
+
var validLen = b64.indexOf("=");
|
|
56
|
+
if (validLen === -1) validLen = len2;
|
|
57
|
+
var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4;
|
|
58
|
+
return [validLen, placeHoldersLen];
|
|
59
|
+
}
|
|
60
|
+
function byteLength(b64) {
|
|
61
|
+
var lens = getLens(b64);
|
|
62
|
+
var validLen = lens[0];
|
|
63
|
+
var placeHoldersLen = lens[1];
|
|
64
|
+
return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
|
|
65
|
+
}
|
|
66
|
+
function _byteLength(b64, validLen, placeHoldersLen) {
|
|
67
|
+
return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
|
|
68
|
+
}
|
|
69
|
+
function toByteArray(b64) {
|
|
70
|
+
var tmp;
|
|
71
|
+
var lens = getLens(b64);
|
|
72
|
+
var validLen = lens[0];
|
|
73
|
+
var placeHoldersLen = lens[1];
|
|
74
|
+
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
|
|
75
|
+
var curByte = 0;
|
|
76
|
+
var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen;
|
|
77
|
+
var i2;
|
|
78
|
+
for (i2 = 0; i2 < len2; i2 += 4) {
|
|
79
|
+
tmp = revLookup[b64.charCodeAt(i2)] << 18 | revLookup[b64.charCodeAt(i2 + 1)] << 12 | revLookup[b64.charCodeAt(i2 + 2)] << 6 | revLookup[b64.charCodeAt(i2 + 3)];
|
|
80
|
+
arr[curByte++] = tmp >> 16 & 255;
|
|
81
|
+
arr[curByte++] = tmp >> 8 & 255;
|
|
82
|
+
arr[curByte++] = tmp & 255;
|
|
83
|
+
}
|
|
84
|
+
if (placeHoldersLen === 2) {
|
|
85
|
+
tmp = revLookup[b64.charCodeAt(i2)] << 2 | revLookup[b64.charCodeAt(i2 + 1)] >> 4;
|
|
86
|
+
arr[curByte++] = tmp & 255;
|
|
87
|
+
}
|
|
88
|
+
if (placeHoldersLen === 1) {
|
|
89
|
+
tmp = revLookup[b64.charCodeAt(i2)] << 10 | revLookup[b64.charCodeAt(i2 + 1)] << 4 | revLookup[b64.charCodeAt(i2 + 2)] >> 2;
|
|
90
|
+
arr[curByte++] = tmp >> 8 & 255;
|
|
91
|
+
arr[curByte++] = tmp & 255;
|
|
92
|
+
}
|
|
93
|
+
return arr;
|
|
94
|
+
}
|
|
95
|
+
function tripletToBase64(num) {
|
|
96
|
+
return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
|
|
97
|
+
}
|
|
98
|
+
function encodeChunk(uint8, start, end) {
|
|
99
|
+
var tmp;
|
|
100
|
+
var output = [];
|
|
101
|
+
for (var i2 = start; i2 < end; i2 += 3) {
|
|
102
|
+
tmp = (uint8[i2] << 16 & 16711680) + (uint8[i2 + 1] << 8 & 65280) + (uint8[i2 + 2] & 255);
|
|
103
|
+
output.push(tripletToBase64(tmp));
|
|
104
|
+
}
|
|
105
|
+
return output.join("");
|
|
106
|
+
}
|
|
107
|
+
function fromByteArray(uint8) {
|
|
108
|
+
var tmp;
|
|
109
|
+
var len2 = uint8.length;
|
|
110
|
+
var extraBytes = len2 % 3;
|
|
111
|
+
var parts = [];
|
|
112
|
+
var maxChunkLength = 16383;
|
|
113
|
+
for (var i2 = 0, len22 = len2 - extraBytes; i2 < len22; i2 += maxChunkLength) {
|
|
114
|
+
parts.push(encodeChunk(uint8, i2, i2 + maxChunkLength > len22 ? len22 : i2 + maxChunkLength));
|
|
115
|
+
}
|
|
116
|
+
if (extraBytes === 1) {
|
|
117
|
+
tmp = uint8[len2 - 1];
|
|
118
|
+
parts.push(
|
|
119
|
+
lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "=="
|
|
120
|
+
);
|
|
121
|
+
} else if (extraBytes === 2) {
|
|
122
|
+
tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1];
|
|
123
|
+
parts.push(
|
|
124
|
+
lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "="
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
return parts.join("");
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// ../../node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js
|
|
133
|
+
var require_ieee754 = __commonJS({
|
|
134
|
+
"../../node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js"(exports) {
|
|
135
|
+
exports.read = function(buffer, offset, isLE, mLen, nBytes) {
|
|
136
|
+
var e, m;
|
|
137
|
+
var eLen = nBytes * 8 - mLen - 1;
|
|
138
|
+
var eMax = (1 << eLen) - 1;
|
|
139
|
+
var eBias = eMax >> 1;
|
|
140
|
+
var nBits = -7;
|
|
141
|
+
var i = isLE ? nBytes - 1 : 0;
|
|
142
|
+
var d = isLE ? -1 : 1;
|
|
143
|
+
var s = buffer[offset + i];
|
|
144
|
+
i += d;
|
|
145
|
+
e = s & (1 << -nBits) - 1;
|
|
146
|
+
s >>= -nBits;
|
|
147
|
+
nBits += eLen;
|
|
148
|
+
for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {
|
|
149
|
+
}
|
|
150
|
+
m = e & (1 << -nBits) - 1;
|
|
151
|
+
e >>= -nBits;
|
|
152
|
+
nBits += mLen;
|
|
153
|
+
for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {
|
|
154
|
+
}
|
|
155
|
+
if (e === 0) {
|
|
156
|
+
e = 1 - eBias;
|
|
157
|
+
} else if (e === eMax) {
|
|
158
|
+
return m ? NaN : (s ? -1 : 1) * Infinity;
|
|
159
|
+
} else {
|
|
160
|
+
m = m + Math.pow(2, mLen);
|
|
161
|
+
e = e - eBias;
|
|
162
|
+
}
|
|
163
|
+
return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
|
|
164
|
+
};
|
|
165
|
+
exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
|
|
166
|
+
var e, m, c;
|
|
167
|
+
var eLen = nBytes * 8 - mLen - 1;
|
|
168
|
+
var eMax = (1 << eLen) - 1;
|
|
169
|
+
var eBias = eMax >> 1;
|
|
170
|
+
var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
|
|
171
|
+
var i = isLE ? 0 : nBytes - 1;
|
|
172
|
+
var d = isLE ? 1 : -1;
|
|
173
|
+
var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
|
|
174
|
+
value = Math.abs(value);
|
|
175
|
+
if (isNaN(value) || value === Infinity) {
|
|
176
|
+
m = isNaN(value) ? 1 : 0;
|
|
177
|
+
e = eMax;
|
|
178
|
+
} else {
|
|
179
|
+
e = Math.floor(Math.log(value) / Math.LN2);
|
|
180
|
+
if (value * (c = Math.pow(2, -e)) < 1) {
|
|
181
|
+
e--;
|
|
182
|
+
c *= 2;
|
|
183
|
+
}
|
|
184
|
+
if (e + eBias >= 1) {
|
|
185
|
+
value += rt / c;
|
|
186
|
+
} else {
|
|
187
|
+
value += rt * Math.pow(2, 1 - eBias);
|
|
188
|
+
}
|
|
189
|
+
if (value * c >= 2) {
|
|
190
|
+
e++;
|
|
191
|
+
c /= 2;
|
|
192
|
+
}
|
|
193
|
+
if (e + eBias >= eMax) {
|
|
194
|
+
m = 0;
|
|
195
|
+
e = eMax;
|
|
196
|
+
} else if (e + eBias >= 1) {
|
|
197
|
+
m = (value * c - 1) * Math.pow(2, mLen);
|
|
198
|
+
e = e + eBias;
|
|
199
|
+
} else {
|
|
200
|
+
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
|
|
201
|
+
e = 0;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
|
|
205
|
+
}
|
|
206
|
+
e = e << mLen | m;
|
|
207
|
+
eLen += mLen;
|
|
208
|
+
for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
|
|
209
|
+
}
|
|
210
|
+
buffer[offset + i - d] |= s * 128;
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// ../../node_modules/.pnpm/buffer@6.0.3/node_modules/buffer/index.js
|
|
216
|
+
var require_buffer = __commonJS({
|
|
217
|
+
"../../node_modules/.pnpm/buffer@6.0.3/node_modules/buffer/index.js"(exports) {
|
|
218
|
+
"use strict";
|
|
219
|
+
var base64 = require_base64_js();
|
|
220
|
+
var ieee754 = require_ieee754();
|
|
221
|
+
var customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null;
|
|
222
|
+
exports.Buffer = Buffer4;
|
|
223
|
+
exports.SlowBuffer = SlowBuffer;
|
|
224
|
+
exports.INSPECT_MAX_BYTES = 50;
|
|
225
|
+
var K_MAX_LENGTH = 2147483647;
|
|
226
|
+
exports.kMaxLength = K_MAX_LENGTH;
|
|
227
|
+
Buffer4.TYPED_ARRAY_SUPPORT = typedArraySupport();
|
|
228
|
+
if (!Buffer4.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") {
|
|
229
|
+
console.error(
|
|
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
|
+
);
|
|
232
|
+
}
|
|
233
|
+
function typedArraySupport() {
|
|
234
|
+
try {
|
|
235
|
+
const arr = new Uint8Array(1);
|
|
236
|
+
const proto = { foo: function() {
|
|
237
|
+
return 42;
|
|
238
|
+
} };
|
|
239
|
+
Object.setPrototypeOf(proto, Uint8Array.prototype);
|
|
240
|
+
Object.setPrototypeOf(arr, proto);
|
|
241
|
+
return arr.foo() === 42;
|
|
242
|
+
} catch (e) {
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
Object.defineProperty(Buffer4.prototype, "parent", {
|
|
247
|
+
enumerable: true,
|
|
248
|
+
get: function() {
|
|
249
|
+
if (!Buffer4.isBuffer(this)) return void 0;
|
|
250
|
+
return this.buffer;
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
Object.defineProperty(Buffer4.prototype, "offset", {
|
|
254
|
+
enumerable: true,
|
|
255
|
+
get: function() {
|
|
256
|
+
if (!Buffer4.isBuffer(this)) return void 0;
|
|
257
|
+
return this.byteOffset;
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
function createBuffer(length) {
|
|
261
|
+
if (length > K_MAX_LENGTH) {
|
|
262
|
+
throw new RangeError('The value "' + length + '" is invalid for option "size"');
|
|
263
|
+
}
|
|
264
|
+
const buf = new Uint8Array(length);
|
|
265
|
+
Object.setPrototypeOf(buf, Buffer4.prototype);
|
|
266
|
+
return buf;
|
|
267
|
+
}
|
|
268
|
+
function Buffer4(arg, encodingOrOffset, length) {
|
|
269
|
+
if (typeof arg === "number") {
|
|
270
|
+
if (typeof encodingOrOffset === "string") {
|
|
271
|
+
throw new TypeError(
|
|
272
|
+
'The "string" argument must be of type string. Received type number'
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
return allocUnsafe(arg);
|
|
276
|
+
}
|
|
277
|
+
return from(arg, encodingOrOffset, length);
|
|
278
|
+
}
|
|
279
|
+
Buffer4.poolSize = 8192;
|
|
280
|
+
function from(value, encodingOrOffset, length) {
|
|
281
|
+
if (typeof value === "string") {
|
|
282
|
+
return fromString(value, encodingOrOffset);
|
|
283
|
+
}
|
|
284
|
+
if (ArrayBuffer.isView(value)) {
|
|
285
|
+
return fromArrayView(value);
|
|
286
|
+
}
|
|
287
|
+
if (value == null) {
|
|
288
|
+
throw new TypeError(
|
|
289
|
+
"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) {
|
|
293
|
+
return fromArrayBuffer(value, encodingOrOffset, length);
|
|
294
|
+
}
|
|
295
|
+
if (typeof SharedArrayBuffer !== "undefined" && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) {
|
|
296
|
+
return fromArrayBuffer(value, encodingOrOffset, length);
|
|
297
|
+
}
|
|
298
|
+
if (typeof value === "number") {
|
|
299
|
+
throw new TypeError(
|
|
300
|
+
'The "value" argument must not be of type number. Received type number'
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
const valueOf = value.valueOf && value.valueOf();
|
|
304
|
+
if (valueOf != null && valueOf !== value) {
|
|
305
|
+
return Buffer4.from(valueOf, encodingOrOffset, length);
|
|
306
|
+
}
|
|
307
|
+
const b = fromObject(value);
|
|
308
|
+
if (b) return b;
|
|
309
|
+
if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") {
|
|
310
|
+
return Buffer4.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length);
|
|
311
|
+
}
|
|
312
|
+
throw new TypeError(
|
|
313
|
+
"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
Buffer4.from = function(value, encodingOrOffset, length) {
|
|
317
|
+
return from(value, encodingOrOffset, length);
|
|
318
|
+
};
|
|
319
|
+
Object.setPrototypeOf(Buffer4.prototype, Uint8Array.prototype);
|
|
320
|
+
Object.setPrototypeOf(Buffer4, Uint8Array);
|
|
321
|
+
function assertSize(size) {
|
|
322
|
+
if (typeof size !== "number") {
|
|
323
|
+
throw new TypeError('"size" argument must be of type number');
|
|
324
|
+
} else if (size < 0) {
|
|
325
|
+
throw new RangeError('The value "' + size + '" is invalid for option "size"');
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
function alloc(size, fill, encoding) {
|
|
329
|
+
assertSize(size);
|
|
330
|
+
if (size <= 0) {
|
|
331
|
+
return createBuffer(size);
|
|
332
|
+
}
|
|
333
|
+
if (fill !== void 0) {
|
|
334
|
+
return typeof encoding === "string" ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill);
|
|
335
|
+
}
|
|
336
|
+
return createBuffer(size);
|
|
337
|
+
}
|
|
338
|
+
Buffer4.alloc = function(size, fill, encoding) {
|
|
339
|
+
return alloc(size, fill, encoding);
|
|
340
|
+
};
|
|
341
|
+
function allocUnsafe(size) {
|
|
342
|
+
assertSize(size);
|
|
343
|
+
return createBuffer(size < 0 ? 0 : checked(size) | 0);
|
|
344
|
+
}
|
|
345
|
+
Buffer4.allocUnsafe = function(size) {
|
|
346
|
+
return allocUnsafe(size);
|
|
347
|
+
};
|
|
348
|
+
Buffer4.allocUnsafeSlow = function(size) {
|
|
349
|
+
return allocUnsafe(size);
|
|
350
|
+
};
|
|
351
|
+
function fromString(string, encoding) {
|
|
352
|
+
if (typeof encoding !== "string" || encoding === "") {
|
|
353
|
+
encoding = "utf8";
|
|
354
|
+
}
|
|
355
|
+
if (!Buffer4.isEncoding(encoding)) {
|
|
356
|
+
throw new TypeError("Unknown encoding: " + encoding);
|
|
357
|
+
}
|
|
358
|
+
const length = byteLength(string, encoding) | 0;
|
|
359
|
+
let buf = createBuffer(length);
|
|
360
|
+
const actual = buf.write(string, encoding);
|
|
361
|
+
if (actual !== length) {
|
|
362
|
+
buf = buf.slice(0, actual);
|
|
363
|
+
}
|
|
364
|
+
return buf;
|
|
365
|
+
}
|
|
366
|
+
function fromArrayLike(array) {
|
|
367
|
+
const length = array.length < 0 ? 0 : checked(array.length) | 0;
|
|
368
|
+
const buf = createBuffer(length);
|
|
369
|
+
for (let i = 0; i < length; i += 1) {
|
|
370
|
+
buf[i] = array[i] & 255;
|
|
371
|
+
}
|
|
372
|
+
return buf;
|
|
373
|
+
}
|
|
374
|
+
function fromArrayView(arrayView) {
|
|
375
|
+
if (isInstance(arrayView, Uint8Array)) {
|
|
376
|
+
const copy = new Uint8Array(arrayView);
|
|
377
|
+
return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength);
|
|
378
|
+
}
|
|
379
|
+
return fromArrayLike(arrayView);
|
|
380
|
+
}
|
|
381
|
+
function fromArrayBuffer(array, byteOffset, length) {
|
|
382
|
+
if (byteOffset < 0 || array.byteLength < byteOffset) {
|
|
383
|
+
throw new RangeError('"offset" is outside of buffer bounds');
|
|
384
|
+
}
|
|
385
|
+
if (array.byteLength < byteOffset + (length || 0)) {
|
|
386
|
+
throw new RangeError('"length" is outside of buffer bounds');
|
|
387
|
+
}
|
|
388
|
+
let buf;
|
|
389
|
+
if (byteOffset === void 0 && length === void 0) {
|
|
390
|
+
buf = new Uint8Array(array);
|
|
391
|
+
} else if (length === void 0) {
|
|
392
|
+
buf = new Uint8Array(array, byteOffset);
|
|
393
|
+
} else {
|
|
394
|
+
buf = new Uint8Array(array, byteOffset, length);
|
|
395
|
+
}
|
|
396
|
+
Object.setPrototypeOf(buf, Buffer4.prototype);
|
|
397
|
+
return buf;
|
|
398
|
+
}
|
|
399
|
+
function fromObject(obj) {
|
|
400
|
+
if (Buffer4.isBuffer(obj)) {
|
|
401
|
+
const len = checked(obj.length) | 0;
|
|
402
|
+
const buf = createBuffer(len);
|
|
403
|
+
if (buf.length === 0) {
|
|
404
|
+
return buf;
|
|
405
|
+
}
|
|
406
|
+
obj.copy(buf, 0, 0, len);
|
|
407
|
+
return buf;
|
|
408
|
+
}
|
|
409
|
+
if (obj.length !== void 0) {
|
|
410
|
+
if (typeof obj.length !== "number" || numberIsNaN(obj.length)) {
|
|
411
|
+
return createBuffer(0);
|
|
412
|
+
}
|
|
413
|
+
return fromArrayLike(obj);
|
|
414
|
+
}
|
|
415
|
+
if (obj.type === "Buffer" && Array.isArray(obj.data)) {
|
|
416
|
+
return fromArrayLike(obj.data);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
function checked(length) {
|
|
420
|
+
if (length >= K_MAX_LENGTH) {
|
|
421
|
+
throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + K_MAX_LENGTH.toString(16) + " bytes");
|
|
422
|
+
}
|
|
423
|
+
return length | 0;
|
|
424
|
+
}
|
|
425
|
+
function SlowBuffer(length) {
|
|
426
|
+
if (+length != length) {
|
|
427
|
+
length = 0;
|
|
428
|
+
}
|
|
429
|
+
return Buffer4.alloc(+length);
|
|
430
|
+
}
|
|
431
|
+
Buffer4.isBuffer = function isBuffer(b) {
|
|
432
|
+
return b != null && b._isBuffer === true && b !== Buffer4.prototype;
|
|
433
|
+
};
|
|
434
|
+
Buffer4.compare = function compare(a, b) {
|
|
435
|
+
if (isInstance(a, Uint8Array)) a = Buffer4.from(a, a.offset, a.byteLength);
|
|
436
|
+
if (isInstance(b, Uint8Array)) b = Buffer4.from(b, b.offset, b.byteLength);
|
|
437
|
+
if (!Buffer4.isBuffer(a) || !Buffer4.isBuffer(b)) {
|
|
438
|
+
throw new TypeError(
|
|
439
|
+
'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
if (a === b) return 0;
|
|
443
|
+
let x = a.length;
|
|
444
|
+
let y = b.length;
|
|
445
|
+
for (let i = 0, len = Math.min(x, y); i < len; ++i) {
|
|
446
|
+
if (a[i] !== b[i]) {
|
|
447
|
+
x = a[i];
|
|
448
|
+
y = b[i];
|
|
449
|
+
break;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
if (x < y) return -1;
|
|
453
|
+
if (y < x) return 1;
|
|
454
|
+
return 0;
|
|
455
|
+
};
|
|
456
|
+
Buffer4.isEncoding = function isEncoding(encoding) {
|
|
457
|
+
switch (String(encoding).toLowerCase()) {
|
|
458
|
+
case "hex":
|
|
459
|
+
case "utf8":
|
|
460
|
+
case "utf-8":
|
|
461
|
+
case "ascii":
|
|
462
|
+
case "latin1":
|
|
463
|
+
case "binary":
|
|
464
|
+
case "base64":
|
|
465
|
+
case "ucs2":
|
|
466
|
+
case "ucs-2":
|
|
467
|
+
case "utf16le":
|
|
468
|
+
case "utf-16le":
|
|
469
|
+
return true;
|
|
470
|
+
default:
|
|
471
|
+
return false;
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
Buffer4.concat = function concat(list, length) {
|
|
475
|
+
if (!Array.isArray(list)) {
|
|
476
|
+
throw new TypeError('"list" argument must be an Array of Buffers');
|
|
477
|
+
}
|
|
478
|
+
if (list.length === 0) {
|
|
479
|
+
return Buffer4.alloc(0);
|
|
480
|
+
}
|
|
481
|
+
let i;
|
|
482
|
+
if (length === void 0) {
|
|
483
|
+
length = 0;
|
|
484
|
+
for (i = 0; i < list.length; ++i) {
|
|
485
|
+
length += list[i].length;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
const buffer = Buffer4.allocUnsafe(length);
|
|
489
|
+
let pos = 0;
|
|
490
|
+
for (i = 0; i < list.length; ++i) {
|
|
491
|
+
let buf = list[i];
|
|
492
|
+
if (isInstance(buf, Uint8Array)) {
|
|
493
|
+
if (pos + buf.length > buffer.length) {
|
|
494
|
+
if (!Buffer4.isBuffer(buf)) buf = Buffer4.from(buf);
|
|
495
|
+
buf.copy(buffer, pos);
|
|
496
|
+
} else {
|
|
497
|
+
Uint8Array.prototype.set.call(
|
|
498
|
+
buffer,
|
|
499
|
+
buf,
|
|
500
|
+
pos
|
|
501
|
+
);
|
|
502
|
+
}
|
|
503
|
+
} else if (!Buffer4.isBuffer(buf)) {
|
|
504
|
+
throw new TypeError('"list" argument must be an Array of Buffers');
|
|
505
|
+
} else {
|
|
506
|
+
buf.copy(buffer, pos);
|
|
507
|
+
}
|
|
508
|
+
pos += buf.length;
|
|
509
|
+
}
|
|
510
|
+
return buffer;
|
|
511
|
+
};
|
|
512
|
+
function byteLength(string, encoding) {
|
|
513
|
+
if (Buffer4.isBuffer(string)) {
|
|
514
|
+
return string.length;
|
|
515
|
+
}
|
|
516
|
+
if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
|
|
517
|
+
return string.byteLength;
|
|
518
|
+
}
|
|
519
|
+
if (typeof string !== "string") {
|
|
520
|
+
throw new TypeError(
|
|
521
|
+
'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof string
|
|
522
|
+
);
|
|
523
|
+
}
|
|
524
|
+
const len = string.length;
|
|
525
|
+
const mustMatch = arguments.length > 2 && arguments[2] === true;
|
|
526
|
+
if (!mustMatch && len === 0) return 0;
|
|
527
|
+
let loweredCase = false;
|
|
528
|
+
for (; ; ) {
|
|
529
|
+
switch (encoding) {
|
|
530
|
+
case "ascii":
|
|
531
|
+
case "latin1":
|
|
532
|
+
case "binary":
|
|
533
|
+
return len;
|
|
534
|
+
case "utf8":
|
|
535
|
+
case "utf-8":
|
|
536
|
+
return utf8ToBytes(string).length;
|
|
537
|
+
case "ucs2":
|
|
538
|
+
case "ucs-2":
|
|
539
|
+
case "utf16le":
|
|
540
|
+
case "utf-16le":
|
|
541
|
+
return len * 2;
|
|
542
|
+
case "hex":
|
|
543
|
+
return len >>> 1;
|
|
544
|
+
case "base64":
|
|
545
|
+
return base64ToBytes(string).length;
|
|
546
|
+
default:
|
|
547
|
+
if (loweredCase) {
|
|
548
|
+
return mustMatch ? -1 : utf8ToBytes(string).length;
|
|
549
|
+
}
|
|
550
|
+
encoding = ("" + encoding).toLowerCase();
|
|
551
|
+
loweredCase = true;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
Buffer4.byteLength = byteLength;
|
|
556
|
+
function slowToString(encoding, start, end) {
|
|
557
|
+
let loweredCase = false;
|
|
558
|
+
if (start === void 0 || start < 0) {
|
|
559
|
+
start = 0;
|
|
560
|
+
}
|
|
561
|
+
if (start > this.length) {
|
|
562
|
+
return "";
|
|
563
|
+
}
|
|
564
|
+
if (end === void 0 || end > this.length) {
|
|
565
|
+
end = this.length;
|
|
566
|
+
}
|
|
567
|
+
if (end <= 0) {
|
|
568
|
+
return "";
|
|
569
|
+
}
|
|
570
|
+
end >>>= 0;
|
|
571
|
+
start >>>= 0;
|
|
572
|
+
if (end <= start) {
|
|
573
|
+
return "";
|
|
574
|
+
}
|
|
575
|
+
if (!encoding) encoding = "utf8";
|
|
576
|
+
while (true) {
|
|
577
|
+
switch (encoding) {
|
|
578
|
+
case "hex":
|
|
579
|
+
return hexSlice(this, start, end);
|
|
580
|
+
case "utf8":
|
|
581
|
+
case "utf-8":
|
|
582
|
+
return utf8Slice(this, start, end);
|
|
583
|
+
case "ascii":
|
|
584
|
+
return asciiSlice(this, start, end);
|
|
585
|
+
case "latin1":
|
|
586
|
+
case "binary":
|
|
587
|
+
return latin1Slice(this, start, end);
|
|
588
|
+
case "base64":
|
|
589
|
+
return base64Slice(this, start, end);
|
|
590
|
+
case "ucs2":
|
|
591
|
+
case "ucs-2":
|
|
592
|
+
case "utf16le":
|
|
593
|
+
case "utf-16le":
|
|
594
|
+
return utf16leSlice(this, start, end);
|
|
595
|
+
default:
|
|
596
|
+
if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
|
|
597
|
+
encoding = (encoding + "").toLowerCase();
|
|
598
|
+
loweredCase = true;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
Buffer4.prototype._isBuffer = true;
|
|
603
|
+
function swap(b, n, m) {
|
|
604
|
+
const i = b[n];
|
|
605
|
+
b[n] = b[m];
|
|
606
|
+
b[m] = i;
|
|
607
|
+
}
|
|
608
|
+
Buffer4.prototype.swap16 = function swap16() {
|
|
609
|
+
const len = this.length;
|
|
610
|
+
if (len % 2 !== 0) {
|
|
611
|
+
throw new RangeError("Buffer size must be a multiple of 16-bits");
|
|
612
|
+
}
|
|
613
|
+
for (let i = 0; i < len; i += 2) {
|
|
614
|
+
swap(this, i, i + 1);
|
|
615
|
+
}
|
|
616
|
+
return this;
|
|
617
|
+
};
|
|
618
|
+
Buffer4.prototype.swap32 = function swap32() {
|
|
619
|
+
const len = this.length;
|
|
620
|
+
if (len % 4 !== 0) {
|
|
621
|
+
throw new RangeError("Buffer size must be a multiple of 32-bits");
|
|
622
|
+
}
|
|
623
|
+
for (let i = 0; i < len; i += 4) {
|
|
624
|
+
swap(this, i, i + 3);
|
|
625
|
+
swap(this, i + 1, i + 2);
|
|
626
|
+
}
|
|
627
|
+
return this;
|
|
628
|
+
};
|
|
629
|
+
Buffer4.prototype.swap64 = function swap64() {
|
|
630
|
+
const len = this.length;
|
|
631
|
+
if (len % 8 !== 0) {
|
|
632
|
+
throw new RangeError("Buffer size must be a multiple of 64-bits");
|
|
633
|
+
}
|
|
634
|
+
for (let i = 0; i < len; i += 8) {
|
|
635
|
+
swap(this, i, i + 7);
|
|
636
|
+
swap(this, i + 1, i + 6);
|
|
637
|
+
swap(this, i + 2, i + 5);
|
|
638
|
+
swap(this, i + 3, i + 4);
|
|
639
|
+
}
|
|
640
|
+
return this;
|
|
641
|
+
};
|
|
642
|
+
Buffer4.prototype.toString = function toString() {
|
|
643
|
+
const length = this.length;
|
|
644
|
+
if (length === 0) return "";
|
|
645
|
+
if (arguments.length === 0) return utf8Slice(this, 0, length);
|
|
646
|
+
return slowToString.apply(this, arguments);
|
|
647
|
+
};
|
|
648
|
+
Buffer4.prototype.toLocaleString = Buffer4.prototype.toString;
|
|
649
|
+
Buffer4.prototype.equals = function equals(b) {
|
|
650
|
+
if (!Buffer4.isBuffer(b)) throw new TypeError("Argument must be a Buffer");
|
|
651
|
+
if (this === b) return true;
|
|
652
|
+
return Buffer4.compare(this, b) === 0;
|
|
653
|
+
};
|
|
654
|
+
Buffer4.prototype.inspect = function inspect() {
|
|
655
|
+
let str = "";
|
|
656
|
+
const max = exports.INSPECT_MAX_BYTES;
|
|
657
|
+
str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim();
|
|
658
|
+
if (this.length > max) str += " ... ";
|
|
659
|
+
return "<Buffer " + str + ">";
|
|
660
|
+
};
|
|
661
|
+
if (customInspectSymbol) {
|
|
662
|
+
Buffer4.prototype[customInspectSymbol] = Buffer4.prototype.inspect;
|
|
663
|
+
}
|
|
664
|
+
Buffer4.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
|
|
665
|
+
if (isInstance(target, Uint8Array)) {
|
|
666
|
+
target = Buffer4.from(target, target.offset, target.byteLength);
|
|
667
|
+
}
|
|
668
|
+
if (!Buffer4.isBuffer(target)) {
|
|
669
|
+
throw new TypeError(
|
|
670
|
+
'The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target
|
|
671
|
+
);
|
|
672
|
+
}
|
|
673
|
+
if (start === void 0) {
|
|
674
|
+
start = 0;
|
|
675
|
+
}
|
|
676
|
+
if (end === void 0) {
|
|
677
|
+
end = target ? target.length : 0;
|
|
678
|
+
}
|
|
679
|
+
if (thisStart === void 0) {
|
|
680
|
+
thisStart = 0;
|
|
681
|
+
}
|
|
682
|
+
if (thisEnd === void 0) {
|
|
683
|
+
thisEnd = this.length;
|
|
684
|
+
}
|
|
685
|
+
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
|
|
686
|
+
throw new RangeError("out of range index");
|
|
687
|
+
}
|
|
688
|
+
if (thisStart >= thisEnd && start >= end) {
|
|
689
|
+
return 0;
|
|
690
|
+
}
|
|
691
|
+
if (thisStart >= thisEnd) {
|
|
692
|
+
return -1;
|
|
693
|
+
}
|
|
694
|
+
if (start >= end) {
|
|
695
|
+
return 1;
|
|
696
|
+
}
|
|
697
|
+
start >>>= 0;
|
|
698
|
+
end >>>= 0;
|
|
699
|
+
thisStart >>>= 0;
|
|
700
|
+
thisEnd >>>= 0;
|
|
701
|
+
if (this === target) return 0;
|
|
702
|
+
let x = thisEnd - thisStart;
|
|
703
|
+
let y = end - start;
|
|
704
|
+
const len = Math.min(x, y);
|
|
705
|
+
const thisCopy = this.slice(thisStart, thisEnd);
|
|
706
|
+
const targetCopy = target.slice(start, end);
|
|
707
|
+
for (let i = 0; i < len; ++i) {
|
|
708
|
+
if (thisCopy[i] !== targetCopy[i]) {
|
|
709
|
+
x = thisCopy[i];
|
|
710
|
+
y = targetCopy[i];
|
|
711
|
+
break;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
if (x < y) return -1;
|
|
715
|
+
if (y < x) return 1;
|
|
716
|
+
return 0;
|
|
717
|
+
};
|
|
718
|
+
function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
|
|
719
|
+
if (buffer.length === 0) return -1;
|
|
720
|
+
if (typeof byteOffset === "string") {
|
|
721
|
+
encoding = byteOffset;
|
|
722
|
+
byteOffset = 0;
|
|
723
|
+
} else if (byteOffset > 2147483647) {
|
|
724
|
+
byteOffset = 2147483647;
|
|
725
|
+
} else if (byteOffset < -2147483648) {
|
|
726
|
+
byteOffset = -2147483648;
|
|
727
|
+
}
|
|
728
|
+
byteOffset = +byteOffset;
|
|
729
|
+
if (numberIsNaN(byteOffset)) {
|
|
730
|
+
byteOffset = dir ? 0 : buffer.length - 1;
|
|
731
|
+
}
|
|
732
|
+
if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
|
|
733
|
+
if (byteOffset >= buffer.length) {
|
|
734
|
+
if (dir) return -1;
|
|
735
|
+
else byteOffset = buffer.length - 1;
|
|
736
|
+
} else if (byteOffset < 0) {
|
|
737
|
+
if (dir) byteOffset = 0;
|
|
738
|
+
else return -1;
|
|
739
|
+
}
|
|
740
|
+
if (typeof val === "string") {
|
|
741
|
+
val = Buffer4.from(val, encoding);
|
|
742
|
+
}
|
|
743
|
+
if (Buffer4.isBuffer(val)) {
|
|
744
|
+
if (val.length === 0) {
|
|
745
|
+
return -1;
|
|
746
|
+
}
|
|
747
|
+
return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
|
|
748
|
+
} else if (typeof val === "number") {
|
|
749
|
+
val = val & 255;
|
|
750
|
+
if (typeof Uint8Array.prototype.indexOf === "function") {
|
|
751
|
+
if (dir) {
|
|
752
|
+
return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
|
|
753
|
+
} else {
|
|
754
|
+
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
|
|
758
|
+
}
|
|
759
|
+
throw new TypeError("val must be string, number or Buffer");
|
|
760
|
+
}
|
|
761
|
+
function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
|
|
762
|
+
let indexSize = 1;
|
|
763
|
+
let arrLength = arr.length;
|
|
764
|
+
let valLength = val.length;
|
|
765
|
+
if (encoding !== void 0) {
|
|
766
|
+
encoding = String(encoding).toLowerCase();
|
|
767
|
+
if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
|
|
768
|
+
if (arr.length < 2 || val.length < 2) {
|
|
769
|
+
return -1;
|
|
770
|
+
}
|
|
771
|
+
indexSize = 2;
|
|
772
|
+
arrLength /= 2;
|
|
773
|
+
valLength /= 2;
|
|
774
|
+
byteOffset /= 2;
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
function read(buf, i2) {
|
|
778
|
+
if (indexSize === 1) {
|
|
779
|
+
return buf[i2];
|
|
780
|
+
} else {
|
|
781
|
+
return buf.readUInt16BE(i2 * indexSize);
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
let i;
|
|
785
|
+
if (dir) {
|
|
786
|
+
let foundIndex = -1;
|
|
787
|
+
for (i = byteOffset; i < arrLength; i++) {
|
|
788
|
+
if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
|
|
789
|
+
if (foundIndex === -1) foundIndex = i;
|
|
790
|
+
if (i - foundIndex + 1 === valLength) return foundIndex * indexSize;
|
|
791
|
+
} else {
|
|
792
|
+
if (foundIndex !== -1) i -= i - foundIndex;
|
|
793
|
+
foundIndex = -1;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
} else {
|
|
797
|
+
if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
|
|
798
|
+
for (i = byteOffset; i >= 0; i--) {
|
|
799
|
+
let found = true;
|
|
800
|
+
for (let j = 0; j < valLength; j++) {
|
|
801
|
+
if (read(arr, i + j) !== read(val, j)) {
|
|
802
|
+
found = false;
|
|
803
|
+
break;
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
if (found) return i;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
return -1;
|
|
810
|
+
}
|
|
811
|
+
Buffer4.prototype.includes = function includes(val, byteOffset, encoding) {
|
|
812
|
+
return this.indexOf(val, byteOffset, encoding) !== -1;
|
|
813
|
+
};
|
|
814
|
+
Buffer4.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
|
|
815
|
+
return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
|
|
816
|
+
};
|
|
817
|
+
Buffer4.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
|
|
818
|
+
return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
|
|
819
|
+
};
|
|
820
|
+
function hexWrite(buf, string, offset, length) {
|
|
821
|
+
offset = Number(offset) || 0;
|
|
822
|
+
const remaining = buf.length - offset;
|
|
823
|
+
if (!length) {
|
|
824
|
+
length = remaining;
|
|
825
|
+
} else {
|
|
826
|
+
length = Number(length);
|
|
827
|
+
if (length > remaining) {
|
|
828
|
+
length = remaining;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
const strLen = string.length;
|
|
832
|
+
if (length > strLen / 2) {
|
|
833
|
+
length = strLen / 2;
|
|
834
|
+
}
|
|
835
|
+
let i;
|
|
836
|
+
for (i = 0; i < length; ++i) {
|
|
837
|
+
const parsed = parseInt(string.substr(i * 2, 2), 16);
|
|
838
|
+
if (numberIsNaN(parsed)) return i;
|
|
839
|
+
buf[offset + i] = parsed;
|
|
840
|
+
}
|
|
841
|
+
return i;
|
|
842
|
+
}
|
|
843
|
+
function utf8Write(buf, string, offset, length) {
|
|
844
|
+
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
|
|
845
|
+
}
|
|
846
|
+
function asciiWrite(buf, string, offset, length) {
|
|
847
|
+
return blitBuffer(asciiToBytes(string), buf, offset, length);
|
|
848
|
+
}
|
|
849
|
+
function base64Write(buf, string, offset, length) {
|
|
850
|
+
return blitBuffer(base64ToBytes(string), buf, offset, length);
|
|
851
|
+
}
|
|
852
|
+
function ucs2Write(buf, string, offset, length) {
|
|
853
|
+
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
|
|
854
|
+
}
|
|
855
|
+
Buffer4.prototype.write = function write(string, offset, length, encoding) {
|
|
856
|
+
if (offset === void 0) {
|
|
857
|
+
encoding = "utf8";
|
|
858
|
+
length = this.length;
|
|
859
|
+
offset = 0;
|
|
860
|
+
} else if (length === void 0 && typeof offset === "string") {
|
|
861
|
+
encoding = offset;
|
|
862
|
+
length = this.length;
|
|
863
|
+
offset = 0;
|
|
864
|
+
} else if (isFinite(offset)) {
|
|
865
|
+
offset = offset >>> 0;
|
|
866
|
+
if (isFinite(length)) {
|
|
867
|
+
length = length >>> 0;
|
|
868
|
+
if (encoding === void 0) encoding = "utf8";
|
|
869
|
+
} else {
|
|
870
|
+
encoding = length;
|
|
871
|
+
length = void 0;
|
|
872
|
+
}
|
|
873
|
+
} else {
|
|
874
|
+
throw new Error(
|
|
875
|
+
"Buffer.write(string, encoding, offset[, length]) is no longer supported"
|
|
876
|
+
);
|
|
877
|
+
}
|
|
878
|
+
const remaining = this.length - offset;
|
|
879
|
+
if (length === void 0 || length > remaining) length = remaining;
|
|
880
|
+
if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) {
|
|
881
|
+
throw new RangeError("Attempt to write outside buffer bounds");
|
|
882
|
+
}
|
|
883
|
+
if (!encoding) encoding = "utf8";
|
|
884
|
+
let loweredCase = false;
|
|
885
|
+
for (; ; ) {
|
|
886
|
+
switch (encoding) {
|
|
887
|
+
case "hex":
|
|
888
|
+
return hexWrite(this, string, offset, length);
|
|
889
|
+
case "utf8":
|
|
890
|
+
case "utf-8":
|
|
891
|
+
return utf8Write(this, string, offset, length);
|
|
892
|
+
case "ascii":
|
|
893
|
+
case "latin1":
|
|
894
|
+
case "binary":
|
|
895
|
+
return asciiWrite(this, string, offset, length);
|
|
896
|
+
case "base64":
|
|
897
|
+
return base64Write(this, string, offset, length);
|
|
898
|
+
case "ucs2":
|
|
899
|
+
case "ucs-2":
|
|
900
|
+
case "utf16le":
|
|
901
|
+
case "utf-16le":
|
|
902
|
+
return ucs2Write(this, string, offset, length);
|
|
903
|
+
default:
|
|
904
|
+
if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
|
|
905
|
+
encoding = ("" + encoding).toLowerCase();
|
|
906
|
+
loweredCase = true;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
};
|
|
910
|
+
Buffer4.prototype.toJSON = function toJSON() {
|
|
911
|
+
return {
|
|
912
|
+
type: "Buffer",
|
|
913
|
+
data: Array.prototype.slice.call(this._arr || this, 0)
|
|
914
|
+
};
|
|
915
|
+
};
|
|
916
|
+
function base64Slice(buf, start, end) {
|
|
917
|
+
if (start === 0 && end === buf.length) {
|
|
918
|
+
return base64.fromByteArray(buf);
|
|
919
|
+
} else {
|
|
920
|
+
return base64.fromByteArray(buf.slice(start, end));
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
function utf8Slice(buf, start, end) {
|
|
924
|
+
end = Math.min(buf.length, end);
|
|
925
|
+
const res = [];
|
|
926
|
+
let i = start;
|
|
927
|
+
while (i < end) {
|
|
928
|
+
const firstByte = buf[i];
|
|
929
|
+
let codePoint = null;
|
|
930
|
+
let bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
|
|
931
|
+
if (i + bytesPerSequence <= end) {
|
|
932
|
+
let secondByte, thirdByte, fourthByte, tempCodePoint;
|
|
933
|
+
switch (bytesPerSequence) {
|
|
934
|
+
case 1:
|
|
935
|
+
if (firstByte < 128) {
|
|
936
|
+
codePoint = firstByte;
|
|
937
|
+
}
|
|
938
|
+
break;
|
|
939
|
+
case 2:
|
|
940
|
+
secondByte = buf[i + 1];
|
|
941
|
+
if ((secondByte & 192) === 128) {
|
|
942
|
+
tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
|
|
943
|
+
if (tempCodePoint > 127) {
|
|
944
|
+
codePoint = tempCodePoint;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
break;
|
|
948
|
+
case 3:
|
|
949
|
+
secondByte = buf[i + 1];
|
|
950
|
+
thirdByte = buf[i + 2];
|
|
951
|
+
if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
|
|
952
|
+
tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
|
|
953
|
+
if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) {
|
|
954
|
+
codePoint = tempCodePoint;
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
break;
|
|
958
|
+
case 4:
|
|
959
|
+
secondByte = buf[i + 1];
|
|
960
|
+
thirdByte = buf[i + 2];
|
|
961
|
+
fourthByte = buf[i + 3];
|
|
962
|
+
if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
|
|
963
|
+
tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
|
|
964
|
+
if (tempCodePoint > 65535 && tempCodePoint < 1114112) {
|
|
965
|
+
codePoint = tempCodePoint;
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
if (codePoint === null) {
|
|
971
|
+
codePoint = 65533;
|
|
972
|
+
bytesPerSequence = 1;
|
|
973
|
+
} else if (codePoint > 65535) {
|
|
974
|
+
codePoint -= 65536;
|
|
975
|
+
res.push(codePoint >>> 10 & 1023 | 55296);
|
|
976
|
+
codePoint = 56320 | codePoint & 1023;
|
|
977
|
+
}
|
|
978
|
+
res.push(codePoint);
|
|
979
|
+
i += bytesPerSequence;
|
|
980
|
+
}
|
|
981
|
+
return decodeCodePointsArray(res);
|
|
982
|
+
}
|
|
983
|
+
var MAX_ARGUMENTS_LENGTH = 4096;
|
|
984
|
+
function decodeCodePointsArray(codePoints) {
|
|
985
|
+
const len = codePoints.length;
|
|
986
|
+
if (len <= MAX_ARGUMENTS_LENGTH) {
|
|
987
|
+
return String.fromCharCode.apply(String, codePoints);
|
|
988
|
+
}
|
|
989
|
+
let res = "";
|
|
990
|
+
let i = 0;
|
|
991
|
+
while (i < len) {
|
|
992
|
+
res += String.fromCharCode.apply(
|
|
993
|
+
String,
|
|
994
|
+
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
|
|
995
|
+
);
|
|
996
|
+
}
|
|
997
|
+
return res;
|
|
998
|
+
}
|
|
999
|
+
function asciiSlice(buf, start, end) {
|
|
1000
|
+
let ret = "";
|
|
1001
|
+
end = Math.min(buf.length, end);
|
|
1002
|
+
for (let i = start; i < end; ++i) {
|
|
1003
|
+
ret += String.fromCharCode(buf[i] & 127);
|
|
1004
|
+
}
|
|
1005
|
+
return ret;
|
|
1006
|
+
}
|
|
1007
|
+
function latin1Slice(buf, start, end) {
|
|
1008
|
+
let ret = "";
|
|
1009
|
+
end = Math.min(buf.length, end);
|
|
1010
|
+
for (let i = start; i < end; ++i) {
|
|
1011
|
+
ret += String.fromCharCode(buf[i]);
|
|
1012
|
+
}
|
|
1013
|
+
return ret;
|
|
1014
|
+
}
|
|
1015
|
+
function hexSlice(buf, start, end) {
|
|
1016
|
+
const len = buf.length;
|
|
1017
|
+
if (!start || start < 0) start = 0;
|
|
1018
|
+
if (!end || end < 0 || end > len) end = len;
|
|
1019
|
+
let out = "";
|
|
1020
|
+
for (let i = start; i < end; ++i) {
|
|
1021
|
+
out += hexSliceLookupTable[buf[i]];
|
|
1022
|
+
}
|
|
1023
|
+
return out;
|
|
1024
|
+
}
|
|
1025
|
+
function utf16leSlice(buf, start, end) {
|
|
1026
|
+
const bytes = buf.slice(start, end);
|
|
1027
|
+
let res = "";
|
|
1028
|
+
for (let i = 0; i < bytes.length - 1; i += 2) {
|
|
1029
|
+
res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
|
|
1030
|
+
}
|
|
1031
|
+
return res;
|
|
1032
|
+
}
|
|
1033
|
+
Buffer4.prototype.slice = function slice(start, end) {
|
|
1034
|
+
const len = this.length;
|
|
1035
|
+
start = ~~start;
|
|
1036
|
+
end = end === void 0 ? len : ~~end;
|
|
1037
|
+
if (start < 0) {
|
|
1038
|
+
start += len;
|
|
1039
|
+
if (start < 0) start = 0;
|
|
1040
|
+
} else if (start > len) {
|
|
1041
|
+
start = len;
|
|
1042
|
+
}
|
|
1043
|
+
if (end < 0) {
|
|
1044
|
+
end += len;
|
|
1045
|
+
if (end < 0) end = 0;
|
|
1046
|
+
} else if (end > len) {
|
|
1047
|
+
end = len;
|
|
1048
|
+
}
|
|
1049
|
+
if (end < start) end = start;
|
|
1050
|
+
const newBuf = this.subarray(start, end);
|
|
1051
|
+
Object.setPrototypeOf(newBuf, Buffer4.prototype);
|
|
1052
|
+
return newBuf;
|
|
1053
|
+
};
|
|
1054
|
+
function checkOffset(offset, ext, length) {
|
|
1055
|
+
if (offset % 1 !== 0 || offset < 0) throw new RangeError("offset is not uint");
|
|
1056
|
+
if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length");
|
|
1057
|
+
}
|
|
1058
|
+
Buffer4.prototype.readUintLE = Buffer4.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) {
|
|
1059
|
+
offset = offset >>> 0;
|
|
1060
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1061
|
+
if (!noAssert) checkOffset(offset, byteLength2, this.length);
|
|
1062
|
+
let val = this[offset];
|
|
1063
|
+
let mul = 1;
|
|
1064
|
+
let i = 0;
|
|
1065
|
+
while (++i < byteLength2 && (mul *= 256)) {
|
|
1066
|
+
val += this[offset + i] * mul;
|
|
1067
|
+
}
|
|
1068
|
+
return val;
|
|
1069
|
+
};
|
|
1070
|
+
Buffer4.prototype.readUintBE = Buffer4.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) {
|
|
1071
|
+
offset = offset >>> 0;
|
|
1072
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1073
|
+
if (!noAssert) {
|
|
1074
|
+
checkOffset(offset, byteLength2, this.length);
|
|
1075
|
+
}
|
|
1076
|
+
let val = this[offset + --byteLength2];
|
|
1077
|
+
let mul = 1;
|
|
1078
|
+
while (byteLength2 > 0 && (mul *= 256)) {
|
|
1079
|
+
val += this[offset + --byteLength2] * mul;
|
|
1080
|
+
}
|
|
1081
|
+
return val;
|
|
1082
|
+
};
|
|
1083
|
+
Buffer4.prototype.readUint8 = Buffer4.prototype.readUInt8 = function readUInt8(offset, noAssert) {
|
|
1084
|
+
offset = offset >>> 0;
|
|
1085
|
+
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
1086
|
+
return this[offset];
|
|
1087
|
+
};
|
|
1088
|
+
Buffer4.prototype.readUint16LE = Buffer4.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
|
|
1089
|
+
offset = offset >>> 0;
|
|
1090
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1091
|
+
return this[offset] | this[offset + 1] << 8;
|
|
1092
|
+
};
|
|
1093
|
+
Buffer4.prototype.readUint16BE = Buffer4.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
|
|
1094
|
+
offset = offset >>> 0;
|
|
1095
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1096
|
+
return this[offset] << 8 | this[offset + 1];
|
|
1097
|
+
};
|
|
1098
|
+
Buffer4.prototype.readUint32LE = Buffer4.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
|
|
1099
|
+
offset = offset >>> 0;
|
|
1100
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1101
|
+
return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
|
|
1102
|
+
};
|
|
1103
|
+
Buffer4.prototype.readUint32BE = Buffer4.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
|
|
1104
|
+
offset = offset >>> 0;
|
|
1105
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1106
|
+
return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
|
|
1107
|
+
};
|
|
1108
|
+
Buffer4.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE(offset) {
|
|
1109
|
+
offset = offset >>> 0;
|
|
1110
|
+
validateNumber(offset, "offset");
|
|
1111
|
+
const first = this[offset];
|
|
1112
|
+
const last = this[offset + 7];
|
|
1113
|
+
if (first === void 0 || last === void 0) {
|
|
1114
|
+
boundsError(offset, this.length - 8);
|
|
1115
|
+
}
|
|
1116
|
+
const lo = first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24;
|
|
1117
|
+
const hi = this[++offset] + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + last * 2 ** 24;
|
|
1118
|
+
return BigInt(lo) + (BigInt(hi) << BigInt(32));
|
|
1119
|
+
});
|
|
1120
|
+
Buffer4.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE(offset) {
|
|
1121
|
+
offset = offset >>> 0;
|
|
1122
|
+
validateNumber(offset, "offset");
|
|
1123
|
+
const first = this[offset];
|
|
1124
|
+
const last = this[offset + 7];
|
|
1125
|
+
if (first === void 0 || last === void 0) {
|
|
1126
|
+
boundsError(offset, this.length - 8);
|
|
1127
|
+
}
|
|
1128
|
+
const hi = first * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
|
|
1129
|
+
const lo = this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last;
|
|
1130
|
+
return (BigInt(hi) << BigInt(32)) + BigInt(lo);
|
|
1131
|
+
});
|
|
1132
|
+
Buffer4.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) {
|
|
1133
|
+
offset = offset >>> 0;
|
|
1134
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1135
|
+
if (!noAssert) checkOffset(offset, byteLength2, this.length);
|
|
1136
|
+
let val = this[offset];
|
|
1137
|
+
let mul = 1;
|
|
1138
|
+
let i = 0;
|
|
1139
|
+
while (++i < byteLength2 && (mul *= 256)) {
|
|
1140
|
+
val += this[offset + i] * mul;
|
|
1141
|
+
}
|
|
1142
|
+
mul *= 128;
|
|
1143
|
+
if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
|
|
1144
|
+
return val;
|
|
1145
|
+
};
|
|
1146
|
+
Buffer4.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) {
|
|
1147
|
+
offset = offset >>> 0;
|
|
1148
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1149
|
+
if (!noAssert) checkOffset(offset, byteLength2, this.length);
|
|
1150
|
+
let i = byteLength2;
|
|
1151
|
+
let mul = 1;
|
|
1152
|
+
let val = this[offset + --i];
|
|
1153
|
+
while (i > 0 && (mul *= 256)) {
|
|
1154
|
+
val += this[offset + --i] * mul;
|
|
1155
|
+
}
|
|
1156
|
+
mul *= 128;
|
|
1157
|
+
if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
|
|
1158
|
+
return val;
|
|
1159
|
+
};
|
|
1160
|
+
Buffer4.prototype.readInt8 = function readInt8(offset, noAssert) {
|
|
1161
|
+
offset = offset >>> 0;
|
|
1162
|
+
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
1163
|
+
if (!(this[offset] & 128)) return this[offset];
|
|
1164
|
+
return (255 - this[offset] + 1) * -1;
|
|
1165
|
+
};
|
|
1166
|
+
Buffer4.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
|
|
1167
|
+
offset = offset >>> 0;
|
|
1168
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1169
|
+
const val = this[offset] | this[offset + 1] << 8;
|
|
1170
|
+
return val & 32768 ? val | 4294901760 : val;
|
|
1171
|
+
};
|
|
1172
|
+
Buffer4.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
|
|
1173
|
+
offset = offset >>> 0;
|
|
1174
|
+
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1175
|
+
const val = this[offset + 1] | this[offset] << 8;
|
|
1176
|
+
return val & 32768 ? val | 4294901760 : val;
|
|
1177
|
+
};
|
|
1178
|
+
Buffer4.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
|
|
1179
|
+
offset = offset >>> 0;
|
|
1180
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1181
|
+
return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
|
|
1182
|
+
};
|
|
1183
|
+
Buffer4.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
|
|
1184
|
+
offset = offset >>> 0;
|
|
1185
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1186
|
+
return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
|
|
1187
|
+
};
|
|
1188
|
+
Buffer4.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE(offset) {
|
|
1189
|
+
offset = offset >>> 0;
|
|
1190
|
+
validateNumber(offset, "offset");
|
|
1191
|
+
const first = this[offset];
|
|
1192
|
+
const last = this[offset + 7];
|
|
1193
|
+
if (first === void 0 || last === void 0) {
|
|
1194
|
+
boundsError(offset, this.length - 8);
|
|
1195
|
+
}
|
|
1196
|
+
const val = this[offset + 4] + this[offset + 5] * 2 ** 8 + this[offset + 6] * 2 ** 16 + (last << 24);
|
|
1197
|
+
return (BigInt(val) << BigInt(32)) + BigInt(first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24);
|
|
1198
|
+
});
|
|
1199
|
+
Buffer4.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE(offset) {
|
|
1200
|
+
offset = offset >>> 0;
|
|
1201
|
+
validateNumber(offset, "offset");
|
|
1202
|
+
const first = this[offset];
|
|
1203
|
+
const last = this[offset + 7];
|
|
1204
|
+
if (first === void 0 || last === void 0) {
|
|
1205
|
+
boundsError(offset, this.length - 8);
|
|
1206
|
+
}
|
|
1207
|
+
const val = (first << 24) + // Overflow
|
|
1208
|
+
this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
|
|
1209
|
+
return (BigInt(val) << BigInt(32)) + BigInt(this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last);
|
|
1210
|
+
});
|
|
1211
|
+
Buffer4.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
|
|
1212
|
+
offset = offset >>> 0;
|
|
1213
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1214
|
+
return ieee754.read(this, offset, true, 23, 4);
|
|
1215
|
+
};
|
|
1216
|
+
Buffer4.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
|
|
1217
|
+
offset = offset >>> 0;
|
|
1218
|
+
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1219
|
+
return ieee754.read(this, offset, false, 23, 4);
|
|
1220
|
+
};
|
|
1221
|
+
Buffer4.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
|
|
1222
|
+
offset = offset >>> 0;
|
|
1223
|
+
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
1224
|
+
return ieee754.read(this, offset, true, 52, 8);
|
|
1225
|
+
};
|
|
1226
|
+
Buffer4.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
|
|
1227
|
+
offset = offset >>> 0;
|
|
1228
|
+
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
1229
|
+
return ieee754.read(this, offset, false, 52, 8);
|
|
1230
|
+
};
|
|
1231
|
+
function checkInt(buf, value, offset, ext, max, min) {
|
|
1232
|
+
if (!Buffer4.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance');
|
|
1233
|
+
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds');
|
|
1234
|
+
if (offset + ext > buf.length) throw new RangeError("Index out of range");
|
|
1235
|
+
}
|
|
1236
|
+
Buffer4.prototype.writeUintLE = Buffer4.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) {
|
|
1237
|
+
value = +value;
|
|
1238
|
+
offset = offset >>> 0;
|
|
1239
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1240
|
+
if (!noAssert) {
|
|
1241
|
+
const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
|
|
1242
|
+
checkInt(this, value, offset, byteLength2, maxBytes, 0);
|
|
1243
|
+
}
|
|
1244
|
+
let mul = 1;
|
|
1245
|
+
let i = 0;
|
|
1246
|
+
this[offset] = value & 255;
|
|
1247
|
+
while (++i < byteLength2 && (mul *= 256)) {
|
|
1248
|
+
this[offset + i] = value / mul & 255;
|
|
1249
|
+
}
|
|
1250
|
+
return offset + byteLength2;
|
|
1251
|
+
};
|
|
1252
|
+
Buffer4.prototype.writeUintBE = Buffer4.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) {
|
|
1253
|
+
value = +value;
|
|
1254
|
+
offset = offset >>> 0;
|
|
1255
|
+
byteLength2 = byteLength2 >>> 0;
|
|
1256
|
+
if (!noAssert) {
|
|
1257
|
+
const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
|
|
1258
|
+
checkInt(this, value, offset, byteLength2, maxBytes, 0);
|
|
1259
|
+
}
|
|
1260
|
+
let i = byteLength2 - 1;
|
|
1261
|
+
let mul = 1;
|
|
1262
|
+
this[offset + i] = value & 255;
|
|
1263
|
+
while (--i >= 0 && (mul *= 256)) {
|
|
1264
|
+
this[offset + i] = value / mul & 255;
|
|
1265
|
+
}
|
|
1266
|
+
return offset + byteLength2;
|
|
1267
|
+
};
|
|
1268
|
+
Buffer4.prototype.writeUint8 = Buffer4.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
|
|
1269
|
+
value = +value;
|
|
1270
|
+
offset = offset >>> 0;
|
|
1271
|
+
if (!noAssert) checkInt(this, value, offset, 1, 255, 0);
|
|
1272
|
+
this[offset] = value & 255;
|
|
1273
|
+
return offset + 1;
|
|
1274
|
+
};
|
|
1275
|
+
Buffer4.prototype.writeUint16LE = Buffer4.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
|
|
1276
|
+
value = +value;
|
|
1277
|
+
offset = offset >>> 0;
|
|
1278
|
+
if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
|
|
1279
|
+
this[offset] = value & 255;
|
|
1280
|
+
this[offset + 1] = value >>> 8;
|
|
1281
|
+
return offset + 2;
|
|
1282
|
+
};
|
|
1283
|
+
Buffer4.prototype.writeUint16BE = Buffer4.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
|
|
1284
|
+
value = +value;
|
|
1285
|
+
offset = offset >>> 0;
|
|
1286
|
+
if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
|
|
1287
|
+
this[offset] = value >>> 8;
|
|
1288
|
+
this[offset + 1] = value & 255;
|
|
1289
|
+
return offset + 2;
|
|
1290
|
+
};
|
|
1291
|
+
Buffer4.prototype.writeUint32LE = Buffer4.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
|
|
1292
|
+
value = +value;
|
|
1293
|
+
offset = offset >>> 0;
|
|
1294
|
+
if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
|
|
1295
|
+
this[offset + 3] = value >>> 24;
|
|
1296
|
+
this[offset + 2] = value >>> 16;
|
|
1297
|
+
this[offset + 1] = value >>> 8;
|
|
1298
|
+
this[offset] = value & 255;
|
|
1299
|
+
return offset + 4;
|
|
1300
|
+
};
|
|
1301
|
+
Buffer4.prototype.writeUint32BE = Buffer4.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
|
|
1302
|
+
value = +value;
|
|
1303
|
+
offset = offset >>> 0;
|
|
1304
|
+
if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
|
|
1305
|
+
this[offset] = value >>> 24;
|
|
1306
|
+
this[offset + 1] = value >>> 16;
|
|
1307
|
+
this[offset + 2] = value >>> 8;
|
|
1308
|
+
this[offset + 3] = value & 255;
|
|
1309
|
+
return offset + 4;
|
|
1310
|
+
};
|
|
1311
|
+
function wrtBigUInt64LE(buf, value, offset, min, max) {
|
|
1312
|
+
checkIntBI(value, min, max, buf, offset, 7);
|
|
1313
|
+
let lo = Number(value & BigInt(4294967295));
|
|
1314
|
+
buf[offset++] = lo;
|
|
1315
|
+
lo = lo >> 8;
|
|
1316
|
+
buf[offset++] = lo;
|
|
1317
|
+
lo = lo >> 8;
|
|
1318
|
+
buf[offset++] = lo;
|
|
1319
|
+
lo = lo >> 8;
|
|
1320
|
+
buf[offset++] = lo;
|
|
1321
|
+
let hi = Number(value >> BigInt(32) & BigInt(4294967295));
|
|
1322
|
+
buf[offset++] = hi;
|
|
1323
|
+
hi = hi >> 8;
|
|
1324
|
+
buf[offset++] = hi;
|
|
1325
|
+
hi = hi >> 8;
|
|
1326
|
+
buf[offset++] = hi;
|
|
1327
|
+
hi = hi >> 8;
|
|
1328
|
+
buf[offset++] = hi;
|
|
1329
|
+
return offset;
|
|
1330
|
+
}
|
|
1331
|
+
function wrtBigUInt64BE(buf, value, offset, min, max) {
|
|
1332
|
+
checkIntBI(value, min, max, buf, offset, 7);
|
|
1333
|
+
let lo = Number(value & BigInt(4294967295));
|
|
1334
|
+
buf[offset + 7] = lo;
|
|
1335
|
+
lo = lo >> 8;
|
|
1336
|
+
buf[offset + 6] = lo;
|
|
1337
|
+
lo = lo >> 8;
|
|
1338
|
+
buf[offset + 5] = lo;
|
|
1339
|
+
lo = lo >> 8;
|
|
1340
|
+
buf[offset + 4] = lo;
|
|
1341
|
+
let hi = Number(value >> BigInt(32) & BigInt(4294967295));
|
|
1342
|
+
buf[offset + 3] = hi;
|
|
1343
|
+
hi = hi >> 8;
|
|
1344
|
+
buf[offset + 2] = hi;
|
|
1345
|
+
hi = hi >> 8;
|
|
1346
|
+
buf[offset + 1] = hi;
|
|
1347
|
+
hi = hi >> 8;
|
|
1348
|
+
buf[offset] = hi;
|
|
1349
|
+
return offset + 8;
|
|
1350
|
+
}
|
|
1351
|
+
Buffer4.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) {
|
|
1352
|
+
return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
|
|
1353
|
+
});
|
|
1354
|
+
Buffer4.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) {
|
|
1355
|
+
return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
|
|
1356
|
+
});
|
|
1357
|
+
Buffer4.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) {
|
|
1358
|
+
value = +value;
|
|
1359
|
+
offset = offset >>> 0;
|
|
1360
|
+
if (!noAssert) {
|
|
1361
|
+
const limit = Math.pow(2, 8 * byteLength2 - 1);
|
|
1362
|
+
checkInt(this, value, offset, byteLength2, limit - 1, -limit);
|
|
1363
|
+
}
|
|
1364
|
+
let i = 0;
|
|
1365
|
+
let mul = 1;
|
|
1366
|
+
let sub = 0;
|
|
1367
|
+
this[offset] = value & 255;
|
|
1368
|
+
while (++i < byteLength2 && (mul *= 256)) {
|
|
1369
|
+
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
|
|
1370
|
+
sub = 1;
|
|
1371
|
+
}
|
|
1372
|
+
this[offset + i] = (value / mul >> 0) - sub & 255;
|
|
1373
|
+
}
|
|
1374
|
+
return offset + byteLength2;
|
|
1375
|
+
};
|
|
1376
|
+
Buffer4.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) {
|
|
1377
|
+
value = +value;
|
|
1378
|
+
offset = offset >>> 0;
|
|
1379
|
+
if (!noAssert) {
|
|
1380
|
+
const limit = Math.pow(2, 8 * byteLength2 - 1);
|
|
1381
|
+
checkInt(this, value, offset, byteLength2, limit - 1, -limit);
|
|
1382
|
+
}
|
|
1383
|
+
let i = byteLength2 - 1;
|
|
1384
|
+
let mul = 1;
|
|
1385
|
+
let sub = 0;
|
|
1386
|
+
this[offset + i] = value & 255;
|
|
1387
|
+
while (--i >= 0 && (mul *= 256)) {
|
|
1388
|
+
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
|
|
1389
|
+
sub = 1;
|
|
1390
|
+
}
|
|
1391
|
+
this[offset + i] = (value / mul >> 0) - sub & 255;
|
|
1392
|
+
}
|
|
1393
|
+
return offset + byteLength2;
|
|
1394
|
+
};
|
|
1395
|
+
Buffer4.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
|
|
1396
|
+
value = +value;
|
|
1397
|
+
offset = offset >>> 0;
|
|
1398
|
+
if (!noAssert) checkInt(this, value, offset, 1, 127, -128);
|
|
1399
|
+
if (value < 0) value = 255 + value + 1;
|
|
1400
|
+
this[offset] = value & 255;
|
|
1401
|
+
return offset + 1;
|
|
1402
|
+
};
|
|
1403
|
+
Buffer4.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
|
|
1404
|
+
value = +value;
|
|
1405
|
+
offset = offset >>> 0;
|
|
1406
|
+
if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
|
|
1407
|
+
this[offset] = value & 255;
|
|
1408
|
+
this[offset + 1] = value >>> 8;
|
|
1409
|
+
return offset + 2;
|
|
1410
|
+
};
|
|
1411
|
+
Buffer4.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
|
|
1412
|
+
value = +value;
|
|
1413
|
+
offset = offset >>> 0;
|
|
1414
|
+
if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
|
|
1415
|
+
this[offset] = value >>> 8;
|
|
1416
|
+
this[offset + 1] = value & 255;
|
|
1417
|
+
return offset + 2;
|
|
1418
|
+
};
|
|
1419
|
+
Buffer4.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
|
|
1420
|
+
value = +value;
|
|
1421
|
+
offset = offset >>> 0;
|
|
1422
|
+
if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
|
|
1423
|
+
this[offset] = value & 255;
|
|
1424
|
+
this[offset + 1] = value >>> 8;
|
|
1425
|
+
this[offset + 2] = value >>> 16;
|
|
1426
|
+
this[offset + 3] = value >>> 24;
|
|
1427
|
+
return offset + 4;
|
|
1428
|
+
};
|
|
1429
|
+
Buffer4.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
|
|
1430
|
+
value = +value;
|
|
1431
|
+
offset = offset >>> 0;
|
|
1432
|
+
if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
|
|
1433
|
+
if (value < 0) value = 4294967295 + value + 1;
|
|
1434
|
+
this[offset] = value >>> 24;
|
|
1435
|
+
this[offset + 1] = value >>> 16;
|
|
1436
|
+
this[offset + 2] = value >>> 8;
|
|
1437
|
+
this[offset + 3] = value & 255;
|
|
1438
|
+
return offset + 4;
|
|
1439
|
+
};
|
|
1440
|
+
Buffer4.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) {
|
|
1441
|
+
return wrtBigUInt64LE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
|
|
1442
|
+
});
|
|
1443
|
+
Buffer4.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset = 0) {
|
|
1444
|
+
return wrtBigUInt64BE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
|
|
1445
|
+
});
|
|
1446
|
+
function checkIEEE754(buf, value, offset, ext, max, min) {
|
|
1447
|
+
if (offset + ext > buf.length) throw new RangeError("Index out of range");
|
|
1448
|
+
if (offset < 0) throw new RangeError("Index out of range");
|
|
1449
|
+
}
|
|
1450
|
+
function writeFloat(buf, value, offset, littleEndian, noAssert) {
|
|
1451
|
+
value = +value;
|
|
1452
|
+
offset = offset >>> 0;
|
|
1453
|
+
if (!noAssert) {
|
|
1454
|
+
checkIEEE754(buf, value, offset, 4, 34028234663852886e22, -34028234663852886e22);
|
|
1455
|
+
}
|
|
1456
|
+
ieee754.write(buf, value, offset, littleEndian, 23, 4);
|
|
1457
|
+
return offset + 4;
|
|
1458
|
+
}
|
|
1459
|
+
Buffer4.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
|
|
1460
|
+
return writeFloat(this, value, offset, true, noAssert);
|
|
1461
|
+
};
|
|
1462
|
+
Buffer4.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
|
|
1463
|
+
return writeFloat(this, value, offset, false, noAssert);
|
|
1464
|
+
};
|
|
1465
|
+
function writeDouble(buf, value, offset, littleEndian, noAssert) {
|
|
1466
|
+
value = +value;
|
|
1467
|
+
offset = offset >>> 0;
|
|
1468
|
+
if (!noAssert) {
|
|
1469
|
+
checkIEEE754(buf, value, offset, 8, 17976931348623157e292, -17976931348623157e292);
|
|
1470
|
+
}
|
|
1471
|
+
ieee754.write(buf, value, offset, littleEndian, 52, 8);
|
|
1472
|
+
return offset + 8;
|
|
1473
|
+
}
|
|
1474
|
+
Buffer4.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
|
|
1475
|
+
return writeDouble(this, value, offset, true, noAssert);
|
|
1476
|
+
};
|
|
1477
|
+
Buffer4.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
|
|
1478
|
+
return writeDouble(this, value, offset, false, noAssert);
|
|
1479
|
+
};
|
|
1480
|
+
Buffer4.prototype.copy = function copy(target, targetStart, start, end) {
|
|
1481
|
+
if (!Buffer4.isBuffer(target)) throw new TypeError("argument should be a Buffer");
|
|
1482
|
+
if (!start) start = 0;
|
|
1483
|
+
if (!end && end !== 0) end = this.length;
|
|
1484
|
+
if (targetStart >= target.length) targetStart = target.length;
|
|
1485
|
+
if (!targetStart) targetStart = 0;
|
|
1486
|
+
if (end > 0 && end < start) end = start;
|
|
1487
|
+
if (end === start) return 0;
|
|
1488
|
+
if (target.length === 0 || this.length === 0) return 0;
|
|
1489
|
+
if (targetStart < 0) {
|
|
1490
|
+
throw new RangeError("targetStart out of bounds");
|
|
1491
|
+
}
|
|
1492
|
+
if (start < 0 || start >= this.length) throw new RangeError("Index out of range");
|
|
1493
|
+
if (end < 0) throw new RangeError("sourceEnd out of bounds");
|
|
1494
|
+
if (end > this.length) end = this.length;
|
|
1495
|
+
if (target.length - targetStart < end - start) {
|
|
1496
|
+
end = target.length - targetStart + start;
|
|
1497
|
+
}
|
|
1498
|
+
const len = end - start;
|
|
1499
|
+
if (this === target && typeof Uint8Array.prototype.copyWithin === "function") {
|
|
1500
|
+
this.copyWithin(targetStart, start, end);
|
|
1501
|
+
} else {
|
|
1502
|
+
Uint8Array.prototype.set.call(
|
|
1503
|
+
target,
|
|
1504
|
+
this.subarray(start, end),
|
|
1505
|
+
targetStart
|
|
1506
|
+
);
|
|
1507
|
+
}
|
|
1508
|
+
return len;
|
|
1509
|
+
};
|
|
1510
|
+
Buffer4.prototype.fill = function fill(val, start, end, encoding) {
|
|
1511
|
+
if (typeof val === "string") {
|
|
1512
|
+
if (typeof start === "string") {
|
|
1513
|
+
encoding = start;
|
|
1514
|
+
start = 0;
|
|
1515
|
+
end = this.length;
|
|
1516
|
+
} else if (typeof end === "string") {
|
|
1517
|
+
encoding = end;
|
|
1518
|
+
end = this.length;
|
|
1519
|
+
}
|
|
1520
|
+
if (encoding !== void 0 && typeof encoding !== "string") {
|
|
1521
|
+
throw new TypeError("encoding must be a string");
|
|
1522
|
+
}
|
|
1523
|
+
if (typeof encoding === "string" && !Buffer4.isEncoding(encoding)) {
|
|
1524
|
+
throw new TypeError("Unknown encoding: " + encoding);
|
|
1525
|
+
}
|
|
1526
|
+
if (val.length === 1) {
|
|
1527
|
+
const code = val.charCodeAt(0);
|
|
1528
|
+
if (encoding === "utf8" && code < 128 || encoding === "latin1") {
|
|
1529
|
+
val = code;
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
} else if (typeof val === "number") {
|
|
1533
|
+
val = val & 255;
|
|
1534
|
+
} else if (typeof val === "boolean") {
|
|
1535
|
+
val = Number(val);
|
|
1536
|
+
}
|
|
1537
|
+
if (start < 0 || this.length < start || this.length < end) {
|
|
1538
|
+
throw new RangeError("Out of range index");
|
|
1539
|
+
}
|
|
1540
|
+
if (end <= start) {
|
|
1541
|
+
return this;
|
|
1542
|
+
}
|
|
1543
|
+
start = start >>> 0;
|
|
1544
|
+
end = end === void 0 ? this.length : end >>> 0;
|
|
1545
|
+
if (!val) val = 0;
|
|
1546
|
+
let i;
|
|
1547
|
+
if (typeof val === "number") {
|
|
1548
|
+
for (i = start; i < end; ++i) {
|
|
1549
|
+
this[i] = val;
|
|
1550
|
+
}
|
|
1551
|
+
} else {
|
|
1552
|
+
const bytes = Buffer4.isBuffer(val) ? val : Buffer4.from(val, encoding);
|
|
1553
|
+
const len = bytes.length;
|
|
1554
|
+
if (len === 0) {
|
|
1555
|
+
throw new TypeError('The value "' + val + '" is invalid for argument "value"');
|
|
1556
|
+
}
|
|
1557
|
+
for (i = 0; i < end - start; ++i) {
|
|
1558
|
+
this[i + start] = bytes[i % len];
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
return this;
|
|
1562
|
+
};
|
|
1563
|
+
var errors = {};
|
|
1564
|
+
function E(sym, getMessage, Base) {
|
|
1565
|
+
errors[sym] = class NodeError extends Base {
|
|
1566
|
+
constructor() {
|
|
1567
|
+
super();
|
|
1568
|
+
Object.defineProperty(this, "message", {
|
|
1569
|
+
value: getMessage.apply(this, arguments),
|
|
1570
|
+
writable: true,
|
|
1571
|
+
configurable: true
|
|
1572
|
+
});
|
|
1573
|
+
this.name = `${this.name} [${sym}]`;
|
|
1574
|
+
this.stack;
|
|
1575
|
+
delete this.name;
|
|
1576
|
+
}
|
|
1577
|
+
get code() {
|
|
1578
|
+
return sym;
|
|
1579
|
+
}
|
|
1580
|
+
set code(value) {
|
|
1581
|
+
Object.defineProperty(this, "code", {
|
|
1582
|
+
configurable: true,
|
|
1583
|
+
enumerable: true,
|
|
1584
|
+
value,
|
|
1585
|
+
writable: true
|
|
1586
|
+
});
|
|
1587
|
+
}
|
|
1588
|
+
toString() {
|
|
1589
|
+
return `${this.name} [${sym}]: ${this.message}`;
|
|
1590
|
+
}
|
|
1591
|
+
};
|
|
1592
|
+
}
|
|
1593
|
+
E(
|
|
1594
|
+
"ERR_BUFFER_OUT_OF_BOUNDS",
|
|
1595
|
+
function(name) {
|
|
1596
|
+
if (name) {
|
|
1597
|
+
return `${name} is outside of buffer bounds`;
|
|
1598
|
+
}
|
|
1599
|
+
return "Attempt to access memory outside buffer bounds";
|
|
1600
|
+
},
|
|
1601
|
+
RangeError
|
|
1602
|
+
);
|
|
1603
|
+
E(
|
|
1604
|
+
"ERR_INVALID_ARG_TYPE",
|
|
1605
|
+
function(name, actual) {
|
|
1606
|
+
return `The "${name}" argument must be of type number. Received type ${typeof actual}`;
|
|
1607
|
+
},
|
|
1608
|
+
TypeError
|
|
1609
|
+
);
|
|
1610
|
+
E(
|
|
1611
|
+
"ERR_OUT_OF_RANGE",
|
|
1612
|
+
function(str, range, input) {
|
|
1613
|
+
let msg = `The value of "${str}" is out of range.`;
|
|
1614
|
+
let received = input;
|
|
1615
|
+
if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
|
|
1616
|
+
received = addNumericalSeparator(String(input));
|
|
1617
|
+
} else if (typeof input === "bigint") {
|
|
1618
|
+
received = String(input);
|
|
1619
|
+
if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
|
|
1620
|
+
received = addNumericalSeparator(received);
|
|
1621
|
+
}
|
|
1622
|
+
received += "n";
|
|
1623
|
+
}
|
|
1624
|
+
msg += ` It must be ${range}. Received ${received}`;
|
|
1625
|
+
return msg;
|
|
1626
|
+
},
|
|
1627
|
+
RangeError
|
|
1628
|
+
);
|
|
1629
|
+
function addNumericalSeparator(val) {
|
|
1630
|
+
let res = "";
|
|
1631
|
+
let i = val.length;
|
|
1632
|
+
const start = val[0] === "-" ? 1 : 0;
|
|
1633
|
+
for (; i >= start + 4; i -= 3) {
|
|
1634
|
+
res = `_${val.slice(i - 3, i)}${res}`;
|
|
1635
|
+
}
|
|
1636
|
+
return `${val.slice(0, i)}${res}`;
|
|
1637
|
+
}
|
|
1638
|
+
function checkBounds(buf, offset, byteLength2) {
|
|
1639
|
+
validateNumber(offset, "offset");
|
|
1640
|
+
if (buf[offset] === void 0 || buf[offset + byteLength2] === void 0) {
|
|
1641
|
+
boundsError(offset, buf.length - (byteLength2 + 1));
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
function checkIntBI(value, min, max, buf, offset, byteLength2) {
|
|
1645
|
+
if (value > max || value < min) {
|
|
1646
|
+
const n = typeof min === "bigint" ? "n" : "";
|
|
1647
|
+
let range;
|
|
1648
|
+
if (byteLength2 > 3) {
|
|
1649
|
+
if (min === 0 || min === BigInt(0)) {
|
|
1650
|
+
range = `>= 0${n} and < 2${n} ** ${(byteLength2 + 1) * 8}${n}`;
|
|
1651
|
+
} else {
|
|
1652
|
+
range = `>= -(2${n} ** ${(byteLength2 + 1) * 8 - 1}${n}) and < 2 ** ${(byteLength2 + 1) * 8 - 1}${n}`;
|
|
1653
|
+
}
|
|
1654
|
+
} else {
|
|
1655
|
+
range = `>= ${min}${n} and <= ${max}${n}`;
|
|
1656
|
+
}
|
|
1657
|
+
throw new errors.ERR_OUT_OF_RANGE("value", range, value);
|
|
1658
|
+
}
|
|
1659
|
+
checkBounds(buf, offset, byteLength2);
|
|
1660
|
+
}
|
|
1661
|
+
function validateNumber(value, name) {
|
|
1662
|
+
if (typeof value !== "number") {
|
|
1663
|
+
throw new errors.ERR_INVALID_ARG_TYPE(name, "number", value);
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
function boundsError(value, length, type) {
|
|
1667
|
+
if (Math.floor(value) !== value) {
|
|
1668
|
+
validateNumber(value, type);
|
|
1669
|
+
throw new errors.ERR_OUT_OF_RANGE(type || "offset", "an integer", value);
|
|
1670
|
+
}
|
|
1671
|
+
if (length < 0) {
|
|
1672
|
+
throw new errors.ERR_BUFFER_OUT_OF_BOUNDS();
|
|
1673
|
+
}
|
|
1674
|
+
throw new errors.ERR_OUT_OF_RANGE(
|
|
1675
|
+
type || "offset",
|
|
1676
|
+
`>= ${type ? 1 : 0} and <= ${length}`,
|
|
1677
|
+
value
|
|
1678
|
+
);
|
|
1679
|
+
}
|
|
1680
|
+
var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
|
|
1681
|
+
function base64clean(str) {
|
|
1682
|
+
str = str.split("=")[0];
|
|
1683
|
+
str = str.trim().replace(INVALID_BASE64_RE, "");
|
|
1684
|
+
if (str.length < 2) return "";
|
|
1685
|
+
while (str.length % 4 !== 0) {
|
|
1686
|
+
str = str + "=";
|
|
1687
|
+
}
|
|
1688
|
+
return str;
|
|
1689
|
+
}
|
|
1690
|
+
function utf8ToBytes(string, units) {
|
|
1691
|
+
units = units || Infinity;
|
|
1692
|
+
let codePoint;
|
|
1693
|
+
const length = string.length;
|
|
1694
|
+
let leadSurrogate = null;
|
|
1695
|
+
const bytes = [];
|
|
1696
|
+
for (let i = 0; i < length; ++i) {
|
|
1697
|
+
codePoint = string.charCodeAt(i);
|
|
1698
|
+
if (codePoint > 55295 && codePoint < 57344) {
|
|
1699
|
+
if (!leadSurrogate) {
|
|
1700
|
+
if (codePoint > 56319) {
|
|
1701
|
+
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
1702
|
+
continue;
|
|
1703
|
+
} else if (i + 1 === length) {
|
|
1704
|
+
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
1705
|
+
continue;
|
|
1706
|
+
}
|
|
1707
|
+
leadSurrogate = codePoint;
|
|
1708
|
+
continue;
|
|
1709
|
+
}
|
|
1710
|
+
if (codePoint < 56320) {
|
|
1711
|
+
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
1712
|
+
leadSurrogate = codePoint;
|
|
1713
|
+
continue;
|
|
1714
|
+
}
|
|
1715
|
+
codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
|
|
1716
|
+
} else if (leadSurrogate) {
|
|
1717
|
+
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
1718
|
+
}
|
|
1719
|
+
leadSurrogate = null;
|
|
1720
|
+
if (codePoint < 128) {
|
|
1721
|
+
if ((units -= 1) < 0) break;
|
|
1722
|
+
bytes.push(codePoint);
|
|
1723
|
+
} else if (codePoint < 2048) {
|
|
1724
|
+
if ((units -= 2) < 0) break;
|
|
1725
|
+
bytes.push(
|
|
1726
|
+
codePoint >> 6 | 192,
|
|
1727
|
+
codePoint & 63 | 128
|
|
1728
|
+
);
|
|
1729
|
+
} else if (codePoint < 65536) {
|
|
1730
|
+
if ((units -= 3) < 0) break;
|
|
1731
|
+
bytes.push(
|
|
1732
|
+
codePoint >> 12 | 224,
|
|
1733
|
+
codePoint >> 6 & 63 | 128,
|
|
1734
|
+
codePoint & 63 | 128
|
|
1735
|
+
);
|
|
1736
|
+
} else if (codePoint < 1114112) {
|
|
1737
|
+
if ((units -= 4) < 0) break;
|
|
1738
|
+
bytes.push(
|
|
1739
|
+
codePoint >> 18 | 240,
|
|
1740
|
+
codePoint >> 12 & 63 | 128,
|
|
1741
|
+
codePoint >> 6 & 63 | 128,
|
|
1742
|
+
codePoint & 63 | 128
|
|
1743
|
+
);
|
|
1744
|
+
} else {
|
|
1745
|
+
throw new Error("Invalid code point");
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
return bytes;
|
|
1749
|
+
}
|
|
1750
|
+
function asciiToBytes(str) {
|
|
1751
|
+
const byteArray = [];
|
|
1752
|
+
for (let i = 0; i < str.length; ++i) {
|
|
1753
|
+
byteArray.push(str.charCodeAt(i) & 255);
|
|
1754
|
+
}
|
|
1755
|
+
return byteArray;
|
|
1756
|
+
}
|
|
1757
|
+
function utf16leToBytes(str, units) {
|
|
1758
|
+
let c, hi, lo;
|
|
1759
|
+
const byteArray = [];
|
|
1760
|
+
for (let i = 0; i < str.length; ++i) {
|
|
1761
|
+
if ((units -= 2) < 0) break;
|
|
1762
|
+
c = str.charCodeAt(i);
|
|
1763
|
+
hi = c >> 8;
|
|
1764
|
+
lo = c % 256;
|
|
1765
|
+
byteArray.push(lo);
|
|
1766
|
+
byteArray.push(hi);
|
|
1767
|
+
}
|
|
1768
|
+
return byteArray;
|
|
1769
|
+
}
|
|
1770
|
+
function base64ToBytes(str) {
|
|
1771
|
+
return base64.toByteArray(base64clean(str));
|
|
1772
|
+
}
|
|
1773
|
+
function blitBuffer(src, dst, offset, length) {
|
|
1774
|
+
let i;
|
|
1775
|
+
for (i = 0; i < length; ++i) {
|
|
1776
|
+
if (i + offset >= dst.length || i >= src.length) break;
|
|
1777
|
+
dst[i + offset] = src[i];
|
|
1778
|
+
}
|
|
1779
|
+
return i;
|
|
1780
|
+
}
|
|
1781
|
+
function isInstance(obj, type) {
|
|
1782
|
+
return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name;
|
|
1783
|
+
}
|
|
1784
|
+
function numberIsNaN(obj) {
|
|
1785
|
+
return obj !== obj;
|
|
1786
|
+
}
|
|
1787
|
+
var hexSliceLookupTable = (function() {
|
|
1788
|
+
const alphabet = "0123456789abcdef";
|
|
1789
|
+
const table = new Array(256);
|
|
1790
|
+
for (let i = 0; i < 16; ++i) {
|
|
1791
|
+
const i16 = i * 16;
|
|
1792
|
+
for (let j = 0; j < 16; ++j) {
|
|
1793
|
+
table[i16 + j] = alphabet[i] + alphabet[j];
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
return table;
|
|
1797
|
+
})();
|
|
1798
|
+
function defineBigIntMethod(fn) {
|
|
1799
|
+
return typeof BigInt === "undefined" ? BufferBigIntNotDefined : fn;
|
|
1800
|
+
}
|
|
1801
|
+
function BufferBigIntNotDefined() {
|
|
1802
|
+
throw new Error("BigInt not supported");
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
});
|
|
1806
|
+
|
|
1
1807
|
// src/vendors/Sub-Store/backend/src/utils/index.js
|
|
2
1808
|
var IPV4_REGEX = /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)(\.(?!$)|$)){4}$/;
|
|
3
1809
|
var IPV6_REGEX = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
|
|
@@ -410,7 +2216,7 @@ var grammars = String.raw`
|
|
|
410
2216
|
}
|
|
411
2217
|
}
|
|
412
2218
|
|
|
413
|
-
start = (anytls/shadowsocks/vmess/trojan/h2_connect/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2/ssh/trust_tunnel/direct) {
|
|
2219
|
+
start = (masque/anytls/shadowsocks/vmess/trojan/h2_connect/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2/ssh/trust_tunnel/direct) {
|
|
414
2220
|
return proxy;
|
|
415
2221
|
}
|
|
416
2222
|
|
|
@@ -500,10 +2306,14 @@ anytls = tag equals "anytls" address (passwordk/reuse/ip_version/underlying_prox
|
|
|
500
2306
|
proxy.type = "anytls";
|
|
501
2307
|
proxy.tls = true;
|
|
502
2308
|
}
|
|
503
|
-
trust_tunnel = tag equals "trust-tunnel" address (usernamek/passwordk/headers/max_streams/reuse/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/client_cert/sni/cert_verify_name/alpn/fast_open/tfo/block_quic/others)* {
|
|
2309
|
+
trust_tunnel = tag equals "trust-tunnel" address (usernamek/passwordk/headers/max_streams/reuse/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/client_cert/sni/cert_verify_name/alpn/h3/fast_open/tfo/block_quic/others)* {
|
|
504
2310
|
proxy.type = "trusttunnel";
|
|
505
2311
|
proxy.tls = true;
|
|
506
2312
|
}
|
|
2313
|
+
masque = tag equals "masque" address (usernamek/passwordk/port_hopping_interval/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/client_cert/sni/cert_verify_name/alpn/fast_open/tfo/udp_relay/ecn/block_quic/others)* {
|
|
2314
|
+
proxy.type = "masque-surge";
|
|
2315
|
+
proxy.tls = true;
|
|
2316
|
+
}
|
|
507
2317
|
|
|
508
2318
|
direct = tag equals "direct" (udp_relay/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/block_quic/others)* {
|
|
509
2319
|
proxy.type = "direct";
|
|
@@ -660,6 +2470,7 @@ alpn = comma "alpn" equals match:quoted_value {
|
|
|
660
2470
|
const values = parseAlpn(match);
|
|
661
2471
|
if (values.length > 0) proxy.alpn = values;
|
|
662
2472
|
}
|
|
2473
|
+
h3 = comma "h3" equals flag:bool { if (flag) proxy.network = "h3"; }
|
|
663
2474
|
quoted_value = '"' match:$[^"]* '"' { return match; } / "'" match:$[^']* "'" { return match; } / match:$[^,]+ { return match; }
|
|
664
2475
|
uuidk = comma "uuid" equals match:[^,]+ { proxy.uuid = match.join(""); }
|
|
665
2476
|
salamander_password = comma "salamander-password" equals match:[^,]+ { proxy['obfs-password'] = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); proxy.obfs = 'salamander'; }
|
|
@@ -746,6 +2557,7 @@ var grammars2 = String.raw`
|
|
|
746
2557
|
function loonClientFingerprint(tlsProfile) {
|
|
747
2558
|
switch (String(tlsProfile || "").trim()) {
|
|
748
2559
|
case "chrome":
|
|
2560
|
+
case "chrome147":
|
|
749
2561
|
return "chrome";
|
|
750
2562
|
case "ios18":
|
|
751
2563
|
case "ios26":
|
|
@@ -945,12 +2757,19 @@ max_stream_count = comma "max-stream-count" equals match:$[0-9]+ { proxy["max-st
|
|
|
945
2757
|
|
|
946
2758
|
udp_over_tcp = comma "udp-over-tcp" equals flag:bool { proxy["udp-over-tcp"] = true; proxy["udp-over-tcp-version"] = 2; }
|
|
947
2759
|
|
|
2760
|
+
server_dns = comma "server-dns" equals value:(
|
|
2761
|
+
'"' match:$[^"]* '"' { return match; }
|
|
2762
|
+
/ $(!(comma [a-zA-Z0-9_-]+ equals) [^"])*
|
|
2763
|
+
) {
|
|
2764
|
+
proxy["server-dns"] = value.split(",").map((item) => item.trim()).filter(Boolean);
|
|
2765
|
+
}
|
|
2766
|
+
|
|
948
2767
|
tag = match:[^=,]* { proxy.name = match.join("").trim(); }
|
|
949
2768
|
comma = _ "," _
|
|
950
2769
|
equals = _ "=" _
|
|
951
2770
|
_ = [ \r\t]*
|
|
952
2771
|
bool = b:("true"/"false") { return b === "true" }
|
|
953
|
-
others = comma [^=,]+ equals [^=,]+
|
|
2772
|
+
others = server_dns / (comma [^=,]+ equals [^=,]+)
|
|
954
2773
|
`;
|
|
955
2774
|
var parser2;
|
|
956
2775
|
function getParser2() {
|
|
@@ -961,7 +2780,22 @@ function getParser2() {
|
|
|
961
2780
|
}
|
|
962
2781
|
|
|
963
2782
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/parsers/peggy/qx.js
|
|
2783
|
+
var import_buffer = __toESM(require_buffer());
|
|
964
2784
|
import peggy3 from "peggy";
|
|
2785
|
+
function decodeQxAlpn(raw) {
|
|
2786
|
+
if (typeof raw !== "string") return void 0;
|
|
2787
|
+
const hex = raw.trim().replace(/:/g, "");
|
|
2788
|
+
if (!hex || hex.length % 2 || /[^0-9a-f]/i.test(hex)) return void 0;
|
|
2789
|
+
const bytes = import_buffer.Buffer.from(hex, "hex");
|
|
2790
|
+
const alpn = [];
|
|
2791
|
+
for (let offset = 0; offset < bytes.length; ) {
|
|
2792
|
+
const length = bytes[offset++];
|
|
2793
|
+
if (!length || offset + length > bytes.length) return void 0;
|
|
2794
|
+
alpn.push(bytes.subarray(offset, offset + length).toString("utf8"));
|
|
2795
|
+
offset += length;
|
|
2796
|
+
}
|
|
2797
|
+
return alpn;
|
|
2798
|
+
}
|
|
965
2799
|
var grammars3 = String.raw`
|
|
966
2800
|
// global initializer
|
|
967
2801
|
{{
|
|
@@ -1133,7 +2967,8 @@ port = digits:[0-9]+ {
|
|
|
1133
2967
|
}
|
|
1134
2968
|
|
|
1135
2969
|
username = comma "username" equals username:[^,]+ { proxy.username = username.join("").trim(); }
|
|
1136
|
-
password = comma "password" equals password
|
|
2970
|
+
password = comma "password" equals password:$((!next_parameter .)+) { proxy.password = password.trim(); }
|
|
2971
|
+
next_parameter = "," _ [^=,]+ equals
|
|
1137
2972
|
uuid = comma "password" equals uuid:[^,]+ { proxy.uuid = uuid.join("").trim(); }
|
|
1138
2973
|
|
|
1139
2974
|
method = comma "method" equals cipher:cipher {
|
|
@@ -1223,7 +3058,15 @@ bool = b:("true"/"false") { return b === "true" }
|
|
|
1223
3058
|
var parser3;
|
|
1224
3059
|
function getParser3() {
|
|
1225
3060
|
if (!parser3) {
|
|
1226
|
-
|
|
3061
|
+
const generated = peggy3.generate(grammars3);
|
|
3062
|
+
parser3 = {
|
|
3063
|
+
parse(input, options) {
|
|
3064
|
+
const proxy = generated.parse(input, options);
|
|
3065
|
+
const alpn = decodeQxAlpn(proxy["tls-alpn"]);
|
|
3066
|
+
if (alpn) proxy.alpn = alpn;
|
|
3067
|
+
return proxy;
|
|
3068
|
+
}
|
|
3069
|
+
};
|
|
1227
3070
|
}
|
|
1228
3071
|
return parser3;
|
|
1229
3072
|
}
|
|
@@ -1250,8 +3093,7 @@ function splitQueryPart(part) {
|
|
|
1250
3093
|
};
|
|
1251
3094
|
}
|
|
1252
3095
|
function parseSafeIntegerValue(value) {
|
|
1253
|
-
if (!/^\d+$/.test(`${value}`))
|
|
1254
|
-
return null;
|
|
3096
|
+
if (!/^\d+$/.test(`${value}`)) return null;
|
|
1255
3097
|
const parsed = parseInt(`${value}`, 10);
|
|
1256
3098
|
return Number.isSafeInteger(parsed) ? parsed : null;
|
|
1257
3099
|
}
|
|
@@ -1269,8 +3111,7 @@ function extractPathQueryParam(rawPath, paramName) {
|
|
|
1269
3111
|
const keptParts = [];
|
|
1270
3112
|
let value = "";
|
|
1271
3113
|
for (const part of query.split("&")) {
|
|
1272
|
-
if (part === "")
|
|
1273
|
-
continue;
|
|
3114
|
+
if (part === "") continue;
|
|
1274
3115
|
const parsed = splitQueryPart(part);
|
|
1275
3116
|
if (parsed.key === paramName) {
|
|
1276
3117
|
if (value === "" && parsed.value !== "") {
|
|
@@ -1288,12 +3129,10 @@ function extractPathQueryParam(rawPath, paramName) {
|
|
|
1288
3129
|
function getPathQueryParam(rawPath, paramName) {
|
|
1289
3130
|
const path = rawPath == null ? "" : `${rawPath}`;
|
|
1290
3131
|
const queryIndex = path.indexOf("?");
|
|
1291
|
-
if (queryIndex === -1)
|
|
1292
|
-
return "";
|
|
3132
|
+
if (queryIndex === -1) return "";
|
|
1293
3133
|
const query = path.slice(queryIndex + 1);
|
|
1294
3134
|
for (const part of query.split("&")) {
|
|
1295
|
-
if (part === "")
|
|
1296
|
-
continue;
|
|
3135
|
+
if (part === "") continue;
|
|
1297
3136
|
const parsed = splitQueryPart(part);
|
|
1298
3137
|
if (parsed.key === paramName && parsed.value !== "") {
|
|
1299
3138
|
return parsed.value;
|
|
@@ -1328,8 +3167,7 @@ function setPathQueryParam(rawPath, paramName, value) {
|
|
|
1328
3167
|
}
|
|
1329
3168
|
function normalizeWebSocketEarlyDataPath(wsOpts) {
|
|
1330
3169
|
const networkPath = wsOpts?.path;
|
|
1331
|
-
if (!wsOpts)
|
|
1332
|
-
return;
|
|
3170
|
+
if (!wsOpts) return;
|
|
1333
3171
|
const { value: ed, parsed: maxEarlyData } = getSafeIntegerPathQueryParam(
|
|
1334
3172
|
networkPath,
|
|
1335
3173
|
"ed"
|
|
@@ -1346,8 +3184,7 @@ function normalizeWebSocketEarlyDataPath(wsOpts) {
|
|
|
1346
3184
|
delete wsOpts["max-early-data"];
|
|
1347
3185
|
return;
|
|
1348
3186
|
}
|
|
1349
|
-
if (ed === "")
|
|
1350
|
-
return;
|
|
3187
|
+
if (ed === "") return;
|
|
1351
3188
|
wsOpts.path = extractPathQueryParam(networkPath, "ed").path;
|
|
1352
3189
|
if (wsOpts["early-data-header-name"] == null) {
|
|
1353
3190
|
wsOpts["early-data-header-name"] = "Sec-WebSocket-Protocol";
|
|
@@ -1357,8 +3194,7 @@ function normalizeWebSocketEarlyDataPath(wsOpts) {
|
|
|
1357
3194
|
}
|
|
1358
3195
|
}
|
|
1359
3196
|
function deleteHttpUpgradeEarlyDataMetadata(wsOpts) {
|
|
1360
|
-
if (!wsOpts)
|
|
1361
|
-
return;
|
|
3197
|
+
if (!wsOpts) return;
|
|
1362
3198
|
delete wsOpts["_v2ray-http-upgrade-ed"];
|
|
1363
3199
|
}
|
|
1364
3200
|
|
|
@@ -1366,10 +3202,8 @@ function deleteHttpUpgradeEarlyDataMetadata(wsOpts) {
|
|
|
1366
3202
|
var unsafePathSegments = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
1367
3203
|
var parser4;
|
|
1368
3204
|
function $set(obj, path, value) {
|
|
1369
|
-
if (Object(obj) !== obj)
|
|
1370
|
-
|
|
1371
|
-
if (!Array.isArray(path))
|
|
1372
|
-
path = path.toString().match(/[^.[\]]+/g) || [];
|
|
3205
|
+
if (Object(obj) !== obj) return obj;
|
|
3206
|
+
if (!Array.isArray(path)) path = path.toString().match(/[^.[\]]+/g) || [];
|
|
1373
3207
|
if (path.some((segment) => unsafePathSegments.has(segment))) {
|
|
1374
3208
|
throw new Error("Unsafe property path");
|
|
1375
3209
|
}
|
|
@@ -1377,8 +3211,7 @@ function $set(obj, path, value) {
|
|
|
1377
3211
|
return obj;
|
|
1378
3212
|
}
|
|
1379
3213
|
function toBool(str) {
|
|
1380
|
-
if (str == null)
|
|
1381
|
-
return void 0;
|
|
3214
|
+
if (str == null) return void 0;
|
|
1382
3215
|
return /(TRUE)|1/i.test(str);
|
|
1383
3216
|
}
|
|
1384
3217
|
function isNumericEarlyData(value) {
|
|
@@ -1887,8 +3720,7 @@ var VMESS_SECURITY_ALIASES = {
|
|
|
1887
3720
|
"chacha20-ietf-poly1305": "chacha20-poly1305"
|
|
1888
3721
|
};
|
|
1889
3722
|
function normalizeSecurityValue(security) {
|
|
1890
|
-
if (security == null)
|
|
1891
|
-
return "";
|
|
3723
|
+
if (security == null) return "";
|
|
1892
3724
|
return `${security}`.trim().toLowerCase();
|
|
1893
3725
|
}
|
|
1894
3726
|
function canonicalizeVmessSecurity(security) {
|
|
@@ -1896,8 +3728,7 @@ function canonicalizeVmessSecurity(security) {
|
|
|
1896
3728
|
}
|
|
1897
3729
|
function normalizeVmessSecurity(security, supportedValues = VMESS_SECURITY_COMMON_VALUES, { acceptAliases = true, fallback = VMESS_SECURITY_AUTO } = {}) {
|
|
1898
3730
|
const normalized = normalizeSecurityValue(security);
|
|
1899
|
-
if (!normalized)
|
|
1900
|
-
return fallback;
|
|
3731
|
+
if (!normalized) return fallback;
|
|
1901
3732
|
const normalizedSupported = supportedValues.map(normalizeSecurityValue);
|
|
1902
3733
|
if (normalizedSupported.includes(normalized)) {
|
|
1903
3734
|
return canonicalizeVmessSecurity(normalized);
|
|
@@ -1928,8 +3759,7 @@ function formatSurgeVmessEncryptMethod(security) {
|
|
|
1928
3759
|
"aes-128-gcm",
|
|
1929
3760
|
"chacha20-poly1305"
|
|
1930
3761
|
]);
|
|
1931
|
-
if (normalized === VMESS_SECURITY_AUTO)
|
|
1932
|
-
return void 0;
|
|
3762
|
+
if (normalized === VMESS_SECURITY_AUTO) return void 0;
|
|
1933
3763
|
return normalized === "chacha20-poly1305" ? "chacha20-ietf-poly1305" : normalized;
|
|
1934
3764
|
}
|
|
1935
3765
|
|
|
@@ -1965,8 +3795,7 @@ function decodeShadowsocksUserInfo(rawUserInfoStr) {
|
|
|
1965
3795
|
return Base64.decode(decodedUserInfoStr);
|
|
1966
3796
|
}
|
|
1967
3797
|
function isNumericEarlyData2(value) {
|
|
1968
|
-
if (value == null || !/^\d+$/.test(`${value}`))
|
|
1969
|
-
return false;
|
|
3798
|
+
if (value == null || !/^\d+$/.test(`${value}`)) return false;
|
|
1970
3799
|
return Number.isSafeInteger(parseInt(`${value}`, 10));
|
|
1971
3800
|
}
|
|
1972
3801
|
function extractEarlyDataFromPath(path) {
|
|
@@ -2004,21 +3833,16 @@ function splitURIHostList(host) {
|
|
|
2004
3833
|
return hosts.length > 0 ? hosts : void 0;
|
|
2005
3834
|
}
|
|
2006
3835
|
function parseWireGuardURIAddressValue(value) {
|
|
2007
|
-
if (value == null)
|
|
2008
|
-
return null;
|
|
3836
|
+
if (value == null) return null;
|
|
2009
3837
|
const raw = `${value}`.trim();
|
|
2010
|
-
if (!raw)
|
|
2011
|
-
return null;
|
|
3838
|
+
if (!raw) return null;
|
|
2012
3839
|
const [, hostRaw = raw, cidrRaw] = /^(.*?)(?:\/(\d+))?$/.exec(raw) || [];
|
|
2013
3840
|
const host = `${hostRaw}`.trim().replace(/^\[/, "").replace(/\]$/, "");
|
|
2014
3841
|
const normalizeCIDR = (cidr, max) => {
|
|
2015
|
-
if (cidr == null)
|
|
2016
|
-
|
|
2017
|
-
if (!/^\d+$/.test(cidr))
|
|
2018
|
-
return void 0;
|
|
3842
|
+
if (cidr == null) return void 0;
|
|
3843
|
+
if (!/^\d+$/.test(cidr)) return void 0;
|
|
2019
3844
|
const parsed = parseInt(cidr, 10);
|
|
2020
|
-
if (parsed < 0 || parsed > max)
|
|
2021
|
-
return void 0;
|
|
3845
|
+
if (parsed < 0 || parsed > max) return void 0;
|
|
2022
3846
|
return parsed;
|
|
2023
3847
|
};
|
|
2024
3848
|
if (isIPv4(host)) {
|
|
@@ -2273,14 +4097,12 @@ function URI_SS() {
|
|
|
2273
4097
|
for (const item of pluginInfo) {
|
|
2274
4098
|
const separatorIndex = item.indexOf("=");
|
|
2275
4099
|
if (separatorIndex === -1) {
|
|
2276
|
-
if (item)
|
|
2277
|
-
params2[item] = true;
|
|
4100
|
+
if (item) params2[item] = true;
|
|
2278
4101
|
continue;
|
|
2279
4102
|
}
|
|
2280
4103
|
const key = item.slice(0, separatorIndex);
|
|
2281
4104
|
const val = item.slice(separatorIndex + 1).replace(/\\=/g, "=");
|
|
2282
|
-
if (key)
|
|
2283
|
-
params2[key] = val || true;
|
|
4105
|
+
if (key) params2[key] = val || true;
|
|
2284
4106
|
}
|
|
2285
4107
|
switch (params2.plugin) {
|
|
2286
4108
|
case "obfs-local":
|
|
@@ -2421,7 +4243,9 @@ function URI_SSR() {
|
|
|
2421
4243
|
...proxy,
|
|
2422
4244
|
name: other_params.remarks ? Base64.decode(other_params.remarks) : proxy.server,
|
|
2423
4245
|
"protocol-param": getIfNotBlank(
|
|
2424
|
-
Base64.decode(
|
|
4246
|
+
Base64.decode(
|
|
4247
|
+
other_params.protoparam || other_params.protocolparam || ""
|
|
4248
|
+
).replace(/\s/g, "")
|
|
2425
4249
|
),
|
|
2426
4250
|
"obfs-param": getIfNotBlank(
|
|
2427
4251
|
Base64.decode(other_params.obfsparam || "").replace(/\s/g, "")
|
|
@@ -2437,6 +4261,9 @@ function URI_VMess() {
|
|
|
2437
4261
|
return /^vmess:\/\//.test(line);
|
|
2438
4262
|
};
|
|
2439
4263
|
const parse2 = (line) => {
|
|
4264
|
+
if (/^vmess:\/\/[^/?#]+@/.test(line)) {
|
|
4265
|
+
return URI_VLESS().parse(line, "vmess");
|
|
4266
|
+
}
|
|
2440
4267
|
let { content: lineWithoutFragment, fragment: fragmentName } = splitURIFragment(line.split("vmess://")[1]);
|
|
2441
4268
|
let content = Base64.decode(lineWithoutFragment.replace(/\?.*?$/, ""));
|
|
2442
4269
|
if (/=\s*vmess/.test(content)) {
|
|
@@ -2659,7 +4486,7 @@ function URI_VLESS() {
|
|
|
2659
4486
|
const test = (line) => {
|
|
2660
4487
|
return /^vless:\/\//.test(line);
|
|
2661
4488
|
};
|
|
2662
|
-
const parse2 = (line) => {
|
|
4489
|
+
const parse2 = (line, protocol = "vless") => {
|
|
2663
4490
|
const mapXmuxToReuseSettings = (xmux) => {
|
|
2664
4491
|
if (!isPlainObject(xmux)) {
|
|
2665
4492
|
return void 0;
|
|
@@ -3369,7 +5196,7 @@ function URI_VLESS() {
|
|
|
3369
5196
|
}
|
|
3370
5197
|
return Object.keys(parsedDownloadSettings).length > 0 ? parsedDownloadSettings : void 0;
|
|
3371
5198
|
};
|
|
3372
|
-
line = line.split(
|
|
5199
|
+
line = line.split(`${protocol}://`)[1];
|
|
3373
5200
|
let isShadowrocket;
|
|
3374
5201
|
let parsed = /^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
3375
5202
|
if (!parsed) {
|
|
@@ -3388,7 +5215,7 @@ function URI_VLESS() {
|
|
|
3388
5215
|
name2 = decodeURIComponent(name2);
|
|
3389
5216
|
}
|
|
3390
5217
|
const proxy = {
|
|
3391
|
-
type:
|
|
5218
|
+
type: protocol,
|
|
3392
5219
|
name: name2,
|
|
3393
5220
|
server,
|
|
3394
5221
|
port,
|
|
@@ -3398,13 +5225,11 @@ function URI_VLESS() {
|
|
|
3398
5225
|
const params = {};
|
|
3399
5226
|
for (const addon of addons.split("&")) {
|
|
3400
5227
|
if (addon) {
|
|
3401
|
-
const [key,
|
|
3402
|
-
|
|
3403
|
-
value = decodeURIComponent(valueRaw);
|
|
3404
|
-
params[key] = value;
|
|
5228
|
+
const [key, ...value] = addon.split("=");
|
|
5229
|
+
params[key] = decodeURIComponent(value.join("="));
|
|
3405
5230
|
}
|
|
3406
5231
|
}
|
|
3407
|
-
proxy.name = name2 ?? params.remarks ?? params.remark ??
|
|
5232
|
+
proxy.name = name2 ?? params.remarks ?? params.remark ?? `${protocol === "vmess" ? "VMess" : "VLESS"} ${server}:${port}`;
|
|
3408
5233
|
proxy.tls = params.security && params.security !== "none";
|
|
3409
5234
|
if (params.pbk) {
|
|
3410
5235
|
params.security = "reality";
|
|
@@ -3450,6 +5275,10 @@ function URI_VLESS() {
|
|
|
3450
5275
|
const opts = {};
|
|
3451
5276
|
if (params.pbk) {
|
|
3452
5277
|
opts["public-key"] = params.pbk;
|
|
5278
|
+
const mlkem = params["support-x25519mlkem768"];
|
|
5279
|
+
if (["1", "t", "T", "true", "TRUE", "True"].includes(mlkem)) {
|
|
5280
|
+
opts["support-x25519mlkem768"] = true;
|
|
5281
|
+
}
|
|
3453
5282
|
}
|
|
3454
5283
|
if (params.sid) {
|
|
3455
5284
|
opts["short-id"] = params.sid;
|
|
@@ -3612,12 +5441,24 @@ function URI_VLESS() {
|
|
|
3612
5441
|
proxy._mode = params.mode;
|
|
3613
5442
|
}
|
|
3614
5443
|
}
|
|
3615
|
-
if (
|
|
5444
|
+
if (protocol === "vmess") {
|
|
5445
|
+
proxy.cipher = normalizeVmessSecurity(params.encryption);
|
|
5446
|
+
proxy.alterId = 0;
|
|
5447
|
+
delete proxy.flow;
|
|
5448
|
+
} else if (params.encryption) {
|
|
3616
5449
|
proxy.encryption = params.encryption;
|
|
3617
5450
|
}
|
|
3618
5451
|
if (params.pqv) {
|
|
3619
5452
|
proxy._pqv = params.pqv;
|
|
3620
5453
|
}
|
|
5454
|
+
if (params.fm) {
|
|
5455
|
+
try {
|
|
5456
|
+
const finalmask = JSON.parse(params.fm);
|
|
5457
|
+
proxy._finalmask = isPlainObject(finalmask) ? finalmask : params.fm;
|
|
5458
|
+
} catch (e) {
|
|
5459
|
+
proxy._finalmask = params.fm;
|
|
5460
|
+
}
|
|
5461
|
+
}
|
|
3621
5462
|
return proxy;
|
|
3622
5463
|
};
|
|
3623
5464
|
return { name, test, parse: parse2 };
|
|
@@ -3943,8 +5784,7 @@ function URI_WireGuard() {
|
|
|
3943
5784
|
} else if (["address", "ip"].includes(key)) {
|
|
3944
5785
|
value.split(",").map((i) => {
|
|
3945
5786
|
const parsed = parseWireGuardURIAddressValue(i);
|
|
3946
|
-
if (!parsed)
|
|
3947
|
-
return;
|
|
5787
|
+
if (!parsed) return;
|
|
3948
5788
|
if (parsed.family === "ipv4") {
|
|
3949
5789
|
proxy.ip = parsed.address;
|
|
3950
5790
|
if (typeof parsed.cidr !== "undefined") {
|
|
@@ -4026,12 +5866,14 @@ function Clash_All() {
|
|
|
4026
5866
|
"gost-relay",
|
|
4027
5867
|
"openvpn",
|
|
4028
5868
|
"tailscale",
|
|
5869
|
+
"easytier",
|
|
4029
5870
|
"trusttunnel",
|
|
4030
5871
|
"h2-connect",
|
|
4031
5872
|
"naive",
|
|
4032
5873
|
"anytls",
|
|
4033
5874
|
"mieru",
|
|
4034
5875
|
"masque",
|
|
5876
|
+
"masque-surge",
|
|
4035
5877
|
"sudoku",
|
|
4036
5878
|
"juicity",
|
|
4037
5879
|
"ss",
|
|
@@ -4253,6 +6095,9 @@ function Loon_WireGuard() {
|
|
|
4253
6095
|
reserved = JSON.parse(reserved);
|
|
4254
6096
|
}
|
|
4255
6097
|
let dns;
|
|
6098
|
+
const serverDns = line.match(
|
|
6099
|
+
/(?:^|,)\s*server-dns\s*=\s*(?:"([^"]*)"|([^"]*?))(?=\s*(?:,\s*[\w-]+\s*=|$))/i
|
|
6100
|
+
);
|
|
4256
6101
|
let dnsv4 = line.match(/(,|^)\s*?dns\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2];
|
|
4257
6102
|
let dnsv6 = line.match(
|
|
4258
6103
|
/(,|^)\s*?dnsv6\s*?=\s*?"?(.+?)"?\s*?(,|$)/i
|
|
@@ -4296,6 +6141,7 @@ function Loon_WireGuard() {
|
|
|
4296
6141
|
"allowed-ips": allowedIps,
|
|
4297
6142
|
"preshared-key": preSharedKey,
|
|
4298
6143
|
dns,
|
|
6144
|
+
"server-dns": (serverDns?.[1] ?? serverDns?.[2])?.split(",").map((item) => item.trim()).filter(Boolean),
|
|
4299
6145
|
udp: true,
|
|
4300
6146
|
peers: [
|
|
4301
6147
|
{
|
|
@@ -4342,6 +6188,19 @@ function Surge_TrustTunnel() {
|
|
|
4342
6188
|
const parse2 = (line) => getParser().parse(line);
|
|
4343
6189
|
return { name, test, parse: parse2 };
|
|
4344
6190
|
}
|
|
6191
|
+
function Surge_Masque() {
|
|
6192
|
+
const name = "Surge MASQUE Parser";
|
|
6193
|
+
const test = (line) => {
|
|
6194
|
+
return /^.*=\s*masque/.test(line.split(",")[0]);
|
|
6195
|
+
};
|
|
6196
|
+
const parse2 = (raw) => {
|
|
6197
|
+
const { port_hopping, line } = surge_port_hopping(raw);
|
|
6198
|
+
const proxy = getParser().parse(line);
|
|
6199
|
+
proxy.ports = port_hopping;
|
|
6200
|
+
return proxy;
|
|
6201
|
+
};
|
|
6202
|
+
return { name, test, parse: parse2 };
|
|
6203
|
+
}
|
|
4345
6204
|
function Surge_H2Connect() {
|
|
4346
6205
|
const name = "Surge HTTP/2 CONNECT Parser";
|
|
4347
6206
|
const test = (line) => {
|
|
@@ -4382,7 +6241,7 @@ function Surge_Trojan() {
|
|
|
4382
6241
|
const parse2 = (line) => getParser().parse(line);
|
|
4383
6242
|
return { name, test, parse: parse2 };
|
|
4384
6243
|
}
|
|
4385
|
-
var LOON_ONLY_OPTIONS = /(^|,)\s*(fast-open|over-tls|tls-name|ip-mode|tls-cert-sha256|tls-pubkey-sha256)\s*=/i;
|
|
6244
|
+
var LOON_ONLY_OPTIONS = /(^|,)\s*(fast-open|over-tls|tls-name|ip-mode|tls-cert-sha256|tls-pubkey-sha256|server-dns)\s*=/i;
|
|
4386
6245
|
function Surge_Http() {
|
|
4387
6246
|
const name = "Surge HTTP Parser";
|
|
4388
6247
|
const test = (line) => {
|
|
@@ -4521,6 +6380,7 @@ var parsers_default = [
|
|
|
4521
6380
|
Surge_Direct(),
|
|
4522
6381
|
Surge_AnyTLS(),
|
|
4523
6382
|
Surge_TrustTunnel(),
|
|
6383
|
+
Surge_Masque(),
|
|
4524
6384
|
Surge_H2Connect(),
|
|
4525
6385
|
Surge_SSH(),
|
|
4526
6386
|
Surge_SS(),
|
|
@@ -4656,8 +6516,7 @@ function fallbackBase64Encoded() {
|
|
|
4656
6516
|
function Clash() {
|
|
4657
6517
|
const name = "Clash Pre-processor";
|
|
4658
6518
|
const test = function(raw) {
|
|
4659
|
-
if (!/proxies/.test(raw))
|
|
4660
|
-
return false;
|
|
6519
|
+
if (!/proxies/.test(raw)) return false;
|
|
4661
6520
|
const content = safeLoad(raw);
|
|
4662
6521
|
return Array.isArray(content.proxies) || Array.isArray(content["proxy-groups"]);
|
|
4663
6522
|
};
|
|
@@ -4754,16 +6613,12 @@ function isShadowsocksOverTls(proxy) {
|
|
|
4754
6613
|
return proxy?.type === "ss" && proxy?.tls === true && !isPresent2(proxy, "plugin") && (!isPresent2(proxy, "network") || normalizedNetwork === "tcp");
|
|
4755
6614
|
}
|
|
4756
6615
|
function normalizePluginMuxValue(mux) {
|
|
4757
|
-
if (typeof mux === "boolean")
|
|
4758
|
-
return Number(mux);
|
|
6616
|
+
if (typeof mux === "boolean") return Number(mux);
|
|
4759
6617
|
if (typeof mux === "string") {
|
|
4760
6618
|
const normalized = mux.trim().toLowerCase();
|
|
4761
|
-
if (normalized === "true")
|
|
4762
|
-
|
|
4763
|
-
if (normalized
|
|
4764
|
-
return 0;
|
|
4765
|
-
if (/^\d+$/.test(normalized))
|
|
4766
|
-
return parseInt(normalized, 10);
|
|
6619
|
+
if (normalized === "true") return 1;
|
|
6620
|
+
if (normalized === "false") return 0;
|
|
6621
|
+
if (/^\d+$/.test(normalized)) return parseInt(normalized, 10);
|
|
4767
6622
|
}
|
|
4768
6623
|
return mux;
|
|
4769
6624
|
}
|
|
@@ -4771,8 +6626,7 @@ function normalizePluginMuxBooleanValue(mux) {
|
|
|
4771
6626
|
return Boolean(normalizePluginMuxValue(mux));
|
|
4772
6627
|
}
|
|
4773
6628
|
function supportsShadowsocksV2rayPluginMode(proxy, supportedModes) {
|
|
4774
|
-
if (proxy?.type !== "ss" || proxy?.plugin !== "v2ray-plugin")
|
|
4775
|
-
return true;
|
|
6629
|
+
if (proxy?.type !== "ss" || proxy?.plugin !== "v2ray-plugin") return true;
|
|
4776
6630
|
const normalizedMode = typeof proxy?.["plugin-opts"]?.mode === "string" ? proxy["plugin-opts"].mode.trim().toLowerCase() : proxy?.["plugin-opts"]?.mode;
|
|
4777
6631
|
return supportedModes.includes(normalizedMode);
|
|
4778
6632
|
}
|
|
@@ -4786,10 +6640,8 @@ function restoreShadowTLSOpts(target, serverNameKey) {
|
|
|
4786
6640
|
password: opts.password,
|
|
4787
6641
|
version: opts.version
|
|
4788
6642
|
};
|
|
4789
|
-
if (opts.host != null)
|
|
4790
|
-
|
|
4791
|
-
if (opts.alpn != null)
|
|
4792
|
-
target.alpn = opts.alpn;
|
|
6643
|
+
if (opts.host != null) target[serverNameKey] = opts.host;
|
|
6644
|
+
if (opts.alpn != null) target.alpn = opts.alpn;
|
|
4793
6645
|
delete target.plugin;
|
|
4794
6646
|
delete target["plugin-opts"];
|
|
4795
6647
|
return enabled;
|
|
@@ -4809,28 +6661,22 @@ function restoreShadowTLSProxyOpts(proxy) {
|
|
|
4809
6661
|
}
|
|
4810
6662
|
}
|
|
4811
6663
|
function parseWireGuardCIDR(cidr, max) {
|
|
4812
|
-
if (cidr == null)
|
|
4813
|
-
return void 0;
|
|
6664
|
+
if (cidr == null) return void 0;
|
|
4814
6665
|
const normalized = `${cidr}`.trim();
|
|
4815
|
-
if (!/^\d+$/.test(normalized))
|
|
4816
|
-
return void 0;
|
|
6666
|
+
if (!/^\d+$/.test(normalized)) return void 0;
|
|
4817
6667
|
const parsed = parseInt(normalized, 10);
|
|
4818
|
-
if (parsed < 0 || parsed > max)
|
|
4819
|
-
return void 0;
|
|
6668
|
+
if (parsed < 0 || parsed > max) return void 0;
|
|
4820
6669
|
return parsed;
|
|
4821
6670
|
}
|
|
4822
6671
|
function parseWireGuardInterfaceAddress(value, family) {
|
|
4823
|
-
if (value == null)
|
|
4824
|
-
return null;
|
|
6672
|
+
if (value == null) return null;
|
|
4825
6673
|
const raw = `${value}`.trim();
|
|
4826
|
-
if (!raw)
|
|
4827
|
-
return null;
|
|
6674
|
+
if (!raw) return null;
|
|
4828
6675
|
const [, hostRaw = raw, cidrRaw] = /^(.*?)(?:\/(\d+))?$/.exec(raw) || [];
|
|
4829
6676
|
const host = `${hostRaw}`.trim().replace(/^\[/, "").replace(/\]$/, "");
|
|
4830
6677
|
const isIPv4Family = family === "ipv4";
|
|
4831
6678
|
const isValid = isIPv4Family ? isIPv4(host) : isIPv6(host);
|
|
4832
|
-
if (!isValid)
|
|
4833
|
-
return null;
|
|
6679
|
+
if (!isValid) return null;
|
|
4834
6680
|
const max = isIPv4Family ? 32 : 128;
|
|
4835
6681
|
return {
|
|
4836
6682
|
address: host,
|
|
@@ -4843,8 +6689,7 @@ function getWireGuardAddressWithCIDR(proxy = {}, family = "ipv4") {
|
|
|
4843
6689
|
proxy[config.addressKey],
|
|
4844
6690
|
family
|
|
4845
6691
|
);
|
|
4846
|
-
if (!parsed)
|
|
4847
|
-
return void 0;
|
|
6692
|
+
if (!parsed) return void 0;
|
|
4848
6693
|
const normalizedCIDR = parseWireGuardCIDR(
|
|
4849
6694
|
proxy[config.cidrKey],
|
|
4850
6695
|
config.defaultCIDR
|
|
@@ -4852,8 +6697,7 @@ function getWireGuardAddressWithCIDR(proxy = {}, family = "ipv4") {
|
|
|
4852
6697
|
return `${parsed.address}/${normalizedCIDR ?? parsed.cidr ?? config.defaultCIDR}`;
|
|
4853
6698
|
}
|
|
4854
6699
|
function produceProxyListOutput(list, type, opts = {}) {
|
|
4855
|
-
if (type === "internal")
|
|
4856
|
-
return list;
|
|
6700
|
+
if (type === "internal") return list;
|
|
4857
6701
|
if (opts.prettyYaml || opts["pretty-yaml"]) {
|
|
4858
6702
|
return normalizeClashYaml(
|
|
4859
6703
|
yaml_default.safeDump(
|
|
@@ -4888,8 +6732,7 @@ var ipVersions = {
|
|
|
4888
6732
|
"ipv6-prefer": "prefer-v6"
|
|
4889
6733
|
};
|
|
4890
6734
|
function stripSurgeQuotes(value) {
|
|
4891
|
-
if (typeof value !== "string")
|
|
4892
|
-
return value;
|
|
6735
|
+
if (typeof value !== "string") return value;
|
|
4893
6736
|
const trimmed = value.trim();
|
|
4894
6737
|
const quote = trimmed[0];
|
|
4895
6738
|
if ((quote === '"' || quote === "'") && trimmed[trimmed.length - 1] === quote) {
|
|
@@ -4910,23 +6753,19 @@ function formatSurgeAlpn(alpn) {
|
|
|
4910
6753
|
}
|
|
4911
6754
|
function appendAlpn(result, proxy) {
|
|
4912
6755
|
const alpn = formatSurgeAlpn(proxy.alpn);
|
|
4913
|
-
if (alpn)
|
|
4914
|
-
result.append(`,alpn="${alpn}"`);
|
|
6756
|
+
if (alpn) result.append(`,alpn="${alpn}"`);
|
|
4915
6757
|
}
|
|
4916
6758
|
function getShadowTLSAlpn(proxy) {
|
|
4917
6759
|
return formatSurgeAlpn(proxy?.["plugin-opts"]?.alpn ?? proxy?.alpn);
|
|
4918
6760
|
}
|
|
4919
6761
|
function appendShadowTLS(result, proxy, includeUdpPort = false) {
|
|
4920
|
-
if (proxy.plugin !== "shadow-tls" || !proxy["plugin-opts"])
|
|
4921
|
-
return;
|
|
6762
|
+
if (proxy.plugin !== "shadow-tls" || !proxy["plugin-opts"]) return;
|
|
4922
6763
|
const password = proxy["plugin-opts"].password;
|
|
4923
6764
|
const host = proxy["plugin-opts"].host;
|
|
4924
6765
|
const version = proxy["plugin-opts"].version;
|
|
4925
|
-
if (!password)
|
|
4926
|
-
return;
|
|
6766
|
+
if (!password) return;
|
|
4927
6767
|
result.append(`,shadow-tls-password="${password}"`);
|
|
4928
|
-
if (host)
|
|
4929
|
-
result.append(`,shadow-tls-sni=${host}`);
|
|
6768
|
+
if (host) result.append(`,shadow-tls-sni=${host}`);
|
|
4930
6769
|
if (version) {
|
|
4931
6770
|
if (version < 2) {
|
|
4932
6771
|
throw unsupported(`shadow-tls version ${version} is not supported`);
|
|
@@ -4934,8 +6773,7 @@ function appendShadowTLS(result, proxy, includeUdpPort = false) {
|
|
|
4934
6773
|
result.append(`,shadow-tls-version=${version}`);
|
|
4935
6774
|
}
|
|
4936
6775
|
const alpn = getShadowTLSAlpn(proxy);
|
|
4937
|
-
if (alpn)
|
|
4938
|
-
result.append(`,alpn="${alpn}"`);
|
|
6776
|
+
if (alpn) result.append(`,alpn="${alpn}"`);
|
|
4939
6777
|
if (includeUdpPort) {
|
|
4940
6778
|
result.appendIfPresent(`,udp-port=${proxy["udp-port"]}`, "udp-port");
|
|
4941
6779
|
}
|
|
@@ -4974,11 +6812,9 @@ function appendSshPrivateKey(result, proxy) {
|
|
|
4974
6812
|
}
|
|
4975
6813
|
}
|
|
4976
6814
|
function warnMaxStreamsIfNeeded(proxy) {
|
|
4977
|
-
if (!isPresent2(proxy, "max-streams"))
|
|
4978
|
-
return;
|
|
6815
|
+
if (!isPresent2(proxy, "max-streams")) return;
|
|
4979
6816
|
const maxStreams = Number(stripSurgeQuotes(proxy["max-streams"]));
|
|
4980
|
-
if (!Number.isInteger(maxStreams) || maxStreams <= 3)
|
|
4981
|
-
return;
|
|
6817
|
+
if (!Number.isInteger(maxStreams) || maxStreams <= 3) return;
|
|
4982
6818
|
app_default.warn(
|
|
4983
6819
|
`Surge ${proxy.type} proxy ${proxy.name}: max-streams=${maxStreams} is greater than 3. Too many streams sharing one TCP connection may hurt performance.`
|
|
4984
6820
|
);
|
|
@@ -5027,6 +6863,8 @@ function Surge_Producer() {
|
|
|
5027
6863
|
return ssh(proxy);
|
|
5028
6864
|
case "trusttunnel":
|
|
5029
6865
|
return trusttunnel(proxy);
|
|
6866
|
+
case "masque-surge":
|
|
6867
|
+
return masque_surge(proxy);
|
|
5030
6868
|
}
|
|
5031
6869
|
if (opts["include-unsupported-proxy"] && proxy.type === "wireguard") {
|
|
5032
6870
|
return wireguard(proxy);
|
|
@@ -5147,7 +6985,6 @@ function trojan(proxy) {
|
|
|
5147
6985
|
result.appendIfPresent(`,tls=${proxy.tls}`, "tls");
|
|
5148
6986
|
appendTlsProxyParams(result, proxy);
|
|
5149
6987
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
5150
|
-
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
5151
6988
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
5152
6989
|
result.appendIfPresent(
|
|
5153
6990
|
`,test-timeout=${proxy["test-timeout"]}`,
|
|
@@ -5185,7 +7022,6 @@ function anytls(proxy) {
|
|
|
5185
7022
|
);
|
|
5186
7023
|
appendTlsProxyParams(result, proxy);
|
|
5187
7024
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
5188
|
-
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
5189
7025
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
5190
7026
|
result.appendIfPresent(
|
|
5191
7027
|
`,test-timeout=${proxy["test-timeout"]}`,
|
|
@@ -5222,6 +7058,7 @@ function trusttunnel(proxy) {
|
|
|
5222
7058
|
`,max-streams=${proxy["max-streams"]}`,
|
|
5223
7059
|
"max-streams"
|
|
5224
7060
|
);
|
|
7061
|
+
if (proxy.network === "h3") result.append(",h3=true");
|
|
5225
7062
|
const ip_version = ipVersions[proxy["ip-version"]] || proxy["ip-version"];
|
|
5226
7063
|
result.appendIfPresent(`,ip-version=${ip_version}`, "ip-version");
|
|
5227
7064
|
result.appendIfPresent(
|
|
@@ -5230,7 +7067,6 @@ function trusttunnel(proxy) {
|
|
|
5230
7067
|
);
|
|
5231
7068
|
appendTlsProxyParams(result, proxy);
|
|
5232
7069
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
5233
|
-
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
5234
7070
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
5235
7071
|
result.appendIfPresent(
|
|
5236
7072
|
`,test-timeout=${proxy["test-timeout"]}`,
|
|
@@ -5256,6 +7092,56 @@ function trusttunnel(proxy) {
|
|
|
5256
7092
|
result.appendIfPresent(`,reuse=${proxy["reuse"]}`, "reuse");
|
|
5257
7093
|
return result.toString();
|
|
5258
7094
|
}
|
|
7095
|
+
function masque_surge(proxy) {
|
|
7096
|
+
const result = new Result(proxy);
|
|
7097
|
+
result.append(`${proxy.name}=masque,${proxy.server},${proxy.port}`);
|
|
7098
|
+
result.appendIfPresent(`,username="${proxy.username}"`, "username");
|
|
7099
|
+
result.appendIfPresent(`,password="${proxy.password}"`, "password");
|
|
7100
|
+
if (hasNonBlankValue(proxy.ports)) {
|
|
7101
|
+
result.append(
|
|
7102
|
+
`,port-hopping="${String(proxy.ports).replace(/,/g, ";")}"`
|
|
7103
|
+
);
|
|
7104
|
+
}
|
|
7105
|
+
if (hasNonBlankValue(proxy["hop-interval"])) {
|
|
7106
|
+
result.append(`,port-hopping-interval=${proxy["hop-interval"]}`);
|
|
7107
|
+
}
|
|
7108
|
+
const ip_version = ipVersions[proxy["ip-version"]] || proxy["ip-version"];
|
|
7109
|
+
result.appendIfPresent(`,ip-version=${ip_version}`, "ip-version");
|
|
7110
|
+
result.appendIfPresent(
|
|
7111
|
+
`,no-error-alert=${proxy["no-error-alert"]}`,
|
|
7112
|
+
"no-error-alert"
|
|
7113
|
+
);
|
|
7114
|
+
appendTlsProxyParams(result, proxy);
|
|
7115
|
+
if (isPresent2(proxy, "tfo")) {
|
|
7116
|
+
result.append(`,tfo=${proxy.tfo}`);
|
|
7117
|
+
} else if (isPresent2(proxy, "fast-open")) {
|
|
7118
|
+
result.append(`,tfo=${proxy["fast-open"]}`);
|
|
7119
|
+
}
|
|
7120
|
+
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
7121
|
+
result.appendIfPresent(
|
|
7122
|
+
`,test-timeout=${proxy["test-timeout"]}`,
|
|
7123
|
+
"test-timeout"
|
|
7124
|
+
);
|
|
7125
|
+
result.appendIfPresent(`,test-udp=${proxy["test-udp"]}`, "test-udp");
|
|
7126
|
+
result.appendIfPresent(`,hybrid=${proxy.hybrid}`, "hybrid");
|
|
7127
|
+
result.appendIfPresent(`,tos=${proxy.tos}`, "tos");
|
|
7128
|
+
result.appendIfPresent(
|
|
7129
|
+
`,allow-other-interface=${proxy["allow-other-interface"]}`,
|
|
7130
|
+
"allow-other-interface"
|
|
7131
|
+
);
|
|
7132
|
+
result.appendIfPresent(
|
|
7133
|
+
`,interface=${proxy["interface-name"]}`,
|
|
7134
|
+
"interface-name"
|
|
7135
|
+
);
|
|
7136
|
+
result.appendIfPresent(`,interface=${proxy.interface}`, "interface");
|
|
7137
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
7138
|
+
result.appendIfPresent(
|
|
7139
|
+
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
7140
|
+
"underlying-proxy"
|
|
7141
|
+
);
|
|
7142
|
+
result.appendIfPresent(`,ecn=${proxy.ecn}`, "ecn");
|
|
7143
|
+
return result.toString();
|
|
7144
|
+
}
|
|
5259
7145
|
function h2Connect(proxy) {
|
|
5260
7146
|
const result = new Result(proxy);
|
|
5261
7147
|
result.append(`${proxy.name}=h2-connect,${proxy.server},${proxy.port}`);
|
|
@@ -5326,7 +7212,6 @@ function vmess(proxy, includeUnsupportedProxy) {
|
|
|
5326
7212
|
result.appendIfPresent(`,tls=${proxy.tls}`, "tls");
|
|
5327
7213
|
appendTlsProxyParams(result, proxy, Boolean(proxy.tls));
|
|
5328
7214
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
5329
|
-
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
5330
7215
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
5331
7216
|
result.appendIfPresent(
|
|
5332
7217
|
`,test-timeout=${proxy["test-timeout"]}`,
|
|
@@ -5373,7 +7258,6 @@ function ssh(proxy) {
|
|
|
5373
7258
|
"no-error-alert"
|
|
5374
7259
|
);
|
|
5375
7260
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
5376
|
-
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
5377
7261
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
5378
7262
|
result.appendIfPresent(
|
|
5379
7263
|
`,test-timeout=${proxy["test-timeout"]}`,
|
|
@@ -5413,7 +7297,6 @@ function http(proxy) {
|
|
|
5413
7297
|
);
|
|
5414
7298
|
appendTlsProxyParams(result, proxy, Boolean(proxy.tls));
|
|
5415
7299
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
5416
|
-
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
5417
7300
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
5418
7301
|
result.appendIfPresent(
|
|
5419
7302
|
`,test-timeout=${proxy["test-timeout"]}`,
|
|
@@ -5450,7 +7333,6 @@ function direct(proxy) {
|
|
|
5450
7333
|
"no-error-alert"
|
|
5451
7334
|
);
|
|
5452
7335
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
5453
|
-
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
5454
7336
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
5455
7337
|
result.appendIfPresent(
|
|
5456
7338
|
`,test-timeout=${proxy["test-timeout"]}`,
|
|
@@ -5565,7 +7447,6 @@ function snell(proxy) {
|
|
|
5565
7447
|
"obfs-opts.path"
|
|
5566
7448
|
);
|
|
5567
7449
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
5568
|
-
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
5569
7450
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
5570
7451
|
result.appendIfPresent(
|
|
5571
7452
|
`,test-timeout=${proxy["test-timeout"]}`,
|
|
@@ -5902,14 +7783,19 @@ function ClashMeta_Producer() {
|
|
|
5902
7783
|
const type = "ALL";
|
|
5903
7784
|
const produce2 = (proxies, type2, opts = {}) => {
|
|
5904
7785
|
const list = proxies.filter((proxy) => {
|
|
5905
|
-
if (opts["include-unsupported-proxy"])
|
|
5906
|
-
return true;
|
|
7786
|
+
if (opts["include-unsupported-proxy"]) return true;
|
|
5907
7787
|
if (proxy.type === "h2-connect") {
|
|
5908
7788
|
app_default.error(
|
|
5909
7789
|
`mihomo does not support HTTP/2 CONNECT proxy type. Proxy ${proxy.name} has been filtered.`
|
|
5910
7790
|
);
|
|
5911
7791
|
return false;
|
|
5912
7792
|
}
|
|
7793
|
+
if (proxy.type === "masque-surge") {
|
|
7794
|
+
app_default.error(
|
|
7795
|
+
`mihomo does not support Surge MASQUE proxy type. Proxy ${proxy.name} has been filtered.`
|
|
7796
|
+
);
|
|
7797
|
+
return false;
|
|
7798
|
+
}
|
|
5913
7799
|
if (hasRootHeaders(proxy) && proxy.type === "trusttunnel") {
|
|
5914
7800
|
app_default.error(
|
|
5915
7801
|
`mihomo does not support headers for TrustTunnel proxy ${proxy.name}. Proxy has been filtered.`
|
|
@@ -6210,6 +8096,8 @@ function SurgeMac_Producer() {
|
|
|
6210
8096
|
switch (proxy.type) {
|
|
6211
8097
|
case "external":
|
|
6212
8098
|
return external(proxy);
|
|
8099
|
+
// case 'ssr':
|
|
8100
|
+
// return shadowsocksr(proxy);
|
|
6213
8101
|
default: {
|
|
6214
8102
|
if (opts.mihomoExternal || proxy._mihomoExternal) {
|
|
6215
8103
|
return mihomo(proxy, type, opts) || "";
|
|
@@ -6399,8 +8287,7 @@ function Clash_Producer() {
|
|
|
6399
8287
|
const type = "ALL";
|
|
6400
8288
|
const produce2 = (proxies, type2, opts = {}) => {
|
|
6401
8289
|
const list = proxies.filter((proxy) => {
|
|
6402
|
-
if (opts["include-unsupported-proxy"])
|
|
6403
|
-
return true;
|
|
8290
|
+
if (opts["include-unsupported-proxy"]) return true;
|
|
6404
8291
|
if (![
|
|
6405
8292
|
"ss",
|
|
6406
8293
|
"ssr",
|
|
@@ -6555,8 +8442,7 @@ function Stash_Producer() {
|
|
|
6555
8442
|
const type = "ALL";
|
|
6556
8443
|
const produce2 = (proxies, type2, opts = {}) => {
|
|
6557
8444
|
const list = proxies.filter((proxy) => {
|
|
6558
|
-
if (opts["include-unsupported-proxy"])
|
|
6559
|
-
return true;
|
|
8445
|
+
if (opts["include-unsupported-proxy"]) return true;
|
|
6560
8446
|
if (![
|
|
6561
8447
|
"ss",
|
|
6562
8448
|
"ssr",
|
|
@@ -6574,7 +8460,9 @@ function Stash_Producer() {
|
|
|
6574
8460
|
"juicity",
|
|
6575
8461
|
"anytls",
|
|
6576
8462
|
"tailscale",
|
|
6577
|
-
"trusttunnel"
|
|
8463
|
+
"trusttunnel",
|
|
8464
|
+
"masque",
|
|
8465
|
+
"mieru"
|
|
6578
8466
|
].includes(proxy.type) || proxy.type === "ss" && ![
|
|
6579
8467
|
"aes-128-gcm",
|
|
6580
8468
|
"aes-192-gcm",
|
|
@@ -6592,7 +8480,7 @@ function Stash_Producer() {
|
|
|
6592
8480
|
"xchacha20-ietf-poly1305",
|
|
6593
8481
|
"2022-blake3-aes-128-gcm",
|
|
6594
8482
|
"2022-blake3-aes-256-gcm"
|
|
6595
|
-
].includes(proxy.cipher) || proxy.type === "snell" && proxy.version
|
|
8483
|
+
].includes(proxy.cipher) || proxy.type === "snell" && proxy.version > 6) {
|
|
6596
8484
|
return false;
|
|
6597
8485
|
} else if (!supportsShadowsocksV2rayPluginMode(proxy, ["websocket"])) {
|
|
6598
8486
|
return false;
|
|
@@ -6600,9 +8488,7 @@ function Stash_Producer() {
|
|
|
6600
8488
|
return false;
|
|
6601
8489
|
} else if (["anytls"].includes(proxy.type) && proxy.network && (!["tcp"].includes(proxy.network) || ["tcp"].includes(proxy.network) && proxy["reality-opts"])) {
|
|
6602
8490
|
return false;
|
|
6603
|
-
} else if (["xhttp"].includes(proxy.network)) {
|
|
6604
|
-
return false;
|
|
6605
|
-
} else if (proxy.encryption && proxy.encryption !== "none" && ["vless"].includes(proxy.type)) {
|
|
8491
|
+
} else if (!["vless"].includes(proxy.type) && ["xhttp"].includes(proxy.network)) {
|
|
6606
8492
|
return false;
|
|
6607
8493
|
} else if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
6608
8494
|
return false;
|
|
@@ -6842,17 +8728,21 @@ function Loon_Producer() {
|
|
|
6842
8728
|
`Platform ${targetPlatform3} does not support proxy type: ${proxy.type}`
|
|
6843
8729
|
);
|
|
6844
8730
|
};
|
|
6845
|
-
return {
|
|
8731
|
+
return {
|
|
8732
|
+
produce: (proxy, type, opts = {}) => {
|
|
8733
|
+
const result = produce2(proxy, type, opts);
|
|
8734
|
+
const serverDns = proxy["server-dns"];
|
|
8735
|
+
return Array.isArray(serverDns) && serverDns.length > 0 ? `${result},server-dns="${serverDns.join(",")}"` : result;
|
|
8736
|
+
}
|
|
8737
|
+
};
|
|
6846
8738
|
}
|
|
6847
8739
|
function appendTlsProfile(result, proxy) {
|
|
6848
8740
|
const tlsProfile = getLoonTlsProfile(proxy);
|
|
6849
|
-
if (tlsProfile)
|
|
6850
|
-
result.append(`,tls-profile=${tlsProfile}`);
|
|
8741
|
+
if (tlsProfile) result.append(`,tls-profile=${tlsProfile}`);
|
|
6851
8742
|
}
|
|
6852
8743
|
function appendAlpn2(result, proxy) {
|
|
6853
8744
|
const alpn = getLoonAlpn(proxy);
|
|
6854
|
-
if (alpn)
|
|
6855
|
-
result.append(`,alpn="${alpn}"`);
|
|
8745
|
+
if (alpn) result.append(`,alpn="${alpn}"`);
|
|
6856
8746
|
}
|
|
6857
8747
|
function getLoonShadowTLSAlpn(proxy) {
|
|
6858
8748
|
const values = proxy?.["plugin-opts"]?.alpn ?? proxy?.alpn;
|
|
@@ -6860,16 +8750,13 @@ function getLoonShadowTLSAlpn(proxy) {
|
|
|
6860
8750
|
return normalized.map((item) => `${item}`.trim()).filter((item) => item !== "").join(",");
|
|
6861
8751
|
}
|
|
6862
8752
|
function appendShadowTLS2(result, proxy) {
|
|
6863
|
-
if (proxy.plugin !== "shadow-tls" || !proxy["plugin-opts"])
|
|
6864
|
-
return;
|
|
8753
|
+
if (proxy.plugin !== "shadow-tls" || !proxy["plugin-opts"]) return;
|
|
6865
8754
|
const password = proxy["plugin-opts"].password;
|
|
6866
8755
|
const host = proxy["plugin-opts"].host;
|
|
6867
8756
|
const version = proxy["plugin-opts"].version;
|
|
6868
|
-
if (!password)
|
|
6869
|
-
return;
|
|
8757
|
+
if (!password) return;
|
|
6870
8758
|
result.append(`,shadow-tls-password=${password}`);
|
|
6871
|
-
if (host)
|
|
6872
|
-
result.append(`,shadow-tls-sni=${host}`);
|
|
8759
|
+
if (host) result.append(`,shadow-tls-sni=${host}`);
|
|
6873
8760
|
if (version) {
|
|
6874
8761
|
if (version < 2) {
|
|
6875
8762
|
throw new Error(`shadow-tls version ${version} is not supported`);
|
|
@@ -6878,8 +8765,7 @@ function appendShadowTLS2(result, proxy) {
|
|
|
6878
8765
|
}
|
|
6879
8766
|
appendTlsProfile(result, proxy);
|
|
6880
8767
|
const alpn = getLoonShadowTLSAlpn(proxy);
|
|
6881
|
-
if (alpn)
|
|
6882
|
-
result.append(`,alpn="${alpn}"`);
|
|
8768
|
+
if (alpn) result.append(`,alpn="${alpn}"`);
|
|
6883
8769
|
result.appendIfPresent(`,udp-port=${proxy["udp-port"]}`, "udp-port");
|
|
6884
8770
|
}
|
|
6885
8771
|
function appendReality(result, proxy) {
|
|
@@ -6899,12 +8785,12 @@ function getLoonAlpn(proxy) {
|
|
|
6899
8785
|
}
|
|
6900
8786
|
function getLoonTlsProfile(proxy) {
|
|
6901
8787
|
const tlsProfile = `${proxy._loon_tls_profile || ""}`.trim();
|
|
6902
|
-
if (["default", "chrome", "ios18", "ios26"].includes(tlsProfile)) {
|
|
8788
|
+
if (["default", "chrome", "chrome147", "ios18", "ios26"].includes(tlsProfile)) {
|
|
6903
8789
|
return tlsProfile;
|
|
6904
8790
|
}
|
|
6905
8791
|
switch (`${proxy["client-fingerprint"] || ""}`.trim()) {
|
|
6906
8792
|
case "chrome":
|
|
6907
|
-
return "
|
|
8793
|
+
return "chrome147";
|
|
6908
8794
|
case "ios":
|
|
6909
8795
|
return "ios26";
|
|
6910
8796
|
}
|
|
@@ -7462,8 +9348,7 @@ function getHttpUpgradeEarlyData(transportOpts, path) {
|
|
|
7462
9348
|
const httpUpgradeEd = getSafeEarlyDataValue(
|
|
7463
9349
|
transportOpts?.["_v2ray-http-upgrade-ed"]
|
|
7464
9350
|
);
|
|
7465
|
-
if (httpUpgradeEd !== "")
|
|
7466
|
-
return httpUpgradeEd;
|
|
9351
|
+
if (httpUpgradeEd !== "") return httpUpgradeEd;
|
|
7467
9352
|
const pathEd = getSafeEarlyDataValue(
|
|
7468
9353
|
extractPathQueryParam(path || "/", "ed").value
|
|
7469
9354
|
);
|
|
@@ -7495,8 +9380,7 @@ function setWebSocketEarlyDataPath(path, transportOpts) {
|
|
|
7495
9380
|
return setPathQueryParam(path || "/", "ed", earlyData);
|
|
7496
9381
|
}
|
|
7497
9382
|
function getSafeEarlyDataValue(value) {
|
|
7498
|
-
if (value == null || `${value}` === "")
|
|
7499
|
-
return "";
|
|
9383
|
+
if (value == null || `${value}` === "") return "";
|
|
7500
9384
|
return parseSafeIntegerValue(value) == null ? "" : `${value}`;
|
|
7501
9385
|
}
|
|
7502
9386
|
function parseIntegerLikeValue(value) {
|
|
@@ -7820,17 +9704,17 @@ function mergeUnsupportedXhttpExtraObject(baseObject, unsupportedObject) {
|
|
|
7820
9704
|
}
|
|
7821
9705
|
return mergedExtra;
|
|
7822
9706
|
}
|
|
7823
|
-
function
|
|
7824
|
-
if (typeof
|
|
7825
|
-
return
|
|
9707
|
+
function serializeUriJsonValue(value) {
|
|
9708
|
+
if (typeof value === "string") {
|
|
9709
|
+
return value;
|
|
7826
9710
|
}
|
|
7827
|
-
if (isPlainObject(
|
|
7828
|
-
return JSON.stringify(
|
|
9711
|
+
if (isPlainObject(value)) {
|
|
9712
|
+
return JSON.stringify(value);
|
|
7829
9713
|
}
|
|
7830
9714
|
return void 0;
|
|
7831
9715
|
}
|
|
7832
9716
|
function buildVlessExtra(proxy) {
|
|
7833
|
-
const explicitExtraOverride =
|
|
9717
|
+
const explicitExtraOverride = serializeUriJsonValue(proxy._extra);
|
|
7834
9718
|
if (explicitExtraOverride != null) {
|
|
7835
9719
|
return explicitExtraOverride;
|
|
7836
9720
|
}
|
|
@@ -7855,6 +9739,10 @@ function vless2(proxy) {
|
|
|
7855
9739
|
const publicKey = proxy["reality-opts"]?.["public-key"];
|
|
7856
9740
|
if (publicKey) {
|
|
7857
9741
|
pbk = `&pbk=${encodeURIComponent(publicKey)}`;
|
|
9742
|
+
const mlkem = proxy["reality-opts"]["support-x25519mlkem768"];
|
|
9743
|
+
if (mlkem) {
|
|
9744
|
+
pbk += `&support-x25519mlkem768=${encodeURIComponent(mlkem)}`;
|
|
9745
|
+
}
|
|
7858
9746
|
}
|
|
7859
9747
|
const shortId = proxy["reality-opts"]?.["short-id"];
|
|
7860
9748
|
if (shortId) {
|
|
@@ -7923,6 +9811,11 @@ function vless2(proxy) {
|
|
|
7923
9811
|
if (extraPayload) {
|
|
7924
9812
|
extra = `&extra=${encodeURIComponent(extraPayload)}`;
|
|
7925
9813
|
}
|
|
9814
|
+
let fm = "";
|
|
9815
|
+
const finalmaskPayload = serializeUriJsonValue(proxy._finalmask);
|
|
9816
|
+
if (finalmaskPayload) {
|
|
9817
|
+
fm = `&fm=${encodeURIComponent(finalmaskPayload)}`;
|
|
9818
|
+
}
|
|
7926
9819
|
let mode = "";
|
|
7927
9820
|
if (["xhttp"].includes(proxy.network) && proxy[`${proxy.network}-opts`]?.mode) {
|
|
7928
9821
|
mode = `&mode=${encodeURIComponent(
|
|
@@ -8041,7 +9934,7 @@ function vless2(proxy) {
|
|
|
8041
9934
|
}
|
|
8042
9935
|
return `vless://${proxy.uuid}@${proxy.server}:${proxy.port}?security=${encodeURIComponent(
|
|
8043
9936
|
security
|
|
8044
|
-
)}${vlessTransport}${packetEncoding}${alpn}${allowInsecure}${pcs}${vcn}${ech}${h2}${sni}${fp}${flow}${sid}${spx}${pbk}${mode}${extra}${pqv}${encryption}#${encodeURIComponent(
|
|
9937
|
+
)}${vlessTransport}${packetEncoding}${alpn}${allowInsecure}${pcs}${vcn}${ech}${h2}${sni}${fp}${flow}${sid}${spx}${pbk}${mode}${extra}${fm}${pqv}${encryption}#${encodeURIComponent(
|
|
8045
9938
|
proxy.name
|
|
8046
9939
|
)}`;
|
|
8047
9940
|
}
|
|
@@ -8222,10 +10115,25 @@ function URI_Producer() {
|
|
|
8222
10115
|
break;
|
|
8223
10116
|
case "ssr":
|
|
8224
10117
|
result = `${proxy.server}:${proxy.port}:${proxy.protocol}:${proxy.cipher}:${proxy.obfs}:${Base644.encode(proxy.password)}/`;
|
|
8225
|
-
result += `?remarks=${Base644.encode(proxy.name)}${proxy["obfs-param"] ? "&obfsparam=" + Base644.encode(proxy["obfs-param"]) : ""}${proxy["protocol-param"] ? "&
|
|
10118
|
+
result += `?remarks=${Base644.encode(proxy.name)}${proxy["obfs-param"] ? "&obfsparam=" + Base644.encode(proxy["obfs-param"]) : ""}${proxy["protocol-param"] ? "&protoparam=" + Base644.encode(proxy["protocol-param"]) : ""}`;
|
|
8226
10119
|
result = "ssr://" + Base644.encode(result);
|
|
8227
10120
|
break;
|
|
8228
10121
|
case "vmess":
|
|
10122
|
+
if (proxy["reality-opts"] || proxy._finalmask) {
|
|
10123
|
+
if (proxy.aead === false || proxy.aead !== true && Number(proxy.alterId || 0) !== 0) {
|
|
10124
|
+
throw new Error(
|
|
10125
|
+
"VMess query URI format cannot represent non-AEAD authentication (alterId must be 0)"
|
|
10126
|
+
);
|
|
10127
|
+
}
|
|
10128
|
+
result = vless2({
|
|
10129
|
+
...proxy,
|
|
10130
|
+
server: isIPv6(proxy.server) ? `[${proxy.server}]` : proxy.server,
|
|
10131
|
+
network: proxy.network || "tcp",
|
|
10132
|
+
encryption: normalizeVmessSecurity(proxy.cipher),
|
|
10133
|
+
flow: void 0
|
|
10134
|
+
}).replace(/^vless:\/\//, "vmess://");
|
|
10135
|
+
break;
|
|
10136
|
+
}
|
|
8229
10137
|
let type2 = "";
|
|
8230
10138
|
let net = proxy.network || "tcp";
|
|
8231
10139
|
if (proxy.network === "http") {
|
|
@@ -8713,7 +10621,26 @@ Reason: ${err}`);
|
|
|
8713
10621
|
}
|
|
8714
10622
|
|
|
8715
10623
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/qx.js
|
|
10624
|
+
var import_buffer2 = __toESM(require_buffer());
|
|
8716
10625
|
var targetPlatform4 = "QX";
|
|
10626
|
+
function encodeQxAlpn(alpn) {
|
|
10627
|
+
const protocols = (Array.isArray(alpn) ? alpn : `${alpn}`.split(",")).map((protocol) => `${protocol}`.trim()).filter(Boolean);
|
|
10628
|
+
return protocols.map((protocol) => {
|
|
10629
|
+
const bytes = import_buffer2.Buffer.from(protocol, "utf8");
|
|
10630
|
+
if (bytes.length > 255) {
|
|
10631
|
+
throw new Error("QX ALPN protocol exceeds 255 bytes");
|
|
10632
|
+
}
|
|
10633
|
+
return `${bytes.length.toString(16).padStart(2, "0")}${bytes.toString("hex")}`;
|
|
10634
|
+
}).join("") || void 0;
|
|
10635
|
+
}
|
|
10636
|
+
function appendTlsAlpn(result, proxy) {
|
|
10637
|
+
if (isPresent2(proxy, "tls-alpn")) {
|
|
10638
|
+
result.append(`,tls-alpn=${proxy["tls-alpn"]}`);
|
|
10639
|
+
return;
|
|
10640
|
+
}
|
|
10641
|
+
const encoded = isPresent2(proxy, "alpn") && encodeQxAlpn(proxy.alpn);
|
|
10642
|
+
if (encoded) result.append(`,tls-alpn=${encoded}`);
|
|
10643
|
+
}
|
|
8717
10644
|
function QX_Producer() {
|
|
8718
10645
|
const produce2 = (proxy, type, opts = {}) => {
|
|
8719
10646
|
if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
@@ -8833,10 +10760,8 @@ function shadowsocks3(proxy) {
|
|
|
8833
10760
|
}
|
|
8834
10761
|
} else if (proxy.plugin === "v2ray-plugin" && proxy["plugin-opts"].mode === "websocket") {
|
|
8835
10762
|
const opts = proxy["plugin-opts"];
|
|
8836
|
-
if (opts.tls)
|
|
8837
|
-
|
|
8838
|
-
else
|
|
8839
|
-
append(`,obfs=ws`);
|
|
10763
|
+
if (opts.tls) append(`,obfs=wss`);
|
|
10764
|
+
else append(`,obfs=ws`);
|
|
8840
10765
|
} else {
|
|
8841
10766
|
throw new Error(`plugin is not supported`);
|
|
8842
10767
|
}
|
|
@@ -8854,7 +10779,7 @@ function shadowsocks3(proxy) {
|
|
|
8854
10779
|
`,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
|
|
8855
10780
|
"tls-pubkey-sha256"
|
|
8856
10781
|
);
|
|
8857
|
-
|
|
10782
|
+
appendTlsAlpn(result, proxy);
|
|
8858
10783
|
appendIfPresent(
|
|
8859
10784
|
`,tls-no-session-ticket=${proxy["tls-no-session-ticket"]}`,
|
|
8860
10785
|
"tls-no-session-ticket"
|
|
@@ -8921,10 +10846,8 @@ function trojan3(proxy) {
|
|
|
8921
10846
|
append(`,password=${proxy.password}`);
|
|
8922
10847
|
if (isPresent2(proxy, "network")) {
|
|
8923
10848
|
if (proxy.network === "ws") {
|
|
8924
|
-
if (needTls(proxy))
|
|
8925
|
-
|
|
8926
|
-
else
|
|
8927
|
-
append(`,obfs=ws`);
|
|
10849
|
+
if (needTls(proxy)) append(`,obfs=wss`);
|
|
10850
|
+
else append(`,obfs=ws`);
|
|
8928
10851
|
appendIfPresent(
|
|
8929
10852
|
`,obfs-uri=${proxy["ws-opts"]?.path}`,
|
|
8930
10853
|
"ws-opts.path"
|
|
@@ -8945,7 +10868,7 @@ function trojan3(proxy) {
|
|
|
8945
10868
|
`,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
|
|
8946
10869
|
"tls-pubkey-sha256"
|
|
8947
10870
|
);
|
|
8948
|
-
|
|
10871
|
+
appendTlsAlpn(result, proxy);
|
|
8949
10872
|
appendIfPresent(
|
|
8950
10873
|
`,tls-no-session-ticket=${proxy["tls-no-session-ticket"]}`,
|
|
8951
10874
|
"tls-no-session-ticket"
|
|
@@ -8983,15 +10906,12 @@ function vmess3(proxy) {
|
|
|
8983
10906
|
}
|
|
8984
10907
|
if (isPresent2(proxy, "network")) {
|
|
8985
10908
|
if (proxy.network === "ws") {
|
|
8986
|
-
if (proxy.tls)
|
|
8987
|
-
|
|
8988
|
-
else
|
|
8989
|
-
append(`,obfs=ws`);
|
|
10909
|
+
if (proxy.tls) append(`,obfs=wss`);
|
|
10910
|
+
else append(`,obfs=ws`);
|
|
8990
10911
|
} else if (proxy.network === "http") {
|
|
8991
10912
|
append(`,obfs=${getQxHttpObfs(proxy)}`);
|
|
8992
10913
|
} else if (["tcp"].includes(proxy.network)) {
|
|
8993
|
-
if (proxy.tls)
|
|
8994
|
-
append(`,obfs=over-tls`);
|
|
10914
|
+
if (proxy.tls) append(`,obfs=over-tls`);
|
|
8995
10915
|
} else if (!["tcp"].includes(proxy.network)) {
|
|
8996
10916
|
throw new Error(`network ${proxy.network} is unsupported`);
|
|
8997
10917
|
}
|
|
@@ -9006,15 +10926,14 @@ function vmess3(proxy) {
|
|
|
9006
10926
|
`${proxy.network}-opts.headers.Host`
|
|
9007
10927
|
);
|
|
9008
10928
|
} else {
|
|
9009
|
-
if (proxy.tls)
|
|
9010
|
-
append(`,obfs=over-tls`);
|
|
10929
|
+
if (proxy.tls) append(`,obfs=over-tls`);
|
|
9011
10930
|
}
|
|
9012
10931
|
if (needTls(proxy)) {
|
|
9013
10932
|
appendIfPresent(
|
|
9014
10933
|
`,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
|
|
9015
10934
|
"tls-pubkey-sha256"
|
|
9016
10935
|
);
|
|
9017
|
-
|
|
10936
|
+
appendTlsAlpn(result, proxy);
|
|
9018
10937
|
appendIfPresent(
|
|
9019
10938
|
`,tls-no-session-ticket=${proxy["tls-no-session-ticket"]}`,
|
|
9020
10939
|
"tls-no-session-ticket"
|
|
@@ -9059,15 +10978,12 @@ function vless3(proxy) {
|
|
|
9059
10978
|
}
|
|
9060
10979
|
if (isPresent2(proxy, "network")) {
|
|
9061
10980
|
if (proxy.network === "ws") {
|
|
9062
|
-
if (proxy.tls)
|
|
9063
|
-
|
|
9064
|
-
else
|
|
9065
|
-
append(`,obfs=ws`);
|
|
10981
|
+
if (proxy.tls) append(`,obfs=wss`);
|
|
10982
|
+
else append(`,obfs=ws`);
|
|
9066
10983
|
} else if (proxy.network === "http") {
|
|
9067
10984
|
append(`,obfs=${getQxHttpObfs(proxy)}`);
|
|
9068
10985
|
} else if (["tcp"].includes(proxy.network)) {
|
|
9069
|
-
if (proxy.tls)
|
|
9070
|
-
append(`,obfs=over-tls`);
|
|
10986
|
+
if (proxy.tls) append(`,obfs=over-tls`);
|
|
9071
10987
|
} else if (!["tcp"].includes(proxy.network)) {
|
|
9072
10988
|
throw new Error(`network ${proxy.network} is unsupported`);
|
|
9073
10989
|
}
|
|
@@ -9082,15 +10998,14 @@ function vless3(proxy) {
|
|
|
9082
10998
|
`${proxy.network}-opts.headers.Host`
|
|
9083
10999
|
);
|
|
9084
11000
|
} else {
|
|
9085
|
-
if (proxy.tls)
|
|
9086
|
-
append(`,obfs=over-tls`);
|
|
11001
|
+
if (proxy.tls) append(`,obfs=over-tls`);
|
|
9087
11002
|
}
|
|
9088
11003
|
if (needTls(proxy)) {
|
|
9089
11004
|
appendIfPresent(
|
|
9090
11005
|
`,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
|
|
9091
11006
|
"tls-pubkey-sha256"
|
|
9092
11007
|
);
|
|
9093
|
-
|
|
11008
|
+
appendTlsAlpn(result, proxy);
|
|
9094
11009
|
appendIfPresent(
|
|
9095
11010
|
`,tls-no-session-ticket=${proxy["tls-no-session-ticket"]}`,
|
|
9096
11011
|
"tls-no-session-ticket"
|
|
@@ -9134,7 +11049,7 @@ function anytls3(proxy) {
|
|
|
9134
11049
|
`,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
|
|
9135
11050
|
"tls-pubkey-sha256"
|
|
9136
11051
|
);
|
|
9137
|
-
|
|
11052
|
+
appendTlsAlpn(result, proxy);
|
|
9138
11053
|
appendIfPresent(
|
|
9139
11054
|
`,tls-no-session-ticket=${proxy["tls-no-session-ticket"]}`,
|
|
9140
11055
|
"tls-no-session-ticket"
|
|
@@ -9174,7 +11089,7 @@ function http3(proxy) {
|
|
|
9174
11089
|
`,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
|
|
9175
11090
|
"tls-pubkey-sha256"
|
|
9176
11091
|
);
|
|
9177
|
-
|
|
11092
|
+
appendTlsAlpn(result, proxy);
|
|
9178
11093
|
appendIfPresent(
|
|
9179
11094
|
`,tls-no-session-ticket=${proxy["tls-no-session-ticket"]}`,
|
|
9180
11095
|
"tls-no-session-ticket"
|
|
@@ -9215,7 +11130,7 @@ function socks53(proxy) {
|
|
|
9215
11130
|
`,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
|
|
9216
11131
|
"tls-pubkey-sha256"
|
|
9217
11132
|
);
|
|
9218
|
-
|
|
11133
|
+
appendTlsAlpn(result, proxy);
|
|
9219
11134
|
appendIfPresent(
|
|
9220
11135
|
`,tls-no-session-ticket=${proxy["tls-no-session-ticket"]}`,
|
|
9221
11136
|
"tls-no-session-ticket"
|
|
@@ -9249,8 +11164,7 @@ function Shadowrocket_Producer() {
|
|
|
9249
11164
|
const type = "ALL";
|
|
9250
11165
|
const produce2 = (proxies, type2, opts = {}) => {
|
|
9251
11166
|
const list = proxies.filter((proxy) => {
|
|
9252
|
-
if (opts["include-unsupported-proxy"])
|
|
9253
|
-
return true;
|
|
11167
|
+
if (opts["include-unsupported-proxy"]) return true;
|
|
9254
11168
|
if (!supportsShadowsocksV2rayPluginMode(proxy, [
|
|
9255
11169
|
"websocket",
|
|
9256
11170
|
"quic",
|
|
@@ -9273,7 +11187,9 @@ function Shadowrocket_Producer() {
|
|
|
9273
11187
|
"openvpn",
|
|
9274
11188
|
"gost-relay",
|
|
9275
11189
|
"shadowquic",
|
|
9276
|
-
"zerotier"
|
|
11190
|
+
"zerotier",
|
|
11191
|
+
"masque-surge",
|
|
11192
|
+
"easytier"
|
|
9277
11193
|
].includes(proxy.type)) {
|
|
9278
11194
|
return false;
|
|
9279
11195
|
} else if (["xhttp"].includes(proxy.network)) {
|
|
@@ -9791,10 +11707,8 @@ var domainResolverParser = (proxy, parsedProxy) => {
|
|
|
9791
11707
|
};
|
|
9792
11708
|
var hasControlHTTPClient = (proxy) => {
|
|
9793
11709
|
const value = proxy["control-http-client"];
|
|
9794
|
-
if (value === void 0 || value === null)
|
|
9795
|
-
|
|
9796
|
-
if (typeof value === "string")
|
|
9797
|
-
return value.trim() !== "";
|
|
11710
|
+
if (value === void 0 || value === null) return false;
|
|
11711
|
+
if (typeof value === "string") return value.trim() !== "";
|
|
9798
11712
|
if (isPlainObject(value)) {
|
|
9799
11713
|
return Object.values(value).some(
|
|
9800
11714
|
(item) => item !== void 0 && item !== null && item !== ""
|
|
@@ -9816,18 +11730,13 @@ var networkParser = (proxy, parsedProxy) => {
|
|
|
9816
11730
|
};
|
|
9817
11731
|
var tfoParser = (proxy, parsedProxy) => {
|
|
9818
11732
|
parsedProxy.tcp_fast_open = false;
|
|
9819
|
-
if (proxy.tfo)
|
|
9820
|
-
|
|
9821
|
-
if (proxy.tcp_fast_open
|
|
9822
|
-
|
|
9823
|
-
if (proxy["tcp-fast-open"])
|
|
9824
|
-
parsedProxy.tcp_fast_open = true;
|
|
9825
|
-
if (!parsedProxy.tcp_fast_open)
|
|
9826
|
-
delete parsedProxy.tcp_fast_open;
|
|
11733
|
+
if (proxy.tfo) parsedProxy.tcp_fast_open = true;
|
|
11734
|
+
if (proxy.tcp_fast_open) parsedProxy.tcp_fast_open = true;
|
|
11735
|
+
if (proxy["tcp-fast-open"]) parsedProxy.tcp_fast_open = true;
|
|
11736
|
+
if (!parsedProxy.tcp_fast_open) delete parsedProxy.tcp_fast_open;
|
|
9827
11737
|
};
|
|
9828
11738
|
var smuxParser = (smux, proxy) => {
|
|
9829
|
-
if (!smux || !smux.enabled)
|
|
9830
|
-
return;
|
|
11739
|
+
if (!smux || !smux.enabled) return;
|
|
9831
11740
|
proxy.multiplex = { enabled: true };
|
|
9832
11741
|
proxy.multiplex.protocol = smux.protocol;
|
|
9833
11742
|
if (smux["max-connections"])
|
|
@@ -9839,8 +11748,7 @@ var smuxParser = (smux, proxy) => {
|
|
|
9839
11748
|
proxy.multiplex.max_streams = parseInt(`${smux["max-streams"]}`, 10);
|
|
9840
11749
|
if (smux["min-streams"])
|
|
9841
11750
|
proxy.multiplex.min_streams = parseInt(`${smux["min-streams"]}`, 10);
|
|
9842
|
-
if (smux.padding)
|
|
9843
|
-
proxy.multiplex.padding = true;
|
|
11751
|
+
if (smux.padding) proxy.multiplex.padding = true;
|
|
9844
11752
|
if (smux["brutal-opts"]?.up || smux["brutal-opts"]?.down) {
|
|
9845
11753
|
proxy.multiplex.brutal = {
|
|
9846
11754
|
enabled: true
|
|
@@ -9868,25 +11776,20 @@ var wsParser = (proxy, parsedProxy) => {
|
|
|
9868
11776
|
} = proxy["ws-opts"];
|
|
9869
11777
|
transport.early_data_header_name = early_data_header_name;
|
|
9870
11778
|
transport.max_early_data = max_early_data ? parseInt(max_early_data, 10) : void 0;
|
|
9871
|
-
if (wsPath !== "")
|
|
9872
|
-
transport.path = `${wsPath}`;
|
|
11779
|
+
if (wsPath !== "") transport.path = `${wsPath}`;
|
|
9873
11780
|
if (Object.keys(wsHeaders).length > 0) {
|
|
9874
11781
|
const headers = {};
|
|
9875
11782
|
for (const key of Object.keys(wsHeaders)) {
|
|
9876
11783
|
let value = wsHeaders[key];
|
|
9877
|
-
if (value === "")
|
|
9878
|
-
|
|
9879
|
-
if (
|
|
9880
|
-
value = [`${value}`];
|
|
9881
|
-
if (value.length > 0)
|
|
9882
|
-
headers[key] = value;
|
|
11784
|
+
if (value === "") continue;
|
|
11785
|
+
if (!Array.isArray(value)) value = [`${value}`];
|
|
11786
|
+
if (value.length > 0) headers[key] = value;
|
|
9883
11787
|
}
|
|
9884
11788
|
const { Host: wsHost } = headers;
|
|
9885
11789
|
if (wsHost.length === 1)
|
|
9886
11790
|
for (const item of `Host:${wsHost[0]}`.split("\n")) {
|
|
9887
11791
|
const [key, value] = item.split(":");
|
|
9888
|
-
if (value.trim() === "")
|
|
9889
|
-
continue;
|
|
11792
|
+
if (value.trim() === "") continue;
|
|
9890
11793
|
headers[key.trim()] = value.trim().split(",");
|
|
9891
11794
|
}
|
|
9892
11795
|
transport.headers = headers;
|
|
@@ -9896,19 +11799,15 @@ var wsParser = (proxy, parsedProxy) => {
|
|
|
9896
11799
|
const headers = {};
|
|
9897
11800
|
for (const key of Object.keys(proxy["ws-headers"])) {
|
|
9898
11801
|
let value = proxy["ws-headers"][key];
|
|
9899
|
-
if (value === "")
|
|
9900
|
-
|
|
9901
|
-
if (
|
|
9902
|
-
value = [`${value}`];
|
|
9903
|
-
if (value.length > 0)
|
|
9904
|
-
headers[key] = value;
|
|
11802
|
+
if (value === "") continue;
|
|
11803
|
+
if (!Array.isArray(value)) value = [`${value}`];
|
|
11804
|
+
if (value.length > 0) headers[key] = value;
|
|
9905
11805
|
}
|
|
9906
11806
|
const { Host: wsHost } = headers;
|
|
9907
11807
|
if (wsHost.length === 1)
|
|
9908
11808
|
for (const item of `Host:${wsHost[0]}`.split("\n")) {
|
|
9909
11809
|
const [key, value] = item.split(":");
|
|
9910
|
-
if (value.trim() === "")
|
|
9911
|
-
continue;
|
|
11810
|
+
if (value.trim() === "") continue;
|
|
9912
11811
|
headers[key.trim()] = value.trim().split(",");
|
|
9913
11812
|
}
|
|
9914
11813
|
for (const key of Object.keys(headers))
|
|
@@ -9932,15 +11831,13 @@ var wsParser = (proxy, parsedProxy) => {
|
|
|
9932
11831
|
transport.host = transport.headers.Host[0];
|
|
9933
11832
|
delete transport.headers.Host;
|
|
9934
11833
|
}
|
|
9935
|
-
if (transport.max_early_data)
|
|
9936
|
-
delete transport.max_early_data;
|
|
11834
|
+
if (transport.max_early_data) delete transport.max_early_data;
|
|
9937
11835
|
if (transport.early_data_header_name)
|
|
9938
11836
|
delete transport.early_data_header_name;
|
|
9939
11837
|
}
|
|
9940
11838
|
for (const key of Object.keys(transport.headers)) {
|
|
9941
11839
|
const value = transport.headers[key];
|
|
9942
|
-
if (value.length === 1)
|
|
9943
|
-
transport.headers[key] = value[0];
|
|
11840
|
+
if (value.length === 1) transport.headers[key] = value[0];
|
|
9944
11841
|
}
|
|
9945
11842
|
parsedProxy.transport = transport;
|
|
9946
11843
|
};
|
|
@@ -9952,52 +11849,43 @@ var h1Parser = (proxy, parsedProxy) => {
|
|
|
9952
11849
|
path: h1Path = "",
|
|
9953
11850
|
headers: h1Headers = {}
|
|
9954
11851
|
} = proxy["http-opts"];
|
|
9955
|
-
if (method !== "")
|
|
9956
|
-
transport.method = method;
|
|
11852
|
+
if (method !== "") transport.method = method;
|
|
9957
11853
|
if (Array.isArray(h1Path)) {
|
|
9958
11854
|
transport.path = `${h1Path[0]}`;
|
|
9959
|
-
} else if (h1Path !== "")
|
|
9960
|
-
transport.path = `${h1Path}`;
|
|
11855
|
+
} else if (h1Path !== "") transport.path = `${h1Path}`;
|
|
9961
11856
|
for (const key of Object.keys(h1Headers)) {
|
|
9962
11857
|
let value = h1Headers[key];
|
|
9963
|
-
if (value === "")
|
|
9964
|
-
continue;
|
|
11858
|
+
if (value === "") continue;
|
|
9965
11859
|
if (key.toLowerCase() === "host") {
|
|
9966
11860
|
let host = value;
|
|
9967
11861
|
if (!Array.isArray(host))
|
|
9968
11862
|
host = `${host}`.split(",").map((i) => i.trim());
|
|
9969
|
-
if (host.length > 0)
|
|
9970
|
-
transport.host = host;
|
|
11863
|
+
if (host.length > 0) transport.host = host;
|
|
9971
11864
|
continue;
|
|
9972
11865
|
}
|
|
9973
11866
|
if (!Array.isArray(value))
|
|
9974
11867
|
value = `${value}`.split(",").map((i) => i.trim());
|
|
9975
|
-
if (value.length > 0)
|
|
9976
|
-
transport.headers[key] = value;
|
|
11868
|
+
if (value.length > 0) transport.headers[key] = value;
|
|
9977
11869
|
}
|
|
9978
11870
|
}
|
|
9979
11871
|
if (proxy["http-host"] && proxy["http-host"] !== "") {
|
|
9980
11872
|
let host = proxy["http-host"];
|
|
9981
11873
|
if (!Array.isArray(host))
|
|
9982
11874
|
host = `${host}`.split(",").map((i) => i.trim());
|
|
9983
|
-
if (host.length > 0)
|
|
9984
|
-
transport.host = host;
|
|
11875
|
+
if (host.length > 0) transport.host = host;
|
|
9985
11876
|
}
|
|
9986
11877
|
if (proxy["http-path"] && proxy["http-path"] !== "") {
|
|
9987
11878
|
const path = proxy["http-path"];
|
|
9988
11879
|
if (Array.isArray(path)) {
|
|
9989
11880
|
transport.path = `${path[0]}`;
|
|
9990
|
-
} else if (path !== "")
|
|
9991
|
-
transport.path = `${path}`;
|
|
11881
|
+
} else if (path !== "") transport.path = `${path}`;
|
|
9992
11882
|
}
|
|
9993
11883
|
if (parsedProxy.tls.insecure)
|
|
9994
11884
|
parsedProxy.tls.server_name = transport.host[0];
|
|
9995
|
-
if (transport.host?.length === 1)
|
|
9996
|
-
transport.host = transport.host[0];
|
|
11885
|
+
if (transport.host?.length === 1) transport.host = transport.host[0];
|
|
9997
11886
|
for (const key of Object.keys(transport.headers)) {
|
|
9998
11887
|
const value = transport.headers[key];
|
|
9999
|
-
if (value.length === 1)
|
|
10000
|
-
transport.headers[key] = value[0];
|
|
11888
|
+
if (value.length === 1) transport.headers[key] = value[0];
|
|
10001
11889
|
}
|
|
10002
11890
|
parsedProxy.transport = transport;
|
|
10003
11891
|
};
|
|
@@ -10005,29 +11893,25 @@ var h2Parser = (proxy, parsedProxy) => {
|
|
|
10005
11893
|
const transport = { type: "http" };
|
|
10006
11894
|
if (proxy["h2-opts"]) {
|
|
10007
11895
|
let { host = "", path = "" } = proxy["h2-opts"];
|
|
10008
|
-
if (path !== "")
|
|
10009
|
-
transport.path = `${path}`;
|
|
11896
|
+
if (path !== "") transport.path = `${path}`;
|
|
10010
11897
|
if (host !== "") {
|
|
10011
11898
|
if (!Array.isArray(host))
|
|
10012
11899
|
host = `${host}`.split(",").map((i) => i.trim());
|
|
10013
|
-
if (host.length > 0)
|
|
10014
|
-
transport.host = host;
|
|
11900
|
+
if (host.length > 0) transport.host = host;
|
|
10015
11901
|
}
|
|
10016
11902
|
}
|
|
10017
11903
|
if (proxy["h2-host"] && proxy["h2-host"] !== "") {
|
|
10018
11904
|
let host = proxy["h2-host"];
|
|
10019
11905
|
if (!Array.isArray(host))
|
|
10020
11906
|
host = `${host}`.split(",").map((i) => i.trim());
|
|
10021
|
-
if (host.length > 0)
|
|
10022
|
-
transport.host = host;
|
|
11907
|
+
if (host.length > 0) transport.host = host;
|
|
10023
11908
|
}
|
|
10024
11909
|
if (proxy["h2-path"] && proxy["h2-path"] !== "")
|
|
10025
11910
|
transport.path = `${proxy["h2-path"]}`;
|
|
10026
11911
|
parsedProxy.tls.enabled = true;
|
|
10027
11912
|
if (parsedProxy.tls.insecure)
|
|
10028
11913
|
parsedProxy.tls.server_name = transport.host[0];
|
|
10029
|
-
if (transport.host.length === 1)
|
|
10030
|
-
transport.host = transport.host[0];
|
|
11914
|
+
if (transport.host.length === 1) transport.host = transport.host[0];
|
|
10031
11915
|
parsedProxy.transport = transport;
|
|
10032
11916
|
};
|
|
10033
11917
|
var grpcParser = (proxy, parsedProxy) => {
|
|
@@ -10044,16 +11928,13 @@ var normalizePemLines = (value, label) => {
|
|
|
10044
11928
|
const lines = [];
|
|
10045
11929
|
for (const item of items) {
|
|
10046
11930
|
const normalized = `${item}`.trim().replace(/\\r\\n/g, "\n").replace(/\\n/g, "\n");
|
|
10047
|
-
if (normalized === "")
|
|
10048
|
-
continue;
|
|
11931
|
+
if (normalized === "") continue;
|
|
10049
11932
|
for (const line of normalized.split(/\r?\n/)) {
|
|
10050
11933
|
const trimmed = line.trim();
|
|
10051
|
-
if (trimmed !== "")
|
|
10052
|
-
lines.push(trimmed);
|
|
11934
|
+
if (trimmed !== "") lines.push(trimmed);
|
|
10053
11935
|
}
|
|
10054
11936
|
}
|
|
10055
|
-
if (lines.length === 0)
|
|
10056
|
-
return void 0;
|
|
11937
|
+
if (lines.length === 0) return void 0;
|
|
10057
11938
|
if (lines.some((line) => /^-----BEGIN [A-Za-z0-9 -]+-----$/.test(line))) {
|
|
10058
11939
|
return lines;
|
|
10059
11940
|
}
|
|
@@ -10073,34 +11954,24 @@ var singBoxUtlsFingerprints = [
|
|
|
10073
11954
|
];
|
|
10074
11955
|
var getSingBoxUtlsFingerprint = (value) => {
|
|
10075
11956
|
const fingerprint = `${value || ""}`.trim().toLowerCase();
|
|
10076
|
-
if (singBoxUtlsFingerprints.includes(fingerprint))
|
|
10077
|
-
return fingerprint;
|
|
11957
|
+
if (singBoxUtlsFingerprints.includes(fingerprint)) return fingerprint;
|
|
10078
11958
|
};
|
|
10079
11959
|
var tlsParser = (proxy, parsedProxy) => {
|
|
10080
|
-
if (proxy.tls)
|
|
10081
|
-
parsedProxy.tls.enabled = true;
|
|
11960
|
+
if (proxy.tls) parsedProxy.tls.enabled = true;
|
|
10082
11961
|
if (proxy.servername && proxy.servername !== "")
|
|
10083
11962
|
parsedProxy.tls.server_name = proxy.servername;
|
|
10084
11963
|
if (proxy.peer && proxy.peer !== "")
|
|
10085
11964
|
parsedProxy.tls.server_name = proxy.peer;
|
|
10086
|
-
if (proxy.sni && proxy.sni !== "")
|
|
10087
|
-
|
|
10088
|
-
if (proxy
|
|
10089
|
-
|
|
10090
|
-
if (proxy.insecure)
|
|
10091
|
-
parsedProxy.tls.insecure = true;
|
|
10092
|
-
if (proxy["disable-sni"])
|
|
10093
|
-
parsedProxy.tls.disable_sni = true;
|
|
11965
|
+
if (proxy.sni && proxy.sni !== "") parsedProxy.tls.server_name = proxy.sni;
|
|
11966
|
+
if (proxy["skip-cert-verify"]) parsedProxy.tls.insecure = true;
|
|
11967
|
+
if (proxy.insecure) parsedProxy.tls.insecure = true;
|
|
11968
|
+
if (proxy["disable-sni"]) parsedProxy.tls.disable_sni = true;
|
|
10094
11969
|
if (typeof proxy.alpn === "string") {
|
|
10095
11970
|
parsedProxy.tls.alpn = [proxy.alpn];
|
|
10096
|
-
} else if (Array.isArray(proxy.alpn))
|
|
10097
|
-
|
|
10098
|
-
if (proxy.
|
|
10099
|
-
|
|
10100
|
-
if (proxy.ca_str)
|
|
10101
|
-
parsedProxy.tls.certificate = [proxy.ca_str];
|
|
10102
|
-
if (proxy["ca-str"])
|
|
10103
|
-
parsedProxy.tls.certificate = [proxy["ca-str"]];
|
|
11971
|
+
} else if (Array.isArray(proxy.alpn)) parsedProxy.tls.alpn = proxy.alpn;
|
|
11972
|
+
if (proxy.ca) parsedProxy.tls.certificate_path = `${proxy.ca}`;
|
|
11973
|
+
if (proxy.ca_str) parsedProxy.tls.certificate = [proxy.ca_str];
|
|
11974
|
+
if (proxy["ca-str"]) parsedProxy.tls.certificate = [proxy["ca-str"]];
|
|
10104
11975
|
if (proxy["reality-opts"]) {
|
|
10105
11976
|
parsedProxy.tls.reality = { enabled: true };
|
|
10106
11977
|
if (proxy["reality-opts"]["public-key"])
|
|
@@ -10128,8 +11999,7 @@ var tlsParser = (proxy, parsedProxy) => {
|
|
|
10128
11999
|
const echOptsConfig = proxy["ech-opts"].config;
|
|
10129
12000
|
if (Array.isArray(echOptsConfig) || typeof echOptsConfig === "string") {
|
|
10130
12001
|
const config = normalizePemLines(echOptsConfig, "ECH CONFIGS");
|
|
10131
|
-
if (config)
|
|
10132
|
-
parsedProxy.tls.ech.config = config;
|
|
12002
|
+
if (config) parsedProxy.tls.ech.config = config;
|
|
10133
12003
|
}
|
|
10134
12004
|
parsedProxy.tls.ech.query_server_name = proxy["ech-opts"]["query-server-name"];
|
|
10135
12005
|
parsedProxy.tls.ech.config_path = proxy["ech-opts"]["config-path"];
|
|
@@ -10140,8 +12010,7 @@ var tlsParser = (proxy, parsedProxy) => {
|
|
|
10140
12010
|
if (proxy._curve_preferences && Array.isArray(proxy._curve_preferences)) {
|
|
10141
12011
|
parsedProxy.tls.curve_preferences = proxy._curve_preferences;
|
|
10142
12012
|
}
|
|
10143
|
-
if (proxy["_fragment"])
|
|
10144
|
-
parsedProxy.tls.fragment = !!proxy["_fragment"];
|
|
12013
|
+
if (proxy["_fragment"]) parsedProxy.tls.fragment = !!proxy["_fragment"];
|
|
10145
12014
|
if (proxy["_fragment_fallback_delay"])
|
|
10146
12015
|
parsedProxy.tls.fragment_fallback_delay = proxy["_fragment_fallback_delay"];
|
|
10147
12016
|
if (proxy["_record_fragment"])
|
|
@@ -10156,12 +12025,16 @@ var tlsParser = (proxy, parsedProxy) => {
|
|
|
10156
12025
|
parsedProxy.tls.client_certificate = proxy["_client_certificate"];
|
|
10157
12026
|
if (proxy["_client_certificate_path"])
|
|
10158
12027
|
parsedProxy.tls.client_certificate_path = proxy["_client_certificate_path"];
|
|
10159
|
-
if (proxy["_client_key"])
|
|
10160
|
-
parsedProxy.tls.client_key = proxy["_client_key"];
|
|
12028
|
+
if (proxy["_client_key"]) parsedProxy.tls.client_key = proxy["_client_key"];
|
|
10161
12029
|
if (proxy["_client_key_path"])
|
|
10162
12030
|
parsedProxy.tls.client_key_path = proxy["_client_key_path"];
|
|
10163
|
-
if (!parsedProxy.tls.enabled)
|
|
12031
|
+
if (!parsedProxy.tls.enabled) {
|
|
10164
12032
|
delete parsedProxy.tls;
|
|
12033
|
+
} else if ((proxy.fingerprint || proxy["tls-fingerprint"]) && !parsedProxy.tls.reality && !parsedProxy.tls.certificate && !parsedProxy.tls.certificate_path && !parsedProxy.tls.certificate_public_key_sha256) {
|
|
12034
|
+
app_default.warn(
|
|
12035
|
+
`Platform sing-box does not support certificate fingerprint pinning, it is dropped for proxy ${proxy.name}. Set _certificate_public_key_sha256 to pin the certificate public key instead`
|
|
12036
|
+
);
|
|
12037
|
+
}
|
|
10165
12038
|
};
|
|
10166
12039
|
var sshParser = (proxy = {}) => {
|
|
10167
12040
|
const parsedProxy = {
|
|
@@ -10172,12 +12045,9 @@ var sshParser = (proxy = {}) => {
|
|
|
10172
12045
|
};
|
|
10173
12046
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10174
12047
|
throw "invalid port";
|
|
10175
|
-
if (proxy.username)
|
|
10176
|
-
|
|
10177
|
-
if (proxy.
|
|
10178
|
-
parsedProxy.password = proxy.password;
|
|
10179
|
-
if (proxy["privateKey"])
|
|
10180
|
-
parsedProxy.private_key_path = proxy["privateKey"];
|
|
12048
|
+
if (proxy.username) parsedProxy.user = proxy.username;
|
|
12049
|
+
if (proxy.password) parsedProxy.password = proxy.password;
|
|
12050
|
+
if (proxy["privateKey"]) parsedProxy.private_key_path = proxy["privateKey"];
|
|
10181
12051
|
if (proxy["private-key"])
|
|
10182
12052
|
parsedProxy.private_key_path = proxy["private-key"];
|
|
10183
12053
|
if (proxy["private-key-passphrase"])
|
|
@@ -10188,12 +12058,10 @@ var sshParser = (proxy = {}) => {
|
|
|
10188
12058
|
proxy["server-fingerprint"].split(" ")[0]
|
|
10189
12059
|
];
|
|
10190
12060
|
}
|
|
10191
|
-
if (proxy["host-key"])
|
|
10192
|
-
parsedProxy.host_key = proxy["host-key"];
|
|
12061
|
+
if (proxy["host-key"]) parsedProxy.host_key = proxy["host-key"];
|
|
10193
12062
|
if (proxy["host-key-algorithms"])
|
|
10194
12063
|
parsedProxy.host_key_algorithms = proxy["host-key-algorithms"];
|
|
10195
|
-
if (proxy["fast-open"])
|
|
10196
|
-
parsedProxy.udp_fragment = true;
|
|
12064
|
+
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
10197
12065
|
tfoParser(proxy, parsedProxy);
|
|
10198
12066
|
detourParser(proxy, parsedProxy);
|
|
10199
12067
|
ipVersionParser(proxy, parsedProxy);
|
|
@@ -10210,10 +12078,8 @@ var httpParser = (proxy = {}) => {
|
|
|
10210
12078
|
};
|
|
10211
12079
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10212
12080
|
throw "invalid port";
|
|
10213
|
-
if (proxy.username)
|
|
10214
|
-
|
|
10215
|
-
if (proxy.password)
|
|
10216
|
-
parsedProxy.password = proxy.password;
|
|
12081
|
+
if (proxy.username) parsedProxy.username = proxy.username;
|
|
12082
|
+
if (proxy.password) parsedProxy.password = proxy.password;
|
|
10217
12083
|
if (proxy.headers) {
|
|
10218
12084
|
parsedProxy.headers = {};
|
|
10219
12085
|
for (const k of Object.keys(proxy.headers)) {
|
|
@@ -10222,8 +12088,7 @@ var httpParser = (proxy = {}) => {
|
|
|
10222
12088
|
if (Object.keys(parsedProxy.headers).length === 0)
|
|
10223
12089
|
delete parsedProxy.headers;
|
|
10224
12090
|
}
|
|
10225
|
-
if (proxy["fast-open"])
|
|
10226
|
-
parsedProxy.udp_fragment = true;
|
|
12091
|
+
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
10227
12092
|
tfoParser(proxy, parsedProxy);
|
|
10228
12093
|
detourParser(proxy, parsedProxy);
|
|
10229
12094
|
tlsParser(proxy, parsedProxy);
|
|
@@ -10241,20 +12106,16 @@ var socks5Parser = (proxy = {}) => {
|
|
|
10241
12106
|
};
|
|
10242
12107
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10243
12108
|
throw "invalid port";
|
|
10244
|
-
if (proxy.username)
|
|
10245
|
-
|
|
10246
|
-
if (proxy.
|
|
10247
|
-
parsedProxy.password = proxy.password;
|
|
10248
|
-
if (proxy.uot)
|
|
10249
|
-
parsedProxy.udp_over_tcp = true;
|
|
12109
|
+
if (proxy.username) parsedProxy.username = proxy.username;
|
|
12110
|
+
if (proxy.password) parsedProxy.password = proxy.password;
|
|
12111
|
+
if (proxy.uot) parsedProxy.udp_over_tcp = true;
|
|
10250
12112
|
if (proxy["udp-over-tcp"]) {
|
|
10251
12113
|
parsedProxy.udp_over_tcp = {
|
|
10252
12114
|
enabled: true,
|
|
10253
12115
|
version: !proxy["udp-over-tcp-version"] || proxy["udp-over-tcp-version"] === 1 ? 1 : 2
|
|
10254
12116
|
};
|
|
10255
12117
|
}
|
|
10256
|
-
if (proxy["fast-open"])
|
|
10257
|
-
parsedProxy.udp_fragment = true;
|
|
12118
|
+
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
10258
12119
|
networkParser(proxy, parsedProxy);
|
|
10259
12120
|
tfoParser(proxy, parsedProxy);
|
|
10260
12121
|
detourParser(proxy, parsedProxy);
|
|
@@ -10271,8 +12132,7 @@ var shadowTLSParser = (proxy = {}) => {
|
|
|
10271
12132
|
password: proxy.password,
|
|
10272
12133
|
detour: getShadowTLSTag(proxy)
|
|
10273
12134
|
};
|
|
10274
|
-
if (proxy.uot)
|
|
10275
|
-
ssPart.udp_over_tcp = true;
|
|
12135
|
+
if (proxy.uot) ssPart.udp_over_tcp = true;
|
|
10276
12136
|
if (proxy["udp-over-tcp"]) {
|
|
10277
12137
|
ssPart.udp_over_tcp = {
|
|
10278
12138
|
enabled: true,
|
|
@@ -10306,13 +12166,11 @@ var normalizeALPN = (alpn) => {
|
|
|
10306
12166
|
if (typeof alpn === "string") {
|
|
10307
12167
|
return alpn.split(",").map((item) => item.trim()).filter((item) => item !== "");
|
|
10308
12168
|
}
|
|
10309
|
-
if (Array.isArray(alpn))
|
|
10310
|
-
return alpn;
|
|
12169
|
+
if (Array.isArray(alpn)) return alpn;
|
|
10311
12170
|
return void 0;
|
|
10312
12171
|
};
|
|
10313
12172
|
var shadowTLSOutboundParser = (proxy = {}, pluginOpts) => {
|
|
10314
|
-
if (!pluginOpts)
|
|
10315
|
-
throw new Error("shadow-tls plugin options are missing");
|
|
12173
|
+
if (!pluginOpts) throw new Error("shadow-tls plugin options are missing");
|
|
10316
12174
|
const fingerprint = getSingBoxUtlsFingerprint(proxy["client-fingerprint"]);
|
|
10317
12175
|
const stPart = {
|
|
10318
12176
|
tag: getShadowTLSTag(proxy),
|
|
@@ -10326,8 +12184,7 @@ var shadowTLSOutboundParser = (proxy = {}, pluginOpts) => {
|
|
|
10326
12184
|
server_name: pluginOpts.host
|
|
10327
12185
|
}
|
|
10328
12186
|
};
|
|
10329
|
-
if (proxy["skip-cert-verify"])
|
|
10330
|
-
stPart.tls.insecure = true;
|
|
12187
|
+
if (proxy["skip-cert-verify"]) stPart.tls.insecure = true;
|
|
10331
12188
|
if (fingerprint) {
|
|
10332
12189
|
stPart.tls.utls = {
|
|
10333
12190
|
enabled: true,
|
|
@@ -10337,10 +12194,8 @@ var shadowTLSOutboundParser = (proxy = {}, pluginOpts) => {
|
|
|
10337
12194
|
if (stPart.server_port < 0 || stPart.server_port > 65535)
|
|
10338
12195
|
throw "\u7AEF\u53E3\u503C\u975E\u6CD5";
|
|
10339
12196
|
const alpn = normalizeALPN(pluginOpts.alpn) ?? normalizeALPN(proxy.alpn);
|
|
10340
|
-
if (alpn)
|
|
10341
|
-
|
|
10342
|
-
if (proxy["fast-open"] === true)
|
|
10343
|
-
stPart.udp_fragment = true;
|
|
12197
|
+
if (alpn) stPart.tls.alpn = alpn;
|
|
12198
|
+
if (proxy["fast-open"] === true) stPart.udp_fragment = true;
|
|
10344
12199
|
tfoParser(proxy, stPart);
|
|
10345
12200
|
detourParser(proxy, stPart);
|
|
10346
12201
|
ipVersionParser(proxy, stPart);
|
|
@@ -10358,16 +12213,14 @@ var ssParser = (proxy = {}) => {
|
|
|
10358
12213
|
};
|
|
10359
12214
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10360
12215
|
throw "invalid port";
|
|
10361
|
-
if (proxy.uot)
|
|
10362
|
-
parsedProxy.udp_over_tcp = true;
|
|
12216
|
+
if (proxy.uot) parsedProxy.udp_over_tcp = true;
|
|
10363
12217
|
if (proxy["udp-over-tcp"]) {
|
|
10364
12218
|
parsedProxy.udp_over_tcp = {
|
|
10365
12219
|
enabled: true,
|
|
10366
12220
|
version: !proxy["udp-over-tcp-version"] || proxy["udp-over-tcp-version"] === 1 ? 1 : 2
|
|
10367
12221
|
};
|
|
10368
12222
|
}
|
|
10369
|
-
if (proxy["fast-open"])
|
|
10370
|
-
parsedProxy.udp_fragment = true;
|
|
12223
|
+
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
10371
12224
|
networkParser(proxy, parsedProxy);
|
|
10372
12225
|
tfoParser(proxy, parsedProxy);
|
|
10373
12226
|
detourParser(proxy, parsedProxy);
|
|
@@ -10397,15 +12250,12 @@ var ssParser = (proxy = {}) => {
|
|
|
10397
12250
|
}
|
|
10398
12251
|
if (proxy.plugin === "v2ray-plugin") {
|
|
10399
12252
|
parsedProxy.plugin = "v2ray-plugin";
|
|
10400
|
-
if (proxy["ws-host"])
|
|
10401
|
-
|
|
10402
|
-
if (proxy["ws-path"])
|
|
10403
|
-
proxy["plugin-opts"].path = proxy["ws-path"];
|
|
12253
|
+
if (proxy["ws-host"]) proxy["plugin-opts"].host = proxy["ws-host"];
|
|
12254
|
+
if (proxy["ws-path"]) proxy["plugin-opts"].path = proxy["ws-path"];
|
|
10404
12255
|
Object.keys(proxy["plugin-opts"]).forEach((k) => {
|
|
10405
12256
|
switch (k) {
|
|
10406
12257
|
case "tls":
|
|
10407
|
-
if (proxy["plugin-opts"].tls)
|
|
10408
|
-
optArr.push("tls");
|
|
12258
|
+
if (proxy["plugin-opts"].tls) optArr.push("tls");
|
|
10409
12259
|
break;
|
|
10410
12260
|
case "host":
|
|
10411
12261
|
optArr.push(`host=${proxy["plugin-opts"].host}`);
|
|
@@ -10424,8 +12274,7 @@ var ssParser = (proxy = {}) => {
|
|
|
10424
12274
|
const mux = normalizePluginMuxValue(
|
|
10425
12275
|
proxy["plugin-opts"].mux
|
|
10426
12276
|
);
|
|
10427
|
-
if (mux)
|
|
10428
|
-
parsedProxy.multiplex = { enabled: true };
|
|
12277
|
+
if (mux) parsedProxy.multiplex = { enabled: true };
|
|
10429
12278
|
optArr.push(`mux=${mux}`);
|
|
10430
12279
|
break;
|
|
10431
12280
|
}
|
|
@@ -10451,12 +12300,10 @@ var ssrParser = (proxy = {}) => {
|
|
|
10451
12300
|
};
|
|
10452
12301
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10453
12302
|
throw "invalid port";
|
|
10454
|
-
if (proxy["obfs-param"])
|
|
10455
|
-
parsedProxy.obfs_param = proxy["obfs-param"];
|
|
12303
|
+
if (proxy["obfs-param"]) parsedProxy.obfs_param = proxy["obfs-param"];
|
|
10456
12304
|
if (proxy["protocol-param"] && proxy["protocol-param"] !== "")
|
|
10457
12305
|
parsedProxy.protocol_param = proxy["protocol-param"];
|
|
10458
|
-
if (proxy["fast-open"])
|
|
10459
|
-
parsedProxy.udp_fragment = true;
|
|
12306
|
+
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
10460
12307
|
networkParser(proxy, parsedProxy);
|
|
10461
12308
|
tfoParser(proxy, parsedProxy);
|
|
10462
12309
|
detourParser(proxy, parsedProxy);
|
|
@@ -10466,11 +12313,9 @@ var ssrParser = (proxy = {}) => {
|
|
|
10466
12313
|
return parsedProxy;
|
|
10467
12314
|
};
|
|
10468
12315
|
var getSnellVersion = (version) => {
|
|
10469
|
-
if (version == null)
|
|
10470
|
-
return void 0;
|
|
12316
|
+
if (version == null) return void 0;
|
|
10471
12317
|
const normalized = `${version}`.trim();
|
|
10472
|
-
if (!/^\d+$/.test(normalized))
|
|
10473
|
-
return NaN;
|
|
12318
|
+
if (!/^\d+$/.test(normalized)) return NaN;
|
|
10474
12319
|
return parseInt(normalized, 10);
|
|
10475
12320
|
};
|
|
10476
12321
|
var snellParser = (proxy = {}, includeUnsupportedProxy = false) => {
|
|
@@ -10492,13 +12337,10 @@ var snellParser = (proxy = {}, includeUnsupportedProxy = false) => {
|
|
|
10492
12337
|
};
|
|
10493
12338
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10494
12339
|
throw "invalid port";
|
|
10495
|
-
if (outputVersion != null)
|
|
10496
|
-
|
|
10497
|
-
if (proxy._userkey)
|
|
10498
|
-
parsedProxy.userkey = proxy._userkey;
|
|
12340
|
+
if (outputVersion != null) parsedProxy.version = outputVersion;
|
|
12341
|
+
if (proxy._userkey) parsedProxy.userkey = proxy._userkey;
|
|
10499
12342
|
if (outputVersion === 6) {
|
|
10500
|
-
if (proxy.mode)
|
|
10501
|
-
parsedProxy.mode = proxy.mode;
|
|
12343
|
+
if (proxy.mode) parsedProxy.mode = proxy.mode;
|
|
10502
12344
|
if (includeUnsupportedProxy && proxy["quic-proxy-mode"])
|
|
10503
12345
|
parsedProxy.quic_proxy_mode = !!proxy["quic-proxy-mode"];
|
|
10504
12346
|
} else {
|
|
@@ -10515,8 +12357,7 @@ var snellParser = (proxy = {}, includeUnsupportedProxy = false) => {
|
|
|
10515
12357
|
delete parsedProxy.server;
|
|
10516
12358
|
delete parsedProxy.server_port;
|
|
10517
12359
|
} else {
|
|
10518
|
-
if (proxy["fast-open"])
|
|
10519
|
-
parsedProxy.udp_fragment = true;
|
|
12360
|
+
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
10520
12361
|
tfoParser(proxy, parsedProxy);
|
|
10521
12362
|
detourParser(proxy, parsedProxy);
|
|
10522
12363
|
ipVersionParser(proxy, parsedProxy);
|
|
@@ -10568,16 +12409,11 @@ var vmessParser = (proxy = {}) => {
|
|
|
10568
12409
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10569
12410
|
throw "invalid port";
|
|
10570
12411
|
vmessProtocolOptionsParser(proxy, parsedProxy);
|
|
10571
|
-
if (proxy["fast-open"])
|
|
10572
|
-
|
|
10573
|
-
if (proxy.network === "
|
|
10574
|
-
|
|
10575
|
-
if (proxy.network === "
|
|
10576
|
-
h2Parser(proxy, parsedProxy);
|
|
10577
|
-
if (proxy.network === "http")
|
|
10578
|
-
h1Parser(proxy, parsedProxy);
|
|
10579
|
-
if (proxy.network === "grpc")
|
|
10580
|
-
grpcParser(proxy, parsedProxy);
|
|
12412
|
+
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
12413
|
+
if (proxy.network === "ws") wsParser(proxy, parsedProxy);
|
|
12414
|
+
if (proxy.network === "h2") h2Parser(proxy, parsedProxy);
|
|
12415
|
+
if (proxy.network === "http") h1Parser(proxy, parsedProxy);
|
|
12416
|
+
if (proxy.network === "grpc") grpcParser(proxy, parsedProxy);
|
|
10581
12417
|
networkParser(proxy, parsedProxy);
|
|
10582
12418
|
tfoParser(proxy, parsedProxy);
|
|
10583
12419
|
detourParser(proxy, parsedProxy);
|
|
@@ -10599,18 +12435,12 @@ var vlessParser = (proxy = {}) => {
|
|
|
10599
12435
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10600
12436
|
throw "invalid port";
|
|
10601
12437
|
vmessVlessPacketEncodingParser(proxy, parsedProxy);
|
|
10602
|
-
if (proxy["fast-open"])
|
|
10603
|
-
|
|
10604
|
-
if (proxy.
|
|
10605
|
-
|
|
10606
|
-
if (proxy.network === "
|
|
10607
|
-
|
|
10608
|
-
if (proxy.network === "h2")
|
|
10609
|
-
h2Parser(proxy, parsedProxy);
|
|
10610
|
-
if (proxy.network === "http")
|
|
10611
|
-
h1Parser(proxy, parsedProxy);
|
|
10612
|
-
if (proxy.network === "grpc")
|
|
10613
|
-
grpcParser(proxy, parsedProxy);
|
|
12438
|
+
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
12439
|
+
if (proxy.flow != null) parsedProxy.flow = proxy.flow;
|
|
12440
|
+
if (proxy.network === "ws") wsParser(proxy, parsedProxy);
|
|
12441
|
+
if (proxy.network === "h2") h2Parser(proxy, parsedProxy);
|
|
12442
|
+
if (proxy.network === "http") h1Parser(proxy, parsedProxy);
|
|
12443
|
+
if (proxy.network === "grpc") grpcParser(proxy, parsedProxy);
|
|
10614
12444
|
networkParser(proxy, parsedProxy);
|
|
10615
12445
|
tfoParser(proxy, parsedProxy);
|
|
10616
12446
|
detourParser(proxy, parsedProxy);
|
|
@@ -10631,12 +12461,9 @@ var trojanParser = (proxy = {}) => {
|
|
|
10631
12461
|
};
|
|
10632
12462
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10633
12463
|
throw "invalid port";
|
|
10634
|
-
if (proxy["fast-open"])
|
|
10635
|
-
|
|
10636
|
-
if (proxy.network === "
|
|
10637
|
-
grpcParser(proxy, parsedProxy);
|
|
10638
|
-
if (proxy.network === "ws")
|
|
10639
|
-
wsParser(proxy, parsedProxy);
|
|
12464
|
+
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
12465
|
+
if (proxy.network === "grpc") grpcParser(proxy, parsedProxy);
|
|
12466
|
+
if (proxy.network === "ws") wsParser(proxy, parsedProxy);
|
|
10640
12467
|
networkParser(proxy, parsedProxy);
|
|
10641
12468
|
tfoParser(proxy, parsedProxy);
|
|
10642
12469
|
detourParser(proxy, parsedProxy);
|
|
@@ -10656,12 +12483,9 @@ var naiveParser = (proxy = {}) => {
|
|
|
10656
12483
|
};
|
|
10657
12484
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10658
12485
|
throw "invalid port";
|
|
10659
|
-
if (proxy.username)
|
|
10660
|
-
|
|
10661
|
-
if (proxy.
|
|
10662
|
-
parsedProxy.password = proxy.password;
|
|
10663
|
-
if (proxy.uot)
|
|
10664
|
-
parsedProxy.udp_over_tcp = true;
|
|
12486
|
+
if (proxy.username) parsedProxy.username = proxy.username;
|
|
12487
|
+
if (proxy.password) parsedProxy.password = proxy.password;
|
|
12488
|
+
if (proxy.uot) parsedProxy.udp_over_tcp = true;
|
|
10665
12489
|
if (proxy["udp-over-tcp"]) {
|
|
10666
12490
|
parsedProxy.udp_over_tcp = {
|
|
10667
12491
|
enabled: true,
|
|
@@ -10676,12 +12500,10 @@ var naiveParser = (proxy = {}) => {
|
|
|
10676
12500
|
parsedProxy.insecure_concurrency = insecure_concurrency;
|
|
10677
12501
|
if (proxy["extra-headers"])
|
|
10678
12502
|
parsedProxy.extra_headers = proxy["extra-headers"];
|
|
10679
|
-
if (proxy.quic)
|
|
10680
|
-
parsedProxy.quic = !!proxy.quic;
|
|
12503
|
+
if (proxy.quic) parsedProxy.quic = !!proxy.quic;
|
|
10681
12504
|
if (proxy["quic-congestion-control"])
|
|
10682
12505
|
parsedProxy.quic_congestion_control = proxy["quic-congestion-control"];
|
|
10683
|
-
if (proxy["fast-open"])
|
|
10684
|
-
parsedProxy.udp_fragment = true;
|
|
12506
|
+
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
10685
12507
|
tfoParser(proxy, parsedProxy);
|
|
10686
12508
|
detourParser(proxy, parsedProxy);
|
|
10687
12509
|
tlsParser(proxy, parsedProxy);
|
|
@@ -10714,12 +12536,9 @@ var hysteriaParser = (proxy = {}) => {
|
|
|
10714
12536
|
const range = p.replace(/\s*-\s*/g, ":");
|
|
10715
12537
|
return range.includes(":") ? range : `${range}:${range}`;
|
|
10716
12538
|
});
|
|
10717
|
-
if (proxy.auth_str)
|
|
10718
|
-
|
|
10719
|
-
if (proxy["
|
|
10720
|
-
parsedProxy.auth_str = `${proxy["auth-str"]}`;
|
|
10721
|
-
if (proxy["fast-open"])
|
|
10722
|
-
parsedProxy.udp_fragment = true;
|
|
12539
|
+
if (proxy.auth_str) parsedProxy.auth_str = `${proxy.auth_str}`;
|
|
12540
|
+
if (proxy["auth-str"]) parsedProxy.auth_str = `${proxy["auth-str"]}`;
|
|
12541
|
+
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
10723
12542
|
const reg = new RegExp("^[0-9]+[ ]*[KMGT]*[Bb]ps$");
|
|
10724
12543
|
if (reg.test(`${proxy.up}`) && !`${proxy.up}`.endsWith("Mbps")) {
|
|
10725
12544
|
parsedProxy.up = `${proxy.up}`;
|
|
@@ -10731,16 +12550,13 @@ var hysteriaParser = (proxy = {}) => {
|
|
|
10731
12550
|
} else {
|
|
10732
12551
|
parsedProxy.down_mbps = parseInt(`${proxy.down}`, 10);
|
|
10733
12552
|
}
|
|
10734
|
-
if (proxy.obfs)
|
|
10735
|
-
parsedProxy.obfs = proxy.obfs;
|
|
12553
|
+
if (proxy.obfs) parsedProxy.obfs = proxy.obfs;
|
|
10736
12554
|
if (proxy.recv_window_conn)
|
|
10737
12555
|
parsedProxy.recv_window_conn = proxy.recv_window_conn;
|
|
10738
12556
|
if (proxy["recv-window-conn"])
|
|
10739
12557
|
parsedProxy.recv_window_conn = proxy["recv-window-conn"];
|
|
10740
|
-
if (proxy.recv_window)
|
|
10741
|
-
|
|
10742
|
-
if (proxy["recv-window"])
|
|
10743
|
-
parsedProxy.recv_window = proxy["recv-window"];
|
|
12558
|
+
if (proxy.recv_window) parsedProxy.recv_window = proxy.recv_window;
|
|
12559
|
+
if (proxy["recv-window"]) parsedProxy.recv_window = proxy["recv-window"];
|
|
10744
12560
|
if (proxy.disable_mtu_discovery) {
|
|
10745
12561
|
if (typeof proxy.disable_mtu_discovery === "boolean") {
|
|
10746
12562
|
parsedProxy.disable_mtu_discovery = proxy.disable_mtu_discovery;
|
|
@@ -10777,10 +12593,8 @@ var hysteria2Parser = (proxy = {}) => {
|
|
|
10777
12593
|
const range = p.replace(/\s*-\s*/g, ":");
|
|
10778
12594
|
return range.includes(":") ? range : `${range}:${range}`;
|
|
10779
12595
|
});
|
|
10780
|
-
if (proxy.up)
|
|
10781
|
-
|
|
10782
|
-
if (proxy.down)
|
|
10783
|
-
parsedProxy.down_mbps = parseInt(`${proxy.down}`, 10);
|
|
12596
|
+
if (proxy.up) parsedProxy.up_mbps = parseInt(`${proxy.up}`, 10);
|
|
12597
|
+
if (proxy.down) parsedProxy.down_mbps = parseInt(`${proxy.down}`, 10);
|
|
10784
12598
|
if (["salamander", "gecko"].includes(proxy.obfs))
|
|
10785
12599
|
parsedProxy.obfs.type = proxy.obfs;
|
|
10786
12600
|
if (proxy.obfs === "gecko") {
|
|
@@ -10804,19 +12618,15 @@ var hysteria2Parser = (proxy = {}) => {
|
|
|
10804
12618
|
`Invalid obfs packet size for proxy ${proxy.name}: min=${minRaw} max=${maxRaw}`
|
|
10805
12619
|
);
|
|
10806
12620
|
} else {
|
|
10807
|
-
if (hasMin)
|
|
10808
|
-
|
|
10809
|
-
if (hasMax)
|
|
10810
|
-
parsedProxy.obfs.max_packet_size = maxPacketSize;
|
|
12621
|
+
if (hasMin) parsedProxy.obfs.min_packet_size = minPacketSize;
|
|
12622
|
+
if (hasMax) parsedProxy.obfs.max_packet_size = maxPacketSize;
|
|
10811
12623
|
}
|
|
10812
12624
|
}
|
|
10813
12625
|
}
|
|
10814
12626
|
if (proxy["obfs-password"])
|
|
10815
12627
|
parsedProxy.obfs.password = proxy["obfs-password"];
|
|
10816
|
-
if (!parsedProxy.obfs.type)
|
|
10817
|
-
|
|
10818
|
-
if (proxy["bbr-profile"])
|
|
10819
|
-
parsedProxy.bbr_profile = proxy["bbr-profile"];
|
|
12628
|
+
if (!parsedProxy.obfs.type) delete parsedProxy.obfs;
|
|
12629
|
+
if (proxy["bbr-profile"]) parsedProxy.bbr_profile = proxy["bbr-profile"];
|
|
10820
12630
|
if (proxy["disable-chrome-parrot"])
|
|
10821
12631
|
parsedProxy.disable_chrome_parrot = !!proxy["disable-chrome-parrot"];
|
|
10822
12632
|
networkParser(proxy, parsedProxy);
|
|
@@ -10840,16 +12650,13 @@ var tuic5Parser = (proxy = {}) => {
|
|
|
10840
12650
|
};
|
|
10841
12651
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10842
12652
|
throw "invalid port";
|
|
10843
|
-
if (proxy["fast-open"])
|
|
10844
|
-
parsedProxy.udp_fragment = true;
|
|
12653
|
+
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
10845
12654
|
if (proxy["congestion-controller"] && proxy["congestion-controller"] !== "cubic")
|
|
10846
12655
|
parsedProxy.congestion_control = proxy["congestion-controller"];
|
|
10847
12656
|
if (proxy["udp-relay-mode"] && proxy["udp-relay-mode"] !== "native")
|
|
10848
12657
|
parsedProxy.udp_relay_mode = proxy["udp-relay-mode"];
|
|
10849
|
-
if (proxy["reduce-rtt"])
|
|
10850
|
-
|
|
10851
|
-
if (proxy["udp-over-stream"])
|
|
10852
|
-
parsedProxy.udp_over_stream = true;
|
|
12658
|
+
if (proxy["reduce-rtt"]) parsedProxy.zero_rtt_handshake = true;
|
|
12659
|
+
if (proxy["udp-over-stream"]) parsedProxy.udp_over_stream = true;
|
|
10853
12660
|
if (proxy["heartbeat-interval"])
|
|
10854
12661
|
parsedProxy.heartbeat = `${proxy["heartbeat-interval"]}ms`;
|
|
10855
12662
|
networkParser(proxy, parsedProxy);
|
|
@@ -10960,13 +12767,11 @@ var wireguardParser = (proxy = {}) => {
|
|
|
10960
12767
|
};
|
|
10961
12768
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10962
12769
|
throw "invalid port";
|
|
10963
|
-
if (proxy["fast-open"])
|
|
10964
|
-
parsedProxy.udp_fragment = true;
|
|
12770
|
+
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
10965
12771
|
if (typeof proxy.reserved === "string") {
|
|
10966
12772
|
parsedProxy.reserved = proxy.reserved;
|
|
10967
12773
|
} else if (Array.isArray(proxy.reserved)) {
|
|
10968
|
-
for (const r of proxy.reserved)
|
|
10969
|
-
parsedProxy.reserved.push(r);
|
|
12774
|
+
for (const r of proxy.reserved) parsedProxy.reserved.push(r);
|
|
10970
12775
|
} else {
|
|
10971
12776
|
delete parsedProxy.reserved;
|
|
10972
12777
|
}
|
|
@@ -11000,8 +12805,7 @@ var wireguardParser = (proxy = {}) => {
|
|
|
11000
12805
|
if (typeof p.reserved === "string") {
|
|
11001
12806
|
peer.reserved.push(p.reserved);
|
|
11002
12807
|
} else if (Array.isArray(p.reserved)) {
|
|
11003
|
-
for (const r of p.reserved)
|
|
11004
|
-
peer.reserved.push(r);
|
|
12808
|
+
for (const r of p.reserved) peer.reserved.push(r);
|
|
11005
12809
|
} else {
|
|
11006
12810
|
delete peer.reserved;
|
|
11007
12811
|
}
|
|
@@ -11241,8 +13045,7 @@ function singbox_Producer() {
|
|
|
11241
13045
|
app_default.error(e.message ?? e);
|
|
11242
13046
|
}
|
|
11243
13047
|
});
|
|
11244
|
-
if (type2 === "internal")
|
|
11245
|
-
return list;
|
|
13048
|
+
if (type2 === "internal") return list;
|
|
11246
13049
|
const categorized = list.reduce(
|
|
11247
13050
|
(result, item) => {
|
|
11248
13051
|
if (["wireguard", "tailscale"].includes(item.type)) {
|
|
@@ -11260,6 +13063,17 @@ function singbox_Producer() {
|
|
|
11260
13063
|
}
|
|
11261
13064
|
|
|
11262
13065
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/egern.js
|
|
13066
|
+
var ipVersions5 = {
|
|
13067
|
+
dual: "dual_stack",
|
|
13068
|
+
ipv4: "v4_only",
|
|
13069
|
+
ipv6: "v6_only",
|
|
13070
|
+
"v4-only": "v4_only",
|
|
13071
|
+
"v6-only": "v6_only",
|
|
13072
|
+
"ipv4-prefer": "v4_prefer",
|
|
13073
|
+
"ipv6-prefer": "v6_prefer",
|
|
13074
|
+
"prefer-v4": "v4_prefer",
|
|
13075
|
+
"prefer-v6": "v6_prefer"
|
|
13076
|
+
};
|
|
11263
13077
|
function Egern_Producer() {
|
|
11264
13078
|
const type = "ALL";
|
|
11265
13079
|
const produce2 = (proxies, type2, opts = {}) => {
|
|
@@ -11269,6 +13083,7 @@ function Egern_Producer() {
|
|
|
11269
13083
|
"https",
|
|
11270
13084
|
"socks5",
|
|
11271
13085
|
"ss",
|
|
13086
|
+
"ssr",
|
|
11272
13087
|
"trojan",
|
|
11273
13088
|
"hysteria2",
|
|
11274
13089
|
"vless",
|
|
@@ -11319,6 +13134,8 @@ function Egern_Producer() {
|
|
|
11319
13134
|
return false;
|
|
11320
13135
|
} else if (proxy.type === "snell" && normalizeSnellVersion(proxy.version) === null) {
|
|
11321
13136
|
return false;
|
|
13137
|
+
} else if (proxy.type === "ssr" && !isEgernSsr(proxy)) {
|
|
13138
|
+
return false;
|
|
11322
13139
|
} else if (["anytls"].includes(proxy.type) && proxy.network && !["tcp"].includes(proxy.network)) {
|
|
11323
13140
|
return false;
|
|
11324
13141
|
} else if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
@@ -11406,6 +13223,21 @@ function Egern_Producer() {
|
|
|
11406
13223
|
);
|
|
11407
13224
|
}
|
|
11408
13225
|
}
|
|
13226
|
+
} else if (proxy.type === "ssr") {
|
|
13227
|
+
proxy = {
|
|
13228
|
+
type: "shadowsocksr",
|
|
13229
|
+
name: proxy.name,
|
|
13230
|
+
method: normalizeSsrMethod(proxy.cipher),
|
|
13231
|
+
server: proxy.server,
|
|
13232
|
+
port: proxy.port,
|
|
13233
|
+
password: proxy.password,
|
|
13234
|
+
protocol: normalizeSsrPlugin(proxy.protocol),
|
|
13235
|
+
protocol_param: proxy["protocol-param"],
|
|
13236
|
+
obfs: normalizeSsrPlugin(proxy.obfs),
|
|
13237
|
+
obfs_param: proxy["obfs-param"],
|
|
13238
|
+
tfo: getTfo(proxy),
|
|
13239
|
+
udp_relay: getUdpRelay(proxy)
|
|
13240
|
+
};
|
|
11409
13241
|
} else if (proxy.type === "hysteria2") {
|
|
11410
13242
|
proxy = {
|
|
11411
13243
|
type: "hysteria2",
|
|
@@ -11595,8 +13427,7 @@ function Egern_Producer() {
|
|
|
11595
13427
|
}
|
|
11596
13428
|
};
|
|
11597
13429
|
flow = proxy.flow;
|
|
11598
|
-
if (flow === "")
|
|
11599
|
-
flow = void 0;
|
|
13430
|
+
if (flow === "") flow = void 0;
|
|
11600
13431
|
}
|
|
11601
13432
|
proxy = {
|
|
11602
13433
|
type: "vless",
|
|
@@ -11680,6 +13511,7 @@ function Egern_Producer() {
|
|
|
11680
13511
|
"https",
|
|
11681
13512
|
"socks5",
|
|
11682
13513
|
"ss",
|
|
13514
|
+
"ssr",
|
|
11683
13515
|
"trojan",
|
|
11684
13516
|
"vless",
|
|
11685
13517
|
"vmess",
|
|
@@ -11711,6 +13543,7 @@ function Egern_Producer() {
|
|
|
11711
13543
|
if ([
|
|
11712
13544
|
"socks5",
|
|
11713
13545
|
"ss",
|
|
13546
|
+
"ssr",
|
|
11714
13547
|
"trojan",
|
|
11715
13548
|
"vless",
|
|
11716
13549
|
"vmess",
|
|
@@ -11731,9 +13564,12 @@ function Egern_Producer() {
|
|
|
11731
13564
|
proxy.block_quic = false;
|
|
11732
13565
|
}
|
|
11733
13566
|
}
|
|
11734
|
-
if (["ss"].includes(original.type) && proxy.shadow_tls && original["udp-port"] > 0 && original["udp-port"] <= 65535) {
|
|
13567
|
+
if (["ss", "ssr"].includes(original.type) && proxy.shadow_tls && original["udp-port"] > 0 && original["udp-port"] <= 65535) {
|
|
11735
13568
|
proxy["udp_port"] = original["udp-port"];
|
|
11736
13569
|
}
|
|
13570
|
+
if (original["ip-version"]) {
|
|
13571
|
+
proxy.ip_version = ipVersions5[original["ip-version"]] || original["ip-version"];
|
|
13572
|
+
}
|
|
11737
13573
|
delete proxy.subName;
|
|
11738
13574
|
delete proxy.collectionName;
|
|
11739
13575
|
delete proxy.id;
|
|
@@ -11787,23 +13623,18 @@ function getUdpRelay(proxy) {
|
|
|
11787
13623
|
return proxy.udp ?? proxy.udp_relay;
|
|
11788
13624
|
}
|
|
11789
13625
|
function getNonEmptyValue(value) {
|
|
11790
|
-
if (value == null)
|
|
11791
|
-
|
|
11792
|
-
if (typeof value === "string" && value.length === 0)
|
|
11793
|
-
return void 0;
|
|
13626
|
+
if (value == null) return void 0;
|
|
13627
|
+
if (typeof value === "string" && value.length === 0) return void 0;
|
|
11794
13628
|
return value;
|
|
11795
13629
|
}
|
|
11796
13630
|
function getReality(proxy) {
|
|
11797
13631
|
const realityOpts = proxy?.["reality-opts"];
|
|
11798
|
-
if (!realityOpts)
|
|
11799
|
-
return void 0;
|
|
13632
|
+
if (!realityOpts) return void 0;
|
|
11800
13633
|
const reality = {};
|
|
11801
13634
|
const publicKey = getNonEmptyValue(realityOpts["public-key"]);
|
|
11802
13635
|
const shortId = getNonEmptyValue(realityOpts["short-id"]);
|
|
11803
|
-
if (publicKey != null)
|
|
11804
|
-
|
|
11805
|
-
if (shortId != null)
|
|
11806
|
-
reality.short_id = shortId;
|
|
13636
|
+
if (publicKey != null) reality.public_key = publicKey;
|
|
13637
|
+
if (shortId != null) reality.short_id = shortId;
|
|
11807
13638
|
return Object.keys(reality).length > 0 ? reality : void 0;
|
|
11808
13639
|
}
|
|
11809
13640
|
function getGrpcTransport(proxy) {
|
|
@@ -11817,26 +13648,71 @@ function getGrpcTransport(proxy) {
|
|
|
11817
13648
|
};
|
|
11818
13649
|
}
|
|
11819
13650
|
function isEgernGrpcGun(proxy) {
|
|
11820
|
-
if (proxy.network !== "grpc")
|
|
11821
|
-
return true;
|
|
13651
|
+
if (proxy.network !== "grpc") return true;
|
|
11822
13652
|
const grpcType = proxy["grpc-opts"]?.["_grpc-type"];
|
|
11823
|
-
if (grpcType == null)
|
|
11824
|
-
return true;
|
|
13653
|
+
if (grpcType == null) return true;
|
|
11825
13654
|
return `${grpcType}`.trim().toLowerCase() === "gun";
|
|
11826
13655
|
}
|
|
11827
13656
|
function normalizeSnellVersion(version) {
|
|
11828
|
-
if (version == null)
|
|
11829
|
-
return void 0;
|
|
13657
|
+
if (version == null) return void 0;
|
|
11830
13658
|
const normalized = `${version}`.trim();
|
|
11831
|
-
if (!/^[1-5]$/.test(normalized))
|
|
11832
|
-
return null;
|
|
13659
|
+
if (!/^[1-5]$/.test(normalized)) return null;
|
|
11833
13660
|
return parseInt(normalized, 10);
|
|
11834
13661
|
}
|
|
13662
|
+
var EGERN_SSR_METHODS = [
|
|
13663
|
+
"none",
|
|
13664
|
+
"dummy",
|
|
13665
|
+
"rc4-md5",
|
|
13666
|
+
"aes-128-cfb",
|
|
13667
|
+
"aes-192-cfb",
|
|
13668
|
+
"aes-256-cfb",
|
|
13669
|
+
"aes-128-ctr",
|
|
13670
|
+
"aes-192-ctr",
|
|
13671
|
+
"aes-256-ctr",
|
|
13672
|
+
"chacha20",
|
|
13673
|
+
"chacha20-ietf",
|
|
13674
|
+
"xchacha20"
|
|
13675
|
+
];
|
|
13676
|
+
var EGERN_SSR_PROTOCOLS = [
|
|
13677
|
+
"origin",
|
|
13678
|
+
"auth_sha1_v4",
|
|
13679
|
+
"auth_aes128_md5",
|
|
13680
|
+
"auth_aes128_sha1",
|
|
13681
|
+
"auth_chain_a",
|
|
13682
|
+
"auth_chain_b"
|
|
13683
|
+
];
|
|
13684
|
+
var EGERN_SSR_OBFS = [
|
|
13685
|
+
"plain",
|
|
13686
|
+
"http_simple",
|
|
13687
|
+
"http_post",
|
|
13688
|
+
"random_head",
|
|
13689
|
+
"tls1.2_ticket_auth",
|
|
13690
|
+
"tls1.2_ticket_fastauth"
|
|
13691
|
+
];
|
|
13692
|
+
function normalizeSsrPlugin(value) {
|
|
13693
|
+
if (value == null) return void 0;
|
|
13694
|
+
const normalized = `${value}`.trim().toLowerCase();
|
|
13695
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
13696
|
+
}
|
|
13697
|
+
function normalizeSsrMethod(cipher) {
|
|
13698
|
+
const method = normalizeSsrPlugin(cipher);
|
|
13699
|
+
return method === "plain" ? "none" : method;
|
|
13700
|
+
}
|
|
13701
|
+
function isEgernSsr(proxy) {
|
|
13702
|
+
if (!EGERN_SSR_METHODS.includes(normalizeSsrMethod(proxy.cipher))) {
|
|
13703
|
+
return false;
|
|
13704
|
+
}
|
|
13705
|
+
const protocol = normalizeSsrPlugin(proxy.protocol);
|
|
13706
|
+
if (protocol != null && !EGERN_SSR_PROTOCOLS.includes(protocol)) {
|
|
13707
|
+
return false;
|
|
13708
|
+
}
|
|
13709
|
+
const obfs = normalizeSsrPlugin(proxy.obfs);
|
|
13710
|
+
return obfs == null || EGERN_SSR_OBFS.includes(obfs);
|
|
13711
|
+
}
|
|
11835
13712
|
function getFirstHeaderValue(headers, ...keys) {
|
|
11836
13713
|
for (const key of keys) {
|
|
11837
13714
|
const value = getFirstValue(headers?.[key]);
|
|
11838
|
-
if (value)
|
|
11839
|
-
return value;
|
|
13715
|
+
if (value) return value;
|
|
11840
13716
|
}
|
|
11841
13717
|
return void 0;
|
|
11842
13718
|
}
|
|
@@ -11847,8 +13723,7 @@ function getH2Headers(h2Opts) {
|
|
|
11847
13723
|
const headers = {};
|
|
11848
13724
|
if (h2Opts?.headers && typeof h2Opts.headers === "object" && !Array.isArray(h2Opts.headers)) {
|
|
11849
13725
|
for (const [key, value] of Object.entries(h2Opts.headers)) {
|
|
11850
|
-
if (/^host$/i.test(key))
|
|
11851
|
-
continue;
|
|
13726
|
+
if (/^host$/i.test(key)) continue;
|
|
11852
13727
|
const headerValue = getFirstValue(value);
|
|
11853
13728
|
if (headerValue != null) {
|
|
11854
13729
|
headers[key] = headerValue;
|
|
@@ -11862,16 +13737,13 @@ function getH2Headers(h2Opts) {
|
|
|
11862
13737
|
return Object.keys(headers).length > 0 ? headers : void 0;
|
|
11863
13738
|
}
|
|
11864
13739
|
function getFirstValue(value) {
|
|
11865
|
-
if (Array.isArray(value))
|
|
11866
|
-
|
|
11867
|
-
if (value != null)
|
|
11868
|
-
return value;
|
|
13740
|
+
if (Array.isArray(value)) return value[0];
|
|
13741
|
+
if (value != null) return value;
|
|
11869
13742
|
return void 0;
|
|
11870
13743
|
}
|
|
11871
13744
|
function getFingerprintSha256(proxy) {
|
|
11872
13745
|
const fingerprint = proxy?.["tls-fingerprint"];
|
|
11873
|
-
if (typeof fingerprint !== "string")
|
|
11874
|
-
return void 0;
|
|
13746
|
+
if (typeof fingerprint !== "string") return void 0;
|
|
11875
13747
|
const trimmedFingerprint = fingerprint.trim();
|
|
11876
13748
|
return trimmedFingerprint.length > 0 ? trimmedFingerprint : void 0;
|
|
11877
13749
|
}
|
|
@@ -11881,8 +13753,7 @@ function supportsRootFingerprintSha256(original, proxy) {
|
|
|
11881
13753
|
) || original.type === "socks5" && proxy.type === "socks5_tls" || original.type === "http" && proxy.type === "https";
|
|
11882
13754
|
}
|
|
11883
13755
|
function addTransportFingerprintSha256(transport, fingerprintSha256) {
|
|
11884
|
-
if (!transport)
|
|
11885
|
-
return;
|
|
13756
|
+
if (!transport) return;
|
|
11886
13757
|
for (const key of ["grpc", "http2", "tls", "wss"]) {
|
|
11887
13758
|
if (transport[key]) {
|
|
11888
13759
|
transport[key].fingerprint_sha256 = fingerprintSha256;
|
|
@@ -11984,8 +13855,7 @@ function parseProxyLines(lines, opts) {
|
|
|
11984
13855
|
const proxyList = [];
|
|
11985
13856
|
let lastParser = null;
|
|
11986
13857
|
for (const line of lines) {
|
|
11987
|
-
if (line.length === 0)
|
|
11988
|
-
continue;
|
|
13858
|
+
if (line.length === 0) continue;
|
|
11989
13859
|
let proxy = null;
|
|
11990
13860
|
if (lastParser) {
|
|
11991
13861
|
proxy = tryParseProxy(lastParser, line);
|
|
@@ -12041,3 +13911,16 @@ export {
|
|
|
12041
13911
|
produceOutput,
|
|
12042
13912
|
tryParseProxy
|
|
12043
13913
|
};
|
|
13914
|
+
/*! Bundled license information:
|
|
13915
|
+
|
|
13916
|
+
ieee754/index.js:
|
|
13917
|
+
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
13918
|
+
|
|
13919
|
+
buffer/index.js:
|
|
13920
|
+
(*!
|
|
13921
|
+
* The buffer module from node.js, for the browser.
|
|
13922
|
+
*
|
|
13923
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
13924
|
+
* @license MIT
|
|
13925
|
+
*)
|
|
13926
|
+
*/
|