sub-store-convert 2.36.33 → 2.39.6
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 +2300 -448
- package/package.json +1 -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'; }
|
|
@@ -961,7 +2772,22 @@ function getParser2() {
|
|
|
961
2772
|
}
|
|
962
2773
|
|
|
963
2774
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/parsers/peggy/qx.js
|
|
2775
|
+
var import_buffer = __toESM(require_buffer());
|
|
964
2776
|
import peggy3 from "peggy";
|
|
2777
|
+
function decodeQxAlpn(raw) {
|
|
2778
|
+
if (typeof raw !== "string") return void 0;
|
|
2779
|
+
const hex = raw.trim().replace(/:/g, "");
|
|
2780
|
+
if (!hex || hex.length % 2 || /[^0-9a-f]/i.test(hex)) return void 0;
|
|
2781
|
+
const bytes = import_buffer.Buffer.from(hex, "hex");
|
|
2782
|
+
const alpn = [];
|
|
2783
|
+
for (let offset = 0; offset < bytes.length; ) {
|
|
2784
|
+
const length = bytes[offset++];
|
|
2785
|
+
if (!length || offset + length > bytes.length) return void 0;
|
|
2786
|
+
alpn.push(bytes.subarray(offset, offset + length).toString("utf8"));
|
|
2787
|
+
offset += length;
|
|
2788
|
+
}
|
|
2789
|
+
return alpn;
|
|
2790
|
+
}
|
|
965
2791
|
var grammars3 = String.raw`
|
|
966
2792
|
// global initializer
|
|
967
2793
|
{{
|
|
@@ -1133,7 +2959,8 @@ port = digits:[0-9]+ {
|
|
|
1133
2959
|
}
|
|
1134
2960
|
|
|
1135
2961
|
username = comma "username" equals username:[^,]+ { proxy.username = username.join("").trim(); }
|
|
1136
|
-
password = comma "password" equals password
|
|
2962
|
+
password = comma "password" equals password:$((!next_parameter .)+) { proxy.password = password.trim(); }
|
|
2963
|
+
next_parameter = "," _ [^=,]+ equals
|
|
1137
2964
|
uuid = comma "password" equals uuid:[^,]+ { proxy.uuid = uuid.join("").trim(); }
|
|
1138
2965
|
|
|
1139
2966
|
method = comma "method" equals cipher:cipher {
|
|
@@ -1223,7 +3050,15 @@ bool = b:("true"/"false") { return b === "true" }
|
|
|
1223
3050
|
var parser3;
|
|
1224
3051
|
function getParser3() {
|
|
1225
3052
|
if (!parser3) {
|
|
1226
|
-
|
|
3053
|
+
const generated = peggy3.generate(grammars3);
|
|
3054
|
+
parser3 = {
|
|
3055
|
+
parse(input, options) {
|
|
3056
|
+
const proxy = generated.parse(input, options);
|
|
3057
|
+
const alpn = decodeQxAlpn(proxy["tls-alpn"]);
|
|
3058
|
+
if (alpn) proxy.alpn = alpn;
|
|
3059
|
+
return proxy;
|
|
3060
|
+
}
|
|
3061
|
+
};
|
|
1227
3062
|
}
|
|
1228
3063
|
return parser3;
|
|
1229
3064
|
}
|
|
@@ -1250,8 +3085,7 @@ function splitQueryPart(part) {
|
|
|
1250
3085
|
};
|
|
1251
3086
|
}
|
|
1252
3087
|
function parseSafeIntegerValue(value) {
|
|
1253
|
-
if (!/^\d+$/.test(`${value}`))
|
|
1254
|
-
return null;
|
|
3088
|
+
if (!/^\d+$/.test(`${value}`)) return null;
|
|
1255
3089
|
const parsed = parseInt(`${value}`, 10);
|
|
1256
3090
|
return Number.isSafeInteger(parsed) ? parsed : null;
|
|
1257
3091
|
}
|
|
@@ -1269,8 +3103,7 @@ function extractPathQueryParam(rawPath, paramName) {
|
|
|
1269
3103
|
const keptParts = [];
|
|
1270
3104
|
let value = "";
|
|
1271
3105
|
for (const part of query.split("&")) {
|
|
1272
|
-
if (part === "")
|
|
1273
|
-
continue;
|
|
3106
|
+
if (part === "") continue;
|
|
1274
3107
|
const parsed = splitQueryPart(part);
|
|
1275
3108
|
if (parsed.key === paramName) {
|
|
1276
3109
|
if (value === "" && parsed.value !== "") {
|
|
@@ -1288,12 +3121,10 @@ function extractPathQueryParam(rawPath, paramName) {
|
|
|
1288
3121
|
function getPathQueryParam(rawPath, paramName) {
|
|
1289
3122
|
const path = rawPath == null ? "" : `${rawPath}`;
|
|
1290
3123
|
const queryIndex = path.indexOf("?");
|
|
1291
|
-
if (queryIndex === -1)
|
|
1292
|
-
return "";
|
|
3124
|
+
if (queryIndex === -1) return "";
|
|
1293
3125
|
const query = path.slice(queryIndex + 1);
|
|
1294
3126
|
for (const part of query.split("&")) {
|
|
1295
|
-
if (part === "")
|
|
1296
|
-
continue;
|
|
3127
|
+
if (part === "") continue;
|
|
1297
3128
|
const parsed = splitQueryPart(part);
|
|
1298
3129
|
if (parsed.key === paramName && parsed.value !== "") {
|
|
1299
3130
|
return parsed.value;
|
|
@@ -1328,8 +3159,7 @@ function setPathQueryParam(rawPath, paramName, value) {
|
|
|
1328
3159
|
}
|
|
1329
3160
|
function normalizeWebSocketEarlyDataPath(wsOpts) {
|
|
1330
3161
|
const networkPath = wsOpts?.path;
|
|
1331
|
-
if (!wsOpts)
|
|
1332
|
-
return;
|
|
3162
|
+
if (!wsOpts) return;
|
|
1333
3163
|
const { value: ed, parsed: maxEarlyData } = getSafeIntegerPathQueryParam(
|
|
1334
3164
|
networkPath,
|
|
1335
3165
|
"ed"
|
|
@@ -1346,8 +3176,7 @@ function normalizeWebSocketEarlyDataPath(wsOpts) {
|
|
|
1346
3176
|
delete wsOpts["max-early-data"];
|
|
1347
3177
|
return;
|
|
1348
3178
|
}
|
|
1349
|
-
if (ed === "")
|
|
1350
|
-
return;
|
|
3179
|
+
if (ed === "") return;
|
|
1351
3180
|
wsOpts.path = extractPathQueryParam(networkPath, "ed").path;
|
|
1352
3181
|
if (wsOpts["early-data-header-name"] == null) {
|
|
1353
3182
|
wsOpts["early-data-header-name"] = "Sec-WebSocket-Protocol";
|
|
@@ -1357,8 +3186,7 @@ function normalizeWebSocketEarlyDataPath(wsOpts) {
|
|
|
1357
3186
|
}
|
|
1358
3187
|
}
|
|
1359
3188
|
function deleteHttpUpgradeEarlyDataMetadata(wsOpts) {
|
|
1360
|
-
if (!wsOpts)
|
|
1361
|
-
return;
|
|
3189
|
+
if (!wsOpts) return;
|
|
1362
3190
|
delete wsOpts["_v2ray-http-upgrade-ed"];
|
|
1363
3191
|
}
|
|
1364
3192
|
|
|
@@ -1366,10 +3194,8 @@ function deleteHttpUpgradeEarlyDataMetadata(wsOpts) {
|
|
|
1366
3194
|
var unsafePathSegments = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
1367
3195
|
var parser4;
|
|
1368
3196
|
function $set(obj, path, value) {
|
|
1369
|
-
if (Object(obj) !== obj)
|
|
1370
|
-
|
|
1371
|
-
if (!Array.isArray(path))
|
|
1372
|
-
path = path.toString().match(/[^.[\]]+/g) || [];
|
|
3197
|
+
if (Object(obj) !== obj) return obj;
|
|
3198
|
+
if (!Array.isArray(path)) path = path.toString().match(/[^.[\]]+/g) || [];
|
|
1373
3199
|
if (path.some((segment) => unsafePathSegments.has(segment))) {
|
|
1374
3200
|
throw new Error("Unsafe property path");
|
|
1375
3201
|
}
|
|
@@ -1377,8 +3203,7 @@ function $set(obj, path, value) {
|
|
|
1377
3203
|
return obj;
|
|
1378
3204
|
}
|
|
1379
3205
|
function toBool(str) {
|
|
1380
|
-
if (str == null)
|
|
1381
|
-
return void 0;
|
|
3206
|
+
if (str == null) return void 0;
|
|
1382
3207
|
return /(TRUE)|1/i.test(str);
|
|
1383
3208
|
}
|
|
1384
3209
|
function isNumericEarlyData(value) {
|
|
@@ -1887,8 +3712,7 @@ var VMESS_SECURITY_ALIASES = {
|
|
|
1887
3712
|
"chacha20-ietf-poly1305": "chacha20-poly1305"
|
|
1888
3713
|
};
|
|
1889
3714
|
function normalizeSecurityValue(security) {
|
|
1890
|
-
if (security == null)
|
|
1891
|
-
return "";
|
|
3715
|
+
if (security == null) return "";
|
|
1892
3716
|
return `${security}`.trim().toLowerCase();
|
|
1893
3717
|
}
|
|
1894
3718
|
function canonicalizeVmessSecurity(security) {
|
|
@@ -1896,8 +3720,7 @@ function canonicalizeVmessSecurity(security) {
|
|
|
1896
3720
|
}
|
|
1897
3721
|
function normalizeVmessSecurity(security, supportedValues = VMESS_SECURITY_COMMON_VALUES, { acceptAliases = true, fallback = VMESS_SECURITY_AUTO } = {}) {
|
|
1898
3722
|
const normalized = normalizeSecurityValue(security);
|
|
1899
|
-
if (!normalized)
|
|
1900
|
-
return fallback;
|
|
3723
|
+
if (!normalized) return fallback;
|
|
1901
3724
|
const normalizedSupported = supportedValues.map(normalizeSecurityValue);
|
|
1902
3725
|
if (normalizedSupported.includes(normalized)) {
|
|
1903
3726
|
return canonicalizeVmessSecurity(normalized);
|
|
@@ -1928,8 +3751,7 @@ function formatSurgeVmessEncryptMethod(security) {
|
|
|
1928
3751
|
"aes-128-gcm",
|
|
1929
3752
|
"chacha20-poly1305"
|
|
1930
3753
|
]);
|
|
1931
|
-
if (normalized === VMESS_SECURITY_AUTO)
|
|
1932
|
-
return void 0;
|
|
3754
|
+
if (normalized === VMESS_SECURITY_AUTO) return void 0;
|
|
1933
3755
|
return normalized === "chacha20-poly1305" ? "chacha20-ietf-poly1305" : normalized;
|
|
1934
3756
|
}
|
|
1935
3757
|
|
|
@@ -1965,8 +3787,7 @@ function decodeShadowsocksUserInfo(rawUserInfoStr) {
|
|
|
1965
3787
|
return Base64.decode(decodedUserInfoStr);
|
|
1966
3788
|
}
|
|
1967
3789
|
function isNumericEarlyData2(value) {
|
|
1968
|
-
if (value == null || !/^\d+$/.test(`${value}`))
|
|
1969
|
-
return false;
|
|
3790
|
+
if (value == null || !/^\d+$/.test(`${value}`)) return false;
|
|
1970
3791
|
return Number.isSafeInteger(parseInt(`${value}`, 10));
|
|
1971
3792
|
}
|
|
1972
3793
|
function extractEarlyDataFromPath(path) {
|
|
@@ -2004,21 +3825,16 @@ function splitURIHostList(host) {
|
|
|
2004
3825
|
return hosts.length > 0 ? hosts : void 0;
|
|
2005
3826
|
}
|
|
2006
3827
|
function parseWireGuardURIAddressValue(value) {
|
|
2007
|
-
if (value == null)
|
|
2008
|
-
return null;
|
|
3828
|
+
if (value == null) return null;
|
|
2009
3829
|
const raw = `${value}`.trim();
|
|
2010
|
-
if (!raw)
|
|
2011
|
-
return null;
|
|
3830
|
+
if (!raw) return null;
|
|
2012
3831
|
const [, hostRaw = raw, cidrRaw] = /^(.*?)(?:\/(\d+))?$/.exec(raw) || [];
|
|
2013
3832
|
const host = `${hostRaw}`.trim().replace(/^\[/, "").replace(/\]$/, "");
|
|
2014
3833
|
const normalizeCIDR = (cidr, max) => {
|
|
2015
|
-
if (cidr == null)
|
|
2016
|
-
|
|
2017
|
-
if (!/^\d+$/.test(cidr))
|
|
2018
|
-
return void 0;
|
|
3834
|
+
if (cidr == null) return void 0;
|
|
3835
|
+
if (!/^\d+$/.test(cidr)) return void 0;
|
|
2019
3836
|
const parsed = parseInt(cidr, 10);
|
|
2020
|
-
if (parsed < 0 || parsed > max)
|
|
2021
|
-
return void 0;
|
|
3837
|
+
if (parsed < 0 || parsed > max) return void 0;
|
|
2022
3838
|
return parsed;
|
|
2023
3839
|
};
|
|
2024
3840
|
if (isIPv4(host)) {
|
|
@@ -2273,14 +4089,12 @@ function URI_SS() {
|
|
|
2273
4089
|
for (const item of pluginInfo) {
|
|
2274
4090
|
const separatorIndex = item.indexOf("=");
|
|
2275
4091
|
if (separatorIndex === -1) {
|
|
2276
|
-
if (item)
|
|
2277
|
-
params2[item] = true;
|
|
4092
|
+
if (item) params2[item] = true;
|
|
2278
4093
|
continue;
|
|
2279
4094
|
}
|
|
2280
4095
|
const key = item.slice(0, separatorIndex);
|
|
2281
4096
|
const val = item.slice(separatorIndex + 1).replace(/\\=/g, "=");
|
|
2282
|
-
if (key)
|
|
2283
|
-
params2[key] = val || true;
|
|
4097
|
+
if (key) params2[key] = val || true;
|
|
2284
4098
|
}
|
|
2285
4099
|
switch (params2.plugin) {
|
|
2286
4100
|
case "obfs-local":
|
|
@@ -2421,7 +4235,9 @@ function URI_SSR() {
|
|
|
2421
4235
|
...proxy,
|
|
2422
4236
|
name: other_params.remarks ? Base64.decode(other_params.remarks) : proxy.server,
|
|
2423
4237
|
"protocol-param": getIfNotBlank(
|
|
2424
|
-
Base64.decode(
|
|
4238
|
+
Base64.decode(
|
|
4239
|
+
other_params.protoparam || other_params.protocolparam || ""
|
|
4240
|
+
).replace(/\s/g, "")
|
|
2425
4241
|
),
|
|
2426
4242
|
"obfs-param": getIfNotBlank(
|
|
2427
4243
|
Base64.decode(other_params.obfsparam || "").replace(/\s/g, "")
|
|
@@ -2437,6 +4253,9 @@ function URI_VMess() {
|
|
|
2437
4253
|
return /^vmess:\/\//.test(line);
|
|
2438
4254
|
};
|
|
2439
4255
|
const parse2 = (line) => {
|
|
4256
|
+
if (/^vmess:\/\/[^/?#]+@/.test(line)) {
|
|
4257
|
+
return URI_VLESS().parse(line, "vmess");
|
|
4258
|
+
}
|
|
2440
4259
|
let { content: lineWithoutFragment, fragment: fragmentName } = splitURIFragment(line.split("vmess://")[1]);
|
|
2441
4260
|
let content = Base64.decode(lineWithoutFragment.replace(/\?.*?$/, ""));
|
|
2442
4261
|
if (/=\s*vmess/.test(content)) {
|
|
@@ -2659,7 +4478,7 @@ function URI_VLESS() {
|
|
|
2659
4478
|
const test = (line) => {
|
|
2660
4479
|
return /^vless:\/\//.test(line);
|
|
2661
4480
|
};
|
|
2662
|
-
const parse2 = (line) => {
|
|
4481
|
+
const parse2 = (line, protocol = "vless") => {
|
|
2663
4482
|
const mapXmuxToReuseSettings = (xmux) => {
|
|
2664
4483
|
if (!isPlainObject(xmux)) {
|
|
2665
4484
|
return void 0;
|
|
@@ -3369,7 +5188,7 @@ function URI_VLESS() {
|
|
|
3369
5188
|
}
|
|
3370
5189
|
return Object.keys(parsedDownloadSettings).length > 0 ? parsedDownloadSettings : void 0;
|
|
3371
5190
|
};
|
|
3372
|
-
line = line.split(
|
|
5191
|
+
line = line.split(`${protocol}://`)[1];
|
|
3373
5192
|
let isShadowrocket;
|
|
3374
5193
|
let parsed = /^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(line);
|
|
3375
5194
|
if (!parsed) {
|
|
@@ -3388,7 +5207,7 @@ function URI_VLESS() {
|
|
|
3388
5207
|
name2 = decodeURIComponent(name2);
|
|
3389
5208
|
}
|
|
3390
5209
|
const proxy = {
|
|
3391
|
-
type:
|
|
5210
|
+
type: protocol,
|
|
3392
5211
|
name: name2,
|
|
3393
5212
|
server,
|
|
3394
5213
|
port,
|
|
@@ -3398,13 +5217,11 @@ function URI_VLESS() {
|
|
|
3398
5217
|
const params = {};
|
|
3399
5218
|
for (const addon of addons.split("&")) {
|
|
3400
5219
|
if (addon) {
|
|
3401
|
-
const [key,
|
|
3402
|
-
|
|
3403
|
-
value = decodeURIComponent(valueRaw);
|
|
3404
|
-
params[key] = value;
|
|
5220
|
+
const [key, ...value] = addon.split("=");
|
|
5221
|
+
params[key] = decodeURIComponent(value.join("="));
|
|
3405
5222
|
}
|
|
3406
5223
|
}
|
|
3407
|
-
proxy.name = name2 ?? params.remarks ?? params.remark ??
|
|
5224
|
+
proxy.name = name2 ?? params.remarks ?? params.remark ?? `${protocol === "vmess" ? "VMess" : "VLESS"} ${server}:${port}`;
|
|
3408
5225
|
proxy.tls = params.security && params.security !== "none";
|
|
3409
5226
|
if (params.pbk) {
|
|
3410
5227
|
params.security = "reality";
|
|
@@ -3450,6 +5267,10 @@ function URI_VLESS() {
|
|
|
3450
5267
|
const opts = {};
|
|
3451
5268
|
if (params.pbk) {
|
|
3452
5269
|
opts["public-key"] = params.pbk;
|
|
5270
|
+
const mlkem = params["support-x25519mlkem768"];
|
|
5271
|
+
if (["1", "t", "T", "true", "TRUE", "True"].includes(mlkem)) {
|
|
5272
|
+
opts["support-x25519mlkem768"] = true;
|
|
5273
|
+
}
|
|
3453
5274
|
}
|
|
3454
5275
|
if (params.sid) {
|
|
3455
5276
|
opts["short-id"] = params.sid;
|
|
@@ -3612,7 +5433,11 @@ function URI_VLESS() {
|
|
|
3612
5433
|
proxy._mode = params.mode;
|
|
3613
5434
|
}
|
|
3614
5435
|
}
|
|
3615
|
-
if (
|
|
5436
|
+
if (protocol === "vmess") {
|
|
5437
|
+
proxy.cipher = normalizeVmessSecurity(params.encryption);
|
|
5438
|
+
proxy.alterId = 0;
|
|
5439
|
+
delete proxy.flow;
|
|
5440
|
+
} else if (params.encryption) {
|
|
3616
5441
|
proxy.encryption = params.encryption;
|
|
3617
5442
|
}
|
|
3618
5443
|
if (params.pqv) {
|
|
@@ -3943,8 +5768,7 @@ function URI_WireGuard() {
|
|
|
3943
5768
|
} else if (["address", "ip"].includes(key)) {
|
|
3944
5769
|
value.split(",").map((i) => {
|
|
3945
5770
|
const parsed = parseWireGuardURIAddressValue(i);
|
|
3946
|
-
if (!parsed)
|
|
3947
|
-
return;
|
|
5771
|
+
if (!parsed) return;
|
|
3948
5772
|
if (parsed.family === "ipv4") {
|
|
3949
5773
|
proxy.ip = parsed.address;
|
|
3950
5774
|
if (typeof parsed.cidr !== "undefined") {
|
|
@@ -4026,12 +5850,14 @@ function Clash_All() {
|
|
|
4026
5850
|
"gost-relay",
|
|
4027
5851
|
"openvpn",
|
|
4028
5852
|
"tailscale",
|
|
5853
|
+
"easytier",
|
|
4029
5854
|
"trusttunnel",
|
|
4030
5855
|
"h2-connect",
|
|
4031
5856
|
"naive",
|
|
4032
5857
|
"anytls",
|
|
4033
5858
|
"mieru",
|
|
4034
5859
|
"masque",
|
|
5860
|
+
"masque-surge",
|
|
4035
5861
|
"sudoku",
|
|
4036
5862
|
"juicity",
|
|
4037
5863
|
"ss",
|
|
@@ -4342,6 +6168,19 @@ function Surge_TrustTunnel() {
|
|
|
4342
6168
|
const parse2 = (line) => getParser().parse(line);
|
|
4343
6169
|
return { name, test, parse: parse2 };
|
|
4344
6170
|
}
|
|
6171
|
+
function Surge_Masque() {
|
|
6172
|
+
const name = "Surge MASQUE Parser";
|
|
6173
|
+
const test = (line) => {
|
|
6174
|
+
return /^.*=\s*masque/.test(line.split(",")[0]);
|
|
6175
|
+
};
|
|
6176
|
+
const parse2 = (raw) => {
|
|
6177
|
+
const { port_hopping, line } = surge_port_hopping(raw);
|
|
6178
|
+
const proxy = getParser().parse(line);
|
|
6179
|
+
proxy.ports = port_hopping;
|
|
6180
|
+
return proxy;
|
|
6181
|
+
};
|
|
6182
|
+
return { name, test, parse: parse2 };
|
|
6183
|
+
}
|
|
4345
6184
|
function Surge_H2Connect() {
|
|
4346
6185
|
const name = "Surge HTTP/2 CONNECT Parser";
|
|
4347
6186
|
const test = (line) => {
|
|
@@ -4521,6 +6360,7 @@ var parsers_default = [
|
|
|
4521
6360
|
Surge_Direct(),
|
|
4522
6361
|
Surge_AnyTLS(),
|
|
4523
6362
|
Surge_TrustTunnel(),
|
|
6363
|
+
Surge_Masque(),
|
|
4524
6364
|
Surge_H2Connect(),
|
|
4525
6365
|
Surge_SSH(),
|
|
4526
6366
|
Surge_SS(),
|
|
@@ -4656,8 +6496,7 @@ function fallbackBase64Encoded() {
|
|
|
4656
6496
|
function Clash() {
|
|
4657
6497
|
const name = "Clash Pre-processor";
|
|
4658
6498
|
const test = function(raw) {
|
|
4659
|
-
if (!/proxies/.test(raw))
|
|
4660
|
-
return false;
|
|
6499
|
+
if (!/proxies/.test(raw)) return false;
|
|
4661
6500
|
const content = safeLoad(raw);
|
|
4662
6501
|
return Array.isArray(content.proxies) || Array.isArray(content["proxy-groups"]);
|
|
4663
6502
|
};
|
|
@@ -4754,16 +6593,12 @@ function isShadowsocksOverTls(proxy) {
|
|
|
4754
6593
|
return proxy?.type === "ss" && proxy?.tls === true && !isPresent2(proxy, "plugin") && (!isPresent2(proxy, "network") || normalizedNetwork === "tcp");
|
|
4755
6594
|
}
|
|
4756
6595
|
function normalizePluginMuxValue(mux) {
|
|
4757
|
-
if (typeof mux === "boolean")
|
|
4758
|
-
return Number(mux);
|
|
6596
|
+
if (typeof mux === "boolean") return Number(mux);
|
|
4759
6597
|
if (typeof mux === "string") {
|
|
4760
6598
|
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);
|
|
6599
|
+
if (normalized === "true") return 1;
|
|
6600
|
+
if (normalized === "false") return 0;
|
|
6601
|
+
if (/^\d+$/.test(normalized)) return parseInt(normalized, 10);
|
|
4767
6602
|
}
|
|
4768
6603
|
return mux;
|
|
4769
6604
|
}
|
|
@@ -4771,8 +6606,7 @@ function normalizePluginMuxBooleanValue(mux) {
|
|
|
4771
6606
|
return Boolean(normalizePluginMuxValue(mux));
|
|
4772
6607
|
}
|
|
4773
6608
|
function supportsShadowsocksV2rayPluginMode(proxy, supportedModes) {
|
|
4774
|
-
if (proxy?.type !== "ss" || proxy?.plugin !== "v2ray-plugin")
|
|
4775
|
-
return true;
|
|
6609
|
+
if (proxy?.type !== "ss" || proxy?.plugin !== "v2ray-plugin") return true;
|
|
4776
6610
|
const normalizedMode = typeof proxy?.["plugin-opts"]?.mode === "string" ? proxy["plugin-opts"].mode.trim().toLowerCase() : proxy?.["plugin-opts"]?.mode;
|
|
4777
6611
|
return supportedModes.includes(normalizedMode);
|
|
4778
6612
|
}
|
|
@@ -4786,10 +6620,8 @@ function restoreShadowTLSOpts(target, serverNameKey) {
|
|
|
4786
6620
|
password: opts.password,
|
|
4787
6621
|
version: opts.version
|
|
4788
6622
|
};
|
|
4789
|
-
if (opts.host != null)
|
|
4790
|
-
|
|
4791
|
-
if (opts.alpn != null)
|
|
4792
|
-
target.alpn = opts.alpn;
|
|
6623
|
+
if (opts.host != null) target[serverNameKey] = opts.host;
|
|
6624
|
+
if (opts.alpn != null) target.alpn = opts.alpn;
|
|
4793
6625
|
delete target.plugin;
|
|
4794
6626
|
delete target["plugin-opts"];
|
|
4795
6627
|
return enabled;
|
|
@@ -4809,28 +6641,22 @@ function restoreShadowTLSProxyOpts(proxy) {
|
|
|
4809
6641
|
}
|
|
4810
6642
|
}
|
|
4811
6643
|
function parseWireGuardCIDR(cidr, max) {
|
|
4812
|
-
if (cidr == null)
|
|
4813
|
-
return void 0;
|
|
6644
|
+
if (cidr == null) return void 0;
|
|
4814
6645
|
const normalized = `${cidr}`.trim();
|
|
4815
|
-
if (!/^\d+$/.test(normalized))
|
|
4816
|
-
return void 0;
|
|
6646
|
+
if (!/^\d+$/.test(normalized)) return void 0;
|
|
4817
6647
|
const parsed = parseInt(normalized, 10);
|
|
4818
|
-
if (parsed < 0 || parsed > max)
|
|
4819
|
-
return void 0;
|
|
6648
|
+
if (parsed < 0 || parsed > max) return void 0;
|
|
4820
6649
|
return parsed;
|
|
4821
6650
|
}
|
|
4822
6651
|
function parseWireGuardInterfaceAddress(value, family) {
|
|
4823
|
-
if (value == null)
|
|
4824
|
-
return null;
|
|
6652
|
+
if (value == null) return null;
|
|
4825
6653
|
const raw = `${value}`.trim();
|
|
4826
|
-
if (!raw)
|
|
4827
|
-
return null;
|
|
6654
|
+
if (!raw) return null;
|
|
4828
6655
|
const [, hostRaw = raw, cidrRaw] = /^(.*?)(?:\/(\d+))?$/.exec(raw) || [];
|
|
4829
6656
|
const host = `${hostRaw}`.trim().replace(/^\[/, "").replace(/\]$/, "");
|
|
4830
6657
|
const isIPv4Family = family === "ipv4";
|
|
4831
6658
|
const isValid = isIPv4Family ? isIPv4(host) : isIPv6(host);
|
|
4832
|
-
if (!isValid)
|
|
4833
|
-
return null;
|
|
6659
|
+
if (!isValid) return null;
|
|
4834
6660
|
const max = isIPv4Family ? 32 : 128;
|
|
4835
6661
|
return {
|
|
4836
6662
|
address: host,
|
|
@@ -4843,8 +6669,7 @@ function getWireGuardAddressWithCIDR(proxy = {}, family = "ipv4") {
|
|
|
4843
6669
|
proxy[config.addressKey],
|
|
4844
6670
|
family
|
|
4845
6671
|
);
|
|
4846
|
-
if (!parsed)
|
|
4847
|
-
return void 0;
|
|
6672
|
+
if (!parsed) return void 0;
|
|
4848
6673
|
const normalizedCIDR = parseWireGuardCIDR(
|
|
4849
6674
|
proxy[config.cidrKey],
|
|
4850
6675
|
config.defaultCIDR
|
|
@@ -4852,8 +6677,7 @@ function getWireGuardAddressWithCIDR(proxy = {}, family = "ipv4") {
|
|
|
4852
6677
|
return `${parsed.address}/${normalizedCIDR ?? parsed.cidr ?? config.defaultCIDR}`;
|
|
4853
6678
|
}
|
|
4854
6679
|
function produceProxyListOutput(list, type, opts = {}) {
|
|
4855
|
-
if (type === "internal")
|
|
4856
|
-
return list;
|
|
6680
|
+
if (type === "internal") return list;
|
|
4857
6681
|
if (opts.prettyYaml || opts["pretty-yaml"]) {
|
|
4858
6682
|
return normalizeClashYaml(
|
|
4859
6683
|
yaml_default.safeDump(
|
|
@@ -4888,8 +6712,7 @@ var ipVersions = {
|
|
|
4888
6712
|
"ipv6-prefer": "prefer-v6"
|
|
4889
6713
|
};
|
|
4890
6714
|
function stripSurgeQuotes(value) {
|
|
4891
|
-
if (typeof value !== "string")
|
|
4892
|
-
return value;
|
|
6715
|
+
if (typeof value !== "string") return value;
|
|
4893
6716
|
const trimmed = value.trim();
|
|
4894
6717
|
const quote = trimmed[0];
|
|
4895
6718
|
if ((quote === '"' || quote === "'") && trimmed[trimmed.length - 1] === quote) {
|
|
@@ -4910,23 +6733,19 @@ function formatSurgeAlpn(alpn) {
|
|
|
4910
6733
|
}
|
|
4911
6734
|
function appendAlpn(result, proxy) {
|
|
4912
6735
|
const alpn = formatSurgeAlpn(proxy.alpn);
|
|
4913
|
-
if (alpn)
|
|
4914
|
-
result.append(`,alpn="${alpn}"`);
|
|
6736
|
+
if (alpn) result.append(`,alpn="${alpn}"`);
|
|
4915
6737
|
}
|
|
4916
6738
|
function getShadowTLSAlpn(proxy) {
|
|
4917
6739
|
return formatSurgeAlpn(proxy?.["plugin-opts"]?.alpn ?? proxy?.alpn);
|
|
4918
6740
|
}
|
|
4919
6741
|
function appendShadowTLS(result, proxy, includeUdpPort = false) {
|
|
4920
|
-
if (proxy.plugin !== "shadow-tls" || !proxy["plugin-opts"])
|
|
4921
|
-
return;
|
|
6742
|
+
if (proxy.plugin !== "shadow-tls" || !proxy["plugin-opts"]) return;
|
|
4922
6743
|
const password = proxy["plugin-opts"].password;
|
|
4923
6744
|
const host = proxy["plugin-opts"].host;
|
|
4924
6745
|
const version = proxy["plugin-opts"].version;
|
|
4925
|
-
if (!password)
|
|
4926
|
-
return;
|
|
6746
|
+
if (!password) return;
|
|
4927
6747
|
result.append(`,shadow-tls-password="${password}"`);
|
|
4928
|
-
if (host)
|
|
4929
|
-
result.append(`,shadow-tls-sni=${host}`);
|
|
6748
|
+
if (host) result.append(`,shadow-tls-sni=${host}`);
|
|
4930
6749
|
if (version) {
|
|
4931
6750
|
if (version < 2) {
|
|
4932
6751
|
throw unsupported(`shadow-tls version ${version} is not supported`);
|
|
@@ -4934,8 +6753,7 @@ function appendShadowTLS(result, proxy, includeUdpPort = false) {
|
|
|
4934
6753
|
result.append(`,shadow-tls-version=${version}`);
|
|
4935
6754
|
}
|
|
4936
6755
|
const alpn = getShadowTLSAlpn(proxy);
|
|
4937
|
-
if (alpn)
|
|
4938
|
-
result.append(`,alpn="${alpn}"`);
|
|
6756
|
+
if (alpn) result.append(`,alpn="${alpn}"`);
|
|
4939
6757
|
if (includeUdpPort) {
|
|
4940
6758
|
result.appendIfPresent(`,udp-port=${proxy["udp-port"]}`, "udp-port");
|
|
4941
6759
|
}
|
|
@@ -4974,11 +6792,9 @@ function appendSshPrivateKey(result, proxy) {
|
|
|
4974
6792
|
}
|
|
4975
6793
|
}
|
|
4976
6794
|
function warnMaxStreamsIfNeeded(proxy) {
|
|
4977
|
-
if (!isPresent2(proxy, "max-streams"))
|
|
4978
|
-
return;
|
|
6795
|
+
if (!isPresent2(proxy, "max-streams")) return;
|
|
4979
6796
|
const maxStreams = Number(stripSurgeQuotes(proxy["max-streams"]));
|
|
4980
|
-
if (!Number.isInteger(maxStreams) || maxStreams <= 3)
|
|
4981
|
-
return;
|
|
6797
|
+
if (!Number.isInteger(maxStreams) || maxStreams <= 3) return;
|
|
4982
6798
|
app_default.warn(
|
|
4983
6799
|
`Surge ${proxy.type} proxy ${proxy.name}: max-streams=${maxStreams} is greater than 3. Too many streams sharing one TCP connection may hurt performance.`
|
|
4984
6800
|
);
|
|
@@ -5027,6 +6843,8 @@ function Surge_Producer() {
|
|
|
5027
6843
|
return ssh(proxy);
|
|
5028
6844
|
case "trusttunnel":
|
|
5029
6845
|
return trusttunnel(proxy);
|
|
6846
|
+
case "masque-surge":
|
|
6847
|
+
return masque_surge(proxy);
|
|
5030
6848
|
}
|
|
5031
6849
|
if (opts["include-unsupported-proxy"] && proxy.type === "wireguard") {
|
|
5032
6850
|
return wireguard(proxy);
|
|
@@ -5147,7 +6965,6 @@ function trojan(proxy) {
|
|
|
5147
6965
|
result.appendIfPresent(`,tls=${proxy.tls}`, "tls");
|
|
5148
6966
|
appendTlsProxyParams(result, proxy);
|
|
5149
6967
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
5150
|
-
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
5151
6968
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
5152
6969
|
result.appendIfPresent(
|
|
5153
6970
|
`,test-timeout=${proxy["test-timeout"]}`,
|
|
@@ -5185,7 +7002,6 @@ function anytls(proxy) {
|
|
|
5185
7002
|
);
|
|
5186
7003
|
appendTlsProxyParams(result, proxy);
|
|
5187
7004
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
5188
|
-
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
5189
7005
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
5190
7006
|
result.appendIfPresent(
|
|
5191
7007
|
`,test-timeout=${proxy["test-timeout"]}`,
|
|
@@ -5222,6 +7038,7 @@ function trusttunnel(proxy) {
|
|
|
5222
7038
|
`,max-streams=${proxy["max-streams"]}`,
|
|
5223
7039
|
"max-streams"
|
|
5224
7040
|
);
|
|
7041
|
+
if (proxy.network === "h3") result.append(",h3=true");
|
|
5225
7042
|
const ip_version = ipVersions[proxy["ip-version"]] || proxy["ip-version"];
|
|
5226
7043
|
result.appendIfPresent(`,ip-version=${ip_version}`, "ip-version");
|
|
5227
7044
|
result.appendIfPresent(
|
|
@@ -5230,7 +7047,6 @@ function trusttunnel(proxy) {
|
|
|
5230
7047
|
);
|
|
5231
7048
|
appendTlsProxyParams(result, proxy);
|
|
5232
7049
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
5233
|
-
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
5234
7050
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
5235
7051
|
result.appendIfPresent(
|
|
5236
7052
|
`,test-timeout=${proxy["test-timeout"]}`,
|
|
@@ -5256,6 +7072,56 @@ function trusttunnel(proxy) {
|
|
|
5256
7072
|
result.appendIfPresent(`,reuse=${proxy["reuse"]}`, "reuse");
|
|
5257
7073
|
return result.toString();
|
|
5258
7074
|
}
|
|
7075
|
+
function masque_surge(proxy) {
|
|
7076
|
+
const result = new Result(proxy);
|
|
7077
|
+
result.append(`${proxy.name}=masque,${proxy.server},${proxy.port}`);
|
|
7078
|
+
result.appendIfPresent(`,username="${proxy.username}"`, "username");
|
|
7079
|
+
result.appendIfPresent(`,password="${proxy.password}"`, "password");
|
|
7080
|
+
if (hasNonBlankValue(proxy.ports)) {
|
|
7081
|
+
result.append(
|
|
7082
|
+
`,port-hopping="${String(proxy.ports).replace(/,/g, ";")}"`
|
|
7083
|
+
);
|
|
7084
|
+
}
|
|
7085
|
+
if (hasNonBlankValue(proxy["hop-interval"])) {
|
|
7086
|
+
result.append(`,port-hopping-interval=${proxy["hop-interval"]}`);
|
|
7087
|
+
}
|
|
7088
|
+
const ip_version = ipVersions[proxy["ip-version"]] || proxy["ip-version"];
|
|
7089
|
+
result.appendIfPresent(`,ip-version=${ip_version}`, "ip-version");
|
|
7090
|
+
result.appendIfPresent(
|
|
7091
|
+
`,no-error-alert=${proxy["no-error-alert"]}`,
|
|
7092
|
+
"no-error-alert"
|
|
7093
|
+
);
|
|
7094
|
+
appendTlsProxyParams(result, proxy);
|
|
7095
|
+
if (isPresent2(proxy, "tfo")) {
|
|
7096
|
+
result.append(`,tfo=${proxy.tfo}`);
|
|
7097
|
+
} else if (isPresent2(proxy, "fast-open")) {
|
|
7098
|
+
result.append(`,tfo=${proxy["fast-open"]}`);
|
|
7099
|
+
}
|
|
7100
|
+
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
7101
|
+
result.appendIfPresent(
|
|
7102
|
+
`,test-timeout=${proxy["test-timeout"]}`,
|
|
7103
|
+
"test-timeout"
|
|
7104
|
+
);
|
|
7105
|
+
result.appendIfPresent(`,test-udp=${proxy["test-udp"]}`, "test-udp");
|
|
7106
|
+
result.appendIfPresent(`,hybrid=${proxy.hybrid}`, "hybrid");
|
|
7107
|
+
result.appendIfPresent(`,tos=${proxy.tos}`, "tos");
|
|
7108
|
+
result.appendIfPresent(
|
|
7109
|
+
`,allow-other-interface=${proxy["allow-other-interface"]}`,
|
|
7110
|
+
"allow-other-interface"
|
|
7111
|
+
);
|
|
7112
|
+
result.appendIfPresent(
|
|
7113
|
+
`,interface=${proxy["interface-name"]}`,
|
|
7114
|
+
"interface-name"
|
|
7115
|
+
);
|
|
7116
|
+
result.appendIfPresent(`,interface=${proxy.interface}`, "interface");
|
|
7117
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
7118
|
+
result.appendIfPresent(
|
|
7119
|
+
`,underlying-proxy=${proxy["underlying-proxy"]}`,
|
|
7120
|
+
"underlying-proxy"
|
|
7121
|
+
);
|
|
7122
|
+
result.appendIfPresent(`,ecn=${proxy.ecn}`, "ecn");
|
|
7123
|
+
return result.toString();
|
|
7124
|
+
}
|
|
5259
7125
|
function h2Connect(proxy) {
|
|
5260
7126
|
const result = new Result(proxy);
|
|
5261
7127
|
result.append(`${proxy.name}=h2-connect,${proxy.server},${proxy.port}`);
|
|
@@ -5326,7 +7192,6 @@ function vmess(proxy, includeUnsupportedProxy) {
|
|
|
5326
7192
|
result.appendIfPresent(`,tls=${proxy.tls}`, "tls");
|
|
5327
7193
|
appendTlsProxyParams(result, proxy, Boolean(proxy.tls));
|
|
5328
7194
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
5329
|
-
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
5330
7195
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
5331
7196
|
result.appendIfPresent(
|
|
5332
7197
|
`,test-timeout=${proxy["test-timeout"]}`,
|
|
@@ -5373,7 +7238,6 @@ function ssh(proxy) {
|
|
|
5373
7238
|
"no-error-alert"
|
|
5374
7239
|
);
|
|
5375
7240
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
5376
|
-
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
5377
7241
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
5378
7242
|
result.appendIfPresent(
|
|
5379
7243
|
`,test-timeout=${proxy["test-timeout"]}`,
|
|
@@ -5413,7 +7277,6 @@ function http(proxy) {
|
|
|
5413
7277
|
);
|
|
5414
7278
|
appendTlsProxyParams(result, proxy, Boolean(proxy.tls));
|
|
5415
7279
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
5416
|
-
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
5417
7280
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
5418
7281
|
result.appendIfPresent(
|
|
5419
7282
|
`,test-timeout=${proxy["test-timeout"]}`,
|
|
@@ -5450,7 +7313,6 @@ function direct(proxy) {
|
|
|
5450
7313
|
"no-error-alert"
|
|
5451
7314
|
);
|
|
5452
7315
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
5453
|
-
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
5454
7316
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
5455
7317
|
result.appendIfPresent(
|
|
5456
7318
|
`,test-timeout=${proxy["test-timeout"]}`,
|
|
@@ -5565,7 +7427,6 @@ function snell(proxy) {
|
|
|
5565
7427
|
"obfs-opts.path"
|
|
5566
7428
|
);
|
|
5567
7429
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
5568
|
-
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
5569
7430
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
5570
7431
|
result.appendIfPresent(
|
|
5571
7432
|
`,test-timeout=${proxy["test-timeout"]}`,
|
|
@@ -5902,14 +7763,19 @@ function ClashMeta_Producer() {
|
|
|
5902
7763
|
const type = "ALL";
|
|
5903
7764
|
const produce2 = (proxies, type2, opts = {}) => {
|
|
5904
7765
|
const list = proxies.filter((proxy) => {
|
|
5905
|
-
if (opts["include-unsupported-proxy"])
|
|
5906
|
-
return true;
|
|
7766
|
+
if (opts["include-unsupported-proxy"]) return true;
|
|
5907
7767
|
if (proxy.type === "h2-connect") {
|
|
5908
7768
|
app_default.error(
|
|
5909
7769
|
`mihomo does not support HTTP/2 CONNECT proxy type. Proxy ${proxy.name} has been filtered.`
|
|
5910
7770
|
);
|
|
5911
7771
|
return false;
|
|
5912
7772
|
}
|
|
7773
|
+
if (proxy.type === "masque-surge") {
|
|
7774
|
+
app_default.error(
|
|
7775
|
+
`mihomo does not support Surge MASQUE proxy type. Proxy ${proxy.name} has been filtered.`
|
|
7776
|
+
);
|
|
7777
|
+
return false;
|
|
7778
|
+
}
|
|
5913
7779
|
if (hasRootHeaders(proxy) && proxy.type === "trusttunnel") {
|
|
5914
7780
|
app_default.error(
|
|
5915
7781
|
`mihomo does not support headers for TrustTunnel proxy ${proxy.name}. Proxy has been filtered.`
|
|
@@ -6210,6 +8076,8 @@ function SurgeMac_Producer() {
|
|
|
6210
8076
|
switch (proxy.type) {
|
|
6211
8077
|
case "external":
|
|
6212
8078
|
return external(proxy);
|
|
8079
|
+
// case 'ssr':
|
|
8080
|
+
// return shadowsocksr(proxy);
|
|
6213
8081
|
default: {
|
|
6214
8082
|
if (opts.mihomoExternal || proxy._mihomoExternal) {
|
|
6215
8083
|
return mihomo(proxy, type, opts) || "";
|
|
@@ -6399,8 +8267,7 @@ function Clash_Producer() {
|
|
|
6399
8267
|
const type = "ALL";
|
|
6400
8268
|
const produce2 = (proxies, type2, opts = {}) => {
|
|
6401
8269
|
const list = proxies.filter((proxy) => {
|
|
6402
|
-
if (opts["include-unsupported-proxy"])
|
|
6403
|
-
return true;
|
|
8270
|
+
if (opts["include-unsupported-proxy"]) return true;
|
|
6404
8271
|
if (![
|
|
6405
8272
|
"ss",
|
|
6406
8273
|
"ssr",
|
|
@@ -6555,8 +8422,7 @@ function Stash_Producer() {
|
|
|
6555
8422
|
const type = "ALL";
|
|
6556
8423
|
const produce2 = (proxies, type2, opts = {}) => {
|
|
6557
8424
|
const list = proxies.filter((proxy) => {
|
|
6558
|
-
if (opts["include-unsupported-proxy"])
|
|
6559
|
-
return true;
|
|
8425
|
+
if (opts["include-unsupported-proxy"]) return true;
|
|
6560
8426
|
if (![
|
|
6561
8427
|
"ss",
|
|
6562
8428
|
"ssr",
|
|
@@ -6574,7 +8440,9 @@ function Stash_Producer() {
|
|
|
6574
8440
|
"juicity",
|
|
6575
8441
|
"anytls",
|
|
6576
8442
|
"tailscale",
|
|
6577
|
-
"trusttunnel"
|
|
8443
|
+
"trusttunnel",
|
|
8444
|
+
"masque",
|
|
8445
|
+
"mieru"
|
|
6578
8446
|
].includes(proxy.type) || proxy.type === "ss" && ![
|
|
6579
8447
|
"aes-128-gcm",
|
|
6580
8448
|
"aes-192-gcm",
|
|
@@ -6592,7 +8460,7 @@ function Stash_Producer() {
|
|
|
6592
8460
|
"xchacha20-ietf-poly1305",
|
|
6593
8461
|
"2022-blake3-aes-128-gcm",
|
|
6594
8462
|
"2022-blake3-aes-256-gcm"
|
|
6595
|
-
].includes(proxy.cipher) || proxy.type === "snell" && proxy.version
|
|
8463
|
+
].includes(proxy.cipher) || proxy.type === "snell" && proxy.version > 6) {
|
|
6596
8464
|
return false;
|
|
6597
8465
|
} else if (!supportsShadowsocksV2rayPluginMode(proxy, ["websocket"])) {
|
|
6598
8466
|
return false;
|
|
@@ -6600,9 +8468,7 @@ function Stash_Producer() {
|
|
|
6600
8468
|
return false;
|
|
6601
8469
|
} else if (["anytls"].includes(proxy.type) && proxy.network && (!["tcp"].includes(proxy.network) || ["tcp"].includes(proxy.network) && proxy["reality-opts"])) {
|
|
6602
8470
|
return false;
|
|
6603
|
-
} else if (["xhttp"].includes(proxy.network)) {
|
|
6604
|
-
return false;
|
|
6605
|
-
} else if (proxy.encryption && proxy.encryption !== "none" && ["vless"].includes(proxy.type)) {
|
|
8471
|
+
} else if (!["vless"].includes(proxy.type) && ["xhttp"].includes(proxy.network)) {
|
|
6606
8472
|
return false;
|
|
6607
8473
|
} else if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
6608
8474
|
return false;
|
|
@@ -6846,13 +8712,11 @@ function Loon_Producer() {
|
|
|
6846
8712
|
}
|
|
6847
8713
|
function appendTlsProfile(result, proxy) {
|
|
6848
8714
|
const tlsProfile = getLoonTlsProfile(proxy);
|
|
6849
|
-
if (tlsProfile)
|
|
6850
|
-
result.append(`,tls-profile=${tlsProfile}`);
|
|
8715
|
+
if (tlsProfile) result.append(`,tls-profile=${tlsProfile}`);
|
|
6851
8716
|
}
|
|
6852
8717
|
function appendAlpn2(result, proxy) {
|
|
6853
8718
|
const alpn = getLoonAlpn(proxy);
|
|
6854
|
-
if (alpn)
|
|
6855
|
-
result.append(`,alpn="${alpn}"`);
|
|
8719
|
+
if (alpn) result.append(`,alpn="${alpn}"`);
|
|
6856
8720
|
}
|
|
6857
8721
|
function getLoonShadowTLSAlpn(proxy) {
|
|
6858
8722
|
const values = proxy?.["plugin-opts"]?.alpn ?? proxy?.alpn;
|
|
@@ -6860,16 +8724,13 @@ function getLoonShadowTLSAlpn(proxy) {
|
|
|
6860
8724
|
return normalized.map((item) => `${item}`.trim()).filter((item) => item !== "").join(",");
|
|
6861
8725
|
}
|
|
6862
8726
|
function appendShadowTLS2(result, proxy) {
|
|
6863
|
-
if (proxy.plugin !== "shadow-tls" || !proxy["plugin-opts"])
|
|
6864
|
-
return;
|
|
8727
|
+
if (proxy.plugin !== "shadow-tls" || !proxy["plugin-opts"]) return;
|
|
6865
8728
|
const password = proxy["plugin-opts"].password;
|
|
6866
8729
|
const host = proxy["plugin-opts"].host;
|
|
6867
8730
|
const version = proxy["plugin-opts"].version;
|
|
6868
|
-
if (!password)
|
|
6869
|
-
return;
|
|
8731
|
+
if (!password) return;
|
|
6870
8732
|
result.append(`,shadow-tls-password=${password}`);
|
|
6871
|
-
if (host)
|
|
6872
|
-
result.append(`,shadow-tls-sni=${host}`);
|
|
8733
|
+
if (host) result.append(`,shadow-tls-sni=${host}`);
|
|
6873
8734
|
if (version) {
|
|
6874
8735
|
if (version < 2) {
|
|
6875
8736
|
throw new Error(`shadow-tls version ${version} is not supported`);
|
|
@@ -6878,8 +8739,7 @@ function appendShadowTLS2(result, proxy) {
|
|
|
6878
8739
|
}
|
|
6879
8740
|
appendTlsProfile(result, proxy);
|
|
6880
8741
|
const alpn = getLoonShadowTLSAlpn(proxy);
|
|
6881
|
-
if (alpn)
|
|
6882
|
-
result.append(`,alpn="${alpn}"`);
|
|
8742
|
+
if (alpn) result.append(`,alpn="${alpn}"`);
|
|
6883
8743
|
result.appendIfPresent(`,udp-port=${proxy["udp-port"]}`, "udp-port");
|
|
6884
8744
|
}
|
|
6885
8745
|
function appendReality(result, proxy) {
|
|
@@ -7462,8 +9322,7 @@ function getHttpUpgradeEarlyData(transportOpts, path) {
|
|
|
7462
9322
|
const httpUpgradeEd = getSafeEarlyDataValue(
|
|
7463
9323
|
transportOpts?.["_v2ray-http-upgrade-ed"]
|
|
7464
9324
|
);
|
|
7465
|
-
if (httpUpgradeEd !== "")
|
|
7466
|
-
return httpUpgradeEd;
|
|
9325
|
+
if (httpUpgradeEd !== "") return httpUpgradeEd;
|
|
7467
9326
|
const pathEd = getSafeEarlyDataValue(
|
|
7468
9327
|
extractPathQueryParam(path || "/", "ed").value
|
|
7469
9328
|
);
|
|
@@ -7495,8 +9354,7 @@ function setWebSocketEarlyDataPath(path, transportOpts) {
|
|
|
7495
9354
|
return setPathQueryParam(path || "/", "ed", earlyData);
|
|
7496
9355
|
}
|
|
7497
9356
|
function getSafeEarlyDataValue(value) {
|
|
7498
|
-
if (value == null || `${value}` === "")
|
|
7499
|
-
return "";
|
|
9357
|
+
if (value == null || `${value}` === "") return "";
|
|
7500
9358
|
return parseSafeIntegerValue(value) == null ? "" : `${value}`;
|
|
7501
9359
|
}
|
|
7502
9360
|
function parseIntegerLikeValue(value) {
|
|
@@ -7855,6 +9713,10 @@ function vless2(proxy) {
|
|
|
7855
9713
|
const publicKey = proxy["reality-opts"]?.["public-key"];
|
|
7856
9714
|
if (publicKey) {
|
|
7857
9715
|
pbk = `&pbk=${encodeURIComponent(publicKey)}`;
|
|
9716
|
+
const mlkem = proxy["reality-opts"]["support-x25519mlkem768"];
|
|
9717
|
+
if (mlkem) {
|
|
9718
|
+
pbk += `&support-x25519mlkem768=${encodeURIComponent(mlkem)}`;
|
|
9719
|
+
}
|
|
7858
9720
|
}
|
|
7859
9721
|
const shortId = proxy["reality-opts"]?.["short-id"];
|
|
7860
9722
|
if (shortId) {
|
|
@@ -8222,10 +10084,25 @@ function URI_Producer() {
|
|
|
8222
10084
|
break;
|
|
8223
10085
|
case "ssr":
|
|
8224
10086
|
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"] ? "&
|
|
10087
|
+
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
10088
|
result = "ssr://" + Base644.encode(result);
|
|
8227
10089
|
break;
|
|
8228
10090
|
case "vmess":
|
|
10091
|
+
if (proxy["reality-opts"]) {
|
|
10092
|
+
if (proxy.aead === false || proxy.aead !== true && Number(proxy.alterId || 0) !== 0) {
|
|
10093
|
+
throw new Error(
|
|
10094
|
+
"VMess REALITY URI requires AEAD (alterId=0)"
|
|
10095
|
+
);
|
|
10096
|
+
}
|
|
10097
|
+
result = vless2({
|
|
10098
|
+
...proxy,
|
|
10099
|
+
server: isIPv6(proxy.server) ? `[${proxy.server}]` : proxy.server,
|
|
10100
|
+
network: proxy.network || "tcp",
|
|
10101
|
+
encryption: normalizeVmessSecurity(proxy.cipher),
|
|
10102
|
+
flow: void 0
|
|
10103
|
+
}).replace(/^vless:\/\//, "vmess://");
|
|
10104
|
+
break;
|
|
10105
|
+
}
|
|
8229
10106
|
let type2 = "";
|
|
8230
10107
|
let net = proxy.network || "tcp";
|
|
8231
10108
|
if (proxy.network === "http") {
|
|
@@ -8713,7 +10590,26 @@ Reason: ${err}`);
|
|
|
8713
10590
|
}
|
|
8714
10591
|
|
|
8715
10592
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/qx.js
|
|
10593
|
+
var import_buffer2 = __toESM(require_buffer());
|
|
8716
10594
|
var targetPlatform4 = "QX";
|
|
10595
|
+
function encodeQxAlpn(alpn) {
|
|
10596
|
+
const protocols = (Array.isArray(alpn) ? alpn : `${alpn}`.split(",")).map((protocol) => `${protocol}`.trim()).filter(Boolean);
|
|
10597
|
+
return protocols.map((protocol) => {
|
|
10598
|
+
const bytes = import_buffer2.Buffer.from(protocol, "utf8");
|
|
10599
|
+
if (bytes.length > 255) {
|
|
10600
|
+
throw new Error("QX ALPN protocol exceeds 255 bytes");
|
|
10601
|
+
}
|
|
10602
|
+
return `${bytes.length.toString(16).padStart(2, "0")}${bytes.toString("hex")}`;
|
|
10603
|
+
}).join("") || void 0;
|
|
10604
|
+
}
|
|
10605
|
+
function appendTlsAlpn(result, proxy) {
|
|
10606
|
+
if (isPresent2(proxy, "tls-alpn")) {
|
|
10607
|
+
result.append(`,tls-alpn=${proxy["tls-alpn"]}`);
|
|
10608
|
+
return;
|
|
10609
|
+
}
|
|
10610
|
+
const encoded = isPresent2(proxy, "alpn") && encodeQxAlpn(proxy.alpn);
|
|
10611
|
+
if (encoded) result.append(`,tls-alpn=${encoded}`);
|
|
10612
|
+
}
|
|
8717
10613
|
function QX_Producer() {
|
|
8718
10614
|
const produce2 = (proxy, type, opts = {}) => {
|
|
8719
10615
|
if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
@@ -8833,10 +10729,8 @@ function shadowsocks3(proxy) {
|
|
|
8833
10729
|
}
|
|
8834
10730
|
} else if (proxy.plugin === "v2ray-plugin" && proxy["plugin-opts"].mode === "websocket") {
|
|
8835
10731
|
const opts = proxy["plugin-opts"];
|
|
8836
|
-
if (opts.tls)
|
|
8837
|
-
|
|
8838
|
-
else
|
|
8839
|
-
append(`,obfs=ws`);
|
|
10732
|
+
if (opts.tls) append(`,obfs=wss`);
|
|
10733
|
+
else append(`,obfs=ws`);
|
|
8840
10734
|
} else {
|
|
8841
10735
|
throw new Error(`plugin is not supported`);
|
|
8842
10736
|
}
|
|
@@ -8854,7 +10748,7 @@ function shadowsocks3(proxy) {
|
|
|
8854
10748
|
`,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
|
|
8855
10749
|
"tls-pubkey-sha256"
|
|
8856
10750
|
);
|
|
8857
|
-
|
|
10751
|
+
appendTlsAlpn(result, proxy);
|
|
8858
10752
|
appendIfPresent(
|
|
8859
10753
|
`,tls-no-session-ticket=${proxy["tls-no-session-ticket"]}`,
|
|
8860
10754
|
"tls-no-session-ticket"
|
|
@@ -8921,10 +10815,8 @@ function trojan3(proxy) {
|
|
|
8921
10815
|
append(`,password=${proxy.password}`);
|
|
8922
10816
|
if (isPresent2(proxy, "network")) {
|
|
8923
10817
|
if (proxy.network === "ws") {
|
|
8924
|
-
if (needTls(proxy))
|
|
8925
|
-
|
|
8926
|
-
else
|
|
8927
|
-
append(`,obfs=ws`);
|
|
10818
|
+
if (needTls(proxy)) append(`,obfs=wss`);
|
|
10819
|
+
else append(`,obfs=ws`);
|
|
8928
10820
|
appendIfPresent(
|
|
8929
10821
|
`,obfs-uri=${proxy["ws-opts"]?.path}`,
|
|
8930
10822
|
"ws-opts.path"
|
|
@@ -8945,7 +10837,7 @@ function trojan3(proxy) {
|
|
|
8945
10837
|
`,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
|
|
8946
10838
|
"tls-pubkey-sha256"
|
|
8947
10839
|
);
|
|
8948
|
-
|
|
10840
|
+
appendTlsAlpn(result, proxy);
|
|
8949
10841
|
appendIfPresent(
|
|
8950
10842
|
`,tls-no-session-ticket=${proxy["tls-no-session-ticket"]}`,
|
|
8951
10843
|
"tls-no-session-ticket"
|
|
@@ -8983,15 +10875,12 @@ function vmess3(proxy) {
|
|
|
8983
10875
|
}
|
|
8984
10876
|
if (isPresent2(proxy, "network")) {
|
|
8985
10877
|
if (proxy.network === "ws") {
|
|
8986
|
-
if (proxy.tls)
|
|
8987
|
-
|
|
8988
|
-
else
|
|
8989
|
-
append(`,obfs=ws`);
|
|
10878
|
+
if (proxy.tls) append(`,obfs=wss`);
|
|
10879
|
+
else append(`,obfs=ws`);
|
|
8990
10880
|
} else if (proxy.network === "http") {
|
|
8991
10881
|
append(`,obfs=${getQxHttpObfs(proxy)}`);
|
|
8992
10882
|
} else if (["tcp"].includes(proxy.network)) {
|
|
8993
|
-
if (proxy.tls)
|
|
8994
|
-
append(`,obfs=over-tls`);
|
|
10883
|
+
if (proxy.tls) append(`,obfs=over-tls`);
|
|
8995
10884
|
} else if (!["tcp"].includes(proxy.network)) {
|
|
8996
10885
|
throw new Error(`network ${proxy.network} is unsupported`);
|
|
8997
10886
|
}
|
|
@@ -9006,15 +10895,14 @@ function vmess3(proxy) {
|
|
|
9006
10895
|
`${proxy.network}-opts.headers.Host`
|
|
9007
10896
|
);
|
|
9008
10897
|
} else {
|
|
9009
|
-
if (proxy.tls)
|
|
9010
|
-
append(`,obfs=over-tls`);
|
|
10898
|
+
if (proxy.tls) append(`,obfs=over-tls`);
|
|
9011
10899
|
}
|
|
9012
10900
|
if (needTls(proxy)) {
|
|
9013
10901
|
appendIfPresent(
|
|
9014
10902
|
`,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
|
|
9015
10903
|
"tls-pubkey-sha256"
|
|
9016
10904
|
);
|
|
9017
|
-
|
|
10905
|
+
appendTlsAlpn(result, proxy);
|
|
9018
10906
|
appendIfPresent(
|
|
9019
10907
|
`,tls-no-session-ticket=${proxy["tls-no-session-ticket"]}`,
|
|
9020
10908
|
"tls-no-session-ticket"
|
|
@@ -9059,15 +10947,12 @@ function vless3(proxy) {
|
|
|
9059
10947
|
}
|
|
9060
10948
|
if (isPresent2(proxy, "network")) {
|
|
9061
10949
|
if (proxy.network === "ws") {
|
|
9062
|
-
if (proxy.tls)
|
|
9063
|
-
|
|
9064
|
-
else
|
|
9065
|
-
append(`,obfs=ws`);
|
|
10950
|
+
if (proxy.tls) append(`,obfs=wss`);
|
|
10951
|
+
else append(`,obfs=ws`);
|
|
9066
10952
|
} else if (proxy.network === "http") {
|
|
9067
10953
|
append(`,obfs=${getQxHttpObfs(proxy)}`);
|
|
9068
10954
|
} else if (["tcp"].includes(proxy.network)) {
|
|
9069
|
-
if (proxy.tls)
|
|
9070
|
-
append(`,obfs=over-tls`);
|
|
10955
|
+
if (proxy.tls) append(`,obfs=over-tls`);
|
|
9071
10956
|
} else if (!["tcp"].includes(proxy.network)) {
|
|
9072
10957
|
throw new Error(`network ${proxy.network} is unsupported`);
|
|
9073
10958
|
}
|
|
@@ -9082,15 +10967,14 @@ function vless3(proxy) {
|
|
|
9082
10967
|
`${proxy.network}-opts.headers.Host`
|
|
9083
10968
|
);
|
|
9084
10969
|
} else {
|
|
9085
|
-
if (proxy.tls)
|
|
9086
|
-
append(`,obfs=over-tls`);
|
|
10970
|
+
if (proxy.tls) append(`,obfs=over-tls`);
|
|
9087
10971
|
}
|
|
9088
10972
|
if (needTls(proxy)) {
|
|
9089
10973
|
appendIfPresent(
|
|
9090
10974
|
`,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
|
|
9091
10975
|
"tls-pubkey-sha256"
|
|
9092
10976
|
);
|
|
9093
|
-
|
|
10977
|
+
appendTlsAlpn(result, proxy);
|
|
9094
10978
|
appendIfPresent(
|
|
9095
10979
|
`,tls-no-session-ticket=${proxy["tls-no-session-ticket"]}`,
|
|
9096
10980
|
"tls-no-session-ticket"
|
|
@@ -9134,7 +11018,7 @@ function anytls3(proxy) {
|
|
|
9134
11018
|
`,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
|
|
9135
11019
|
"tls-pubkey-sha256"
|
|
9136
11020
|
);
|
|
9137
|
-
|
|
11021
|
+
appendTlsAlpn(result, proxy);
|
|
9138
11022
|
appendIfPresent(
|
|
9139
11023
|
`,tls-no-session-ticket=${proxy["tls-no-session-ticket"]}`,
|
|
9140
11024
|
"tls-no-session-ticket"
|
|
@@ -9174,7 +11058,7 @@ function http3(proxy) {
|
|
|
9174
11058
|
`,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
|
|
9175
11059
|
"tls-pubkey-sha256"
|
|
9176
11060
|
);
|
|
9177
|
-
|
|
11061
|
+
appendTlsAlpn(result, proxy);
|
|
9178
11062
|
appendIfPresent(
|
|
9179
11063
|
`,tls-no-session-ticket=${proxy["tls-no-session-ticket"]}`,
|
|
9180
11064
|
"tls-no-session-ticket"
|
|
@@ -9215,7 +11099,7 @@ function socks53(proxy) {
|
|
|
9215
11099
|
`,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
|
|
9216
11100
|
"tls-pubkey-sha256"
|
|
9217
11101
|
);
|
|
9218
|
-
|
|
11102
|
+
appendTlsAlpn(result, proxy);
|
|
9219
11103
|
appendIfPresent(
|
|
9220
11104
|
`,tls-no-session-ticket=${proxy["tls-no-session-ticket"]}`,
|
|
9221
11105
|
"tls-no-session-ticket"
|
|
@@ -9249,8 +11133,7 @@ function Shadowrocket_Producer() {
|
|
|
9249
11133
|
const type = "ALL";
|
|
9250
11134
|
const produce2 = (proxies, type2, opts = {}) => {
|
|
9251
11135
|
const list = proxies.filter((proxy) => {
|
|
9252
|
-
if (opts["include-unsupported-proxy"])
|
|
9253
|
-
return true;
|
|
11136
|
+
if (opts["include-unsupported-proxy"]) return true;
|
|
9254
11137
|
if (!supportsShadowsocksV2rayPluginMode(proxy, [
|
|
9255
11138
|
"websocket",
|
|
9256
11139
|
"quic",
|
|
@@ -9273,7 +11156,9 @@ function Shadowrocket_Producer() {
|
|
|
9273
11156
|
"openvpn",
|
|
9274
11157
|
"gost-relay",
|
|
9275
11158
|
"shadowquic",
|
|
9276
|
-
"zerotier"
|
|
11159
|
+
"zerotier",
|
|
11160
|
+
"masque-surge",
|
|
11161
|
+
"easytier"
|
|
9277
11162
|
].includes(proxy.type)) {
|
|
9278
11163
|
return false;
|
|
9279
11164
|
} else if (["xhttp"].includes(proxy.network)) {
|
|
@@ -9791,10 +11676,8 @@ var domainResolverParser = (proxy, parsedProxy) => {
|
|
|
9791
11676
|
};
|
|
9792
11677
|
var hasControlHTTPClient = (proxy) => {
|
|
9793
11678
|
const value = proxy["control-http-client"];
|
|
9794
|
-
if (value === void 0 || value === null)
|
|
9795
|
-
|
|
9796
|
-
if (typeof value === "string")
|
|
9797
|
-
return value.trim() !== "";
|
|
11679
|
+
if (value === void 0 || value === null) return false;
|
|
11680
|
+
if (typeof value === "string") return value.trim() !== "";
|
|
9798
11681
|
if (isPlainObject(value)) {
|
|
9799
11682
|
return Object.values(value).some(
|
|
9800
11683
|
(item) => item !== void 0 && item !== null && item !== ""
|
|
@@ -9816,18 +11699,13 @@ var networkParser = (proxy, parsedProxy) => {
|
|
|
9816
11699
|
};
|
|
9817
11700
|
var tfoParser = (proxy, parsedProxy) => {
|
|
9818
11701
|
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;
|
|
11702
|
+
if (proxy.tfo) parsedProxy.tcp_fast_open = true;
|
|
11703
|
+
if (proxy.tcp_fast_open) parsedProxy.tcp_fast_open = true;
|
|
11704
|
+
if (proxy["tcp-fast-open"]) parsedProxy.tcp_fast_open = true;
|
|
11705
|
+
if (!parsedProxy.tcp_fast_open) delete parsedProxy.tcp_fast_open;
|
|
9827
11706
|
};
|
|
9828
11707
|
var smuxParser = (smux, proxy) => {
|
|
9829
|
-
if (!smux || !smux.enabled)
|
|
9830
|
-
return;
|
|
11708
|
+
if (!smux || !smux.enabled) return;
|
|
9831
11709
|
proxy.multiplex = { enabled: true };
|
|
9832
11710
|
proxy.multiplex.protocol = smux.protocol;
|
|
9833
11711
|
if (smux["max-connections"])
|
|
@@ -9839,8 +11717,7 @@ var smuxParser = (smux, proxy) => {
|
|
|
9839
11717
|
proxy.multiplex.max_streams = parseInt(`${smux["max-streams"]}`, 10);
|
|
9840
11718
|
if (smux["min-streams"])
|
|
9841
11719
|
proxy.multiplex.min_streams = parseInt(`${smux["min-streams"]}`, 10);
|
|
9842
|
-
if (smux.padding)
|
|
9843
|
-
proxy.multiplex.padding = true;
|
|
11720
|
+
if (smux.padding) proxy.multiplex.padding = true;
|
|
9844
11721
|
if (smux["brutal-opts"]?.up || smux["brutal-opts"]?.down) {
|
|
9845
11722
|
proxy.multiplex.brutal = {
|
|
9846
11723
|
enabled: true
|
|
@@ -9868,25 +11745,20 @@ var wsParser = (proxy, parsedProxy) => {
|
|
|
9868
11745
|
} = proxy["ws-opts"];
|
|
9869
11746
|
transport.early_data_header_name = early_data_header_name;
|
|
9870
11747
|
transport.max_early_data = max_early_data ? parseInt(max_early_data, 10) : void 0;
|
|
9871
|
-
if (wsPath !== "")
|
|
9872
|
-
transport.path = `${wsPath}`;
|
|
11748
|
+
if (wsPath !== "") transport.path = `${wsPath}`;
|
|
9873
11749
|
if (Object.keys(wsHeaders).length > 0) {
|
|
9874
11750
|
const headers = {};
|
|
9875
11751
|
for (const key of Object.keys(wsHeaders)) {
|
|
9876
11752
|
let value = wsHeaders[key];
|
|
9877
|
-
if (value === "")
|
|
9878
|
-
|
|
9879
|
-
if (
|
|
9880
|
-
value = [`${value}`];
|
|
9881
|
-
if (value.length > 0)
|
|
9882
|
-
headers[key] = value;
|
|
11753
|
+
if (value === "") continue;
|
|
11754
|
+
if (!Array.isArray(value)) value = [`${value}`];
|
|
11755
|
+
if (value.length > 0) headers[key] = value;
|
|
9883
11756
|
}
|
|
9884
11757
|
const { Host: wsHost } = headers;
|
|
9885
11758
|
if (wsHost.length === 1)
|
|
9886
11759
|
for (const item of `Host:${wsHost[0]}`.split("\n")) {
|
|
9887
11760
|
const [key, value] = item.split(":");
|
|
9888
|
-
if (value.trim() === "")
|
|
9889
|
-
continue;
|
|
11761
|
+
if (value.trim() === "") continue;
|
|
9890
11762
|
headers[key.trim()] = value.trim().split(",");
|
|
9891
11763
|
}
|
|
9892
11764
|
transport.headers = headers;
|
|
@@ -9896,19 +11768,15 @@ var wsParser = (proxy, parsedProxy) => {
|
|
|
9896
11768
|
const headers = {};
|
|
9897
11769
|
for (const key of Object.keys(proxy["ws-headers"])) {
|
|
9898
11770
|
let value = proxy["ws-headers"][key];
|
|
9899
|
-
if (value === "")
|
|
9900
|
-
|
|
9901
|
-
if (
|
|
9902
|
-
value = [`${value}`];
|
|
9903
|
-
if (value.length > 0)
|
|
9904
|
-
headers[key] = value;
|
|
11771
|
+
if (value === "") continue;
|
|
11772
|
+
if (!Array.isArray(value)) value = [`${value}`];
|
|
11773
|
+
if (value.length > 0) headers[key] = value;
|
|
9905
11774
|
}
|
|
9906
11775
|
const { Host: wsHost } = headers;
|
|
9907
11776
|
if (wsHost.length === 1)
|
|
9908
11777
|
for (const item of `Host:${wsHost[0]}`.split("\n")) {
|
|
9909
11778
|
const [key, value] = item.split(":");
|
|
9910
|
-
if (value.trim() === "")
|
|
9911
|
-
continue;
|
|
11779
|
+
if (value.trim() === "") continue;
|
|
9912
11780
|
headers[key.trim()] = value.trim().split(",");
|
|
9913
11781
|
}
|
|
9914
11782
|
for (const key of Object.keys(headers))
|
|
@@ -9932,15 +11800,13 @@ var wsParser = (proxy, parsedProxy) => {
|
|
|
9932
11800
|
transport.host = transport.headers.Host[0];
|
|
9933
11801
|
delete transport.headers.Host;
|
|
9934
11802
|
}
|
|
9935
|
-
if (transport.max_early_data)
|
|
9936
|
-
delete transport.max_early_data;
|
|
11803
|
+
if (transport.max_early_data) delete transport.max_early_data;
|
|
9937
11804
|
if (transport.early_data_header_name)
|
|
9938
11805
|
delete transport.early_data_header_name;
|
|
9939
11806
|
}
|
|
9940
11807
|
for (const key of Object.keys(transport.headers)) {
|
|
9941
11808
|
const value = transport.headers[key];
|
|
9942
|
-
if (value.length === 1)
|
|
9943
|
-
transport.headers[key] = value[0];
|
|
11809
|
+
if (value.length === 1) transport.headers[key] = value[0];
|
|
9944
11810
|
}
|
|
9945
11811
|
parsedProxy.transport = transport;
|
|
9946
11812
|
};
|
|
@@ -9952,52 +11818,43 @@ var h1Parser = (proxy, parsedProxy) => {
|
|
|
9952
11818
|
path: h1Path = "",
|
|
9953
11819
|
headers: h1Headers = {}
|
|
9954
11820
|
} = proxy["http-opts"];
|
|
9955
|
-
if (method !== "")
|
|
9956
|
-
transport.method = method;
|
|
11821
|
+
if (method !== "") transport.method = method;
|
|
9957
11822
|
if (Array.isArray(h1Path)) {
|
|
9958
11823
|
transport.path = `${h1Path[0]}`;
|
|
9959
|
-
} else if (h1Path !== "")
|
|
9960
|
-
transport.path = `${h1Path}`;
|
|
11824
|
+
} else if (h1Path !== "") transport.path = `${h1Path}`;
|
|
9961
11825
|
for (const key of Object.keys(h1Headers)) {
|
|
9962
11826
|
let value = h1Headers[key];
|
|
9963
|
-
if (value === "")
|
|
9964
|
-
continue;
|
|
11827
|
+
if (value === "") continue;
|
|
9965
11828
|
if (key.toLowerCase() === "host") {
|
|
9966
11829
|
let host = value;
|
|
9967
11830
|
if (!Array.isArray(host))
|
|
9968
11831
|
host = `${host}`.split(",").map((i) => i.trim());
|
|
9969
|
-
if (host.length > 0)
|
|
9970
|
-
transport.host = host;
|
|
11832
|
+
if (host.length > 0) transport.host = host;
|
|
9971
11833
|
continue;
|
|
9972
11834
|
}
|
|
9973
11835
|
if (!Array.isArray(value))
|
|
9974
11836
|
value = `${value}`.split(",").map((i) => i.trim());
|
|
9975
|
-
if (value.length > 0)
|
|
9976
|
-
transport.headers[key] = value;
|
|
11837
|
+
if (value.length > 0) transport.headers[key] = value;
|
|
9977
11838
|
}
|
|
9978
11839
|
}
|
|
9979
11840
|
if (proxy["http-host"] && proxy["http-host"] !== "") {
|
|
9980
11841
|
let host = proxy["http-host"];
|
|
9981
11842
|
if (!Array.isArray(host))
|
|
9982
11843
|
host = `${host}`.split(",").map((i) => i.trim());
|
|
9983
|
-
if (host.length > 0)
|
|
9984
|
-
transport.host = host;
|
|
11844
|
+
if (host.length > 0) transport.host = host;
|
|
9985
11845
|
}
|
|
9986
11846
|
if (proxy["http-path"] && proxy["http-path"] !== "") {
|
|
9987
11847
|
const path = proxy["http-path"];
|
|
9988
11848
|
if (Array.isArray(path)) {
|
|
9989
11849
|
transport.path = `${path[0]}`;
|
|
9990
|
-
} else if (path !== "")
|
|
9991
|
-
transport.path = `${path}`;
|
|
11850
|
+
} else if (path !== "") transport.path = `${path}`;
|
|
9992
11851
|
}
|
|
9993
11852
|
if (parsedProxy.tls.insecure)
|
|
9994
11853
|
parsedProxy.tls.server_name = transport.host[0];
|
|
9995
|
-
if (transport.host?.length === 1)
|
|
9996
|
-
transport.host = transport.host[0];
|
|
11854
|
+
if (transport.host?.length === 1) transport.host = transport.host[0];
|
|
9997
11855
|
for (const key of Object.keys(transport.headers)) {
|
|
9998
11856
|
const value = transport.headers[key];
|
|
9999
|
-
if (value.length === 1)
|
|
10000
|
-
transport.headers[key] = value[0];
|
|
11857
|
+
if (value.length === 1) transport.headers[key] = value[0];
|
|
10001
11858
|
}
|
|
10002
11859
|
parsedProxy.transport = transport;
|
|
10003
11860
|
};
|
|
@@ -10005,29 +11862,25 @@ var h2Parser = (proxy, parsedProxy) => {
|
|
|
10005
11862
|
const transport = { type: "http" };
|
|
10006
11863
|
if (proxy["h2-opts"]) {
|
|
10007
11864
|
let { host = "", path = "" } = proxy["h2-opts"];
|
|
10008
|
-
if (path !== "")
|
|
10009
|
-
transport.path = `${path}`;
|
|
11865
|
+
if (path !== "") transport.path = `${path}`;
|
|
10010
11866
|
if (host !== "") {
|
|
10011
11867
|
if (!Array.isArray(host))
|
|
10012
11868
|
host = `${host}`.split(",").map((i) => i.trim());
|
|
10013
|
-
if (host.length > 0)
|
|
10014
|
-
transport.host = host;
|
|
11869
|
+
if (host.length > 0) transport.host = host;
|
|
10015
11870
|
}
|
|
10016
11871
|
}
|
|
10017
11872
|
if (proxy["h2-host"] && proxy["h2-host"] !== "") {
|
|
10018
11873
|
let host = proxy["h2-host"];
|
|
10019
11874
|
if (!Array.isArray(host))
|
|
10020
11875
|
host = `${host}`.split(",").map((i) => i.trim());
|
|
10021
|
-
if (host.length > 0)
|
|
10022
|
-
transport.host = host;
|
|
11876
|
+
if (host.length > 0) transport.host = host;
|
|
10023
11877
|
}
|
|
10024
11878
|
if (proxy["h2-path"] && proxy["h2-path"] !== "")
|
|
10025
11879
|
transport.path = `${proxy["h2-path"]}`;
|
|
10026
11880
|
parsedProxy.tls.enabled = true;
|
|
10027
11881
|
if (parsedProxy.tls.insecure)
|
|
10028
11882
|
parsedProxy.tls.server_name = transport.host[0];
|
|
10029
|
-
if (transport.host.length === 1)
|
|
10030
|
-
transport.host = transport.host[0];
|
|
11883
|
+
if (transport.host.length === 1) transport.host = transport.host[0];
|
|
10031
11884
|
parsedProxy.transport = transport;
|
|
10032
11885
|
};
|
|
10033
11886
|
var grpcParser = (proxy, parsedProxy) => {
|
|
@@ -10044,16 +11897,13 @@ var normalizePemLines = (value, label) => {
|
|
|
10044
11897
|
const lines = [];
|
|
10045
11898
|
for (const item of items) {
|
|
10046
11899
|
const normalized = `${item}`.trim().replace(/\\r\\n/g, "\n").replace(/\\n/g, "\n");
|
|
10047
|
-
if (normalized === "")
|
|
10048
|
-
continue;
|
|
11900
|
+
if (normalized === "") continue;
|
|
10049
11901
|
for (const line of normalized.split(/\r?\n/)) {
|
|
10050
11902
|
const trimmed = line.trim();
|
|
10051
|
-
if (trimmed !== "")
|
|
10052
|
-
lines.push(trimmed);
|
|
11903
|
+
if (trimmed !== "") lines.push(trimmed);
|
|
10053
11904
|
}
|
|
10054
11905
|
}
|
|
10055
|
-
if (lines.length === 0)
|
|
10056
|
-
return void 0;
|
|
11906
|
+
if (lines.length === 0) return void 0;
|
|
10057
11907
|
if (lines.some((line) => /^-----BEGIN [A-Za-z0-9 -]+-----$/.test(line))) {
|
|
10058
11908
|
return lines;
|
|
10059
11909
|
}
|
|
@@ -10073,34 +11923,24 @@ var singBoxUtlsFingerprints = [
|
|
|
10073
11923
|
];
|
|
10074
11924
|
var getSingBoxUtlsFingerprint = (value) => {
|
|
10075
11925
|
const fingerprint = `${value || ""}`.trim().toLowerCase();
|
|
10076
|
-
if (singBoxUtlsFingerprints.includes(fingerprint))
|
|
10077
|
-
return fingerprint;
|
|
11926
|
+
if (singBoxUtlsFingerprints.includes(fingerprint)) return fingerprint;
|
|
10078
11927
|
};
|
|
10079
11928
|
var tlsParser = (proxy, parsedProxy) => {
|
|
10080
|
-
if (proxy.tls)
|
|
10081
|
-
parsedProxy.tls.enabled = true;
|
|
11929
|
+
if (proxy.tls) parsedProxy.tls.enabled = true;
|
|
10082
11930
|
if (proxy.servername && proxy.servername !== "")
|
|
10083
11931
|
parsedProxy.tls.server_name = proxy.servername;
|
|
10084
11932
|
if (proxy.peer && proxy.peer !== "")
|
|
10085
11933
|
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;
|
|
11934
|
+
if (proxy.sni && proxy.sni !== "") parsedProxy.tls.server_name = proxy.sni;
|
|
11935
|
+
if (proxy["skip-cert-verify"]) parsedProxy.tls.insecure = true;
|
|
11936
|
+
if (proxy.insecure) parsedProxy.tls.insecure = true;
|
|
11937
|
+
if (proxy["disable-sni"]) parsedProxy.tls.disable_sni = true;
|
|
10094
11938
|
if (typeof proxy.alpn === "string") {
|
|
10095
11939
|
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"]];
|
|
11940
|
+
} else if (Array.isArray(proxy.alpn)) parsedProxy.tls.alpn = proxy.alpn;
|
|
11941
|
+
if (proxy.ca) parsedProxy.tls.certificate_path = `${proxy.ca}`;
|
|
11942
|
+
if (proxy.ca_str) parsedProxy.tls.certificate = [proxy.ca_str];
|
|
11943
|
+
if (proxy["ca-str"]) parsedProxy.tls.certificate = [proxy["ca-str"]];
|
|
10104
11944
|
if (proxy["reality-opts"]) {
|
|
10105
11945
|
parsedProxy.tls.reality = { enabled: true };
|
|
10106
11946
|
if (proxy["reality-opts"]["public-key"])
|
|
@@ -10128,8 +11968,7 @@ var tlsParser = (proxy, parsedProxy) => {
|
|
|
10128
11968
|
const echOptsConfig = proxy["ech-opts"].config;
|
|
10129
11969
|
if (Array.isArray(echOptsConfig) || typeof echOptsConfig === "string") {
|
|
10130
11970
|
const config = normalizePemLines(echOptsConfig, "ECH CONFIGS");
|
|
10131
|
-
if (config)
|
|
10132
|
-
parsedProxy.tls.ech.config = config;
|
|
11971
|
+
if (config) parsedProxy.tls.ech.config = config;
|
|
10133
11972
|
}
|
|
10134
11973
|
parsedProxy.tls.ech.query_server_name = proxy["ech-opts"]["query-server-name"];
|
|
10135
11974
|
parsedProxy.tls.ech.config_path = proxy["ech-opts"]["config-path"];
|
|
@@ -10140,8 +11979,7 @@ var tlsParser = (proxy, parsedProxy) => {
|
|
|
10140
11979
|
if (proxy._curve_preferences && Array.isArray(proxy._curve_preferences)) {
|
|
10141
11980
|
parsedProxy.tls.curve_preferences = proxy._curve_preferences;
|
|
10142
11981
|
}
|
|
10143
|
-
if (proxy["_fragment"])
|
|
10144
|
-
parsedProxy.tls.fragment = !!proxy["_fragment"];
|
|
11982
|
+
if (proxy["_fragment"]) parsedProxy.tls.fragment = !!proxy["_fragment"];
|
|
10145
11983
|
if (proxy["_fragment_fallback_delay"])
|
|
10146
11984
|
parsedProxy.tls.fragment_fallback_delay = proxy["_fragment_fallback_delay"];
|
|
10147
11985
|
if (proxy["_record_fragment"])
|
|
@@ -10156,12 +11994,16 @@ var tlsParser = (proxy, parsedProxy) => {
|
|
|
10156
11994
|
parsedProxy.tls.client_certificate = proxy["_client_certificate"];
|
|
10157
11995
|
if (proxy["_client_certificate_path"])
|
|
10158
11996
|
parsedProxy.tls.client_certificate_path = proxy["_client_certificate_path"];
|
|
10159
|
-
if (proxy["_client_key"])
|
|
10160
|
-
parsedProxy.tls.client_key = proxy["_client_key"];
|
|
11997
|
+
if (proxy["_client_key"]) parsedProxy.tls.client_key = proxy["_client_key"];
|
|
10161
11998
|
if (proxy["_client_key_path"])
|
|
10162
11999
|
parsedProxy.tls.client_key_path = proxy["_client_key_path"];
|
|
10163
|
-
if (!parsedProxy.tls.enabled)
|
|
12000
|
+
if (!parsedProxy.tls.enabled) {
|
|
10164
12001
|
delete parsedProxy.tls;
|
|
12002
|
+
} else if ((proxy.fingerprint || proxy["tls-fingerprint"]) && !parsedProxy.tls.reality && !parsedProxy.tls.certificate && !parsedProxy.tls.certificate_path && !parsedProxy.tls.certificate_public_key_sha256) {
|
|
12003
|
+
app_default.warn(
|
|
12004
|
+
`Platform sing-box does not support certificate fingerprint pinning, it is dropped for proxy ${proxy.name}. Set _certificate_public_key_sha256 to pin the certificate public key instead`
|
|
12005
|
+
);
|
|
12006
|
+
}
|
|
10165
12007
|
};
|
|
10166
12008
|
var sshParser = (proxy = {}) => {
|
|
10167
12009
|
const parsedProxy = {
|
|
@@ -10172,12 +12014,9 @@ var sshParser = (proxy = {}) => {
|
|
|
10172
12014
|
};
|
|
10173
12015
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10174
12016
|
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"];
|
|
12017
|
+
if (proxy.username) parsedProxy.user = proxy.username;
|
|
12018
|
+
if (proxy.password) parsedProxy.password = proxy.password;
|
|
12019
|
+
if (proxy["privateKey"]) parsedProxy.private_key_path = proxy["privateKey"];
|
|
10181
12020
|
if (proxy["private-key"])
|
|
10182
12021
|
parsedProxy.private_key_path = proxy["private-key"];
|
|
10183
12022
|
if (proxy["private-key-passphrase"])
|
|
@@ -10188,12 +12027,10 @@ var sshParser = (proxy = {}) => {
|
|
|
10188
12027
|
proxy["server-fingerprint"].split(" ")[0]
|
|
10189
12028
|
];
|
|
10190
12029
|
}
|
|
10191
|
-
if (proxy["host-key"])
|
|
10192
|
-
parsedProxy.host_key = proxy["host-key"];
|
|
12030
|
+
if (proxy["host-key"]) parsedProxy.host_key = proxy["host-key"];
|
|
10193
12031
|
if (proxy["host-key-algorithms"])
|
|
10194
12032
|
parsedProxy.host_key_algorithms = proxy["host-key-algorithms"];
|
|
10195
|
-
if (proxy["fast-open"])
|
|
10196
|
-
parsedProxy.udp_fragment = true;
|
|
12033
|
+
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
10197
12034
|
tfoParser(proxy, parsedProxy);
|
|
10198
12035
|
detourParser(proxy, parsedProxy);
|
|
10199
12036
|
ipVersionParser(proxy, parsedProxy);
|
|
@@ -10210,10 +12047,8 @@ var httpParser = (proxy = {}) => {
|
|
|
10210
12047
|
};
|
|
10211
12048
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10212
12049
|
throw "invalid port";
|
|
10213
|
-
if (proxy.username)
|
|
10214
|
-
|
|
10215
|
-
if (proxy.password)
|
|
10216
|
-
parsedProxy.password = proxy.password;
|
|
12050
|
+
if (proxy.username) parsedProxy.username = proxy.username;
|
|
12051
|
+
if (proxy.password) parsedProxy.password = proxy.password;
|
|
10217
12052
|
if (proxy.headers) {
|
|
10218
12053
|
parsedProxy.headers = {};
|
|
10219
12054
|
for (const k of Object.keys(proxy.headers)) {
|
|
@@ -10222,8 +12057,7 @@ var httpParser = (proxy = {}) => {
|
|
|
10222
12057
|
if (Object.keys(parsedProxy.headers).length === 0)
|
|
10223
12058
|
delete parsedProxy.headers;
|
|
10224
12059
|
}
|
|
10225
|
-
if (proxy["fast-open"])
|
|
10226
|
-
parsedProxy.udp_fragment = true;
|
|
12060
|
+
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
10227
12061
|
tfoParser(proxy, parsedProxy);
|
|
10228
12062
|
detourParser(proxy, parsedProxy);
|
|
10229
12063
|
tlsParser(proxy, parsedProxy);
|
|
@@ -10241,20 +12075,16 @@ var socks5Parser = (proxy = {}) => {
|
|
|
10241
12075
|
};
|
|
10242
12076
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10243
12077
|
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;
|
|
12078
|
+
if (proxy.username) parsedProxy.username = proxy.username;
|
|
12079
|
+
if (proxy.password) parsedProxy.password = proxy.password;
|
|
12080
|
+
if (proxy.uot) parsedProxy.udp_over_tcp = true;
|
|
10250
12081
|
if (proxy["udp-over-tcp"]) {
|
|
10251
12082
|
parsedProxy.udp_over_tcp = {
|
|
10252
12083
|
enabled: true,
|
|
10253
12084
|
version: !proxy["udp-over-tcp-version"] || proxy["udp-over-tcp-version"] === 1 ? 1 : 2
|
|
10254
12085
|
};
|
|
10255
12086
|
}
|
|
10256
|
-
if (proxy["fast-open"])
|
|
10257
|
-
parsedProxy.udp_fragment = true;
|
|
12087
|
+
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
10258
12088
|
networkParser(proxy, parsedProxy);
|
|
10259
12089
|
tfoParser(proxy, parsedProxy);
|
|
10260
12090
|
detourParser(proxy, parsedProxy);
|
|
@@ -10271,8 +12101,7 @@ var shadowTLSParser = (proxy = {}) => {
|
|
|
10271
12101
|
password: proxy.password,
|
|
10272
12102
|
detour: getShadowTLSTag(proxy)
|
|
10273
12103
|
};
|
|
10274
|
-
if (proxy.uot)
|
|
10275
|
-
ssPart.udp_over_tcp = true;
|
|
12104
|
+
if (proxy.uot) ssPart.udp_over_tcp = true;
|
|
10276
12105
|
if (proxy["udp-over-tcp"]) {
|
|
10277
12106
|
ssPart.udp_over_tcp = {
|
|
10278
12107
|
enabled: true,
|
|
@@ -10306,13 +12135,11 @@ var normalizeALPN = (alpn) => {
|
|
|
10306
12135
|
if (typeof alpn === "string") {
|
|
10307
12136
|
return alpn.split(",").map((item) => item.trim()).filter((item) => item !== "");
|
|
10308
12137
|
}
|
|
10309
|
-
if (Array.isArray(alpn))
|
|
10310
|
-
return alpn;
|
|
12138
|
+
if (Array.isArray(alpn)) return alpn;
|
|
10311
12139
|
return void 0;
|
|
10312
12140
|
};
|
|
10313
12141
|
var shadowTLSOutboundParser = (proxy = {}, pluginOpts) => {
|
|
10314
|
-
if (!pluginOpts)
|
|
10315
|
-
throw new Error("shadow-tls plugin options are missing");
|
|
12142
|
+
if (!pluginOpts) throw new Error("shadow-tls plugin options are missing");
|
|
10316
12143
|
const fingerprint = getSingBoxUtlsFingerprint(proxy["client-fingerprint"]);
|
|
10317
12144
|
const stPart = {
|
|
10318
12145
|
tag: getShadowTLSTag(proxy),
|
|
@@ -10326,8 +12153,7 @@ var shadowTLSOutboundParser = (proxy = {}, pluginOpts) => {
|
|
|
10326
12153
|
server_name: pluginOpts.host
|
|
10327
12154
|
}
|
|
10328
12155
|
};
|
|
10329
|
-
if (proxy["skip-cert-verify"])
|
|
10330
|
-
stPart.tls.insecure = true;
|
|
12156
|
+
if (proxy["skip-cert-verify"]) stPart.tls.insecure = true;
|
|
10331
12157
|
if (fingerprint) {
|
|
10332
12158
|
stPart.tls.utls = {
|
|
10333
12159
|
enabled: true,
|
|
@@ -10337,10 +12163,8 @@ var shadowTLSOutboundParser = (proxy = {}, pluginOpts) => {
|
|
|
10337
12163
|
if (stPart.server_port < 0 || stPart.server_port > 65535)
|
|
10338
12164
|
throw "\u7AEF\u53E3\u503C\u975E\u6CD5";
|
|
10339
12165
|
const alpn = normalizeALPN(pluginOpts.alpn) ?? normalizeALPN(proxy.alpn);
|
|
10340
|
-
if (alpn)
|
|
10341
|
-
|
|
10342
|
-
if (proxy["fast-open"] === true)
|
|
10343
|
-
stPart.udp_fragment = true;
|
|
12166
|
+
if (alpn) stPart.tls.alpn = alpn;
|
|
12167
|
+
if (proxy["fast-open"] === true) stPart.udp_fragment = true;
|
|
10344
12168
|
tfoParser(proxy, stPart);
|
|
10345
12169
|
detourParser(proxy, stPart);
|
|
10346
12170
|
ipVersionParser(proxy, stPart);
|
|
@@ -10358,16 +12182,14 @@ var ssParser = (proxy = {}) => {
|
|
|
10358
12182
|
};
|
|
10359
12183
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10360
12184
|
throw "invalid port";
|
|
10361
|
-
if (proxy.uot)
|
|
10362
|
-
parsedProxy.udp_over_tcp = true;
|
|
12185
|
+
if (proxy.uot) parsedProxy.udp_over_tcp = true;
|
|
10363
12186
|
if (proxy["udp-over-tcp"]) {
|
|
10364
12187
|
parsedProxy.udp_over_tcp = {
|
|
10365
12188
|
enabled: true,
|
|
10366
12189
|
version: !proxy["udp-over-tcp-version"] || proxy["udp-over-tcp-version"] === 1 ? 1 : 2
|
|
10367
12190
|
};
|
|
10368
12191
|
}
|
|
10369
|
-
if (proxy["fast-open"])
|
|
10370
|
-
parsedProxy.udp_fragment = true;
|
|
12192
|
+
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
10371
12193
|
networkParser(proxy, parsedProxy);
|
|
10372
12194
|
tfoParser(proxy, parsedProxy);
|
|
10373
12195
|
detourParser(proxy, parsedProxy);
|
|
@@ -10397,15 +12219,12 @@ var ssParser = (proxy = {}) => {
|
|
|
10397
12219
|
}
|
|
10398
12220
|
if (proxy.plugin === "v2ray-plugin") {
|
|
10399
12221
|
parsedProxy.plugin = "v2ray-plugin";
|
|
10400
|
-
if (proxy["ws-host"])
|
|
10401
|
-
|
|
10402
|
-
if (proxy["ws-path"])
|
|
10403
|
-
proxy["plugin-opts"].path = proxy["ws-path"];
|
|
12222
|
+
if (proxy["ws-host"]) proxy["plugin-opts"].host = proxy["ws-host"];
|
|
12223
|
+
if (proxy["ws-path"]) proxy["plugin-opts"].path = proxy["ws-path"];
|
|
10404
12224
|
Object.keys(proxy["plugin-opts"]).forEach((k) => {
|
|
10405
12225
|
switch (k) {
|
|
10406
12226
|
case "tls":
|
|
10407
|
-
if (proxy["plugin-opts"].tls)
|
|
10408
|
-
optArr.push("tls");
|
|
12227
|
+
if (proxy["plugin-opts"].tls) optArr.push("tls");
|
|
10409
12228
|
break;
|
|
10410
12229
|
case "host":
|
|
10411
12230
|
optArr.push(`host=${proxy["plugin-opts"].host}`);
|
|
@@ -10424,8 +12243,7 @@ var ssParser = (proxy = {}) => {
|
|
|
10424
12243
|
const mux = normalizePluginMuxValue(
|
|
10425
12244
|
proxy["plugin-opts"].mux
|
|
10426
12245
|
);
|
|
10427
|
-
if (mux)
|
|
10428
|
-
parsedProxy.multiplex = { enabled: true };
|
|
12246
|
+
if (mux) parsedProxy.multiplex = { enabled: true };
|
|
10429
12247
|
optArr.push(`mux=${mux}`);
|
|
10430
12248
|
break;
|
|
10431
12249
|
}
|
|
@@ -10451,12 +12269,10 @@ var ssrParser = (proxy = {}) => {
|
|
|
10451
12269
|
};
|
|
10452
12270
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10453
12271
|
throw "invalid port";
|
|
10454
|
-
if (proxy["obfs-param"])
|
|
10455
|
-
parsedProxy.obfs_param = proxy["obfs-param"];
|
|
12272
|
+
if (proxy["obfs-param"]) parsedProxy.obfs_param = proxy["obfs-param"];
|
|
10456
12273
|
if (proxy["protocol-param"] && proxy["protocol-param"] !== "")
|
|
10457
12274
|
parsedProxy.protocol_param = proxy["protocol-param"];
|
|
10458
|
-
if (proxy["fast-open"])
|
|
10459
|
-
parsedProxy.udp_fragment = true;
|
|
12275
|
+
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
10460
12276
|
networkParser(proxy, parsedProxy);
|
|
10461
12277
|
tfoParser(proxy, parsedProxy);
|
|
10462
12278
|
detourParser(proxy, parsedProxy);
|
|
@@ -10466,11 +12282,9 @@ var ssrParser = (proxy = {}) => {
|
|
|
10466
12282
|
return parsedProxy;
|
|
10467
12283
|
};
|
|
10468
12284
|
var getSnellVersion = (version) => {
|
|
10469
|
-
if (version == null)
|
|
10470
|
-
return void 0;
|
|
12285
|
+
if (version == null) return void 0;
|
|
10471
12286
|
const normalized = `${version}`.trim();
|
|
10472
|
-
if (!/^\d+$/.test(normalized))
|
|
10473
|
-
return NaN;
|
|
12287
|
+
if (!/^\d+$/.test(normalized)) return NaN;
|
|
10474
12288
|
return parseInt(normalized, 10);
|
|
10475
12289
|
};
|
|
10476
12290
|
var snellParser = (proxy = {}, includeUnsupportedProxy = false) => {
|
|
@@ -10492,13 +12306,10 @@ var snellParser = (proxy = {}, includeUnsupportedProxy = false) => {
|
|
|
10492
12306
|
};
|
|
10493
12307
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10494
12308
|
throw "invalid port";
|
|
10495
|
-
if (outputVersion != null)
|
|
10496
|
-
|
|
10497
|
-
if (proxy._userkey)
|
|
10498
|
-
parsedProxy.userkey = proxy._userkey;
|
|
12309
|
+
if (outputVersion != null) parsedProxy.version = outputVersion;
|
|
12310
|
+
if (proxy._userkey) parsedProxy.userkey = proxy._userkey;
|
|
10499
12311
|
if (outputVersion === 6) {
|
|
10500
|
-
if (proxy.mode)
|
|
10501
|
-
parsedProxy.mode = proxy.mode;
|
|
12312
|
+
if (proxy.mode) parsedProxy.mode = proxy.mode;
|
|
10502
12313
|
if (includeUnsupportedProxy && proxy["quic-proxy-mode"])
|
|
10503
12314
|
parsedProxy.quic_proxy_mode = !!proxy["quic-proxy-mode"];
|
|
10504
12315
|
} else {
|
|
@@ -10515,8 +12326,7 @@ var snellParser = (proxy = {}, includeUnsupportedProxy = false) => {
|
|
|
10515
12326
|
delete parsedProxy.server;
|
|
10516
12327
|
delete parsedProxy.server_port;
|
|
10517
12328
|
} else {
|
|
10518
|
-
if (proxy["fast-open"])
|
|
10519
|
-
parsedProxy.udp_fragment = true;
|
|
12329
|
+
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
10520
12330
|
tfoParser(proxy, parsedProxy);
|
|
10521
12331
|
detourParser(proxy, parsedProxy);
|
|
10522
12332
|
ipVersionParser(proxy, parsedProxy);
|
|
@@ -10568,16 +12378,11 @@ var vmessParser = (proxy = {}) => {
|
|
|
10568
12378
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10569
12379
|
throw "invalid port";
|
|
10570
12380
|
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);
|
|
12381
|
+
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
12382
|
+
if (proxy.network === "ws") wsParser(proxy, parsedProxy);
|
|
12383
|
+
if (proxy.network === "h2") h2Parser(proxy, parsedProxy);
|
|
12384
|
+
if (proxy.network === "http") h1Parser(proxy, parsedProxy);
|
|
12385
|
+
if (proxy.network === "grpc") grpcParser(proxy, parsedProxy);
|
|
10581
12386
|
networkParser(proxy, parsedProxy);
|
|
10582
12387
|
tfoParser(proxy, parsedProxy);
|
|
10583
12388
|
detourParser(proxy, parsedProxy);
|
|
@@ -10599,18 +12404,12 @@ var vlessParser = (proxy = {}) => {
|
|
|
10599
12404
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10600
12405
|
throw "invalid port";
|
|
10601
12406
|
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);
|
|
12407
|
+
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
12408
|
+
if (proxy.flow != null) parsedProxy.flow = proxy.flow;
|
|
12409
|
+
if (proxy.network === "ws") wsParser(proxy, parsedProxy);
|
|
12410
|
+
if (proxy.network === "h2") h2Parser(proxy, parsedProxy);
|
|
12411
|
+
if (proxy.network === "http") h1Parser(proxy, parsedProxy);
|
|
12412
|
+
if (proxy.network === "grpc") grpcParser(proxy, parsedProxy);
|
|
10614
12413
|
networkParser(proxy, parsedProxy);
|
|
10615
12414
|
tfoParser(proxy, parsedProxy);
|
|
10616
12415
|
detourParser(proxy, parsedProxy);
|
|
@@ -10631,12 +12430,9 @@ var trojanParser = (proxy = {}) => {
|
|
|
10631
12430
|
};
|
|
10632
12431
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10633
12432
|
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);
|
|
12433
|
+
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
12434
|
+
if (proxy.network === "grpc") grpcParser(proxy, parsedProxy);
|
|
12435
|
+
if (proxy.network === "ws") wsParser(proxy, parsedProxy);
|
|
10640
12436
|
networkParser(proxy, parsedProxy);
|
|
10641
12437
|
tfoParser(proxy, parsedProxy);
|
|
10642
12438
|
detourParser(proxy, parsedProxy);
|
|
@@ -10656,12 +12452,9 @@ var naiveParser = (proxy = {}) => {
|
|
|
10656
12452
|
};
|
|
10657
12453
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10658
12454
|
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;
|
|
12455
|
+
if (proxy.username) parsedProxy.username = proxy.username;
|
|
12456
|
+
if (proxy.password) parsedProxy.password = proxy.password;
|
|
12457
|
+
if (proxy.uot) parsedProxy.udp_over_tcp = true;
|
|
10665
12458
|
if (proxy["udp-over-tcp"]) {
|
|
10666
12459
|
parsedProxy.udp_over_tcp = {
|
|
10667
12460
|
enabled: true,
|
|
@@ -10676,12 +12469,10 @@ var naiveParser = (proxy = {}) => {
|
|
|
10676
12469
|
parsedProxy.insecure_concurrency = insecure_concurrency;
|
|
10677
12470
|
if (proxy["extra-headers"])
|
|
10678
12471
|
parsedProxy.extra_headers = proxy["extra-headers"];
|
|
10679
|
-
if (proxy.quic)
|
|
10680
|
-
parsedProxy.quic = !!proxy.quic;
|
|
12472
|
+
if (proxy.quic) parsedProxy.quic = !!proxy.quic;
|
|
10681
12473
|
if (proxy["quic-congestion-control"])
|
|
10682
12474
|
parsedProxy.quic_congestion_control = proxy["quic-congestion-control"];
|
|
10683
|
-
if (proxy["fast-open"])
|
|
10684
|
-
parsedProxy.udp_fragment = true;
|
|
12475
|
+
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
10685
12476
|
tfoParser(proxy, parsedProxy);
|
|
10686
12477
|
detourParser(proxy, parsedProxy);
|
|
10687
12478
|
tlsParser(proxy, parsedProxy);
|
|
@@ -10714,12 +12505,9 @@ var hysteriaParser = (proxy = {}) => {
|
|
|
10714
12505
|
const range = p.replace(/\s*-\s*/g, ":");
|
|
10715
12506
|
return range.includes(":") ? range : `${range}:${range}`;
|
|
10716
12507
|
});
|
|
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;
|
|
12508
|
+
if (proxy.auth_str) parsedProxy.auth_str = `${proxy.auth_str}`;
|
|
12509
|
+
if (proxy["auth-str"]) parsedProxy.auth_str = `${proxy["auth-str"]}`;
|
|
12510
|
+
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
10723
12511
|
const reg = new RegExp("^[0-9]+[ ]*[KMGT]*[Bb]ps$");
|
|
10724
12512
|
if (reg.test(`${proxy.up}`) && !`${proxy.up}`.endsWith("Mbps")) {
|
|
10725
12513
|
parsedProxy.up = `${proxy.up}`;
|
|
@@ -10731,16 +12519,13 @@ var hysteriaParser = (proxy = {}) => {
|
|
|
10731
12519
|
} else {
|
|
10732
12520
|
parsedProxy.down_mbps = parseInt(`${proxy.down}`, 10);
|
|
10733
12521
|
}
|
|
10734
|
-
if (proxy.obfs)
|
|
10735
|
-
parsedProxy.obfs = proxy.obfs;
|
|
12522
|
+
if (proxy.obfs) parsedProxy.obfs = proxy.obfs;
|
|
10736
12523
|
if (proxy.recv_window_conn)
|
|
10737
12524
|
parsedProxy.recv_window_conn = proxy.recv_window_conn;
|
|
10738
12525
|
if (proxy["recv-window-conn"])
|
|
10739
12526
|
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"];
|
|
12527
|
+
if (proxy.recv_window) parsedProxy.recv_window = proxy.recv_window;
|
|
12528
|
+
if (proxy["recv-window"]) parsedProxy.recv_window = proxy["recv-window"];
|
|
10744
12529
|
if (proxy.disable_mtu_discovery) {
|
|
10745
12530
|
if (typeof proxy.disable_mtu_discovery === "boolean") {
|
|
10746
12531
|
parsedProxy.disable_mtu_discovery = proxy.disable_mtu_discovery;
|
|
@@ -10777,10 +12562,8 @@ var hysteria2Parser = (proxy = {}) => {
|
|
|
10777
12562
|
const range = p.replace(/\s*-\s*/g, ":");
|
|
10778
12563
|
return range.includes(":") ? range : `${range}:${range}`;
|
|
10779
12564
|
});
|
|
10780
|
-
if (proxy.up)
|
|
10781
|
-
|
|
10782
|
-
if (proxy.down)
|
|
10783
|
-
parsedProxy.down_mbps = parseInt(`${proxy.down}`, 10);
|
|
12565
|
+
if (proxy.up) parsedProxy.up_mbps = parseInt(`${proxy.up}`, 10);
|
|
12566
|
+
if (proxy.down) parsedProxy.down_mbps = parseInt(`${proxy.down}`, 10);
|
|
10784
12567
|
if (["salamander", "gecko"].includes(proxy.obfs))
|
|
10785
12568
|
parsedProxy.obfs.type = proxy.obfs;
|
|
10786
12569
|
if (proxy.obfs === "gecko") {
|
|
@@ -10804,19 +12587,15 @@ var hysteria2Parser = (proxy = {}) => {
|
|
|
10804
12587
|
`Invalid obfs packet size for proxy ${proxy.name}: min=${minRaw} max=${maxRaw}`
|
|
10805
12588
|
);
|
|
10806
12589
|
} else {
|
|
10807
|
-
if (hasMin)
|
|
10808
|
-
|
|
10809
|
-
if (hasMax)
|
|
10810
|
-
parsedProxy.obfs.max_packet_size = maxPacketSize;
|
|
12590
|
+
if (hasMin) parsedProxy.obfs.min_packet_size = minPacketSize;
|
|
12591
|
+
if (hasMax) parsedProxy.obfs.max_packet_size = maxPacketSize;
|
|
10811
12592
|
}
|
|
10812
12593
|
}
|
|
10813
12594
|
}
|
|
10814
12595
|
if (proxy["obfs-password"])
|
|
10815
12596
|
parsedProxy.obfs.password = proxy["obfs-password"];
|
|
10816
|
-
if (!parsedProxy.obfs.type)
|
|
10817
|
-
|
|
10818
|
-
if (proxy["bbr-profile"])
|
|
10819
|
-
parsedProxy.bbr_profile = proxy["bbr-profile"];
|
|
12597
|
+
if (!parsedProxy.obfs.type) delete parsedProxy.obfs;
|
|
12598
|
+
if (proxy["bbr-profile"]) parsedProxy.bbr_profile = proxy["bbr-profile"];
|
|
10820
12599
|
if (proxy["disable-chrome-parrot"])
|
|
10821
12600
|
parsedProxy.disable_chrome_parrot = !!proxy["disable-chrome-parrot"];
|
|
10822
12601
|
networkParser(proxy, parsedProxy);
|
|
@@ -10840,16 +12619,13 @@ var tuic5Parser = (proxy = {}) => {
|
|
|
10840
12619
|
};
|
|
10841
12620
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10842
12621
|
throw "invalid port";
|
|
10843
|
-
if (proxy["fast-open"])
|
|
10844
|
-
parsedProxy.udp_fragment = true;
|
|
12622
|
+
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
10845
12623
|
if (proxy["congestion-controller"] && proxy["congestion-controller"] !== "cubic")
|
|
10846
12624
|
parsedProxy.congestion_control = proxy["congestion-controller"];
|
|
10847
12625
|
if (proxy["udp-relay-mode"] && proxy["udp-relay-mode"] !== "native")
|
|
10848
12626
|
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;
|
|
12627
|
+
if (proxy["reduce-rtt"]) parsedProxy.zero_rtt_handshake = true;
|
|
12628
|
+
if (proxy["udp-over-stream"]) parsedProxy.udp_over_stream = true;
|
|
10853
12629
|
if (proxy["heartbeat-interval"])
|
|
10854
12630
|
parsedProxy.heartbeat = `${proxy["heartbeat-interval"]}ms`;
|
|
10855
12631
|
networkParser(proxy, parsedProxy);
|
|
@@ -10960,13 +12736,11 @@ var wireguardParser = (proxy = {}) => {
|
|
|
10960
12736
|
};
|
|
10961
12737
|
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
|
|
10962
12738
|
throw "invalid port";
|
|
10963
|
-
if (proxy["fast-open"])
|
|
10964
|
-
parsedProxy.udp_fragment = true;
|
|
12739
|
+
if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
|
|
10965
12740
|
if (typeof proxy.reserved === "string") {
|
|
10966
12741
|
parsedProxy.reserved = proxy.reserved;
|
|
10967
12742
|
} else if (Array.isArray(proxy.reserved)) {
|
|
10968
|
-
for (const r of proxy.reserved)
|
|
10969
|
-
parsedProxy.reserved.push(r);
|
|
12743
|
+
for (const r of proxy.reserved) parsedProxy.reserved.push(r);
|
|
10970
12744
|
} else {
|
|
10971
12745
|
delete parsedProxy.reserved;
|
|
10972
12746
|
}
|
|
@@ -11000,8 +12774,7 @@ var wireguardParser = (proxy = {}) => {
|
|
|
11000
12774
|
if (typeof p.reserved === "string") {
|
|
11001
12775
|
peer.reserved.push(p.reserved);
|
|
11002
12776
|
} else if (Array.isArray(p.reserved)) {
|
|
11003
|
-
for (const r of p.reserved)
|
|
11004
|
-
peer.reserved.push(r);
|
|
12777
|
+
for (const r of p.reserved) peer.reserved.push(r);
|
|
11005
12778
|
} else {
|
|
11006
12779
|
delete peer.reserved;
|
|
11007
12780
|
}
|
|
@@ -11241,8 +13014,7 @@ function singbox_Producer() {
|
|
|
11241
13014
|
app_default.error(e.message ?? e);
|
|
11242
13015
|
}
|
|
11243
13016
|
});
|
|
11244
|
-
if (type2 === "internal")
|
|
11245
|
-
return list;
|
|
13017
|
+
if (type2 === "internal") return list;
|
|
11246
13018
|
const categorized = list.reduce(
|
|
11247
13019
|
(result, item) => {
|
|
11248
13020
|
if (["wireguard", "tailscale"].includes(item.type)) {
|
|
@@ -11260,6 +13032,17 @@ function singbox_Producer() {
|
|
|
11260
13032
|
}
|
|
11261
13033
|
|
|
11262
13034
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/egern.js
|
|
13035
|
+
var ipVersions5 = {
|
|
13036
|
+
dual: "dual_stack",
|
|
13037
|
+
ipv4: "v4_only",
|
|
13038
|
+
ipv6: "v6_only",
|
|
13039
|
+
"v4-only": "v4_only",
|
|
13040
|
+
"v6-only": "v6_only",
|
|
13041
|
+
"ipv4-prefer": "v4_prefer",
|
|
13042
|
+
"ipv6-prefer": "v6_prefer",
|
|
13043
|
+
"prefer-v4": "v4_prefer",
|
|
13044
|
+
"prefer-v6": "v6_prefer"
|
|
13045
|
+
};
|
|
11263
13046
|
function Egern_Producer() {
|
|
11264
13047
|
const type = "ALL";
|
|
11265
13048
|
const produce2 = (proxies, type2, opts = {}) => {
|
|
@@ -11269,6 +13052,7 @@ function Egern_Producer() {
|
|
|
11269
13052
|
"https",
|
|
11270
13053
|
"socks5",
|
|
11271
13054
|
"ss",
|
|
13055
|
+
"ssr",
|
|
11272
13056
|
"trojan",
|
|
11273
13057
|
"hysteria2",
|
|
11274
13058
|
"vless",
|
|
@@ -11319,6 +13103,8 @@ function Egern_Producer() {
|
|
|
11319
13103
|
return false;
|
|
11320
13104
|
} else if (proxy.type === "snell" && normalizeSnellVersion(proxy.version) === null) {
|
|
11321
13105
|
return false;
|
|
13106
|
+
} else if (proxy.type === "ssr" && !isEgernSsr(proxy)) {
|
|
13107
|
+
return false;
|
|
11322
13108
|
} else if (["anytls"].includes(proxy.type) && proxy.network && !["tcp"].includes(proxy.network)) {
|
|
11323
13109
|
return false;
|
|
11324
13110
|
} else if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
@@ -11406,6 +13192,21 @@ function Egern_Producer() {
|
|
|
11406
13192
|
);
|
|
11407
13193
|
}
|
|
11408
13194
|
}
|
|
13195
|
+
} else if (proxy.type === "ssr") {
|
|
13196
|
+
proxy = {
|
|
13197
|
+
type: "shadowsocksr",
|
|
13198
|
+
name: proxy.name,
|
|
13199
|
+
method: normalizeSsrMethod(proxy.cipher),
|
|
13200
|
+
server: proxy.server,
|
|
13201
|
+
port: proxy.port,
|
|
13202
|
+
password: proxy.password,
|
|
13203
|
+
protocol: normalizeSsrPlugin(proxy.protocol),
|
|
13204
|
+
protocol_param: proxy["protocol-param"],
|
|
13205
|
+
obfs: normalizeSsrPlugin(proxy.obfs),
|
|
13206
|
+
obfs_param: proxy["obfs-param"],
|
|
13207
|
+
tfo: getTfo(proxy),
|
|
13208
|
+
udp_relay: getUdpRelay(proxy)
|
|
13209
|
+
};
|
|
11409
13210
|
} else if (proxy.type === "hysteria2") {
|
|
11410
13211
|
proxy = {
|
|
11411
13212
|
type: "hysteria2",
|
|
@@ -11595,8 +13396,7 @@ function Egern_Producer() {
|
|
|
11595
13396
|
}
|
|
11596
13397
|
};
|
|
11597
13398
|
flow = proxy.flow;
|
|
11598
|
-
if (flow === "")
|
|
11599
|
-
flow = void 0;
|
|
13399
|
+
if (flow === "") flow = void 0;
|
|
11600
13400
|
}
|
|
11601
13401
|
proxy = {
|
|
11602
13402
|
type: "vless",
|
|
@@ -11680,6 +13480,7 @@ function Egern_Producer() {
|
|
|
11680
13480
|
"https",
|
|
11681
13481
|
"socks5",
|
|
11682
13482
|
"ss",
|
|
13483
|
+
"ssr",
|
|
11683
13484
|
"trojan",
|
|
11684
13485
|
"vless",
|
|
11685
13486
|
"vmess",
|
|
@@ -11711,6 +13512,7 @@ function Egern_Producer() {
|
|
|
11711
13512
|
if ([
|
|
11712
13513
|
"socks5",
|
|
11713
13514
|
"ss",
|
|
13515
|
+
"ssr",
|
|
11714
13516
|
"trojan",
|
|
11715
13517
|
"vless",
|
|
11716
13518
|
"vmess",
|
|
@@ -11731,9 +13533,12 @@ function Egern_Producer() {
|
|
|
11731
13533
|
proxy.block_quic = false;
|
|
11732
13534
|
}
|
|
11733
13535
|
}
|
|
11734
|
-
if (["ss"].includes(original.type) && proxy.shadow_tls && original["udp-port"] > 0 && original["udp-port"] <= 65535) {
|
|
13536
|
+
if (["ss", "ssr"].includes(original.type) && proxy.shadow_tls && original["udp-port"] > 0 && original["udp-port"] <= 65535) {
|
|
11735
13537
|
proxy["udp_port"] = original["udp-port"];
|
|
11736
13538
|
}
|
|
13539
|
+
if (original["ip-version"]) {
|
|
13540
|
+
proxy.ip_version = ipVersions5[original["ip-version"]] || original["ip-version"];
|
|
13541
|
+
}
|
|
11737
13542
|
delete proxy.subName;
|
|
11738
13543
|
delete proxy.collectionName;
|
|
11739
13544
|
delete proxy.id;
|
|
@@ -11787,23 +13592,18 @@ function getUdpRelay(proxy) {
|
|
|
11787
13592
|
return proxy.udp ?? proxy.udp_relay;
|
|
11788
13593
|
}
|
|
11789
13594
|
function getNonEmptyValue(value) {
|
|
11790
|
-
if (value == null)
|
|
11791
|
-
|
|
11792
|
-
if (typeof value === "string" && value.length === 0)
|
|
11793
|
-
return void 0;
|
|
13595
|
+
if (value == null) return void 0;
|
|
13596
|
+
if (typeof value === "string" && value.length === 0) return void 0;
|
|
11794
13597
|
return value;
|
|
11795
13598
|
}
|
|
11796
13599
|
function getReality(proxy) {
|
|
11797
13600
|
const realityOpts = proxy?.["reality-opts"];
|
|
11798
|
-
if (!realityOpts)
|
|
11799
|
-
return void 0;
|
|
13601
|
+
if (!realityOpts) return void 0;
|
|
11800
13602
|
const reality = {};
|
|
11801
13603
|
const publicKey = getNonEmptyValue(realityOpts["public-key"]);
|
|
11802
13604
|
const shortId = getNonEmptyValue(realityOpts["short-id"]);
|
|
11803
|
-
if (publicKey != null)
|
|
11804
|
-
|
|
11805
|
-
if (shortId != null)
|
|
11806
|
-
reality.short_id = shortId;
|
|
13605
|
+
if (publicKey != null) reality.public_key = publicKey;
|
|
13606
|
+
if (shortId != null) reality.short_id = shortId;
|
|
11807
13607
|
return Object.keys(reality).length > 0 ? reality : void 0;
|
|
11808
13608
|
}
|
|
11809
13609
|
function getGrpcTransport(proxy) {
|
|
@@ -11817,26 +13617,71 @@ function getGrpcTransport(proxy) {
|
|
|
11817
13617
|
};
|
|
11818
13618
|
}
|
|
11819
13619
|
function isEgernGrpcGun(proxy) {
|
|
11820
|
-
if (proxy.network !== "grpc")
|
|
11821
|
-
return true;
|
|
13620
|
+
if (proxy.network !== "grpc") return true;
|
|
11822
13621
|
const grpcType = proxy["grpc-opts"]?.["_grpc-type"];
|
|
11823
|
-
if (grpcType == null)
|
|
11824
|
-
return true;
|
|
13622
|
+
if (grpcType == null) return true;
|
|
11825
13623
|
return `${grpcType}`.trim().toLowerCase() === "gun";
|
|
11826
13624
|
}
|
|
11827
13625
|
function normalizeSnellVersion(version) {
|
|
11828
|
-
if (version == null)
|
|
11829
|
-
return void 0;
|
|
13626
|
+
if (version == null) return void 0;
|
|
11830
13627
|
const normalized = `${version}`.trim();
|
|
11831
|
-
if (!/^[1-5]$/.test(normalized))
|
|
11832
|
-
return null;
|
|
13628
|
+
if (!/^[1-5]$/.test(normalized)) return null;
|
|
11833
13629
|
return parseInt(normalized, 10);
|
|
11834
13630
|
}
|
|
13631
|
+
var EGERN_SSR_METHODS = [
|
|
13632
|
+
"none",
|
|
13633
|
+
"dummy",
|
|
13634
|
+
"rc4-md5",
|
|
13635
|
+
"aes-128-cfb",
|
|
13636
|
+
"aes-192-cfb",
|
|
13637
|
+
"aes-256-cfb",
|
|
13638
|
+
"aes-128-ctr",
|
|
13639
|
+
"aes-192-ctr",
|
|
13640
|
+
"aes-256-ctr",
|
|
13641
|
+
"chacha20",
|
|
13642
|
+
"chacha20-ietf",
|
|
13643
|
+
"xchacha20"
|
|
13644
|
+
];
|
|
13645
|
+
var EGERN_SSR_PROTOCOLS = [
|
|
13646
|
+
"origin",
|
|
13647
|
+
"auth_sha1_v4",
|
|
13648
|
+
"auth_aes128_md5",
|
|
13649
|
+
"auth_aes128_sha1",
|
|
13650
|
+
"auth_chain_a",
|
|
13651
|
+
"auth_chain_b"
|
|
13652
|
+
];
|
|
13653
|
+
var EGERN_SSR_OBFS = [
|
|
13654
|
+
"plain",
|
|
13655
|
+
"http_simple",
|
|
13656
|
+
"http_post",
|
|
13657
|
+
"random_head",
|
|
13658
|
+
"tls1.2_ticket_auth",
|
|
13659
|
+
"tls1.2_ticket_fastauth"
|
|
13660
|
+
];
|
|
13661
|
+
function normalizeSsrPlugin(value) {
|
|
13662
|
+
if (value == null) return void 0;
|
|
13663
|
+
const normalized = `${value}`.trim().toLowerCase();
|
|
13664
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
13665
|
+
}
|
|
13666
|
+
function normalizeSsrMethod(cipher) {
|
|
13667
|
+
const method = normalizeSsrPlugin(cipher);
|
|
13668
|
+
return method === "plain" ? "none" : method;
|
|
13669
|
+
}
|
|
13670
|
+
function isEgernSsr(proxy) {
|
|
13671
|
+
if (!EGERN_SSR_METHODS.includes(normalizeSsrMethod(proxy.cipher))) {
|
|
13672
|
+
return false;
|
|
13673
|
+
}
|
|
13674
|
+
const protocol = normalizeSsrPlugin(proxy.protocol);
|
|
13675
|
+
if (protocol != null && !EGERN_SSR_PROTOCOLS.includes(protocol)) {
|
|
13676
|
+
return false;
|
|
13677
|
+
}
|
|
13678
|
+
const obfs = normalizeSsrPlugin(proxy.obfs);
|
|
13679
|
+
return obfs == null || EGERN_SSR_OBFS.includes(obfs);
|
|
13680
|
+
}
|
|
11835
13681
|
function getFirstHeaderValue(headers, ...keys) {
|
|
11836
13682
|
for (const key of keys) {
|
|
11837
13683
|
const value = getFirstValue(headers?.[key]);
|
|
11838
|
-
if (value)
|
|
11839
|
-
return value;
|
|
13684
|
+
if (value) return value;
|
|
11840
13685
|
}
|
|
11841
13686
|
return void 0;
|
|
11842
13687
|
}
|
|
@@ -11847,8 +13692,7 @@ function getH2Headers(h2Opts) {
|
|
|
11847
13692
|
const headers = {};
|
|
11848
13693
|
if (h2Opts?.headers && typeof h2Opts.headers === "object" && !Array.isArray(h2Opts.headers)) {
|
|
11849
13694
|
for (const [key, value] of Object.entries(h2Opts.headers)) {
|
|
11850
|
-
if (/^host$/i.test(key))
|
|
11851
|
-
continue;
|
|
13695
|
+
if (/^host$/i.test(key)) continue;
|
|
11852
13696
|
const headerValue = getFirstValue(value);
|
|
11853
13697
|
if (headerValue != null) {
|
|
11854
13698
|
headers[key] = headerValue;
|
|
@@ -11862,16 +13706,13 @@ function getH2Headers(h2Opts) {
|
|
|
11862
13706
|
return Object.keys(headers).length > 0 ? headers : void 0;
|
|
11863
13707
|
}
|
|
11864
13708
|
function getFirstValue(value) {
|
|
11865
|
-
if (Array.isArray(value))
|
|
11866
|
-
|
|
11867
|
-
if (value != null)
|
|
11868
|
-
return value;
|
|
13709
|
+
if (Array.isArray(value)) return value[0];
|
|
13710
|
+
if (value != null) return value;
|
|
11869
13711
|
return void 0;
|
|
11870
13712
|
}
|
|
11871
13713
|
function getFingerprintSha256(proxy) {
|
|
11872
13714
|
const fingerprint = proxy?.["tls-fingerprint"];
|
|
11873
|
-
if (typeof fingerprint !== "string")
|
|
11874
|
-
return void 0;
|
|
13715
|
+
if (typeof fingerprint !== "string") return void 0;
|
|
11875
13716
|
const trimmedFingerprint = fingerprint.trim();
|
|
11876
13717
|
return trimmedFingerprint.length > 0 ? trimmedFingerprint : void 0;
|
|
11877
13718
|
}
|
|
@@ -11881,8 +13722,7 @@ function supportsRootFingerprintSha256(original, proxy) {
|
|
|
11881
13722
|
) || original.type === "socks5" && proxy.type === "socks5_tls" || original.type === "http" && proxy.type === "https";
|
|
11882
13723
|
}
|
|
11883
13724
|
function addTransportFingerprintSha256(transport, fingerprintSha256) {
|
|
11884
|
-
if (!transport)
|
|
11885
|
-
return;
|
|
13725
|
+
if (!transport) return;
|
|
11886
13726
|
for (const key of ["grpc", "http2", "tls", "wss"]) {
|
|
11887
13727
|
if (transport[key]) {
|
|
11888
13728
|
transport[key].fingerprint_sha256 = fingerprintSha256;
|
|
@@ -11984,8 +13824,7 @@ function parseProxyLines(lines, opts) {
|
|
|
11984
13824
|
const proxyList = [];
|
|
11985
13825
|
let lastParser = null;
|
|
11986
13826
|
for (const line of lines) {
|
|
11987
|
-
if (line.length === 0)
|
|
11988
|
-
continue;
|
|
13827
|
+
if (line.length === 0) continue;
|
|
11989
13828
|
let proxy = null;
|
|
11990
13829
|
if (lastParser) {
|
|
11991
13830
|
proxy = tryParseProxy(lastParser, line);
|
|
@@ -12041,3 +13880,16 @@ export {
|
|
|
12041
13880
|
produceOutput,
|
|
12042
13881
|
tryParseProxy
|
|
12043
13882
|
};
|
|
13883
|
+
/*! Bundled license information:
|
|
13884
|
+
|
|
13885
|
+
ieee754/index.js:
|
|
13886
|
+
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
13887
|
+
|
|
13888
|
+
buffer/index.js:
|
|
13889
|
+
(*!
|
|
13890
|
+
* The buffer module from node.js, for the browser.
|
|
13891
|
+
*
|
|
13892
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
13893
|
+
* @license MIT
|
|
13894
|
+
*)
|
|
13895
|
+
*/
|