ddan-js 2.8.0 → 2.8.2
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/bin/ddan-js.esm.js +1 -1
- package/bin/ddan-js.js +1 -1
- package/bin/lib/class/kvalue.js +4 -1
- package/bin/lib/index.js +3 -1
- package/bin/lib/modules/crypto/tea.js +2 -1
- package/bin/lib/modules/hook/base.js +29 -6
- package/bin/lib/modules/hook/log.js +27 -3
- package/bin/lib/modules/math/index.js +27 -23
- package/bin/lib/modules/node/socks5.js +24 -4
- package/bin/types/class/kvalue.d.ts +1 -0
- package/bin/types/index.d.ts +64 -32
- package/bin/types/modules/crypto/index.d.ts +1 -0
- package/bin/types/modules/crypto/tea.d.ts +1 -0
- package/bin/types/modules/hook/base.d.ts +5 -3
- package/bin/types/modules/hook/index.d.ts +9 -5
- package/bin/types/modules/hook/log.d.ts +4 -2
- package/bin/types/modules/math/index.d.ts +5 -4
- package/bin/types/modules/node/socks5.d.ts +5 -0
- package/package.json +1 -1
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const is_1 = require("../../util/is");
|
|
4
|
-
async function to(promise, errorExt) {
|
|
4
|
+
async function to(promise, errorExt, fn) {
|
|
5
5
|
return promise
|
|
6
|
-
.then((data) =>
|
|
6
|
+
.then((data) => {
|
|
7
|
+
fn && fn();
|
|
8
|
+
return [null, data];
|
|
9
|
+
})
|
|
7
10
|
.catch((err) => {
|
|
8
11
|
if (errorExt) {
|
|
9
12
|
Object.assign(err, errorExt);
|
|
10
13
|
}
|
|
14
|
+
fn && fn();
|
|
11
15
|
return [err, undefined];
|
|
12
16
|
});
|
|
13
17
|
}
|
|
@@ -17,7 +21,7 @@ async function to(promise, errorExt) {
|
|
|
17
21
|
* @returns
|
|
18
22
|
*/
|
|
19
23
|
const delay = (ms = 1000) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
20
|
-
const safeRun = (func) => {
|
|
24
|
+
const safeRun = (func, fn) => {
|
|
21
25
|
try {
|
|
22
26
|
let temp;
|
|
23
27
|
if (is_1.default.isFunction(func)) {
|
|
@@ -27,11 +31,30 @@ const safeRun = (func) => {
|
|
|
27
31
|
temp = func;
|
|
28
32
|
}
|
|
29
33
|
// promise = is.isPromise(temp) ? temp : Promise.resolve(temp);
|
|
30
|
-
return to(Promise.resolve(temp));
|
|
34
|
+
return to(Promise.resolve(temp), undefined, fn);
|
|
31
35
|
}
|
|
32
36
|
catch (err) {
|
|
37
|
+
fn && fn();
|
|
33
38
|
return Promise.resolve([err, undefined]);
|
|
34
39
|
}
|
|
35
40
|
};
|
|
36
|
-
const go = (task) => safeRun(task);
|
|
37
|
-
|
|
41
|
+
const go = (task, fn) => safeRun(task, fn);
|
|
42
|
+
const toError = (value) => {
|
|
43
|
+
value = typeof value === 'function' ? value() : value;
|
|
44
|
+
return typeof value === 'string' ? new Error(value) : value;
|
|
45
|
+
};
|
|
46
|
+
const timeout = (task, ms = 0, desc = 'timeout') => {
|
|
47
|
+
if (ms <= 0) {
|
|
48
|
+
return safeRun(task);
|
|
49
|
+
}
|
|
50
|
+
let timerid;
|
|
51
|
+
function clear() {
|
|
52
|
+
timerid && clearTimeout(timerid);
|
|
53
|
+
}
|
|
54
|
+
const fn = new Promise((resolve) => {
|
|
55
|
+
clear();
|
|
56
|
+
timerid = setTimeout(() => resolve([toError(desc || 'timeout'), undefined]), ms);
|
|
57
|
+
});
|
|
58
|
+
return Promise.race([safeRun(task, clear), fn]);
|
|
59
|
+
};
|
|
60
|
+
exports.default = { to, go, delay, safeRun, toError, timeout };
|
|
@@ -3,8 +3,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const is_1 = require("../../util/is");
|
|
4
4
|
const rsa_web_1 = require("../node/rsa-web");
|
|
5
5
|
const rsa_1 = require("../rsa");
|
|
6
|
+
const tea_1 = require("../crypto/tea");
|
|
7
|
+
const convert_1 = require("../convert");
|
|
6
8
|
const string_1 = require("../string");
|
|
7
|
-
const logString =
|
|
9
|
+
const logString = (data) => {
|
|
10
|
+
try {
|
|
11
|
+
const jsonString = JSON.stringify(data);
|
|
12
|
+
if (jsonString === undefined)
|
|
13
|
+
return '';
|
|
14
|
+
return tea_1.default.encode(jsonString, convert_1.default.hex2str(tea_1.default.TEAKey));
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
return '';
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const logParse = (logStr) => {
|
|
21
|
+
try {
|
|
22
|
+
if (!logStr)
|
|
23
|
+
return '';
|
|
24
|
+
const ret = tea_1.default.decode(logStr, convert_1.default.hex2str(tea_1.default.TEAKey));
|
|
25
|
+
return string_1.default.jsonFormat(ret);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
return '';
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const logRString = async (data) => {
|
|
8
32
|
try {
|
|
9
33
|
const jsonString = JSON.stringify(data);
|
|
10
34
|
if (jsonString === undefined)
|
|
@@ -16,7 +40,7 @@ const logString = async (data) => {
|
|
|
16
40
|
return '';
|
|
17
41
|
}
|
|
18
42
|
};
|
|
19
|
-
const
|
|
43
|
+
const logRParse = async (logStr) => {
|
|
20
44
|
try {
|
|
21
45
|
if (!logStr)
|
|
22
46
|
return '';
|
|
@@ -27,4 +51,4 @@ const logParse = async (logStr) => {
|
|
|
27
51
|
return '';
|
|
28
52
|
}
|
|
29
53
|
};
|
|
30
|
-
exports.default = { logString, logParse };
|
|
54
|
+
exports.default = { logString, logParse, logRString, logRParse };
|
|
@@ -69,36 +69,40 @@ function radian2degree(radians) {
|
|
|
69
69
|
function degree2radian(degrees) {
|
|
70
70
|
return degrees / radiansToAngles;
|
|
71
71
|
}
|
|
72
|
-
function
|
|
73
|
-
let _mem = mem;
|
|
72
|
+
function calcDataSize(data) {
|
|
74
73
|
const result = {
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
gb: 0,
|
|
75
|
+
mb: 0,
|
|
77
76
|
kb: 0,
|
|
78
77
|
b: 0,
|
|
78
|
+
total: data,
|
|
79
79
|
desc: '',
|
|
80
80
|
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
const units = [
|
|
82
|
+
{ name: 'gb', divisor: 1 << 30 },
|
|
83
|
+
{ name: 'mb', divisor: 1 << 20 },
|
|
84
|
+
{ name: 'kb', divisor: 1 << 10 },
|
|
85
|
+
{ name: 'b', divisor: 1 },
|
|
86
|
+
];
|
|
87
|
+
// 计算每个单位的数量
|
|
88
|
+
for (const unit of units) {
|
|
89
|
+
const value = Math.floor(data / unit.divisor);
|
|
90
|
+
result[unit.name] = value;
|
|
91
|
+
data -= value * unit.divisor;
|
|
84
92
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
93
|
+
// 计算简洁的描述
|
|
94
|
+
if (result.gb > 0) {
|
|
95
|
+
result.desc = (result.gb + result.mb / 1024).toFixed(2) + 'GB';
|
|
88
96
|
}
|
|
89
|
-
if (
|
|
90
|
-
result.
|
|
91
|
-
|
|
97
|
+
else if (result.mb > 0) {
|
|
98
|
+
result.desc = (result.mb + result.kb / 1024).toFixed(2) + 'MB';
|
|
99
|
+
}
|
|
100
|
+
else if (result.kb > 0) {
|
|
101
|
+
result.desc = (result.kb + result.b / 1024).toFixed(2) + 'KB';
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
result.desc = result.b + 'B';
|
|
92
105
|
}
|
|
93
|
-
result.b = _mem;
|
|
94
|
-
if (mem >= 1 << 30)
|
|
95
|
-
result.desc = (mem / (1 << 30)).toFixed(2) + 'G';
|
|
96
|
-
else if (mem >= 1 << 20)
|
|
97
|
-
result.desc = (mem / (1 << 20)).toFixed(2) + 'M';
|
|
98
|
-
else if (mem >= 1 << 10)
|
|
99
|
-
result.desc = (mem / (1 << 10)).toFixed(2) + 'KB';
|
|
100
|
-
else
|
|
101
|
-
result.desc = mem + 'B';
|
|
102
106
|
return result;
|
|
103
107
|
}
|
|
104
108
|
exports.default = {
|
|
@@ -110,5 +114,5 @@ exports.default = {
|
|
|
110
114
|
float,
|
|
111
115
|
radian2degree,
|
|
112
116
|
degree2radian,
|
|
113
|
-
|
|
117
|
+
calcDataSize,
|
|
114
118
|
};
|
|
@@ -23,6 +23,8 @@ class Socks5 {
|
|
|
23
23
|
__event;
|
|
24
24
|
__pipeline;
|
|
25
25
|
__logger;
|
|
26
|
+
__totalReceived = 0;
|
|
27
|
+
__totalSent = 0;
|
|
26
28
|
constructor(upstreamProxy, allowedDomains = ['*'], debug = false, logger) {
|
|
27
29
|
this.__event = new event_1.default();
|
|
28
30
|
this.upstreamProxy = upstreamProxy;
|
|
@@ -43,6 +45,12 @@ class Socks5 {
|
|
|
43
45
|
return '';
|
|
44
46
|
return `socks5://127.0.0.1:${this.__port}`;
|
|
45
47
|
}
|
|
48
|
+
get totalReceived() {
|
|
49
|
+
return this.__totalReceived;
|
|
50
|
+
}
|
|
51
|
+
get totalSent() {
|
|
52
|
+
return this.__totalSent;
|
|
53
|
+
}
|
|
46
54
|
validateProxyConfig(proxyConfig = this.upstreamProxy) {
|
|
47
55
|
const { ipaddress, port, userId, password } = proxyConfig || {};
|
|
48
56
|
if (!ipaddress || typeof ipaddress !== 'string') {
|
|
@@ -146,19 +154,19 @@ class Socks5 {
|
|
|
146
154
|
// 走上游代理
|
|
147
155
|
const upstreamSocket = await this.connectToUpstreamProxy(destination);
|
|
148
156
|
this.__logger?.info(`[socks5] handle connection upstream`, addrport);
|
|
149
|
-
this.setupDataForwarding(clientSocket, upstreamSocket);
|
|
157
|
+
this.setupDataForwarding(clientSocket, upstreamSocket, 'upstream');
|
|
150
158
|
}
|
|
151
159
|
else if (this.useSystemProxy && this.systemProxy && !index_1.default.isLocalIpAddress(addr)) {
|
|
152
160
|
// 走系统代理
|
|
153
161
|
const systemSocket = await this.connectToSystemProxy(destination);
|
|
154
162
|
this.__debug && console.info(`[socks5] handle connection system`, addrport);
|
|
155
|
-
this.setupDataForwarding(clientSocket, systemSocket);
|
|
163
|
+
this.setupDataForwarding(clientSocket, systemSocket, 'system');
|
|
156
164
|
}
|
|
157
165
|
else {
|
|
158
166
|
this.__debug && console.info(`[socks5] handle connection local`, addrport);
|
|
159
167
|
// 本地连接
|
|
160
168
|
const localSocket = await this.connectToLocal(destination);
|
|
161
|
-
this.setupDataForwarding(clientSocket, localSocket);
|
|
169
|
+
this.setupDataForwarding(clientSocket, localSocket, 'local');
|
|
162
170
|
}
|
|
163
171
|
}
|
|
164
172
|
catch (err) {
|
|
@@ -281,12 +289,20 @@ class Socks5 {
|
|
|
281
289
|
});
|
|
282
290
|
});
|
|
283
291
|
}
|
|
284
|
-
setupDataForwarding(clientSocket, targetSocket) {
|
|
292
|
+
setupDataForwarding(clientSocket, targetSocket, type = 'local') {
|
|
285
293
|
clientSocket.write(new Uint8Array([0x05, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]));
|
|
286
294
|
clientSocket.pipe(targetSocket);
|
|
287
295
|
targetSocket.pipe(clientSocket);
|
|
288
296
|
const addrPort = `${targetSocket.localAddress}:${targetSocket.localPort}`;
|
|
289
297
|
this.__debug && console.info(`[socks5] setupDataForwarding ${addrPort}`);
|
|
298
|
+
if (type === 'upstream') {
|
|
299
|
+
targetSocket.on('data', (buf) => {
|
|
300
|
+
this.__totalSent += buf.length;
|
|
301
|
+
});
|
|
302
|
+
clientSocket.on('data', (buf) => {
|
|
303
|
+
this.__totalReceived += buf.length;
|
|
304
|
+
});
|
|
305
|
+
}
|
|
290
306
|
clientSocket.on('close', () => {
|
|
291
307
|
this.__debug && console.info('[socks5] client socket close', addrPort);
|
|
292
308
|
targetSocket.end();
|
|
@@ -348,6 +364,10 @@ class Socks5 {
|
|
|
348
364
|
return;
|
|
349
365
|
this.__event.off(name, listener);
|
|
350
366
|
}
|
|
367
|
+
resetStatistics() {
|
|
368
|
+
this.__totalReceived = 0;
|
|
369
|
+
this.__totalSent = 0;
|
|
370
|
+
}
|
|
351
371
|
_emit(name, ...args) {
|
|
352
372
|
try {
|
|
353
373
|
if (!name)
|
package/bin/types/index.d.ts
CHANGED
|
@@ -64,6 +64,7 @@ declare const dUtil: {
|
|
|
64
64
|
encodeByOss: (input: string) => string;
|
|
65
65
|
};
|
|
66
66
|
tea: {
|
|
67
|
+
TEAKey: string;
|
|
67
68
|
encrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
|
|
68
69
|
decrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
|
|
69
70
|
toTeaKey: (str: string) => Uint32Array;
|
|
@@ -124,11 +125,12 @@ declare const dUtil: {
|
|
|
124
125
|
}) => number;
|
|
125
126
|
radian2degree: (radians: number) => number;
|
|
126
127
|
degree2radian: (degrees: number) => number;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
calcDataSize: (data: number) => {
|
|
129
|
+
gb: number;
|
|
130
|
+
mb: number;
|
|
130
131
|
kb: number;
|
|
131
132
|
b: number;
|
|
133
|
+
total: number;
|
|
132
134
|
desc: string;
|
|
133
135
|
};
|
|
134
136
|
};
|
|
@@ -285,6 +287,25 @@ declare const dHook: {
|
|
|
285
287
|
readonly Instance: T;
|
|
286
288
|
readonly I: T;
|
|
287
289
|
};
|
|
290
|
+
random: (max: number) => number;
|
|
291
|
+
randomRange: (min: number, max: number) => number;
|
|
292
|
+
lerp: (start: number, end: number, t: number) => number;
|
|
293
|
+
randoms: (max: number, count?: number, repeat?: boolean) => number[];
|
|
294
|
+
strip: (num: string | number, digits?: number) => number;
|
|
295
|
+
float: (num: string | number, { digits, fixed }?: {
|
|
296
|
+
digits?: number | undefined;
|
|
297
|
+
fixed?: boolean | undefined;
|
|
298
|
+
}) => number;
|
|
299
|
+
radian2degree: (radians: number) => number;
|
|
300
|
+
degree2radian: (degrees: number) => number;
|
|
301
|
+
calcDataSize: (data: number) => {
|
|
302
|
+
gb: number;
|
|
303
|
+
mb: number;
|
|
304
|
+
kb: number;
|
|
305
|
+
b: number;
|
|
306
|
+
total: number;
|
|
307
|
+
desc: string;
|
|
308
|
+
};
|
|
288
309
|
toString: (value: any) => any;
|
|
289
310
|
startCase: (string: any) => any;
|
|
290
311
|
snakeCase: (string: any) => any;
|
|
@@ -312,18 +333,23 @@ declare const dHook: {
|
|
|
312
333
|
pipe: (func: import("./typings").Ddan.Function, callback?: ((result: import("./typings").Ddan.SafeResult<any>) => void) | undefined) => import("./modules/hook/modules/pipeline").default;
|
|
313
334
|
pipeline: (max?: number) => import("./modules/hook/modules/pipeline").default;
|
|
314
335
|
safeTask: (func: import("./typings").Ddan.Function, callback?: ((result: import("./typings").Ddan.SafeResult<any>) => void) | undefined) => import("./modules/hook/modules/safeTask").default;
|
|
315
|
-
logString: (data: any) =>
|
|
316
|
-
logParse: (logStr: string) =>
|
|
317
|
-
|
|
318
|
-
|
|
336
|
+
logString: (data: any) => string;
|
|
337
|
+
logParse: (logStr: string) => string;
|
|
338
|
+
logRString: (data: any) => Promise<string>;
|
|
339
|
+
logRParse: (logStr: string) => Promise<string>;
|
|
340
|
+
to: <T_2 = any, U extends object = any>(promise: Promise<T_2>, errorExt?: object | undefined, fn?: import("./typings").Ddan.noop | undefined) => Promise<[null, T_2] | [U, undefined]>;
|
|
341
|
+
go: <T_3 = any>(task?: import("./typings").Ddan.PFunction<T_3> | undefined, fn?: import("./typings").Ddan.noop | undefined) => Promise<[any, undefined] | [null, T_3]>;
|
|
319
342
|
delay: (ms?: number) => Promise<unknown>;
|
|
320
|
-
safeRun: <T_4 = any>(func: any) => Promise<[any, undefined] | [null, T_4]>;
|
|
343
|
+
safeRun: <T_4 = any>(func: any, fn?: import("./typings").Ddan.noop | undefined) => Promise<[any, undefined] | [null, T_4]>;
|
|
344
|
+
toError: (value: any) => any;
|
|
345
|
+
timeout: <T_5 = any>(task?: import("./typings").Ddan.PFunction<T_5> | undefined, ms?: number, desc?: string) => Promise<[any, undefined] | [null, T_5]>;
|
|
321
346
|
base64: {
|
|
322
347
|
encode: (input: string) => string;
|
|
323
348
|
decode: (base64Str: string) => string;
|
|
324
349
|
encodeByOss: (input: string) => string;
|
|
325
350
|
};
|
|
326
351
|
tea: {
|
|
352
|
+
TEAKey: string;
|
|
327
353
|
encrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
|
|
328
354
|
decrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
|
|
329
355
|
toTeaKey: (str: string) => Uint32Array;
|
|
@@ -650,7 +676,7 @@ declare const dNode: {
|
|
|
650
676
|
brotliCompress: typeof import("./modules/node/brotli").brotliCompress;
|
|
651
677
|
brotliDecompress: typeof import("./modules/node/brotli").brotliDecompress;
|
|
652
678
|
};
|
|
653
|
-
export { dUtil, dHook, dWeb, dMini, dCdn, dStore, dJoker, dTracker, dLogger, dNode, KValue, Mapping };
|
|
679
|
+
export { dUtil, dHook, dWeb, dMini, dCdn, dStore, dJoker, dTracker, dLogger, dNode, Event, KValue, Mapping };
|
|
654
680
|
declare const _default: {
|
|
655
681
|
gbk: {
|
|
656
682
|
gbkLength: (str: string) => number;
|
|
@@ -691,12 +717,16 @@ declare const _default: {
|
|
|
691
717
|
pipe: (func: import("./typings").Ddan.Function, callback?: ((result: import("./typings").Ddan.SafeResult<any>) => void) | undefined) => import("./modules/hook/modules/pipeline").default;
|
|
692
718
|
pipeline: (max?: number) => import("./modules/hook/modules/pipeline").default;
|
|
693
719
|
safeTask: (func: import("./typings").Ddan.Function, callback?: ((result: import("./typings").Ddan.SafeResult<any>) => void) | undefined) => import("./modules/hook/modules/safeTask").default;
|
|
694
|
-
logString: (data: any) =>
|
|
695
|
-
logParse: (logStr: string) =>
|
|
696
|
-
|
|
697
|
-
|
|
720
|
+
logString: (data: any) => string;
|
|
721
|
+
logParse: (logStr: string) => string;
|
|
722
|
+
logRString: (data: any) => Promise<string>;
|
|
723
|
+
logRParse: (logStr: string) => Promise<string>;
|
|
724
|
+
to: <T_1 = any, U extends object = any>(promise: Promise<T_1>, errorExt?: object | undefined, fn?: import("./typings").Ddan.noop | undefined) => Promise<[null, T_1] | [U, undefined]>;
|
|
725
|
+
go: <T_2 = any>(task?: import("./typings").Ddan.PFunction<T_2> | undefined, fn?: import("./typings").Ddan.noop | undefined) => Promise<[any, undefined] | [null, T_2]>;
|
|
698
726
|
delay: (ms?: number) => Promise<unknown>;
|
|
699
|
-
safeRun: <T_3 = any>(func: any) => Promise<[any, undefined] | [null, T_3]>;
|
|
727
|
+
safeRun: <T_3 = any>(func: any, fn?: import("./typings").Ddan.noop | undefined) => Promise<[any, undefined] | [null, T_3]>;
|
|
728
|
+
toError: (value: any) => any;
|
|
729
|
+
timeout: <T_4 = any>(task?: import("./typings").Ddan.PFunction<T_4> | undefined, ms?: number, desc?: string) => Promise<[any, undefined] | [null, T_4]>;
|
|
700
730
|
};
|
|
701
731
|
math: {
|
|
702
732
|
random: (max: number) => number;
|
|
@@ -710,24 +740,25 @@ declare const _default: {
|
|
|
710
740
|
}) => number;
|
|
711
741
|
radian2degree: (radians: number) => number;
|
|
712
742
|
degree2radian: (degrees: number) => number;
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
743
|
+
calcDataSize: (data: number) => {
|
|
744
|
+
gb: number;
|
|
745
|
+
mb: number;
|
|
716
746
|
kb: number;
|
|
717
747
|
b: number;
|
|
748
|
+
total: number;
|
|
718
749
|
desc: string;
|
|
719
750
|
};
|
|
720
751
|
};
|
|
721
752
|
util: {
|
|
722
753
|
includes: typeof import("./util/includes").default;
|
|
723
754
|
forof: (source: any, cb: (key: any, val: any) => void) => void;
|
|
724
|
-
singleton: <
|
|
755
|
+
singleton: <T_5>() => {
|
|
725
756
|
new (): {};
|
|
726
757
|
__instance__: any;
|
|
727
|
-
readonly Instance:
|
|
728
|
-
readonly I:
|
|
758
|
+
readonly Instance: T_5;
|
|
759
|
+
readonly I: T_5;
|
|
729
760
|
};
|
|
730
|
-
getset: <
|
|
761
|
+
getset: <T_6 = any>(t?: T_6 | undefined) => import("./typings").Ddan.IGetset<T_6>;
|
|
731
762
|
copy: (source: any, options?: {
|
|
732
763
|
fields?: string[] | undefined;
|
|
733
764
|
camel?: boolean | undefined;
|
|
@@ -740,7 +771,7 @@ declare const _default: {
|
|
|
740
771
|
number?: boolean | undefined;
|
|
741
772
|
boolean?: boolean | undefined;
|
|
742
773
|
}) => any;
|
|
743
|
-
cloneClass: <
|
|
774
|
+
cloneClass: <T_7>(source: T_7) => T_7;
|
|
744
775
|
combine: (target: any, source: any, options?: import("./typings").Ddan.IIgnoreParams) => any;
|
|
745
776
|
combines: (objs: any[], options?: import("./typings").Ddan.IIgnoreParams) => {};
|
|
746
777
|
observe: (obj: any, key: any, watchFun: any, owner: any, deep?: boolean) => void;
|
|
@@ -772,16 +803,16 @@ declare const _default: {
|
|
|
772
803
|
isArrayBuffer: (data: any) => boolean;
|
|
773
804
|
};
|
|
774
805
|
list: {
|
|
775
|
-
stepAction: <
|
|
776
|
-
skip: <
|
|
777
|
-
take: <
|
|
778
|
-
distinct: <
|
|
779
|
-
randoms: <
|
|
806
|
+
stepAction: <T_8>(list: T_8[], func: import("./typings").Ddan.Task<T_8, void>, stepCount?: number) => void;
|
|
807
|
+
skip: <T_9>(list: T_9[], count: number) => T_9[];
|
|
808
|
+
take: <T_10>(list: T_10[], count: number, skip?: number) => T_10[];
|
|
809
|
+
distinct: <T_11>(list: T_11[]) => T_11[];
|
|
810
|
+
randoms: <T_12>(list: T_12[], count?: number, repeat?: boolean) => T_12[];
|
|
780
811
|
toKV: (list: import("./typings").Ddan.KV<any>[], key: string, value: string) => import("./typings").Ddan.KV<any>;
|
|
781
|
-
groupBy: <
|
|
782
|
-
first: <
|
|
783
|
-
last: <
|
|
784
|
-
toList: <
|
|
812
|
+
groupBy: <T_13>(list: T_13[], key: string) => Record<string, T_13[]>;
|
|
813
|
+
first: <T_14>(list: T_14[]) => T_14 | undefined;
|
|
814
|
+
last: <T_15>(list: T_15[]) => T_15 | undefined;
|
|
815
|
+
toList: <T_16>(val: T_16 | T_16[]) => T_16[];
|
|
785
816
|
};
|
|
786
817
|
string: {
|
|
787
818
|
toString: (value: any) => any;
|
|
@@ -814,7 +845,7 @@ declare const _default: {
|
|
|
814
845
|
number?: boolean | undefined;
|
|
815
846
|
boolean?: boolean | undefined;
|
|
816
847
|
}) => any;
|
|
817
|
-
cloneClass: <
|
|
848
|
+
cloneClass: <T_7>(source: T_7) => T_7;
|
|
818
849
|
combine: (target: any, source: any, options?: import("./typings").Ddan.IIgnoreParams) => any;
|
|
819
850
|
combines: (objs: any[], options?: import("./typings").Ddan.IIgnoreParams) => {};
|
|
820
851
|
observe: (obj: any, key: any, watchFun: any, owner: any, deep?: boolean) => void;
|
|
@@ -827,6 +858,7 @@ declare const _default: {
|
|
|
827
858
|
encodeByOss: (input: string) => string;
|
|
828
859
|
};
|
|
829
860
|
tea: {
|
|
861
|
+
TEAKey: string;
|
|
830
862
|
encrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
|
|
831
863
|
decrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
|
|
832
864
|
toTeaKey: (str: string) => Uint32Array;
|
|
@@ -5,6 +5,7 @@ declare const _default: {
|
|
|
5
5
|
encodeByOss: (input: string) => string;
|
|
6
6
|
};
|
|
7
7
|
tea: {
|
|
8
|
+
TEAKey: string;
|
|
8
9
|
encrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
|
|
9
10
|
decrypt: (v: Uint32Array, teaKey: Uint32Array) => Uint32Array;
|
|
10
11
|
toTeaKey: (str: string) => Uint32Array;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Ddan } from '../../typings';
|
|
2
|
-
declare function to<T = any, U extends object = any>(promise: Promise<T>, errorExt?: object): Promise<[null, T] | [U, undefined]>;
|
|
2
|
+
declare function to<T = any, U extends object = any>(promise: Promise<T>, errorExt?: object, fn?: Ddan.noop): Promise<[null, T] | [U, undefined]>;
|
|
3
3
|
declare const _default: {
|
|
4
4
|
to: typeof to;
|
|
5
|
-
go: <T = any>(task?: Ddan.PFunction<T> | undefined) => Promise<[any, undefined] | [null, T]>;
|
|
5
|
+
go: <T = any>(task?: Ddan.PFunction<T> | undefined, fn?: Ddan.noop | undefined) => Promise<[any, undefined] | [null, T]>;
|
|
6
6
|
delay: (ms?: number) => Promise<unknown>;
|
|
7
|
-
safeRun: <T_1 = any>(func: any) => Promise<[null, T_1] | [any, undefined]>;
|
|
7
|
+
safeRun: <T_1 = any>(func: any, fn?: Ddan.noop | undefined) => Promise<[null, T_1] | [any, undefined]>;
|
|
8
|
+
toError: (value: any) => any;
|
|
9
|
+
timeout: <T_2 = any>(task?: Ddan.PFunction<T_2> | undefined, ms?: number, desc?: string) => Promise<[any, undefined] | [null, T_2]>;
|
|
8
10
|
};
|
|
9
11
|
export default _default;
|
|
@@ -25,11 +25,15 @@ declare const _default: {
|
|
|
25
25
|
pipe: (func: Ddan.Function, callback?: ((result: Ddan.SafeResult<any>) => void) | undefined) => DPipeline;
|
|
26
26
|
pipeline: (max?: number) => DPipeline;
|
|
27
27
|
safeTask: (func: Ddan.Function, callback?: ((result: Ddan.SafeResult<any>) => void) | undefined) => DSafeTask;
|
|
28
|
-
logString: (data: any) =>
|
|
29
|
-
logParse: (logStr: string) =>
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
logString: (data: any) => string;
|
|
29
|
+
logParse: (logStr: string) => string;
|
|
30
|
+
logRString: (data: any) => Promise<string>;
|
|
31
|
+
logRParse: (logStr: string) => Promise<string>;
|
|
32
|
+
to: <T = any, U extends object = any>(promise: Promise<T>, errorExt?: object | undefined, fn?: Ddan.noop | undefined) => Promise<[null, T] | [U, undefined]>;
|
|
33
|
+
go: <T_1 = any>(task?: Ddan.PFunction<T_1> | undefined, fn?: Ddan.noop | undefined) => Promise<[any, undefined] | [null, T_1]>;
|
|
32
34
|
delay: (ms?: number) => Promise<unknown>;
|
|
33
|
-
safeRun: <T_2 = any>(func: any) => Promise<[null, T_2] | [any, undefined]>;
|
|
35
|
+
safeRun: <T_2 = any>(func: any, fn?: Ddan.noop | undefined) => Promise<[null, T_2] | [any, undefined]>;
|
|
36
|
+
toError: (value: any) => any;
|
|
37
|
+
timeout: <T_3 = any>(task?: Ddan.PFunction<T_3> | undefined, ms?: number, desc?: string) => Promise<[any, undefined] | [null, T_3]>;
|
|
34
38
|
};
|
|
35
39
|
export default _default;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
-
logString: (data: any) =>
|
|
3
|
-
logParse: (logStr: string) =>
|
|
2
|
+
logString: (data: any) => string;
|
|
3
|
+
logParse: (logStr: string) => string;
|
|
4
|
+
logRString: (data: any) => Promise<string>;
|
|
5
|
+
logRParse: (logStr: string) => Promise<string>;
|
|
4
6
|
};
|
|
5
7
|
export default _default;
|
|
@@ -34,11 +34,12 @@ declare function radian2degree(radians: number): number;
|
|
|
34
34
|
* @returns
|
|
35
35
|
*/
|
|
36
36
|
declare function degree2radian(degrees: number): number;
|
|
37
|
-
declare function
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
declare function calcDataSize(data: number): {
|
|
38
|
+
gb: number;
|
|
39
|
+
mb: number;
|
|
40
40
|
kb: number;
|
|
41
41
|
b: number;
|
|
42
|
+
total: number;
|
|
42
43
|
desc: string;
|
|
43
44
|
};
|
|
44
45
|
declare const _default: {
|
|
@@ -50,6 +51,6 @@ declare const _default: {
|
|
|
50
51
|
float: typeof float;
|
|
51
52
|
radian2degree: typeof radian2degree;
|
|
52
53
|
degree2radian: typeof degree2radian;
|
|
53
|
-
|
|
54
|
+
calcDataSize: typeof calcDataSize;
|
|
54
55
|
};
|
|
55
56
|
export default _default;
|
|
@@ -30,10 +30,14 @@ export declare class Socks5 {
|
|
|
30
30
|
__event: DEvent;
|
|
31
31
|
__pipeline: DPipeline;
|
|
32
32
|
__logger: ILogger;
|
|
33
|
+
__totalReceived: number;
|
|
34
|
+
__totalSent: number;
|
|
33
35
|
constructor(upstreamProxy: IProxyConfig, allowedDomains?: string[] | ['*'], debug?: boolean, logger?: ILogger);
|
|
34
36
|
get id(): string;
|
|
35
37
|
get port(): number;
|
|
36
38
|
get url(): string;
|
|
39
|
+
get totalReceived(): number;
|
|
40
|
+
get totalSent(): number;
|
|
37
41
|
validateProxyConfig(proxyConfig?: IProxyConfig): "" | "无效的上游代理 IP 地址" | "无效的上游代理端口" | "无效的上游代理用户名" | "无效的上游代理密码";
|
|
38
42
|
start(startPort?: number): Promise<number>;
|
|
39
43
|
setUpstreamProxy(upstreamProxy: IProxyConfig): boolean;
|
|
@@ -83,6 +87,7 @@ export declare class Socks5 {
|
|
|
83
87
|
close(): void;
|
|
84
88
|
on(name: Socks5EventType, listener: (...args: any[]) => void): void;
|
|
85
89
|
off(name: Socks5EventType, listener: (...args: any[]) => void): void;
|
|
90
|
+
resetStatistics(): void;
|
|
86
91
|
private _emit;
|
|
87
92
|
}
|
|
88
93
|
export {};
|