@maiyunnet/kebab 2.0.14 → 2.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/index.d.ts +1 -1
  2. package/index.js +1 -1
  3. package/lib/buffer.js +3 -9
  4. package/lib/captcha.js +2 -2
  5. package/lib/consistent.js +1 -1
  6. package/lib/core.d.ts +42 -18
  7. package/lib/core.js +147 -152
  8. package/lib/crypto.js +2 -2
  9. package/lib/db.d.ts +3 -3
  10. package/lib/db.js +32 -73
  11. package/lib/dns.d.ts +1 -1
  12. package/lib/dns.js +5 -5
  13. package/lib/fs.js +17 -9
  14. package/lib/jwt.d.ts +3 -3
  15. package/lib/jwt.js +5 -5
  16. package/lib/kv.d.ts +2 -2
  17. package/lib/kv.js +2 -2
  18. package/lib/lan.js +1 -1
  19. package/lib/net/formdata.js +2 -2
  20. package/lib/net/request.d.ts +1 -1
  21. package/lib/net/request.js +1 -1
  22. package/lib/net/response.d.ts +1 -1
  23. package/lib/net.d.ts +2 -2
  24. package/lib/net.js +4 -4
  25. package/lib/s3.d.ts +1 -1
  26. package/lib/s3.js +5 -5
  27. package/lib/scan.d.ts +3 -3
  28. package/lib/scan.js +6 -6
  29. package/lib/session.d.ts +3 -3
  30. package/lib/session.js +7 -7
  31. package/lib/sql.d.ts +3 -3
  32. package/lib/sql.js +7 -37
  33. package/lib/ssh/sftp.js +2 -2
  34. package/lib/ssh/shell.js +1 -1
  35. package/lib/text.d.ts +6 -1
  36. package/lib/text.js +9 -1
  37. package/lib/time.d.ts +1 -1
  38. package/lib/time.js +1 -1
  39. package/lib/turnstile.d.ts +1 -1
  40. package/lib/turnstile.js +2 -2
  41. package/lib/ws.d.ts +10 -2
  42. package/lib/ws.js +62 -3
  43. package/lib/zip.d.ts +1 -1
  44. package/lib/zip.js +5 -11
  45. package/lib/zlib.js +7 -21
  46. package/package.json +5 -4
  47. package/sys/child.js +43 -84
  48. package/sys/cmd.js +7 -6
  49. package/sys/ctr.d.ts +2 -2
  50. package/sys/ctr.js +2 -2
  51. package/sys/master.js +131 -9
  52. package/sys/mod.d.ts +4 -4
  53. package/sys/mod.js +24 -176
  54. package/sys/route.d.ts +1 -1
  55. package/sys/route.js +22 -20
  56. package/www/example/ctr/main.d.ts +1 -1
  57. package/www/example/ctr/main.js +1 -1
  58. package/www/example/ctr/middle.d.ts +2 -2
  59. package/www/example/ctr/middle.js +1 -1
  60. package/www/example/ctr/test.d.ts +3 -2
  61. package/www/example/ctr/test.js +83 -30
  62. package/www/example/mod/test.d.ts +2 -2
  63. package/www/example/mod/test.js +2 -2
  64. package/www/example/mod/testdata.d.ts +1 -1
  65. package/www/example/mod/testdata.js +1 -1
  66. package/www/example/ws/mproxy.d.ts +1 -1
  67. package/www/example/ws/mproxy.js +2 -2
  68. package/www/example/ws/rproxy.d.ts +1 -1
  69. package/www/example/ws/rproxy.js +2 -2
  70. package/www/example/ws/rsocket.d.ts +4 -0
  71. package/www/example/ws/rsocket.js +47 -0
  72. package/www/example/ws/test.d.ts +6 -1
  73. package/www/example/ws/test.js +10 -3
package/sys/mod.js CHANGED
@@ -38,11 +38,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
38
38
  * Date: 2019-6-4 21:35
39
39
  * Last: 2020-4-14 13:33:51, 2022-07-23 16:01:34, 2022-09-06 22:59:26, 2023-5-24 19:11:37, 2023-6-13 21:47:58, 2023-7-10 18:54:03, 2023-8-23 17:03:16, 2023-12-11 15:21:22, 2023-12-20 23:12:03, 2024-3-8 16:05:29, 2024-3-20 19:58:15, 2024-8-11 21:14:54, 2024-10-5 14:00:22, 2024-12-14 19:58:34
40
40
  */
41
- const lSql = __importStar(require("../lib/sql"));
42
- const lTime = __importStar(require("../lib/time"));
43
- const lCore = __importStar(require("../lib/core"));
44
- const lText = __importStar(require("../lib/text"));
45
- const sCtr = __importStar(require("../sys/ctr"));
41
+ const lSql = __importStar(require("~/lib/sql"));
42
+ const lTime = __importStar(require("~/lib/time"));
43
+ const lCore = __importStar(require("~/lib/core"));
44
+ const lText = __importStar(require("~/lib/text"));
45
+ const sCtr = __importStar(require("~/sys/ctr"));
46
46
  /** --- 条数列表 --- */
47
47
  class Rows {
48
48
  constructor(initialItems = []) {
@@ -189,15 +189,7 @@ class Mod {
189
189
  sq.insert(this._$table + (opt.index ? ('_' + opt.index) : '')).values(cs, vs);
190
190
  const r = await db.execute(sq.getSql(), sq.getData());
191
191
  if (r.packet === null) {
192
- await lCore.log(opt.pre instanceof sCtr.Ctr ? opt.pre : {
193
- 'path': '',
194
- 'urlFull': '',
195
- 'hostname': '',
196
- 'req': null,
197
- 'get': {},
198
- 'cookie': {},
199
- 'headers': {}
200
- }, '[insert, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1), '-error');
192
+ lCore.log(opt.pre instanceof sCtr.Ctr ? opt.pre : {}, '[insert, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1), '-error');
201
193
  return false;
202
194
  }
203
195
  if (r.packet.affectedRows > 0) {
@@ -230,15 +222,7 @@ class Mod {
230
222
  sq.insert(this._$table + (opt.index ? ('_' + opt.index) : '')).values(data).duplicate(update);
231
223
  const r = await db.execute(sq.getSql(), sq.getData());
232
224
  if (r.packet === null) {
233
- await lCore.log(opt.pre instanceof sCtr.Ctr ? opt.pre : {
234
- 'path': '',
235
- 'urlFull': '',
236
- 'hostname': '',
237
- 'req': null,
238
- 'get': {},
239
- 'cookie': {},
240
- 'headers': {}
241
- }, '[insertDuplicate, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
225
+ lCore.log(opt.pre instanceof sCtr.Ctr ? opt.pre : {}, '[insertDuplicate, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
242
226
  return false;
243
227
  }
244
228
  if (r.packet.affectedRows > 0) {
@@ -287,15 +271,7 @@ class Mod {
287
271
  }
288
272
  const r = await db.execute(sq.getSql(), sq.getData());
289
273
  if (r.packet === null) {
290
- await lCore.log(opt.pre instanceof sCtr.Ctr ? opt.pre : {
291
- 'path': '',
292
- 'urlFull': '',
293
- 'hostname': '',
294
- 'req': null,
295
- 'get': {},
296
- 'cookie': {},
297
- 'headers': {}
298
- }, '[removeByWhere, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
274
+ lCore.log(opt.pre instanceof sCtr.Ctr ? opt.pre : {}, '[removeByWhere, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
299
275
  return false;
300
276
  }
301
277
  if (r.packet.affectedRows > 0) {
@@ -382,15 +358,7 @@ class Mod {
382
358
  }
383
359
  const r = await db.execute(sq.getSql(), sq.getData());
384
360
  if (r.packet === null) {
385
- await lCore.log(opt.pre instanceof sCtr.Ctr ? opt.pre : {
386
- 'path': '',
387
- 'urlFull': '',
388
- 'hostname': '',
389
- 'req': null,
390
- 'get': {},
391
- 'cookie': {},
392
- 'headers': {}
393
- }, '[updateByWhere, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
361
+ lCore.log(opt.pre instanceof sCtr.Ctr ? opt.pre : {}, '[updateByWhere, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
394
362
  return false;
395
363
  }
396
364
  if (r.packet.affectedRows > 0) {
@@ -579,15 +547,7 @@ class Mod {
579
547
  sq.select(this._$primary, this._$table + (opt.index ? ('_' + opt.index) : '')).where(where);
580
548
  const r = await db.query(sq.getSql(), sq.getData());
581
549
  if (r.rows === null) {
582
- await lCore.log(opt.ctr ?? {
583
- 'path': '',
584
- 'urlFull': '',
585
- 'hostname': '',
586
- 'req': null,
587
- 'get': {},
588
- 'cookie': {},
589
- 'headers': {}
590
- }, '[primarys, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
550
+ lCore.log(opt.ctr ?? {}, '[primarys, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
591
551
  return false;
592
552
  }
593
553
  const primarys = [];
@@ -693,15 +653,7 @@ class Mod {
693
653
  }
694
654
  }
695
655
  // --- 未处理的错误 ---
696
- await lCore.log(this._ctr ?? {
697
- 'path': '',
698
- 'urlFull': '',
699
- 'hostname': '',
700
- 'req': null,
701
- 'get': {},
702
- 'cookie': {},
703
- 'headers': {}
704
- }, '[create0, mod] [' + table + '] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
656
+ lCore.log(this._ctr ?? {}, '[create0, mod] [' + table + '] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
705
657
  return false;
706
658
  }
707
659
  }
@@ -716,15 +668,7 @@ class Mod {
716
668
  r = await this._db.execute(this._sql.getSql(), this._sql.getData());
717
669
  if (r.error) {
718
670
  if (r.error.errno !== 1062) {
719
- await lCore.log(this._ctr ?? {
720
- 'path': '',
721
- 'urlFull': '',
722
- 'hostname': '',
723
- 'req': null,
724
- 'get': {},
725
- 'cookie': {},
726
- 'headers': {}
727
- }, '[create1, mod] [' + table + '] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
671
+ lCore.log(this._ctr ?? {}, '[create1, mod] [' + table + '] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
728
672
  }
729
673
  return false;
730
674
  }
@@ -751,15 +695,7 @@ class Mod {
751
695
  this._sql.replace(cstr._$table + (this._index ? ('_' + this._index[0]) : '')).values(updates);
752
696
  const r = await this._db.execute(this._sql.getSql(), this._sql.getData());
753
697
  if (r.packet === null) {
754
- await lCore.log(this._ctr ?? {
755
- 'path': '',
756
- 'urlFull': '',
757
- 'hostname': '',
758
- 'req': null,
759
- 'get': {},
760
- 'cookie': {},
761
- 'headers': {}
762
- }, '[replace, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
698
+ lCore.log(this._ctr ?? {}, '[replace, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
763
699
  return false;
764
700
  }
765
701
  if (r.packet.affectedRows > 0) {
@@ -786,15 +722,7 @@ class Mod {
786
722
  }
787
723
  const r = await this._db.query(this._sql.getSql(), this._sql.getData());
788
724
  if (r.rows === null) {
789
- await lCore.log(this._ctr ?? {
790
- 'path': '',
791
- 'urlFull': '',
792
- 'hostname': '',
793
- 'req': null,
794
- 'get': {},
795
- 'cookie': {},
796
- 'headers': {}
797
- }, '[refresh, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
725
+ lCore.log(this._ctr ?? {}, '[refresh, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
798
726
  return false;
799
727
  }
800
728
  if (r.rows.length === 0) {
@@ -824,15 +752,7 @@ class Mod {
824
752
  }]);
825
753
  const r = await this._db.execute(this._sql.getSql(), this._sql.getData());
826
754
  if (r.packet === null) {
827
- await lCore.log(this._ctr ?? {
828
- 'path': '',
829
- 'urlFull': '',
830
- 'hostname': '',
831
- 'req': null,
832
- 'get': {},
833
- 'cookie': {},
834
- 'headers': {}
835
- }, '[save, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
755
+ lCore.log(this._ctr ?? {}, '[save, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
836
756
  return false;
837
757
  }
838
758
  if (r.packet.affectedRows > 0) {
@@ -865,15 +785,7 @@ class Mod {
865
785
  }
866
786
  const r = await this._db.execute(this._sql.getSql(), this._sql.getData());
867
787
  if (r.packet === null) {
868
- await lCore.log(this._ctr ?? {
869
- 'path': '',
870
- 'urlFull': '',
871
- 'hostname': '',
872
- 'req': null,
873
- 'get': {},
874
- 'cookie': {},
875
- 'headers': {}
876
- }, '[remove, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
788
+ lCore.log(this._ctr ?? {}, '[remove, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
877
789
  return false;
878
790
  }
879
791
  if (r.packet.affectedRows > 0) {
@@ -895,15 +807,7 @@ class Mod {
895
807
  }
896
808
  const r = await this._db.query(this._sql.getSql(), this._sql.getData());
897
809
  if (r.rows === null) {
898
- await lCore.log(this._ctr ?? {
899
- 'path': '',
900
- 'urlFull': '',
901
- 'hostname': '',
902
- 'req': null,
903
- 'get': {},
904
- 'cookie': {},
905
- 'headers': {}
906
- }, '[first, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
810
+ lCore.log(this._ctr ?? {}, '[first, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
907
811
  return false;
908
812
  }
909
813
  if (r.rows.length === 0) {
@@ -1034,15 +938,7 @@ class Mod {
1034
938
  const lsql = sql.replace(/ LIMIT [0-9 ,]/g, ` LIMIT ${cz}, ${remain}`);
1035
939
  const r = await this._db.query(lsql, this._sql.getData());
1036
940
  if (r.rows === null) {
1037
- await lCore.log(this._ctr ?? {
1038
- 'path': '',
1039
- 'urlFull': '',
1040
- 'hostname': '',
1041
- 'req': null,
1042
- 'get': {},
1043
- 'cookie': {},
1044
- 'headers': {}
1045
- }, '[all, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
941
+ lCore.log(this._ctr ?? {}, '[all, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
1046
942
  return false;
1047
943
  }
1048
944
  if (key) {
@@ -1078,15 +974,7 @@ class Mod {
1078
974
  const contain = this._contain ? lCore.clone(this._contain.list) : null;
1079
975
  const r = await this._db.query(this._sql.getSql(), this._sql.getData());
1080
976
  if (r.rows === null) {
1081
- await lCore.log(this._ctr ?? {
1082
- 'path': '',
1083
- 'urlFull': '',
1084
- 'hostname': '',
1085
- 'req': null,
1086
- 'get': {},
1087
- 'cookie': {},
1088
- 'headers': {}
1089
- }, '[all, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
977
+ lCore.log(this._ctr ?? {}, '[all, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
1090
978
  return false;
1091
979
  }
1092
980
  // --- 检查没被查到的必包含项 ---
@@ -1211,15 +1099,7 @@ class Mod {
1211
1099
  const lsql = sql.replace(/ LIMIT [0-9 ,]+/g, ` LIMIT ${cz}, ${remain}`);
1212
1100
  const r = await this._db.query(lsql, this._sql.getData());
1213
1101
  if (r.rows === null) {
1214
- await lCore.log(this._ctr ?? {
1215
- 'path': '',
1216
- 'urlFull': '',
1217
- 'hostname': '',
1218
- 'req': null,
1219
- 'get': {},
1220
- 'cookie': {},
1221
- 'headers': {}
1222
- }, '[allArray, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
1102
+ lCore.log(this._ctr ?? {}, '[allArray, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
1223
1103
  return false;
1224
1104
  }
1225
1105
  if (key) {
@@ -1241,15 +1121,7 @@ class Mod {
1241
1121
  const contain = this._contain ? lCore.clone(this._contain.list) : null;
1242
1122
  const r = await this._db.query(this._sql.getSql(), this._sql.getData());
1243
1123
  if (r.rows === null) {
1244
- await lCore.log(this._ctr ?? {
1245
- 'path': '',
1246
- 'urlFull': '',
1247
- 'hostname': '',
1248
- 'req': null,
1249
- 'get': {},
1250
- 'cookie': {},
1251
- 'headers': {}
1252
- }, '[allArray, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
1124
+ lCore.log(this._ctr ?? {}, '[allArray, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
1253
1125
  return false;
1254
1126
  }
1255
1127
  // --- 检查没被查到的必包含项 ---
@@ -1298,15 +1170,7 @@ class Mod {
1298
1170
  async explain(all = false) {
1299
1171
  const r = await this._db.query('EXPLAIN ' + this._sql.getSql(), this._sql.getData());
1300
1172
  if (r.rows === null) {
1301
- await lCore.log(this._ctr ?? {
1302
- 'path': '',
1303
- 'urlFull': '',
1304
- 'hostname': '',
1305
- 'req': null,
1306
- 'get': {},
1307
- 'cookie': {},
1308
- 'headers': {}
1309
- }, '[explain, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
1173
+ lCore.log(this._ctr ?? {}, '[explain, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
1310
1174
  return false;
1311
1175
  }
1312
1176
  if (!r.rows[0]) {
@@ -1341,15 +1205,7 @@ class Mod {
1341
1205
  const sql = this._formatTotal(this._sql.getSql(), f);
1342
1206
  const r = await this._db.query(sql, this._sql.getData());
1343
1207
  if (r.rows === null) {
1344
- await lCore.log(this._ctr ?? {
1345
- 'path': '',
1346
- 'urlFull': '',
1347
- 'hostname': '',
1348
- 'req': null,
1349
- 'get': {},
1350
- 'cookie': {},
1351
- 'headers': {}
1352
- }, '[total, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
1208
+ lCore.log(this._ctr ?? {}, '[total, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
1353
1209
  return 0;
1354
1210
  }
1355
1211
  let count = 0;
@@ -1365,15 +1221,7 @@ class Mod {
1365
1221
  const sql = this._sql.getSql().replace(/SELECT .+? FROM/, 'SELECT COUNT(*) AS `count` FROM');
1366
1222
  const r = await this._db.query(sql, this._sql.getData());
1367
1223
  if (r.rows === null) {
1368
- await lCore.log(this._ctr ?? {
1369
- 'path': '',
1370
- 'urlFull': '',
1371
- 'hostname': '',
1372
- 'req': null,
1373
- 'get': {},
1374
- 'cookie': {},
1375
- 'headers': {}
1376
- }, '[count, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
1224
+ lCore.log(this._ctr ?? {}, '[count, mod] ' + lText.stringifyJson(r.error?.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
1377
1225
  return 0;
1378
1226
  }
1379
1227
  let count = 0;
package/sys/route.d.ts CHANGED
@@ -7,7 +7,7 @@ import * as http from 'http';
7
7
  import * as http2 from 'http2';
8
8
  import * as net from 'net';
9
9
  import * as sCtr from './ctr';
10
- import * as types from '../types';
10
+ import * as types from '~/types';
11
11
  /**
12
12
  * --- 清除已经加载的虚拟主机配置文件 ---
13
13
  */
package/sys/route.js CHANGED
@@ -49,15 +49,15 @@ const stream = __importStar(require("stream"));
49
49
  // --- 第三方 ---
50
50
  const ws = __importStar(require("@litert/websocket"));
51
51
  // --- 库和定义 ---
52
- const lFs = __importStar(require("../lib/fs"));
53
- const lZlib = __importStar(require("../lib/zlib"));
54
- const lCore = __importStar(require("../lib/core"));
55
- const lText = __importStar(require("../lib/text"));
56
- const lTime = __importStar(require("../lib/time"));
57
- const lResponse = __importStar(require("../lib/net/response"));
58
- const lWs = __importStar(require("../lib/ws"));
52
+ const lFs = __importStar(require("~/lib/fs"));
53
+ const lZlib = __importStar(require("~/lib/zlib"));
54
+ const lCore = __importStar(require("~/lib/core"));
55
+ const lText = __importStar(require("~/lib/text"));
56
+ const lTime = __importStar(require("~/lib/time"));
57
+ const lResponse = __importStar(require("~/lib/net/response"));
58
+ const lWs = __importStar(require("~/lib/ws"));
59
59
  const sCtr = __importStar(require("./ctr"));
60
- const kebab = __importStar(require("../index"));
60
+ const kebab = __importStar(require("~/index"));
61
61
  /** --- 动态层 kebab.json 缓存(文件路径: 最终合并值) --- */
62
62
  let kebabConfigs = {};
63
63
  /**
@@ -299,11 +299,13 @@ async function run(data) {
299
299
  let wsSocket;
300
300
  try {
301
301
  const options = await cctr.onUpgrade();
302
+ // --- 默认无消息发送 3 分钟 ---
303
+ options.timeout ??= 60_000 * 3;
302
304
  wsSocket = lWs.createServer(data.req, data.socket, options);
303
305
  cctr.setPrototype('_socket', wsSocket);
304
306
  }
305
307
  catch (e) {
306
- await lCore.log(cctr, lText.stringifyJson(e.stack).slice(1, -1), '-error');
308
+ lCore.log(cctr, lText.stringifyJson(e.stack).slice(1, -1), '-error');
307
309
  data.socket.destroy();
308
310
  return true;
309
311
  }
@@ -312,12 +314,12 @@ async function run(data) {
312
314
  cctr.setPrototype('_headers', headers);
313
315
  cctr.setPrototype('_get', get);
314
316
  cctr.setPrototype('_cookie', cookies);
315
- await lCore.log(cctr, '', '-visit');
317
+ lCore.log(cctr, '', '-visit');
316
318
  try {
317
319
  rtn = await cctr.onLoad();
318
320
  }
319
321
  catch (e) {
320
- await lCore.log(cctr, lText.stringifyJson(e.stack).slice(1, -1), '-error');
322
+ lCore.log(cctr, lText.stringifyJson(e.stack).slice(1, -1), '-error');
321
323
  data.socket.destroy();
322
324
  return true;
323
325
  }
@@ -374,7 +376,7 @@ async function run(data) {
374
376
  }
375
377
  }
376
378
  catch (e) {
377
- await lCore.log(cctr, lText.stringifyJson(e.stack).slice(1, -1), '-error');
379
+ lCore.log(cctr, lText.stringifyJson(e.stack).slice(1, -1), '-error');
378
380
  }
379
381
  break;
380
382
  }
@@ -387,16 +389,16 @@ async function run(data) {
387
389
  await cctr['onDrain']();
388
390
  }
389
391
  catch (e) {
390
- await lCore.log(cctr, lText.stringifyJson(e.stack).slice(1, -1), '-error');
392
+ lCore.log(cctr, lText.stringifyJson(e.stack).slice(1, -1), '-error');
391
393
  }
392
- }).on('error', async (e) => {
393
- await lCore.log(cctr, lText.stringifyJson(e.stack).slice(1, -1), '-error');
394
+ }).on('error', (e) => {
395
+ lCore.log(cctr, lText.stringifyJson(e.stack).slice(1, -1), '-error');
394
396
  }).on('close', async () => {
395
397
  try {
396
398
  await cctr['onClose']();
397
399
  }
398
400
  catch (e) {
399
- await lCore.log(cctr, lText.stringifyJson(e.stack).slice(1, -1), '-error');
401
+ lCore.log(cctr, lText.stringifyJson(e.stack).slice(1, -1), '-error');
400
402
  }
401
403
  resolve();
402
404
  });
@@ -443,7 +445,7 @@ async function run(data) {
443
445
  rtn = await middle.onLoad();
444
446
  }
445
447
  catch (e) {
446
- await lCore.log(middle, '(E03)' + lText.stringifyJson(e.stack).slice(1, -1), '-error');
448
+ lCore.log(middle, '(E03)' + lText.stringifyJson(e.stack).slice(1, -1), '-error');
447
449
  data.res.setHeader('content-type', 'text/html; charset=utf-8');
448
450
  data.res.setHeader('content-length', 25);
449
451
  data.res.writeHead(500);
@@ -495,7 +497,7 @@ async function run(data) {
495
497
  cctr.setPrototype('_cacheTTL', middle.getPrototype('_cacheTTL'));
496
498
  cctr.setPrototype('_xsrf', middle.getPrototype('_xsrf'));
497
499
  cctr.setPrototype('_httpCode', middle.getPrototype('_httpCode'));
498
- await lCore.log(cctr, '', '-visit');
500
+ lCore.log(cctr, '', '-visit');
499
501
  // --- 强制 HTTPS ---
500
502
  if (config.set.mustHttps && !config.const.https) {
501
503
  data.res.setHeader('location', data.req.url ?? '');
@@ -553,7 +555,7 @@ async function run(data) {
553
555
  httpCode = cctr.getPrototype('_httpCode');
554
556
  }
555
557
  catch (e) {
556
- await lCore.log(cctr, '(E04)' + lText.stringifyJson(e.stack).slice(1, -1), '-error');
558
+ lCore.log(cctr, '(E04)' + lText.stringifyJson(e.stack).slice(1, -1), '-error');
557
559
  data.res.setHeader('content-type', 'text/html; charset=utf-8');
558
560
  data.res.setHeader('content-length', 25);
559
561
  data.res.writeHead(500);
@@ -820,7 +822,7 @@ async function waitCtr(cctr) {
820
822
  // --- 有事务未关闭 ---
821
823
  const msg = 'transaction(' + waitInfo.transaction + ') not be closed';
822
824
  lCore.display('[ERROR][ROUTE][WAITCTR] ' + msg + ': ', cctr.getPrototype('_config').const.path);
823
- await lCore.log(cctr, msg, '-error');
825
+ lCore.log(cctr, msg, '-error');
824
826
  }
825
827
  // --- 彻底结束,删除文件 ---
826
828
  await unlinkUploadFiles(cctr);
@@ -1,4 +1,4 @@
1
- import * as ctr from '../../../sys/ctr';
1
+ import * as ctr from '~/sys/ctr';
2
2
  export default class extends ctr.Ctr {
3
3
  index(): string;
4
4
  }
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- const ctr = __importStar(require("../../../sys/ctr"));
36
+ const ctr = __importStar(require("~/sys/ctr"));
37
37
  class default_1 extends ctr.Ctr {
38
38
  index() {
39
39
  return `<a href="${this._config.const.urlBase}test">Hello world! Click here to visit demo.</a>`;
@@ -1,5 +1,5 @@
1
- import * as ctr from '../../../sys/ctr';
2
- import * as types from '../../../types';
1
+ import * as ctr from '~/sys/ctr';
2
+ import * as types from '~/types';
3
3
  export default class extends ctr.Ctr {
4
4
  onLoad(): string | boolean;
5
5
  onUnload(rtn: string | boolean | types.DbValue[]): string | boolean | types.DbValue[];
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- const ctr = __importStar(require("../../../sys/ctr"));
36
+ const ctr = __importStar(require("~/sys/ctr"));
37
37
  class default_1 extends ctr.Ctr {
38
38
  onLoad() {
39
39
  if (this._config.const.path !== 'test/middle') {
@@ -1,6 +1,6 @@
1
1
  import * as fs from 'fs';
2
- import * as sCtr from '../../../sys/ctr';
3
- import * as types from '../../../types';
2
+ import * as sCtr from '~/sys/ctr';
3
+ import * as types from '~/types';
4
4
  export default class extends sCtr.Ctr {
5
5
  private _internalUrl;
6
6
  onLoad(): Array<string | number> | boolean;
@@ -37,6 +37,7 @@ export default class extends sCtr.Ctr {
37
37
  coreChecktype(): string;
38
38
  coreMuid(): string;
39
39
  coreGetlog(): Promise<string>;
40
+ coreLs(): Promise<string>;
40
41
  coreUpdatecode(): Promise<string>;
41
42
  coreReload(): Promise<string>;
42
43
  coreRestart(): Promise<string>;