@maiyunnet/kebab 2.0.14 → 2.0.15
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.d.ts +1 -1
- package/index.js +1 -1
- package/lib/captcha.js +2 -2
- package/lib/consistent.js +1 -1
- package/lib/core.d.ts +42 -18
- package/lib/core.js +147 -152
- package/lib/crypto.js +2 -2
- package/lib/db.d.ts +3 -3
- package/lib/db.js +32 -73
- package/lib/dns.d.ts +1 -1
- package/lib/dns.js +5 -5
- package/lib/fs.js +17 -9
- package/lib/jwt.d.ts +3 -3
- package/lib/jwt.js +5 -5
- package/lib/kv.d.ts +2 -2
- package/lib/kv.js +2 -2
- package/lib/lan.js +1 -1
- package/lib/net/formdata.js +2 -2
- package/lib/net/request.d.ts +1 -1
- package/lib/net/request.js +1 -1
- package/lib/net/response.d.ts +1 -1
- package/lib/net.d.ts +2 -2
- package/lib/net.js +4 -4
- package/lib/s3.d.ts +1 -1
- package/lib/s3.js +2 -2
- package/lib/scan.d.ts +3 -3
- package/lib/scan.js +6 -6
- package/lib/session.d.ts +3 -3
- package/lib/session.js +7 -7
- package/lib/sql.d.ts +3 -3
- package/lib/sql.js +7 -37
- package/lib/ssh/sftp.js +2 -2
- package/lib/ssh/shell.js +1 -1
- package/lib/text.d.ts +6 -1
- package/lib/text.js +9 -1
- package/lib/time.d.ts +1 -1
- package/lib/time.js +1 -1
- package/lib/turnstile.d.ts +1 -1
- package/lib/turnstile.js +2 -2
- package/lib/ws.d.ts +2 -2
- package/lib/ws.js +3 -3
- package/lib/zip.d.ts +1 -1
- package/lib/zip.js +1 -1
- package/package.json +5 -4
- package/sys/child.js +43 -84
- package/sys/cmd.js +7 -6
- package/sys/ctr.d.ts +2 -2
- package/sys/master.js +131 -9
- package/sys/mod.d.ts +4 -4
- package/sys/mod.js +5 -5
- package/sys/route.d.ts +1 -1
- package/sys/route.js +20 -20
- package/www/example/ctr/main.d.ts +1 -1
- package/www/example/ctr/main.js +1 -1
- package/www/example/ctr/middle.d.ts +2 -2
- package/www/example/ctr/middle.js +1 -1
- package/www/example/ctr/test.d.ts +3 -2
- package/www/example/ctr/test.js +83 -30
- package/www/example/mod/test.d.ts +2 -2
- package/www/example/mod/test.js +2 -2
- package/www/example/mod/testdata.d.ts +1 -1
- package/www/example/mod/testdata.js +1 -1
- package/www/example/ws/mproxy.d.ts +1 -1
- package/www/example/ws/mproxy.js +2 -2
- package/www/example/ws/rproxy.d.ts +1 -1
- package/www/example/ws/rproxy.js +2 -2
- package/www/example/ws/test.d.ts +1 -1
- package/www/example/ws/test.js +4 -3
package/lib/db.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Project: Kebab, User: JianSuoQiYue
|
|
4
4
|
* Date: 2019-4-15 13:40
|
|
5
|
-
* Last: 2020-4-13 15:34:45, 2022-09-12 13:10:34, 2023-5-24 18:29:38, 2024-7-11 14:37:54, 2024-8-25 00:32:53, 2024-9-22 17:30:47
|
|
5
|
+
* Last: 2020-4-13 15:34:45, 2022-09-12 13:10:34, 2023-5-24 18:29:38, 2024-7-11 14:37:54, 2024-8-25 00:32:53, 2024-9-22 17:30:47, 2025-8-3 20:24:03
|
|
6
6
|
*/
|
|
7
7
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
8
|
if (k2 === undefined) k2 = k;
|
|
@@ -45,11 +45,11 @@ exports.getConnectionList = getConnectionList;
|
|
|
45
45
|
// --- 第三方 ---
|
|
46
46
|
const mysql2 = __importStar(require("mysql2/promise"));
|
|
47
47
|
// --- 库和定义 ---
|
|
48
|
-
const time = __importStar(require("
|
|
49
|
-
const lSql = __importStar(require("
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const ctr = __importStar(require("
|
|
48
|
+
const time = __importStar(require("~/lib/time"));
|
|
49
|
+
const lSql = __importStar(require("~/lib/sql"));
|
|
50
|
+
const lCore = __importStar(require("~/lib/core"));
|
|
51
|
+
const lText = __importStar(require("~/lib/text"));
|
|
52
|
+
const ctr = __importStar(require("~/sys/ctr"));
|
|
53
53
|
/** --- 连接列表池 --- */
|
|
54
54
|
const connections = [];
|
|
55
55
|
/**
|
|
@@ -71,23 +71,14 @@ async function checkConnection() {
|
|
|
71
71
|
if (connection.getLast() <= now - 60) {
|
|
72
72
|
// --- 1 分钟之前开始的 ---
|
|
73
73
|
const ls = connection.getLastSql();
|
|
74
|
-
const sql = ls[1] ?? ls[0];
|
|
75
|
-
console.log(`[child] [db] [error] There is a transactional connection[${i}] that is not closed, last sql: ${sql?.sql ?? 'undefined'}.`);
|
|
76
74
|
const newarr = ls.map(item => {
|
|
77
75
|
if (!item.values) {
|
|
78
76
|
return item.sql;
|
|
79
77
|
}
|
|
80
78
|
return lSql.format(item.sql, item.values);
|
|
81
79
|
});
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
'urlFull': '',
|
|
85
|
-
'hostname': '',
|
|
86
|
-
'req': null,
|
|
87
|
-
'get': {},
|
|
88
|
-
'cookie': {},
|
|
89
|
-
'headers': {}
|
|
90
|
-
}, `(db.checkConnection)There is a transactional connection[${i}] that is not closed, last sql: ${newarr.join(', ')}.`, '-error');
|
|
80
|
+
lCore.display(`[DB][error] There is a transactional connection[${i}] that is not closed, last sql: ${newarr.join(', ')}.`);
|
|
81
|
+
lCore.log({}, `[DB][checkConnection] There is a transactional connection[${i}] that is not closed, last sql: ${newarr.join(', ')}.`, '-error');
|
|
91
82
|
await connection.rollback();
|
|
92
83
|
}
|
|
93
84
|
continue;
|
|
@@ -103,12 +94,12 @@ async function checkConnection() {
|
|
|
103
94
|
--i;
|
|
104
95
|
}
|
|
105
96
|
setTimeout(function () {
|
|
106
|
-
checkConnection().catch(e => {
|
|
107
|
-
},
|
|
97
|
+
checkConnection().catch(e => { lCore.display('[DB][checkConnection]', e); });
|
|
98
|
+
}, 30_000);
|
|
108
99
|
}
|
|
109
100
|
setTimeout(function () {
|
|
110
|
-
checkConnection().catch(e => {
|
|
111
|
-
},
|
|
101
|
+
checkConnection().catch(e => { lCore.display('[DB][checkConnection]', e); });
|
|
102
|
+
}, 30_000);
|
|
112
103
|
/** --- 数据库连接池对象 --- */
|
|
113
104
|
class Pool {
|
|
114
105
|
constructor(etc) {
|
|
@@ -209,7 +200,7 @@ class Pool {
|
|
|
209
200
|
c.using();
|
|
210
201
|
link.on('error', function (err) {
|
|
211
202
|
if (err.code !== 'PROTOCOL_CONNECTION_LOST') {
|
|
212
|
-
|
|
203
|
+
lCore.display('[DB][_getConnection]', err);
|
|
213
204
|
}
|
|
214
205
|
c.setLost();
|
|
215
206
|
}).on('end', function () {
|
|
@@ -219,15 +210,7 @@ class Pool {
|
|
|
219
210
|
connections.push(conn);
|
|
220
211
|
}
|
|
221
212
|
catch (e) {
|
|
222
|
-
|
|
223
|
-
'path': '',
|
|
224
|
-
'urlFull': '',
|
|
225
|
-
'hostname': '',
|
|
226
|
-
'req': null,
|
|
227
|
-
'get': {},
|
|
228
|
-
'cookie': {},
|
|
229
|
-
'headers': {}
|
|
230
|
-
}, '(db._getConnection)' + text.stringifyJson(e.stack).slice(1, -1), '-error');
|
|
213
|
+
lCore.log({}, '[DB][Pool][_getConnection]' + lText.stringifyJson(e.stack).slice(1, -1), '-error');
|
|
231
214
|
}
|
|
232
215
|
}
|
|
233
216
|
return conn;
|
|
@@ -260,12 +243,12 @@ class Transaction {
|
|
|
260
243
|
const warning = opts.warning ?? 1_500;
|
|
261
244
|
this._timer.warning = setTimeout(() => {
|
|
262
245
|
this._timer.warning = undefined;
|
|
263
|
-
|
|
246
|
+
lCore.display('[WARNING][DB][Transaction] time too long, ms: ' + warning + ' ' + (this._ctr?.getPrototype('_config').const.path ?? 'no ctr'));
|
|
264
247
|
}, warning);
|
|
265
248
|
const danger = opts.danger ?? 5_000;
|
|
266
249
|
this._timer.danger = setTimeout(() => {
|
|
267
250
|
this._timer.danger = undefined;
|
|
268
|
-
|
|
251
|
+
lCore.display('[DANGER][DB][Transaction] time too long, ms:', danger, this._ctr?.getPrototype('_config').const.path ?? 'no ctr');
|
|
269
252
|
}, danger);
|
|
270
253
|
}
|
|
271
254
|
/**
|
|
@@ -276,16 +259,8 @@ class Transaction {
|
|
|
276
259
|
async query(sql, values) {
|
|
277
260
|
if (!this._conn) {
|
|
278
261
|
// --- 当前连接已不可用 ---
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
'path': '',
|
|
282
|
-
'urlFull': '',
|
|
283
|
-
'hostname': '',
|
|
284
|
-
'req': null,
|
|
285
|
-
'get': {},
|
|
286
|
-
'cookie': {},
|
|
287
|
-
'headers': {}
|
|
288
|
-
}, '(db.Transaction.query) has been closed, ' + (this._ctr?.getPrototype('_config').const.path ?? 'no ctr') + ': ' + sql, '-error');
|
|
262
|
+
lCore.display('[DB][Transaction][query] has been closed ' + (this._ctr?.getPrototype('_config').const.path ?? 'no ctr') + ': ' + sql);
|
|
263
|
+
lCore.log({}, '[DB][Transaction][query] has been closed ' + (this._ctr?.getPrototype('_config').const.path ?? 'no ctr') + ': ' + sql, '-error');
|
|
289
264
|
return {
|
|
290
265
|
'rows': null,
|
|
291
266
|
'fields': [],
|
|
@@ -306,16 +281,8 @@ class Transaction {
|
|
|
306
281
|
async execute(sql, values) {
|
|
307
282
|
if (!this._conn) {
|
|
308
283
|
// --- 当前连接已不可用 ---
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
'path': '',
|
|
312
|
-
'urlFull': '',
|
|
313
|
-
'hostname': '',
|
|
314
|
-
'req': null,
|
|
315
|
-
'get': {},
|
|
316
|
-
'cookie': {},
|
|
317
|
-
'headers': {}
|
|
318
|
-
}, '(db.Transaction.execute) has been closed, ' + (this._ctr?.getPrototype('_config').const.path ?? 'no ctr') + ': ' + sql, '-error');
|
|
284
|
+
lCore.display('[DB][Transaction][execute] has been closed ' + (this._ctr?.getPrototype('_config').const.path ?? 'no ctr') + ': ' + sql);
|
|
285
|
+
lCore.log({}, '(db.Transaction.execute) has been closed ' + (this._ctr?.getPrototype('_config').const.path ?? 'no ctr') + ': ' + sql, '-error');
|
|
319
286
|
return {
|
|
320
287
|
'packet': null,
|
|
321
288
|
'fields': [],
|
|
@@ -331,16 +298,8 @@ class Transaction {
|
|
|
331
298
|
async commit() {
|
|
332
299
|
if (!this._conn) {
|
|
333
300
|
// --- 当前连接已不可用 ---
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
'path': '',
|
|
337
|
-
'urlFull': '',
|
|
338
|
-
'hostname': '',
|
|
339
|
-
'req': null,
|
|
340
|
-
'get': {},
|
|
341
|
-
'cookie': {},
|
|
342
|
-
'headers': {}
|
|
343
|
-
}, '(db.Transaction.commit) has been closed: ' + (this._ctr?.getPrototype('_config').const.path ?? 'no ctr'), '-error');
|
|
301
|
+
lCore.display('[DB][Transaction][commit] has been closed ' + (this._ctr?.getPrototype('_config').const.path ?? 'no ctr'));
|
|
302
|
+
lCore.log({}, '[DB][Transaction][commit] has been closed ' + (this._ctr?.getPrototype('_config').const.path ?? 'no ctr'), '-error');
|
|
344
303
|
return false;
|
|
345
304
|
}
|
|
346
305
|
const r = await this._conn.commit();
|
|
@@ -360,16 +319,8 @@ class Transaction {
|
|
|
360
319
|
async rollback() {
|
|
361
320
|
if (!this._conn) {
|
|
362
321
|
// --- 当前连接已不可用 ---
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
'path': '',
|
|
366
|
-
'urlFull': '',
|
|
367
|
-
'hostname': '',
|
|
368
|
-
'req': null,
|
|
369
|
-
'get': {},
|
|
370
|
-
'cookie': {},
|
|
371
|
-
'headers': {}
|
|
372
|
-
}, '(db.Transaction.rollback) has been closed: ' + (this._ctr?.getPrototype('_config').const.path ?? 'no ctr'), '-error');
|
|
322
|
+
lCore.display('[DB][Transaction][rollback] has been closed: ' + (this._ctr?.getPrototype('_config').const.path ?? 'no ctr'));
|
|
323
|
+
lCore.log({}, '[DB][Transaction][rollback] has been closed: ' + (this._ctr?.getPrototype('_config').const.path ?? 'no ctr'), '-error');
|
|
373
324
|
return false;
|
|
374
325
|
}
|
|
375
326
|
const r = await this._conn.rollback();
|
|
@@ -501,7 +452,11 @@ class Connection {
|
|
|
501
452
|
'sql': sql,
|
|
502
453
|
'values': values
|
|
503
454
|
});
|
|
455
|
+
const time = Date.now();
|
|
504
456
|
res = await this._link.query(sql, values);
|
|
457
|
+
if (Date.now() - time > 200) {
|
|
458
|
+
lCore.log({}, '[WARNING][DB][Connection][query] slow sql 200ms: ' + sql, '-warning');
|
|
459
|
+
}
|
|
505
460
|
}
|
|
506
461
|
catch (e) {
|
|
507
462
|
if (!this._transaction) {
|
|
@@ -539,7 +494,11 @@ class Connection {
|
|
|
539
494
|
'sql': sql,
|
|
540
495
|
'values': values
|
|
541
496
|
});
|
|
497
|
+
const time = Date.now();
|
|
542
498
|
res = await this._link.execute(sql, values);
|
|
499
|
+
if (Date.now() - time > 200) {
|
|
500
|
+
lCore.log({}, '[WARNING][DB][Connection][execute] slow sql 200ms: ' + sql, '-warning');
|
|
501
|
+
}
|
|
543
502
|
}
|
|
544
503
|
catch (e) {
|
|
545
504
|
if (!this._transaction) {
|
package/lib/dns.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Date: 2019-6-19
|
|
4
4
|
* Last: 2022-09-12 20:58:07, 2024-2-21 17:55:54, 2025-6-13 19:08:56
|
|
5
5
|
*/
|
|
6
|
-
import * as ctr from '
|
|
6
|
+
import * as ctr from '~/sys/ctr';
|
|
7
7
|
/**
|
|
8
8
|
* 0.DNSPod:https://www.dnspod.cn/docs/index.html(腾讯云也请使用 DNSPod 的 API)
|
|
9
9
|
* 1.阿里云:https://help.aliyun.com/document_detail/29745.html
|
package/lib/dns.js
CHANGED
|
@@ -41,11 +41,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
41
41
|
exports.Dns = exports.ERecordLine = exports.RECORD_TYPE = exports.ESERVICE = void 0;
|
|
42
42
|
exports.get = get;
|
|
43
43
|
// --- 库和定义 ---
|
|
44
|
-
const net = __importStar(require("
|
|
45
|
-
const core = __importStar(require("
|
|
46
|
-
const text = __importStar(require("
|
|
47
|
-
const crypto = __importStar(require("
|
|
48
|
-
const response = __importStar(require("
|
|
44
|
+
const net = __importStar(require("~/lib/net"));
|
|
45
|
+
const core = __importStar(require("~/lib/core"));
|
|
46
|
+
const text = __importStar(require("~/lib/text"));
|
|
47
|
+
const crypto = __importStar(require("~/lib/crypto"));
|
|
48
|
+
const response = __importStar(require("~/lib/net/response"));
|
|
49
49
|
/**
|
|
50
50
|
* 0.DNSPod:https://www.dnspod.cn/docs/index.html(腾讯云也请使用 DNSPod 的 API)
|
|
51
51
|
* 1.阿里云:https://help.aliyun.com/document_detail/29745.html
|
package/lib/fs.js
CHANGED
|
@@ -75,8 +75,8 @@ async function getContent(path, options) {
|
|
|
75
75
|
'encoding': options
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
-
else
|
|
79
|
-
options
|
|
78
|
+
else {
|
|
79
|
+
options ??= {};
|
|
80
80
|
}
|
|
81
81
|
const encoding = options.encoding;
|
|
82
82
|
const start = options.start;
|
|
@@ -337,6 +337,16 @@ async function readDir(path, encoding) {
|
|
|
337
337
|
}
|
|
338
338
|
list.push(item);
|
|
339
339
|
}
|
|
340
|
+
// --- 将 list 根据先目录后文件排序,如果是同是目录或文件,则以名称排序 ---
|
|
341
|
+
list.sort((a, b) => {
|
|
342
|
+
// --- 目录排在文件前面 ---
|
|
343
|
+
if (a.isDirectory() && !b.isDirectory())
|
|
344
|
+
return -1;
|
|
345
|
+
if (!a.isDirectory() && b.isDirectory())
|
|
346
|
+
return 1;
|
|
347
|
+
// --- 同类型按名称排序 ---
|
|
348
|
+
return a.name.localeCompare(b.name);
|
|
349
|
+
});
|
|
340
350
|
return list;
|
|
341
351
|
}
|
|
342
352
|
catch {
|
|
@@ -413,8 +423,8 @@ function createReadStream(path, options) {
|
|
|
413
423
|
'encoding': options
|
|
414
424
|
};
|
|
415
425
|
}
|
|
416
|
-
else
|
|
417
|
-
options
|
|
426
|
+
else {
|
|
427
|
+
options ??= {};
|
|
418
428
|
}
|
|
419
429
|
return fs.createReadStream(path, {
|
|
420
430
|
'flags': options.flags,
|
|
@@ -450,8 +460,8 @@ function createWriteStream(path, options) {
|
|
|
450
460
|
'encoding': options
|
|
451
461
|
};
|
|
452
462
|
}
|
|
453
|
-
else
|
|
454
|
-
options
|
|
463
|
+
else {
|
|
464
|
+
options ??= {};
|
|
455
465
|
}
|
|
456
466
|
return fs.createWriteStream(path, {
|
|
457
467
|
'flags': options.flags,
|
|
@@ -469,9 +479,7 @@ function createWriteStream(path, options) {
|
|
|
469
479
|
* @param stat 文件的 stat(如果有)
|
|
470
480
|
*/
|
|
471
481
|
async function readToResponse(path, req, res, stat) {
|
|
472
|
-
|
|
473
|
-
stat = await stats(path);
|
|
474
|
-
}
|
|
482
|
+
stat ??= await stats(path);
|
|
475
483
|
if (!stat) {
|
|
476
484
|
res.setHeader('content-length', 22);
|
|
477
485
|
res.writeHead(404);
|
package/lib/jwt.d.ts
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Date: 2023-1-31 20:34:47
|
|
4
4
|
* Last: 2023-1-31 20:34:47, 2023-12-8 13:55:09
|
|
5
5
|
*/
|
|
6
|
-
import * as kv from '
|
|
7
|
-
import * as ctr from '
|
|
8
|
-
import * as types from '
|
|
6
|
+
import * as kv from '~/lib/kv';
|
|
7
|
+
import * as ctr from '~/sys/ctr';
|
|
8
|
+
import * as types from '~/types';
|
|
9
9
|
export interface IOptions {
|
|
10
10
|
'name'?: string;
|
|
11
11
|
'ttl'?: number;
|
package/lib/jwt.js
CHANGED
|
@@ -44,10 +44,10 @@ exports.decode = decode;
|
|
|
44
44
|
exports.block = block;
|
|
45
45
|
exports.get = get;
|
|
46
46
|
// --- 库和定义 ---
|
|
47
|
-
const lCore = __importStar(require("
|
|
48
|
-
const lTime = __importStar(require("
|
|
49
|
-
const lText = __importStar(require("
|
|
50
|
-
const lCrypto = __importStar(require("
|
|
47
|
+
const lCore = __importStar(require("~/lib/core"));
|
|
48
|
+
const lTime = __importStar(require("~/lib/time"));
|
|
49
|
+
const lText = __importStar(require("~/lib/text"));
|
|
50
|
+
const lCrypto = __importStar(require("~/lib/crypto"));
|
|
51
51
|
class Jwt {
|
|
52
52
|
/**
|
|
53
53
|
* --- 初始化函数,相当于 construct ---
|
|
@@ -98,7 +98,7 @@ class Jwt {
|
|
|
98
98
|
renew() {
|
|
99
99
|
const time = lTime.stamp();
|
|
100
100
|
const data = this._ctr.getPrototype('_jwt');
|
|
101
|
-
const token = data['token'] ?
|
|
101
|
+
const token = lText.isFalsy(data['token']) ? lCore.random(16, lCore.RANDOM_LUN) : data['token'];
|
|
102
102
|
data['exp'] = time + this._ttl;
|
|
103
103
|
data['token'] = token;
|
|
104
104
|
// --- 拼装 ---
|
package/lib/kv.d.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Last: 2020-3-28 18:54:04, 2022-09-12 23:24:45, 2022-09-22 01:06:22, 2024-2-21 13:32:56, 2024-8-21 16:59:57
|
|
5
5
|
*/
|
|
6
6
|
import * as redis from '@litert/redis';
|
|
7
|
-
import * as ctr from '
|
|
8
|
-
import * as types from '
|
|
7
|
+
import * as ctr from '~/sys/ctr';
|
|
8
|
+
import * as types from '~/types';
|
|
9
9
|
/** --- 连接信息 --- */
|
|
10
10
|
export interface IConnectionInfo {
|
|
11
11
|
'id': number;
|
package/lib/kv.js
CHANGED
|
@@ -46,8 +46,8 @@ exports.getConnectionList = getConnectionList;
|
|
|
46
46
|
// --- 第三方 ---
|
|
47
47
|
const redis = __importStar(require("@litert/redis"));
|
|
48
48
|
// --- 库和定义 ---
|
|
49
|
-
const time = __importStar(require("
|
|
50
|
-
const text = __importStar(require("
|
|
49
|
+
const time = __importStar(require("~/lib/time"));
|
|
50
|
+
const text = __importStar(require("~/lib/text"));
|
|
51
51
|
/** --- 连接列表(同一个 host、port、index、auth 只有一个连接) --- */
|
|
52
52
|
const connections = [];
|
|
53
53
|
/**
|
package/lib/lan.js
CHANGED
|
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.card = card;
|
|
37
37
|
exports.scan = scan;
|
|
38
38
|
const os = __importStar(require("os"));
|
|
39
|
-
const lCore = __importStar(require("
|
|
39
|
+
const lCore = __importStar(require("~/lib/core"));
|
|
40
40
|
/**
|
|
41
41
|
* --- 获取当前网卡的 IP、MAC 信息 ---
|
|
42
42
|
*/
|
package/lib/net/formdata.js
CHANGED
|
@@ -41,8 +41,8 @@ exports.FormData = void 0;
|
|
|
41
41
|
*/
|
|
42
42
|
const stream = __importStar(require("stream"));
|
|
43
43
|
const mime = __importStar(require("@litert/mime"));
|
|
44
|
-
const core = __importStar(require("
|
|
45
|
-
const fs = __importStar(require("
|
|
44
|
+
const core = __importStar(require("~/lib/core"));
|
|
45
|
+
const fs = __importStar(require("~/lib/fs"));
|
|
46
46
|
class FormData extends stream.Readable {
|
|
47
47
|
constructor() {
|
|
48
48
|
super(...arguments);
|
package/lib/net/request.d.ts
CHANGED
package/lib/net/request.js
CHANGED
|
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.Request = void 0;
|
|
37
|
-
const net = __importStar(require("
|
|
37
|
+
const net = __importStar(require("~/lib/net"));
|
|
38
38
|
class Request {
|
|
39
39
|
constructor(url) {
|
|
40
40
|
/** --- get 或 post 的数据 --- */
|
package/lib/net/response.d.ts
CHANGED
package/lib/net.d.ts
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
import * as stream from 'stream';
|
|
8
8
|
import * as http from 'http';
|
|
9
9
|
import * as http2 from 'http2';
|
|
10
|
-
import * as ctr from '
|
|
11
|
-
import * as types from '
|
|
10
|
+
import * as ctr from '~/sys/ctr';
|
|
11
|
+
import * as types from '~/types';
|
|
12
12
|
import * as fd from './net/formdata';
|
|
13
13
|
import * as lRequest from './net/request';
|
|
14
14
|
import * as response from './net/response';
|
package/lib/net.js
CHANGED
|
@@ -57,10 +57,10 @@ const stream = __importStar(require("stream"));
|
|
|
57
57
|
// --- 第三方 ---
|
|
58
58
|
const hc = __importStar(require("@litert/http-client"));
|
|
59
59
|
// --- 库和定义 ---
|
|
60
|
-
const fs = __importStar(require("
|
|
61
|
-
const text = __importStar(require("
|
|
62
|
-
const time = __importStar(require("
|
|
63
|
-
const kebab = __importStar(require("
|
|
60
|
+
const fs = __importStar(require("~/lib/fs"));
|
|
61
|
+
const text = __importStar(require("~/lib/text"));
|
|
62
|
+
const time = __importStar(require("~/lib/time"));
|
|
63
|
+
const kebab = __importStar(require("~/index"));
|
|
64
64
|
// --- 自己 ---
|
|
65
65
|
const fd = __importStar(require("./net/formdata"));
|
|
66
66
|
const lRequest = __importStar(require("./net/request"));
|
package/lib/s3.d.ts
CHANGED
package/lib/s3.js
CHANGED
|
@@ -43,8 +43,8 @@ exports.get = get;
|
|
|
43
43
|
// --- 库和定义 ---
|
|
44
44
|
const s3 = __importStar(require("@aws-sdk/client-s3"));
|
|
45
45
|
const ls = __importStar(require("@aws-sdk/lib-storage"));
|
|
46
|
-
const lCore = __importStar(require("
|
|
47
|
-
const lText = __importStar(require("
|
|
46
|
+
const lCore = __importStar(require("~/lib/core"));
|
|
47
|
+
const lText = __importStar(require("~/lib/text"));
|
|
48
48
|
/**
|
|
49
49
|
* s3 文档:https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/s3/
|
|
50
50
|
*/
|
package/lib/scan.d.ts
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Date: 2022-09-24 15:23:25
|
|
4
4
|
* Last: 2022-09-24 15:23:25, 2022-9-26 12:37:01, 2022-12-29 00:11:16
|
|
5
5
|
*/
|
|
6
|
-
import * as lDb from '
|
|
7
|
-
import * as lKv from '
|
|
8
|
-
import * as sCtr from '
|
|
6
|
+
import * as lDb from '~/lib/db';
|
|
7
|
+
import * as lKv from '~/lib/kv';
|
|
8
|
+
import * as sCtr from '~/sys/ctr';
|
|
9
9
|
/** --- Scan 设置的选项 --- */
|
|
10
10
|
export interface IOptions {
|
|
11
11
|
'ttl'?: number;
|
package/lib/scan.js
CHANGED
|
@@ -56,12 +56,12 @@ CREATE TABLE IF NOT EXISTS `scan` (
|
|
|
56
56
|
KEY `time_exp` (`time_exp`)
|
|
57
57
|
) ENGINE = InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
|
|
58
58
|
*/
|
|
59
|
-
const lCore = __importStar(require("
|
|
60
|
-
const lDb = __importStar(require("
|
|
61
|
-
const lKv = __importStar(require("
|
|
62
|
-
const lSql = __importStar(require("
|
|
63
|
-
const lTime = __importStar(require("
|
|
64
|
-
const lText = __importStar(require("
|
|
59
|
+
const lCore = __importStar(require("~/lib/core"));
|
|
60
|
+
const lDb = __importStar(require("~/lib/db"));
|
|
61
|
+
const lKv = __importStar(require("~/lib/kv"));
|
|
62
|
+
const lSql = __importStar(require("~/lib/sql"));
|
|
63
|
+
const lTime = __importStar(require("~/lib/time"));
|
|
64
|
+
const lText = __importStar(require("~/lib/text"));
|
|
65
65
|
class Scan {
|
|
66
66
|
constructor(link, token, opt = {}) {
|
|
67
67
|
this._sql = null;
|
package/lib/session.d.ts
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Date: 2019-6-5 22:01:40
|
|
4
4
|
* Last: 2020-3-30 00:11:15, 2022-12-29 00:10:28, 2023-5-24 18:59:27
|
|
5
5
|
*/
|
|
6
|
-
import * as db from '
|
|
7
|
-
import * as kv from '
|
|
8
|
-
import * as ctr from '
|
|
6
|
+
import * as db from '~/lib/db';
|
|
7
|
+
import * as kv from '~/lib/kv';
|
|
8
|
+
import * as ctr from '~/sys/ctr';
|
|
9
9
|
export interface IOptions {
|
|
10
10
|
'name'?: string;
|
|
11
11
|
'ttl'?: number;
|
package/lib/session.js
CHANGED
|
@@ -53,12 +53,12 @@ CREATE TABLE `session` (
|
|
|
53
53
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
|
|
54
54
|
*/
|
|
55
55
|
// --- 库和定义 ---
|
|
56
|
-
const core = __importStar(require("
|
|
57
|
-
const time = __importStar(require("
|
|
58
|
-
const db = __importStar(require("
|
|
59
|
-
const kv = __importStar(require("
|
|
60
|
-
const sql = __importStar(require("
|
|
61
|
-
const text = __importStar(require("
|
|
56
|
+
const core = __importStar(require("~/lib/core"));
|
|
57
|
+
const time = __importStar(require("~/lib/time"));
|
|
58
|
+
const db = __importStar(require("~/lib/db"));
|
|
59
|
+
const kv = __importStar(require("~/lib/kv"));
|
|
60
|
+
const sql = __importStar(require("~/lib/sql"));
|
|
61
|
+
const text = __importStar(require("~/lib/text"));
|
|
62
62
|
class Session {
|
|
63
63
|
constructor() {
|
|
64
64
|
/** --- 当前 Session 的 token --- */
|
|
@@ -93,7 +93,7 @@ class Session {
|
|
|
93
93
|
}
|
|
94
94
|
this._link = link;
|
|
95
95
|
if (link instanceof db.Pool) {
|
|
96
|
-
this._sql = sql.get(pre
|
|
96
|
+
this._sql = sql.get(pre ?? ctr);
|
|
97
97
|
await this._gc(); // --- 执行 gc ---
|
|
98
98
|
}
|
|
99
99
|
// --- 初始化 Session 数组 ---
|
package/lib/sql.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Project: Kebab, User: JianSuoQiYue
|
|
3
3
|
* Date: 2019-5-27 20:18:50
|
|
4
|
-
* Last: 2020-3-29 19:37:25, 2022-07-24 22:38:11, 2023-5-24 18:49:18, 2023-6-13 22:20:21, 2023-12-11 13:58:54, 2023-12-14 13:14:40, 2023-12-21 00:04:40, 2024-4-11 19:29:29, 2024-9-2 17:15:28
|
|
4
|
+
* Last: 2020-3-29 19:37:25, 2022-07-24 22:38:11, 2023-5-24 18:49:18, 2023-6-13 22:20:21, 2023-12-11 13:58:54, 2023-12-14 13:14:40, 2023-12-21 00:04:40, 2024-4-11 19:29:29, 2024-9-2 17:15:28, 2025-8-3 21:28:18
|
|
5
5
|
*/
|
|
6
|
-
import * as ctr from '
|
|
7
|
-
import * as types from '
|
|
6
|
+
import * as ctr from '~/sys/ctr';
|
|
7
|
+
import * as types from '~/types';
|
|
8
8
|
export declare class Sql {
|
|
9
9
|
/** --- 前置 --- */
|
|
10
10
|
private readonly _pre;
|
package/lib/sql.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Project: Kebab, User: JianSuoQiYue
|
|
4
4
|
* Date: 2019-5-27 20:18:50
|
|
5
|
-
* Last: 2020-3-29 19:37:25, 2022-07-24 22:38:11, 2023-5-24 18:49:18, 2023-6-13 22:20:21, 2023-12-11 13:58:54, 2023-12-14 13:14:40, 2023-12-21 00:04:40, 2024-4-11 19:29:29, 2024-9-2 17:15:28
|
|
5
|
+
* Last: 2020-3-29 19:37:25, 2022-07-24 22:38:11, 2023-5-24 18:49:18, 2023-6-13 22:20:21, 2023-12-11 13:58:54, 2023-12-14 13:14:40, 2023-12-21 00:04:40, 2024-4-11 19:29:29, 2024-9-2 17:15:28, 2025-8-3 21:28:18
|
|
6
6
|
*/
|
|
7
7
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
8
|
if (k2 === undefined) k2 = k;
|
|
@@ -43,12 +43,12 @@ exports.get = get;
|
|
|
43
43
|
exports.format = format;
|
|
44
44
|
exports.aoMix = aoMix;
|
|
45
45
|
exports.column = column;
|
|
46
|
-
const lText = __importStar(require("
|
|
47
|
-
const lCore = __importStar(require("
|
|
46
|
+
const lText = __importStar(require("~/lib/text"));
|
|
47
|
+
const lCore = __importStar(require("~/lib/core"));
|
|
48
48
|
// --- 第三方 ---
|
|
49
49
|
const mysql2 = __importStar(require("mysql2/promise"));
|
|
50
50
|
// --- 库和定义 ---
|
|
51
|
-
const ctr = __importStar(require("
|
|
51
|
+
const ctr = __importStar(require("~/sys/ctr"));
|
|
52
52
|
/** --- filed 用 token --- */
|
|
53
53
|
let columnToken = '';
|
|
54
54
|
class Sql {
|
|
@@ -116,17 +116,7 @@ class Sql {
|
|
|
116
116
|
// --- v1 是项目值,如 {'x': 1, 'y': 2}, 'string', 0 ---
|
|
117
117
|
if (v1 === undefined || Number.isNaN(v1)) {
|
|
118
118
|
// --- 异常情况 ---
|
|
119
|
-
lCore.log({
|
|
120
|
-
'path': '',
|
|
121
|
-
'urlFull': '',
|
|
122
|
-
'hostname': '',
|
|
123
|
-
'req': null,
|
|
124
|
-
'get': {},
|
|
125
|
-
'cookie': {},
|
|
126
|
-
'headers': {}
|
|
127
|
-
}, '(sql.values) value error', '-error').catch(() => {
|
|
128
|
-
//
|
|
129
|
-
});
|
|
119
|
+
lCore.log({}, '[SQL][values] value error', '-error');
|
|
130
120
|
sql += `'', `;
|
|
131
121
|
}
|
|
132
122
|
else if (v1 === null) {
|
|
@@ -200,17 +190,7 @@ class Sql {
|
|
|
200
190
|
sql += this.field(k) + ', ';
|
|
201
191
|
if (v === undefined || Number.isNaN(v)) {
|
|
202
192
|
// --- 异常情况 ---
|
|
203
|
-
lCore.log({
|
|
204
|
-
'path': '',
|
|
205
|
-
'urlFull': '',
|
|
206
|
-
'hostname': '',
|
|
207
|
-
'req': null,
|
|
208
|
-
'get': {},
|
|
209
|
-
'cookie': {},
|
|
210
|
-
'headers': {}
|
|
211
|
-
}, '(sql.values) value error', '-error').catch(() => {
|
|
212
|
-
//
|
|
213
|
-
});
|
|
193
|
+
lCore.log({}, '[SQL][values] value error', '-error');
|
|
214
194
|
values += `'', `;
|
|
215
195
|
}
|
|
216
196
|
else if (v === null) {
|
|
@@ -413,17 +393,7 @@ class Sql {
|
|
|
413
393
|
sql += this.field(k) + ' = ';
|
|
414
394
|
if (v === undefined || Number.isNaN(v)) {
|
|
415
395
|
// --- 异常情况 ---
|
|
416
|
-
lCore.log({
|
|
417
|
-
'path': '',
|
|
418
|
-
'urlFull': '',
|
|
419
|
-
'hostname': '',
|
|
420
|
-
'req': null,
|
|
421
|
-
'get': {},
|
|
422
|
-
'cookie': {},
|
|
423
|
-
'headers': {}
|
|
424
|
-
}, '(sql._updateSub) value error, key: ' + k, '-error').catch(() => {
|
|
425
|
-
//
|
|
426
|
-
});
|
|
396
|
+
lCore.log({}, '[SQL][_updateSub] value error, key: ' + k, '-error');
|
|
427
397
|
sql += '"", ';
|
|
428
398
|
}
|
|
429
399
|
else if (v === null) {
|