@maiyunnet/kebab 9.14.1 → 9.14.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/doc/kebab-rag.md +174 -122
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/lib/core.d.ts +17 -0
- package/lib/core.js +139 -0
- package/lib/db/pool.js +3 -2
- package/lib/text.d.ts +2 -9
- package/lib/text.js +5 -6
- package/package.json +1 -1
- package/www/example/ctr/test.d.ts +2 -0
- package/www/example/ctr/test.js +20 -0
package/doc/kebab-rag.md
CHANGED
|
@@ -1360,7 +1360,7 @@ index/variables/VER.md
|
|
|
1360
1360
|
|
|
1361
1361
|
# Variable: VER
|
|
1362
1362
|
|
|
1363
|
-
> `const` **VER**: `"9.14.
|
|
1363
|
+
> `const` **VER**: `"9.14.2"` = `'9.14.2'`
|
|
1364
1364
|
|
|
1365
1365
|
Defined in: [index.ts:10](https://github.com/maiyunnet/kebab/blob/master/index.ts#L10)
|
|
1366
1366
|
|
|
@@ -3350,7 +3350,7 @@ lib/core/functions/clone.md
|
|
|
3350
3350
|
|
|
3351
3351
|
> **clone**\<`T`\>(`obj`): `T`
|
|
3352
3352
|
|
|
3353
|
-
Defined in: [lib/core.ts:
|
|
3353
|
+
Defined in: [lib/core.ts:1333](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1333)
|
|
3354
3354
|
|
|
3355
3355
|
完整的克隆一份数组/对象
|
|
3356
3356
|
|
|
@@ -3414,7 +3414,7 @@ lib/core/functions/debug.md
|
|
|
3414
3414
|
|
|
3415
3415
|
> **debug**(`message?`, ...`optionalParams`): `void`
|
|
3416
3416
|
|
|
3417
|
-
Defined in: [lib/core.ts:
|
|
3417
|
+
Defined in: [lib/core.ts:1367](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1367)
|
|
3418
3418
|
|
|
3419
3419
|
打印调试信息,线上环境不会打印
|
|
3420
3420
|
|
|
@@ -3449,7 +3449,7 @@ lib/core/functions/display.md
|
|
|
3449
3449
|
|
|
3450
3450
|
> **display**(`message?`, ...`optionalParams`): `void`
|
|
3451
3451
|
|
|
3452
|
-
Defined in: [lib/core.ts:
|
|
3452
|
+
Defined in: [lib/core.ts:1380](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1380)
|
|
3453
3453
|
|
|
3454
3454
|
向控制台直接显示内容,一般情况下禁止使用
|
|
3455
3455
|
|
|
@@ -3484,7 +3484,7 @@ lib/core/functions/emptyObject.md
|
|
|
3484
3484
|
|
|
3485
3485
|
> **emptyObject**(`obj`, `deep?`): `void`
|
|
3486
3486
|
|
|
3487
|
-
Defined in: [lib/core.ts:
|
|
3487
|
+
Defined in: [lib/core.ts:615](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L615)
|
|
3488
3488
|
|
|
3489
3489
|
将对象的所有属性清除包括键,不会破坏引用关系,对象变量依然保证是引用状态
|
|
3490
3490
|
|
|
@@ -3519,7 +3519,7 @@ lib/core/functions/exec.md
|
|
|
3519
3519
|
|
|
3520
3520
|
> **exec**(`command`, `options?`): `Promise`\<`string` \| `false`\>
|
|
3521
3521
|
|
|
3522
|
-
Defined in: [lib/core.ts:
|
|
3522
|
+
Defined in: [lib/core.ts:677](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L677)
|
|
3523
3523
|
|
|
3524
3524
|
执行命令行
|
|
3525
3525
|
|
|
@@ -3554,7 +3554,7 @@ lib/core/functions/getLog.md
|
|
|
3554
3554
|
|
|
3555
3555
|
> **getLog**(`opt`): `Promise`\<`false` \| \{ `list`: `any`[] \| `string`[][]; `total`: `number`; \}\>
|
|
3556
3556
|
|
|
3557
|
-
Defined in: [lib/core.ts:
|
|
3557
|
+
Defined in: [lib/core.ts:1245](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1245)
|
|
3558
3558
|
|
|
3559
3559
|
获取日志内容为一个数组
|
|
3560
3560
|
|
|
@@ -3610,6 +3610,44 @@ Defined in: [lib/core.ts:1101](https://github.com/maiyunnet/kebab/blob/master/li
|
|
|
3610
3610
|
|
|
3611
3611
|
`Promise`\<`false` \| \{ `list`: `any`[] \| `string`[][]; `total`: `number`; \}\>
|
|
3612
3612
|
|
|
3613
|
+
lib/core/functions/ipLimit.md
|
|
3614
|
+
---
|
|
3615
|
+
|
|
3616
|
+
[**Documents for @maiyunnet/kebab**](../../../index.md)
|
|
3617
|
+
|
|
3618
|
+
***
|
|
3619
|
+
|
|
3620
|
+
[Documents for @maiyunnet/kebab](../../../index.md) / [lib/core](../index.md) / ipLimit
|
|
3621
|
+
|
|
3622
|
+
# Function: ipLimit()
|
|
3623
|
+
|
|
3624
|
+
> **ipLimit**(`ip`, `mask?`): `string`
|
|
3625
|
+
|
|
3626
|
+
Defined in: [lib/core.ts:443](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L443)
|
|
3627
|
+
|
|
3628
|
+
截取 IP 的限速段
|
|
3629
|
+
IPv4 原样返回;IPv6 截取前 mask 位(默认 /64),防止同一人使用大量 IPv6 地址绕过限速
|
|
3630
|
+
|
|
3631
|
+
## Parameters
|
|
3632
|
+
|
|
3633
|
+
### ip
|
|
3634
|
+
|
|
3635
|
+
`string`
|
|
3636
|
+
|
|
3637
|
+
IP 地址
|
|
3638
|
+
|
|
3639
|
+
### mask?
|
|
3640
|
+
|
|
3641
|
+
`number` = `64`
|
|
3642
|
+
|
|
3643
|
+
IPv6 前缀长度,0-128 的整数,默认 64
|
|
3644
|
+
|
|
3645
|
+
## Returns
|
|
3646
|
+
|
|
3647
|
+
`string`
|
|
3648
|
+
|
|
3649
|
+
限速段,如 192.168.1.1、2001:db8:1234:5678::
|
|
3650
|
+
|
|
3613
3651
|
lib/core/functions/ip.md
|
|
3614
3652
|
---
|
|
3615
3653
|
|
|
@@ -3689,7 +3727,7 @@ lib/core/functions/loadEnv.md
|
|
|
3689
3727
|
|
|
3690
3728
|
> **loadEnv**(`dir`): `Promise`\<`void`\>
|
|
3691
3729
|
|
|
3692
|
-
Defined in: [lib/core.ts:
|
|
3730
|
+
Defined in: [lib/core.ts:1432](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1432)
|
|
3693
3731
|
|
|
3694
3732
|
加载 .env 文件到 process.env,若文件不存在则跳过
|
|
3695
3733
|
|
|
@@ -3718,7 +3756,7 @@ lib/core/functions/log.md
|
|
|
3718
3756
|
|
|
3719
3757
|
> **log**(`opt`, `msg`, `fend?`): `void`
|
|
3720
3758
|
|
|
3721
|
-
Defined in: [lib/core.ts:
|
|
3759
|
+
Defined in: [lib/core.ts:1132](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1132)
|
|
3722
3760
|
|
|
3723
3761
|
写入文件日志
|
|
3724
3762
|
|
|
@@ -3759,7 +3797,7 @@ lib/core/functions/ls.md
|
|
|
3759
3797
|
|
|
3760
3798
|
> **ls**(`opt`): `Promise`\<`object`[]\>
|
|
3761
3799
|
|
|
3762
|
-
Defined in: [lib/core.ts:
|
|
3800
|
+
Defined in: [lib/core.ts:1294](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1294)
|
|
3763
3801
|
|
|
3764
3802
|
获取目录内文件/文件夹列表
|
|
3765
3803
|
|
|
@@ -3865,7 +3903,7 @@ lib/core/functions/objectSort.md
|
|
|
3865
3903
|
|
|
3866
3904
|
> **objectSort**\<`T`\>(`o`): `T`
|
|
3867
3905
|
|
|
3868
|
-
Defined in: [lib/core.ts:
|
|
3906
|
+
Defined in: [lib/core.ts:596](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L596)
|
|
3869
3907
|
|
|
3870
3908
|
将对象进行升序排列
|
|
3871
3909
|
|
|
@@ -3900,7 +3938,7 @@ lib/core/functions/passThroughAppend.md
|
|
|
3900
3938
|
|
|
3901
3939
|
> **passThroughAppend**(`passThrough`, `data`, `end?`): `Promise`\<`void`\>
|
|
3902
3940
|
|
|
3903
|
-
Defined in: [lib/core.ts:
|
|
3941
|
+
Defined in: [lib/core.ts:634](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L634)
|
|
3904
3942
|
|
|
3905
3943
|
调用前自行创建 passThrough,并且调用 pipe 绑定到应该绑定的对象,然后再调用本函数
|
|
3906
3944
|
|
|
@@ -4039,6 +4077,50 @@ Defined in: [lib/core.ts:129](https://github.com/maiyunnet/kebab/blob/master/lib
|
|
|
4039
4077
|
|
|
4040
4078
|
`string`
|
|
4041
4079
|
|
|
4080
|
+
lib/core/functions/realIPLimit.md
|
|
4081
|
+
---
|
|
4082
|
+
|
|
4083
|
+
[**Documents for @maiyunnet/kebab**](../../../index.md)
|
|
4084
|
+
|
|
4085
|
+
***
|
|
4086
|
+
|
|
4087
|
+
[Documents for @maiyunnet/kebab](../../../index.md) / [lib/core](../index.md) / realIPLimit
|
|
4088
|
+
|
|
4089
|
+
# Function: realIPLimit()
|
|
4090
|
+
|
|
4091
|
+
> **realIPLimit**(`ctr`, `name?`, `mask?`): `string`
|
|
4092
|
+
|
|
4093
|
+
Defined in: [lib/core.ts:463](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L463)
|
|
4094
|
+
|
|
4095
|
+
获取安全 IP 的限速段(用于 ratelimit 库的 key)
|
|
4096
|
+
IPv4 原样返回;IPv6 截取前 mask 位(默认 /64)
|
|
4097
|
+
|
|
4098
|
+
## Parameters
|
|
4099
|
+
|
|
4100
|
+
### ctr
|
|
4101
|
+
|
|
4102
|
+
[`Ctr`](../../../sys/ctr/classes/Ctr.md)
|
|
4103
|
+
|
|
4104
|
+
Ctr 实例
|
|
4105
|
+
|
|
4106
|
+
### name?
|
|
4107
|
+
|
|
4108
|
+
`string` = `''`
|
|
4109
|
+
|
|
4110
|
+
输入安全的 header
|
|
4111
|
+
|
|
4112
|
+
### mask?
|
|
4113
|
+
|
|
4114
|
+
`number` = `64`
|
|
4115
|
+
|
|
4116
|
+
IPv6 前缀长度,0-128 的整数,默认 64
|
|
4117
|
+
|
|
4118
|
+
## Returns
|
|
4119
|
+
|
|
4120
|
+
`string`
|
|
4121
|
+
|
|
4122
|
+
限速段,如 192.168.1.1、2001:db8:1234:5678::
|
|
4123
|
+
|
|
4042
4124
|
lib/core/functions/realIP.md
|
|
4043
4125
|
---
|
|
4044
4126
|
|
|
@@ -4085,7 +4167,7 @@ lib/core/functions/removeGlobal.md
|
|
|
4085
4167
|
|
|
4086
4168
|
> **removeGlobal**(`key`, `hosts?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
|
|
4087
4169
|
|
|
4088
|
-
Defined in: [lib/core.ts:
|
|
4170
|
+
Defined in: [lib/core.ts:949](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L949)
|
|
4089
4171
|
|
|
4090
4172
|
移除某个跨线程/跨内网服务器全局变量
|
|
4091
4173
|
|
|
@@ -4120,7 +4202,7 @@ lib/core/functions/resolveEnvVars.md
|
|
|
4120
4202
|
|
|
4121
4203
|
> **resolveEnvVars**(`obj`): `void`
|
|
4122
4204
|
|
|
4123
|
-
Defined in: [lib/core.ts:
|
|
4205
|
+
Defined in: [lib/core.ts:1462](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1462)
|
|
4124
4206
|
|
|
4125
4207
|
将配置对象中的 ${ENV_VAR} 占位符替换为 process.env 的值
|
|
4126
4208
|
|
|
@@ -4149,7 +4231,7 @@ lib/core/functions/sendNpm.md
|
|
|
4149
4231
|
|
|
4150
4232
|
> **sendNpm**(`path`, `hosts?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
|
|
4151
4233
|
|
|
4152
|
-
Defined in: [lib/core.ts:
|
|
4234
|
+
Defined in: [lib/core.ts:848](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L848)
|
|
4153
4235
|
|
|
4154
4236
|
向本机或局域网 RPC 发送 npm install 操作
|
|
4155
4237
|
|
|
@@ -4184,7 +4266,7 @@ lib/core/functions/sendPackage.md
|
|
|
4184
4266
|
|
|
4185
4267
|
> **sendPackage**(`content`, `hosts?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
|
|
4186
4268
|
|
|
4187
|
-
Defined in: [lib/core.ts:
|
|
4269
|
+
Defined in: [lib/core.ts:1072](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1072)
|
|
4188
4270
|
|
|
4189
4271
|
向本机或局域网 RPC 发送 package.json 更新操作
|
|
4190
4272
|
|
|
@@ -4219,7 +4301,7 @@ lib/core/functions/sendPm2.md
|
|
|
4219
4301
|
|
|
4220
4302
|
> **sendPm2**(`name`, `action?`, `hosts?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
|
|
4221
4303
|
|
|
4222
|
-
Defined in: [lib/core.ts:
|
|
4304
|
+
Defined in: [lib/core.ts:800](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L800)
|
|
4223
4305
|
|
|
4224
4306
|
向本机或局域网 RPC 发送 PM2 操作
|
|
4225
4307
|
|
|
@@ -4260,7 +4342,7 @@ lib/core/functions/sendProject.md
|
|
|
4260
4342
|
|
|
4261
4343
|
> **sendProject**(`path`, `key`, `value`, `hosts?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
|
|
4262
4344
|
|
|
4263
|
-
Defined in: [lib/core.ts:
|
|
4345
|
+
Defined in: [lib/core.ts:1024](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1024)
|
|
4264
4346
|
|
|
4265
4347
|
向本机或局域网 RPC 发送项目配置更新操作
|
|
4266
4348
|
|
|
@@ -4307,7 +4389,7 @@ lib/core/functions/sendReload.md
|
|
|
4307
4389
|
|
|
4308
4390
|
> **sendReload**(`hosts?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
|
|
4309
4391
|
|
|
4310
|
-
Defined in: [lib/core.ts:
|
|
4392
|
+
Defined in: [lib/core.ts:697](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L697)
|
|
4311
4393
|
|
|
4312
4394
|
向主进程(或局域网同代码机子)发送广播将进行 reload 操作,等待回传
|
|
4313
4395
|
主要作用除代码热更新以外的其他情况
|
|
@@ -4335,7 +4417,7 @@ lib/core/functions/sendRestart.md
|
|
|
4335
4417
|
|
|
4336
4418
|
> **sendRestart**(`hosts?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
|
|
4337
4419
|
|
|
4338
|
-
Defined in: [lib/core.ts:
|
|
4420
|
+
Defined in: [lib/core.ts:746](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L746)
|
|
4339
4421
|
|
|
4340
4422
|
向主进程(或局域网同代码机子)发送广播将进行 restart 操作,停止监听并启动新进程,老进程在连接全部断开后自行销毁
|
|
4341
4423
|
主要用作不间断的代码热更新
|
|
@@ -4410,7 +4492,7 @@ lib/core/functions/setGlobal.md
|
|
|
4410
4492
|
|
|
4411
4493
|
> **setGlobal**(`key`, `data`, `hosts?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
|
|
4412
4494
|
|
|
4413
|
-
Defined in: [lib/core.ts:
|
|
4495
|
+
Defined in: [lib/core.ts:899](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L899)
|
|
4414
4496
|
|
|
4415
4497
|
设置跨线程/指定的局域网主机的全局变量
|
|
4416
4498
|
|
|
@@ -4451,7 +4533,7 @@ lib/core/functions/sleep.md
|
|
|
4451
4533
|
|
|
4452
4534
|
> **sleep**(`ms`): `Promise`\<`void`\>
|
|
4453
4535
|
|
|
4454
|
-
Defined in: [lib/core.ts:
|
|
4536
|
+
Defined in: [lib/core.ts:584](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L584)
|
|
4455
4537
|
|
|
4456
4538
|
间隔一段时间
|
|
4457
4539
|
|
|
@@ -4509,7 +4591,7 @@ lib/core/functions/updateCode.md
|
|
|
4509
4591
|
|
|
4510
4592
|
> **updateCode**(`sourcePath`, `path`, `hosts?`, `config?`, `strict?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
|
|
4511
4593
|
|
|
4512
|
-
Defined in: [lib/core.ts:
|
|
4594
|
+
Defined in: [lib/core.ts:964](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L964)
|
|
4513
4595
|
|
|
4514
4596
|
上传并覆盖代码文件,config.json、kebab.json、.js.map、.ts, .gitignore 不会被覆盖和新创建
|
|
4515
4597
|
|
|
@@ -4562,7 +4644,7 @@ lib/core/functions/writeEventStreamHead.md
|
|
|
4562
4644
|
|
|
4563
4645
|
> **writeEventStreamHead**(`res`): `void`
|
|
4564
4646
|
|
|
4565
|
-
Defined in: [lib/core.ts:
|
|
4647
|
+
Defined in: [lib/core.ts:1402](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1402)
|
|
4566
4648
|
|
|
4567
4649
|
## Parameters
|
|
4568
4650
|
|
|
@@ -4587,7 +4669,7 @@ lib/core/functions/writeHead.md
|
|
|
4587
4669
|
|
|
4588
4670
|
> **writeHead**(`res`, `statusCode`, `headers?`): `void`
|
|
4589
4671
|
|
|
4590
|
-
Defined in: [lib/core.ts:
|
|
4672
|
+
Defined in: [lib/core.ts:1391](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1391)
|
|
4591
4673
|
|
|
4592
4674
|
让 res 发送头部(前提是头部没有被发送才能调用本方法
|
|
4593
4675
|
|
|
@@ -4628,7 +4710,7 @@ lib/core/functions/write.md
|
|
|
4628
4710
|
|
|
4629
4711
|
> **write**(`res`, `data`): `void`
|
|
4630
4712
|
|
|
4631
|
-
Defined in: [lib/core.ts:
|
|
4713
|
+
Defined in: [lib/core.ts:1414](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1414)
|
|
4632
4714
|
|
|
4633
4715
|
向 res 发送数据
|
|
4634
4716
|
|
|
@@ -4698,6 +4780,7 @@ lib/core/index.md
|
|
|
4698
4780
|
- [exec](functions/exec.md)
|
|
4699
4781
|
- [getLog](functions/getLog.md)
|
|
4700
4782
|
- [ip](functions/ip.md)
|
|
4783
|
+
- [ipLimit](functions/ipLimit.md)
|
|
4701
4784
|
- [ips](functions/ips.md)
|
|
4702
4785
|
- [loadEnv](functions/loadEnv.md)
|
|
4703
4786
|
- [log](functions/log.md)
|
|
@@ -4709,6 +4792,7 @@ lib/core/index.md
|
|
|
4709
4792
|
- [rand](functions/rand.md)
|
|
4710
4793
|
- [random](functions/random.md)
|
|
4711
4794
|
- [realIP](functions/realIP.md)
|
|
4795
|
+
- [realIPLimit](functions/realIPLimit.md)
|
|
4712
4796
|
- [removeGlobal](functions/removeGlobal.md)
|
|
4713
4797
|
- [resolveEnvVars](functions/resolveEnvVars.md)
|
|
4714
4798
|
- [sendNpm](functions/sendNpm.md)
|
|
@@ -4800,7 +4884,7 @@ lib/core/interfaces/ILogOptions.md
|
|
|
4800
4884
|
|
|
4801
4885
|
# Interface: ILogOptions
|
|
4802
4886
|
|
|
4803
|
-
Defined in: [lib/core.ts:
|
|
4887
|
+
Defined in: [lib/core.ts:1115](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1115)
|
|
4804
4888
|
|
|
4805
4889
|
log 设置的选项
|
|
4806
4890
|
|
|
@@ -4810,7 +4894,7 @@ log 设置的选项
|
|
|
4810
4894
|
|
|
4811
4895
|
> `optional` **cookie?**: `Record`\<`string`, `string`\>
|
|
4812
4896
|
|
|
4813
|
-
Defined in: [lib/core.ts:
|
|
4897
|
+
Defined in: [lib/core.ts:1121](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1121)
|
|
4814
4898
|
|
|
4815
4899
|
***
|
|
4816
4900
|
|
|
@@ -4818,7 +4902,7 @@ Defined in: [lib/core.ts:977](https://github.com/maiyunnet/kebab/blob/master/lib
|
|
|
4818
4902
|
|
|
4819
4903
|
> `optional` **get?**: `Record`\<`string`, `any`\>
|
|
4820
4904
|
|
|
4821
|
-
Defined in: [lib/core.ts:
|
|
4905
|
+
Defined in: [lib/core.ts:1120](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1120)
|
|
4822
4906
|
|
|
4823
4907
|
***
|
|
4824
4908
|
|
|
@@ -4826,7 +4910,7 @@ Defined in: [lib/core.ts:976](https://github.com/maiyunnet/kebab/blob/master/lib
|
|
|
4826
4910
|
|
|
4827
4911
|
> `optional` **headers?**: `IncomingHttpHeaders`
|
|
4828
4912
|
|
|
4829
|
-
Defined in: [lib/core.ts:
|
|
4913
|
+
Defined in: [lib/core.ts:1123](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1123)
|
|
4830
4914
|
|
|
4831
4915
|
***
|
|
4832
4916
|
|
|
@@ -4834,7 +4918,7 @@ Defined in: [lib/core.ts:979](https://github.com/maiyunnet/kebab/blob/master/lib
|
|
|
4834
4918
|
|
|
4835
4919
|
> `optional` **hostname?**: `string`
|
|
4836
4920
|
|
|
4837
|
-
Defined in: [lib/core.ts:
|
|
4921
|
+
Defined in: [lib/core.ts:1118](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1118)
|
|
4838
4922
|
|
|
4839
4923
|
***
|
|
4840
4924
|
|
|
@@ -4842,7 +4926,7 @@ Defined in: [lib/core.ts:974](https://github.com/maiyunnet/kebab/blob/master/lib
|
|
|
4842
4926
|
|
|
4843
4927
|
> `optional` **path?**: `string`
|
|
4844
4928
|
|
|
4845
|
-
Defined in: [lib/core.ts:
|
|
4929
|
+
Defined in: [lib/core.ts:1116](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1116)
|
|
4846
4930
|
|
|
4847
4931
|
***
|
|
4848
4932
|
|
|
@@ -4850,7 +4934,7 @@ Defined in: [lib/core.ts:972](https://github.com/maiyunnet/kebab/blob/master/lib
|
|
|
4850
4934
|
|
|
4851
4935
|
> `optional` **req?**: `IncomingMessage` \| `Http2ServerRequest` \| `null`
|
|
4852
4936
|
|
|
4853
|
-
Defined in: [lib/core.ts:
|
|
4937
|
+
Defined in: [lib/core.ts:1119](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1119)
|
|
4854
4938
|
|
|
4855
4939
|
***
|
|
4856
4940
|
|
|
@@ -4858,7 +4942,7 @@ Defined in: [lib/core.ts:975](https://github.com/maiyunnet/kebab/blob/master/lib
|
|
|
4858
4942
|
|
|
4859
4943
|
> `optional` **session?**: `Record`\<`string`, `any`\>
|
|
4860
4944
|
|
|
4861
|
-
Defined in: [lib/core.ts:
|
|
4945
|
+
Defined in: [lib/core.ts:1122](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1122)
|
|
4862
4946
|
|
|
4863
4947
|
***
|
|
4864
4948
|
|
|
@@ -4866,7 +4950,7 @@ Defined in: [lib/core.ts:978](https://github.com/maiyunnet/kebab/blob/master/lib
|
|
|
4866
4950
|
|
|
4867
4951
|
> `optional` **urlFull?**: `string`
|
|
4868
4952
|
|
|
4869
|
-
Defined in: [lib/core.ts:
|
|
4953
|
+
Defined in: [lib/core.ts:1117](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1117)
|
|
4870
4954
|
|
|
4871
4955
|
lib/core/type-aliases/TPm2Action.md
|
|
4872
4956
|
---
|
|
@@ -4881,7 +4965,7 @@ lib/core/type-aliases/TPm2Action.md
|
|
|
4881
4965
|
|
|
4882
4966
|
> **TPm2Action** = `"start"` \| `"stop"` \| `"restart"`
|
|
4883
4967
|
|
|
4884
|
-
Defined in: [lib/core.ts:
|
|
4968
|
+
Defined in: [lib/core.ts:792](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L792)
|
|
4885
4969
|
|
|
4886
4970
|
PM2 操作类型
|
|
4887
4971
|
|
|
@@ -4955,7 +5039,7 @@ lib/core/variables/global.md
|
|
|
4955
5039
|
|
|
4956
5040
|
> `const` **global**: `Record`\<`string`, `any`\> = `{}`
|
|
4957
5041
|
|
|
4958
|
-
Defined in: [lib/core.ts:
|
|
5042
|
+
Defined in: [lib/core.ts:891](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L891)
|
|
4959
5043
|
|
|
4960
5044
|
跨进程全局变量
|
|
4961
5045
|
|
|
@@ -7439,7 +7523,7 @@ lib/db/pool/classes/Pool.md
|
|
|
7439
7523
|
|
|
7440
7524
|
# Class: Pool
|
|
7441
7525
|
|
|
7442
|
-
Defined in: [lib/db/pool.ts:
|
|
7526
|
+
Defined in: [lib/db/pool.ts:116](https://github.com/maiyunnet/kebab/blob/master/lib/db/pool.ts#L116)
|
|
7443
7527
|
|
|
7444
7528
|
数据库连接池对象
|
|
7445
7529
|
|
|
@@ -7449,7 +7533,7 @@ Defined in: [lib/db/pool.ts:115](https://github.com/maiyunnet/kebab/blob/master/
|
|
|
7449
7533
|
|
|
7450
7534
|
> **new Pool**(`etc`, `opt`): `Pool`
|
|
7451
7535
|
|
|
7452
|
-
Defined in: [lib/db/pool.ts:
|
|
7536
|
+
Defined in: [lib/db/pool.ts:127](https://github.com/maiyunnet/kebab/blob/master/lib/db/pool.ts#L127)
|
|
7453
7537
|
|
|
7454
7538
|
#### Parameters
|
|
7455
7539
|
|
|
@@ -7475,7 +7559,7 @@ Defined in: [lib/db/pool.ts:126](https://github.com/maiyunnet/kebab/blob/master/
|
|
|
7475
7559
|
|
|
7476
7560
|
> **beginTransaction**(`ctr`): `Promise`\<[`Transaction`](../../tran/classes/Transaction.md) \| `null`\>
|
|
7477
7561
|
|
|
7478
|
-
Defined in: [lib/db/pool.ts:
|
|
7562
|
+
Defined in: [lib/db/pool.ts:195](https://github.com/maiyunnet/kebab/blob/master/lib/db/pool.ts#L195)
|
|
7479
7563
|
|
|
7480
7564
|
开启事务,返回事务对象并锁定连接,别人任何人不可用,有 ctr 的话必传 this,独立执行时可传 null
|
|
7481
7565
|
|
|
@@ -7495,7 +7579,7 @@ Defined in: [lib/db/pool.ts:194](https://github.com/maiyunnet/kebab/blob/master/
|
|
|
7495
7579
|
|
|
7496
7580
|
> **execute**(`sql`, `values?`): `Promise`\<[`IPacket`](../../interfaces/IPacket.md)\>
|
|
7497
7581
|
|
|
7498
|
-
Defined in: [lib/db/pool.ts:
|
|
7582
|
+
Defined in: [lib/db/pool.ts:175](https://github.com/maiyunnet/kebab/blob/master/lib/db/pool.ts#L175)
|
|
7499
7583
|
|
|
7500
7584
|
执行一条 SQL 并获得影响行数对象 packet,连接失败抛出错误
|
|
7501
7585
|
|
|
@@ -7523,7 +7607,7 @@ Defined in: [lib/db/pool.ts:174](https://github.com/maiyunnet/kebab/blob/master/
|
|
|
7523
7607
|
|
|
7524
7608
|
> **getName**(): `string`
|
|
7525
7609
|
|
|
7526
|
-
Defined in: [lib/db/pool.ts:
|
|
7610
|
+
Defined in: [lib/db/pool.ts:141](https://github.com/maiyunnet/kebab/blob/master/lib/db/pool.ts#L141)
|
|
7527
7611
|
|
|
7528
7612
|
获取当前连接的数据库名称
|
|
7529
7613
|
|
|
@@ -7537,7 +7621,7 @@ Defined in: [lib/db/pool.ts:140](https://github.com/maiyunnet/kebab/blob/master/
|
|
|
7537
7621
|
|
|
7538
7622
|
> **getQueries**(): `number`
|
|
7539
7623
|
|
|
7540
|
-
Defined in: [lib/db/pool.ts:
|
|
7624
|
+
Defined in: [lib/db/pool.ts:327](https://github.com/maiyunnet/kebab/blob/master/lib/db/pool.ts#L327)
|
|
7541
7625
|
|
|
7542
7626
|
获取 SQL 执行次数
|
|
7543
7627
|
|
|
@@ -7551,7 +7635,7 @@ Defined in: [lib/db/pool.ts:326](https://github.com/maiyunnet/kebab/blob/master/
|
|
|
7551
7635
|
|
|
7552
7636
|
> **getService**(): [`ESERVICE`](../../enumerations/ESERVICE.md)
|
|
7553
7637
|
|
|
7554
|
-
Defined in: [lib/db/pool.ts:
|
|
7638
|
+
Defined in: [lib/db/pool.ts:136](https://github.com/maiyunnet/kebab/blob/master/lib/db/pool.ts#L136)
|
|
7555
7639
|
|
|
7556
7640
|
获取当前连接的服务商
|
|
7557
7641
|
|
|
@@ -7565,7 +7649,7 @@ Defined in: [lib/db/pool.ts:135](https://github.com/maiyunnet/kebab/blob/master/
|
|
|
7565
7649
|
|
|
7566
7650
|
> **query**(`sql`, `values?`): `Promise`\<[`IData`](../../interfaces/IData.md)\>
|
|
7567
7651
|
|
|
7568
|
-
Defined in: [lib/db/pool.ts:
|
|
7652
|
+
Defined in: [lib/db/pool.ts:151](https://github.com/maiyunnet/kebab/blob/master/lib/db/pool.ts#L151)
|
|
7569
7653
|
|
|
7570
7654
|
执行一条 SQL,无视顺序和相同连接,随用随取
|
|
7571
7655
|
|
|
@@ -16293,7 +16377,7 @@ lib/text/functions/csvescape.md
|
|
|
16293
16377
|
|
|
16294
16378
|
> **csvescape**(`str`): `string`
|
|
16295
16379
|
|
|
16296
|
-
Defined in: [lib/text.ts:
|
|
16380
|
+
Defined in: [lib/text.ts:511](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L511)
|
|
16297
16381
|
|
|
16298
16382
|
CSV 特殊字符转换为实体字符
|
|
16299
16383
|
|
|
@@ -16320,7 +16404,7 @@ lib/text/functions/getFileExt.md
|
|
|
16320
16404
|
|
|
16321
16405
|
> **getFileExt**(`path`): `string`
|
|
16322
16406
|
|
|
16323
|
-
Defined in: [lib/text.ts:
|
|
16407
|
+
Defined in: [lib/text.ts:552](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L552)
|
|
16324
16408
|
|
|
16325
16409
|
获取文件后缀
|
|
16326
16410
|
|
|
@@ -16349,7 +16433,7 @@ lib/text/functions/getFileNameExt.md
|
|
|
16349
16433
|
|
|
16350
16434
|
> **getFileNameExt**(`path`): `object`
|
|
16351
16435
|
|
|
16352
|
-
Defined in: [lib/text.ts:
|
|
16436
|
+
Defined in: [lib/text.ts:565](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L565)
|
|
16353
16437
|
|
|
16354
16438
|
获取文件名和后缀
|
|
16355
16439
|
|
|
@@ -16386,7 +16470,7 @@ lib/text/functions/getFilename.md
|
|
|
16386
16470
|
|
|
16387
16471
|
> **getFilename**(`path`, `ext?`): `string`
|
|
16388
16472
|
|
|
16389
|
-
Defined in: [lib/text.ts:
|
|
16473
|
+
Defined in: [lib/text.ts:532](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L532)
|
|
16390
16474
|
|
|
16391
16475
|
获取文件名
|
|
16392
16476
|
|
|
@@ -16421,7 +16505,7 @@ lib/text/functions/htmlescape.md
|
|
|
16421
16505
|
|
|
16422
16506
|
> **htmlescape**(`html`): `string`
|
|
16423
16507
|
|
|
16424
|
-
Defined in: [lib/text.ts:
|
|
16508
|
+
Defined in: [lib/text.ts:502](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L502)
|
|
16425
16509
|
|
|
16426
16510
|
HTML 特殊字符转换为实体字符
|
|
16427
16511
|
|
|
@@ -16450,7 +16534,7 @@ lib/text/functions/int2str.md
|
|
|
16450
16534
|
|
|
16451
16535
|
> **int2str**(`int`, `digits?`, `decimal?`): `string`
|
|
16452
16536
|
|
|
16453
|
-
Defined in: [lib/text.ts:
|
|
16537
|
+
Defined in: [lib/text.ts:765](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L765)
|
|
16454
16538
|
|
|
16455
16539
|
为解决精度问题,将整数转换为小数字符串
|
|
16456
16540
|
以下几个示例都是当 digits 为 3、decimal 为 2 时
|
|
@@ -16496,7 +16580,7 @@ lib/text/functions/isAscii.md
|
|
|
16496
16580
|
|
|
16497
16581
|
> **isAscii**(`text`): `boolean`
|
|
16498
16582
|
|
|
16499
|
-
Defined in: [lib/text.ts:
|
|
16583
|
+
Defined in: [lib/text.ts:270](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L270)
|
|
16500
16584
|
|
|
16501
16585
|
判断是否在 ascii 字符集内,仅可输入部分
|
|
16502
16586
|
|
|
@@ -16525,7 +16609,7 @@ lib/text/functions/isDomain.md
|
|
|
16525
16609
|
|
|
16526
16610
|
> **isDomain**(`domain`): `boolean`
|
|
16527
16611
|
|
|
16528
|
-
Defined in: [lib/text.ts:
|
|
16612
|
+
Defined in: [lib/text.ts:259](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L259)
|
|
16529
16613
|
|
|
16530
16614
|
判断是否是域名
|
|
16531
16615
|
|
|
@@ -16556,7 +16640,7 @@ lib/text/functions/isEMail.md
|
|
|
16556
16640
|
|
|
16557
16641
|
> **isEMail**(`email`): `boolean`
|
|
16558
16642
|
|
|
16559
|
-
Defined in: [lib/text.ts:
|
|
16643
|
+
Defined in: [lib/text.ts:232](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L232)
|
|
16560
16644
|
|
|
16561
16645
|
是否是邮件地址
|
|
16562
16646
|
|
|
@@ -16583,7 +16667,7 @@ lib/text/functions/isFalsy.md
|
|
|
16583
16667
|
|
|
16584
16668
|
> **isFalsy**(`val`): `val is TFalsy`
|
|
16585
16669
|
|
|
16586
|
-
Defined in: [lib/text.ts:
|
|
16670
|
+
Defined in: [lib/text.ts:716](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L716)
|
|
16587
16671
|
|
|
16588
16672
|
判断一个值是否是虚假的(为 null/undefined/空字符串/false/0)
|
|
16589
16673
|
|
|
@@ -16612,7 +16696,7 @@ lib/text/functions/isIdCardCN.md
|
|
|
16612
16696
|
|
|
16613
16697
|
> **isIdCardCN**(`idcard`): `boolean`
|
|
16614
16698
|
|
|
16615
|
-
Defined in: [lib/text.ts:
|
|
16699
|
+
Defined in: [lib/text.ts:382](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L382)
|
|
16616
16700
|
|
|
16617
16701
|
是否是中国大陆身份证号码
|
|
16618
16702
|
|
|
@@ -16641,9 +16725,9 @@ lib/text/functions/isIPv4.md
|
|
|
16641
16725
|
|
|
16642
16726
|
> **isIPv4**(`ip`): `boolean`
|
|
16643
16727
|
|
|
16644
|
-
Defined in: [lib/text.ts:
|
|
16728
|
+
Defined in: [lib/text.ts:240](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L240)
|
|
16645
16729
|
|
|
16646
|
-
是否是 IPv4
|
|
16730
|
+
是否是 IPv4(基于 Node 原生 net.isIP,严格校验)
|
|
16647
16731
|
|
|
16648
16732
|
## Parameters
|
|
16649
16733
|
|
|
@@ -16668,9 +16752,9 @@ lib/text/functions/isIPv6.md
|
|
|
16668
16752
|
|
|
16669
16753
|
> **isIPv6**(`ip`): `boolean`
|
|
16670
16754
|
|
|
16671
|
-
Defined in: [lib/text.ts:
|
|
16755
|
+
Defined in: [lib/text.ts:248](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L248)
|
|
16672
16756
|
|
|
16673
|
-
是否是 IPv6
|
|
16757
|
+
是否是 IPv6(基于 Node 原生 net.isIP,严格校验)
|
|
16674
16758
|
|
|
16675
16759
|
## Parameters
|
|
16676
16760
|
|
|
@@ -16695,7 +16779,7 @@ lib/text/functions/isPhoneCN.md
|
|
|
16695
16779
|
|
|
16696
16780
|
> **isPhoneCN**(`p`): `boolean`
|
|
16697
16781
|
|
|
16698
|
-
Defined in: [lib/text.ts:
|
|
16782
|
+
Defined in: [lib/text.ts:374](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L374)
|
|
16699
16783
|
|
|
16700
16784
|
判断手机号是否是 11 位,不做真实性校验
|
|
16701
16785
|
|
|
@@ -16724,7 +16808,7 @@ lib/text/functions/isRealPath.md
|
|
|
16724
16808
|
|
|
16725
16809
|
> **isRealPath**(`path`): `boolean`
|
|
16726
16810
|
|
|
16727
|
-
Defined in: [lib/text.ts:
|
|
16811
|
+
Defined in: [lib/text.ts:519](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L519)
|
|
16728
16812
|
|
|
16729
16813
|
判断是否是绝对路径,是返回 true,相对路径返回 false
|
|
16730
16814
|
|
|
@@ -16753,7 +16837,7 @@ lib/text/functions/isTruthy.md
|
|
|
16753
16837
|
|
|
16754
16838
|
> **isTruthy**\<`T`\>(`val`): `val is Exclude<T, TFalsy>`
|
|
16755
16839
|
|
|
16756
|
-
Defined in: [lib/text.ts:
|
|
16840
|
+
Defined in: [lib/text.ts:724](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L724)
|
|
16757
16841
|
|
|
16758
16842
|
判断一个值是否是真实的(不为 null/undefined/空字符串/false/0)
|
|
16759
16843
|
|
|
@@ -16788,7 +16872,7 @@ lib/text/functions/logicalOr.md
|
|
|
16788
16872
|
|
|
16789
16873
|
> **logicalOr**\<`T`, `T2`\>(`v1`, `v2`): `T` *extends* [`TFalsy`](../type-aliases/TFalsy.md) ? `T2` : `T`
|
|
16790
16874
|
|
|
16791
|
-
Defined in: [lib/text.ts:
|
|
16875
|
+
Defined in: [lib/text.ts:733](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L733)
|
|
16792
16876
|
|
|
16793
16877
|
类似 || 运算符的效果
|
|
16794
16878
|
|
|
@@ -16833,7 +16917,7 @@ lib/text/functions/match.md
|
|
|
16833
16917
|
|
|
16834
16918
|
> **match**(`str`, `regs`): `boolean`
|
|
16835
16919
|
|
|
16836
|
-
Defined in: [lib/text.ts:
|
|
16920
|
+
Defined in: [lib/text.ts:359](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L359)
|
|
16837
16921
|
|
|
16838
16922
|
传入正则进行匹配 str 是否有一项满足
|
|
16839
16923
|
|
|
@@ -16868,7 +16952,7 @@ lib/text/functions/nlReplace.md
|
|
|
16868
16952
|
|
|
16869
16953
|
> **nlReplace**(`str`, `to?`): `string`
|
|
16870
16954
|
|
|
16871
|
-
Defined in: [lib/text.ts:
|
|
16955
|
+
Defined in: [lib/text.ts:279](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L279)
|
|
16872
16956
|
|
|
16873
16957
|
换行替换为别的
|
|
16874
16958
|
|
|
@@ -16903,7 +16987,7 @@ lib/text/functions/parseDomain.md
|
|
|
16903
16987
|
|
|
16904
16988
|
> **parseDomain**(`domain`): `Promise`\<[`IDomain`](../interfaces/IDomain.md)\>
|
|
16905
16989
|
|
|
16906
|
-
Defined in: [lib/text.ts:
|
|
16990
|
+
Defined in: [lib/text.ts:302](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L302)
|
|
16907
16991
|
|
|
16908
16992
|
解析域名并获取 tld/sld/domain/sub
|
|
16909
16993
|
|
|
@@ -16932,7 +17016,7 @@ lib/text/functions/parseHost.md
|
|
|
16932
17016
|
|
|
16933
17017
|
> **parseHost**(`host`): `object`
|
|
16934
17018
|
|
|
16935
|
-
Defined in: [lib/text.ts:
|
|
17019
|
+
Defined in: [lib/text.ts:30](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L30)
|
|
16936
17020
|
|
|
16937
17021
|
解析主机名和端口号
|
|
16938
17022
|
|
|
@@ -16973,7 +17057,7 @@ lib/text/functions/parseJson.md
|
|
|
16973
17057
|
|
|
16974
17058
|
> **parseJson**\<`T`\>(`str`): `false` \| `T`
|
|
16975
17059
|
|
|
16976
|
-
Defined in: [lib/text.ts:
|
|
17060
|
+
Defined in: [lib/text.ts:627](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L627)
|
|
16977
17061
|
|
|
16978
17062
|
将字符串解析为对象,返回 false 代表解析失败,支持 BigInt
|
|
16979
17063
|
|
|
@@ -17008,7 +17092,7 @@ lib/text/functions/parseUrl.md
|
|
|
17008
17092
|
|
|
17009
17093
|
> **parseUrl**(`url`): [`IUrlParse`](../../../index/interfaces/IUrlParse.md)
|
|
17010
17094
|
|
|
17011
|
-
Defined in: [lib/text.ts:
|
|
17095
|
+
Defined in: [lib/text.ts:56](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L56)
|
|
17012
17096
|
|
|
17013
17097
|
格式化一段 URL
|
|
17014
17098
|
|
|
@@ -17035,7 +17119,7 @@ lib/text/functions/queryParse.md
|
|
|
17035
17119
|
|
|
17036
17120
|
> **queryParse**(`query`): `Record`\<`string`, `string` \| `string`[]\>
|
|
17037
17121
|
|
|
17038
|
-
Defined in: [lib/text.ts:
|
|
17122
|
+
Defined in: [lib/text.ts:459](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L459)
|
|
17039
17123
|
|
|
17040
17124
|
将 query string 转换为对象
|
|
17041
17125
|
|
|
@@ -17066,7 +17150,7 @@ lib/text/functions/queryStringify.md
|
|
|
17066
17150
|
|
|
17067
17151
|
> **queryStringify**(`query`, `encode?`): `string`
|
|
17068
17152
|
|
|
17069
|
-
Defined in: [lib/text.ts:
|
|
17153
|
+
Defined in: [lib/text.ts:410](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L410)
|
|
17070
17154
|
|
|
17071
17155
|
将对象转换为 query string
|
|
17072
17156
|
|
|
@@ -17092,7 +17176,7 @@ Defined in: [lib/text.ts:413](https://github.com/maiyunnet/kebab/blob/master/lib
|
|
|
17092
17176
|
|
|
17093
17177
|
> **queryStringify**(`query`, `options`): `string`
|
|
17094
17178
|
|
|
17095
|
-
Defined in: [lib/text.ts:
|
|
17179
|
+
Defined in: [lib/text.ts:416](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L416)
|
|
17096
17180
|
|
|
17097
17181
|
将对象转换为 query string
|
|
17098
17182
|
|
|
@@ -17137,7 +17221,7 @@ lib/text/functions/sizeFormat.md
|
|
|
17137
17221
|
|
|
17138
17222
|
> **sizeFormat**(`size`, `spliter?`): `string`
|
|
17139
17223
|
|
|
17140
|
-
Defined in: [lib/text.ts:
|
|
17224
|
+
Defined in: [lib/text.ts:16](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L16)
|
|
17141
17225
|
|
|
17142
17226
|
将文件大小格式化为带单位的字符串
|
|
17143
17227
|
|
|
@@ -17172,7 +17256,7 @@ lib/text/functions/str2int.md
|
|
|
17172
17256
|
|
|
17173
17257
|
> **str2int**(`str`, `digits?`): `number`
|
|
17174
17258
|
|
|
17175
|
-
Defined in: [lib/text.ts:
|
|
17259
|
+
Defined in: [lib/text.ts:747](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L747)
|
|
17176
17260
|
|
|
17177
17261
|
为解决精度问题,将字符串数字转换为整数显示
|
|
17178
17262
|
以下几个示例都是当 digits 为 2 时
|
|
@@ -17212,7 +17296,7 @@ lib/text/functions/stringifyBuffer.md
|
|
|
17212
17296
|
|
|
17213
17297
|
> **stringifyBuffer**(`buf`): `string`
|
|
17214
17298
|
|
|
17215
|
-
Defined in: [lib/text.ts:
|
|
17299
|
+
Defined in: [lib/text.ts:670](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L670)
|
|
17216
17300
|
|
|
17217
17301
|
输出文本格式的 buffer
|
|
17218
17302
|
|
|
@@ -17241,7 +17325,7 @@ lib/text/functions/stringifyJson.md
|
|
|
17241
17325
|
|
|
17242
17326
|
> **stringifyJson**(`obj`, `space?`): `string`
|
|
17243
17327
|
|
|
17244
|
-
Defined in: [lib/text.ts:
|
|
17328
|
+
Defined in: [lib/text.ts:657](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L657)
|
|
17245
17329
|
|
|
17246
17330
|
将对象转换为 json 字符串,返回 false 代表解析失败,支持 BigInt
|
|
17247
17331
|
|
|
@@ -17276,7 +17360,7 @@ lib/text/functions/stringifyResult.md
|
|
|
17276
17360
|
|
|
17277
17361
|
> **stringifyResult**(`rtn`): `string`
|
|
17278
17362
|
|
|
17279
|
-
Defined in: [lib/text.ts:
|
|
17363
|
+
Defined in: [lib/text.ts:587](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L587)
|
|
17280
17364
|
|
|
17281
17365
|
将普通的返回 JSON 对象序列化为字符串
|
|
17282
17366
|
|
|
@@ -17305,7 +17389,7 @@ lib/text/functions/trimJson.md
|
|
|
17305
17389
|
|
|
17306
17390
|
> **trimJson**(`json`): `any`
|
|
17307
17391
|
|
|
17308
|
-
Defined in: [lib/text.ts:
|
|
17392
|
+
Defined in: [lib/text.ts:678](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L678)
|
|
17309
17393
|
|
|
17310
17394
|
递归删除 json 中的字符串首尾空格,会返回一个新的对象
|
|
17311
17395
|
|
|
@@ -17332,7 +17416,7 @@ lib/text/functions/urlAtom.md
|
|
|
17332
17416
|
|
|
17333
17417
|
> **urlAtom**(`url`): `string`
|
|
17334
17418
|
|
|
17335
|
-
Defined in: [lib/text.ts:
|
|
17419
|
+
Defined in: [lib/text.ts:213](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L213)
|
|
17336
17420
|
|
|
17337
17421
|
将路径中的 ../ ./ 都按规范妥善处理
|
|
17338
17422
|
|
|
@@ -17361,7 +17445,7 @@ lib/text/functions/urlResolve.md
|
|
|
17361
17445
|
|
|
17362
17446
|
> **urlResolve**(`from`, `to`, `limit?`): `string`
|
|
17363
17447
|
|
|
17364
|
-
Defined in: [lib/text.ts:
|
|
17448
|
+
Defined in: [lib/text.ts:147](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L147)
|
|
17365
17449
|
|
|
17366
17450
|
将相对路径根据基准路径进行转换
|
|
17367
17451
|
|
|
@@ -17413,8 +17497,6 @@ lib/text/index.md
|
|
|
17413
17497
|
- [REGEXP\_ASCII](variables/REGEXP_ASCII.md)
|
|
17414
17498
|
- [REGEXP\_DOMAIN](variables/REGEXP_DOMAIN.md)
|
|
17415
17499
|
- [REGEXP\_EMAIL](variables/REGEXP_EMAIL.md)
|
|
17416
|
-
- [REGEXP\_IPV4](variables/REGEXP_IPV4.md)
|
|
17417
|
-
- [REGEXP\_IPV6](variables/REGEXP_IPV6.md)
|
|
17418
17500
|
|
|
17419
17501
|
## Functions
|
|
17420
17502
|
|
|
@@ -17463,7 +17545,7 @@ lib/text/interfaces/IDomain.md
|
|
|
17463
17545
|
|
|
17464
17546
|
# Interface: IDomain
|
|
17465
17547
|
|
|
17466
|
-
Defined in: [lib/text.ts:
|
|
17548
|
+
Defined in: [lib/text.ts:291](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L291)
|
|
17467
17549
|
|
|
17468
17550
|
解析后的 domain
|
|
17469
17551
|
|
|
@@ -17473,7 +17555,7 @@ Defined in: [lib/text.ts:294](https://github.com/maiyunnet/kebab/blob/master/lib
|
|
|
17473
17555
|
|
|
17474
17556
|
> **domain**: `string` \| `null`
|
|
17475
17557
|
|
|
17476
|
-
Defined in: [lib/text.ts:
|
|
17558
|
+
Defined in: [lib/text.ts:294](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L294)
|
|
17477
17559
|
|
|
17478
17560
|
***
|
|
17479
17561
|
|
|
@@ -17481,7 +17563,7 @@ Defined in: [lib/text.ts:297](https://github.com/maiyunnet/kebab/blob/master/lib
|
|
|
17481
17563
|
|
|
17482
17564
|
> **sld**: `string` \| `null`
|
|
17483
17565
|
|
|
17484
|
-
Defined in: [lib/text.ts:
|
|
17566
|
+
Defined in: [lib/text.ts:293](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L293)
|
|
17485
17567
|
|
|
17486
17568
|
***
|
|
17487
17569
|
|
|
@@ -17489,7 +17571,7 @@ Defined in: [lib/text.ts:296](https://github.com/maiyunnet/kebab/blob/master/lib
|
|
|
17489
17571
|
|
|
17490
17572
|
> **sub**: `string` \| `null`
|
|
17491
17573
|
|
|
17492
|
-
Defined in: [lib/text.ts:
|
|
17574
|
+
Defined in: [lib/text.ts:295](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L295)
|
|
17493
17575
|
|
|
17494
17576
|
***
|
|
17495
17577
|
|
|
@@ -17497,7 +17579,7 @@ Defined in: [lib/text.ts:298](https://github.com/maiyunnet/kebab/blob/master/lib
|
|
|
17497
17579
|
|
|
17498
17580
|
> **tld**: `string` \| `null`
|
|
17499
17581
|
|
|
17500
|
-
Defined in: [lib/text.ts:
|
|
17582
|
+
Defined in: [lib/text.ts:292](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L292)
|
|
17501
17583
|
|
|
17502
17584
|
lib/text/type-aliases/TFalsy.md
|
|
17503
17585
|
---
|
|
@@ -17512,7 +17594,7 @@ lib/text/type-aliases/TFalsy.md
|
|
|
17512
17594
|
|
|
17513
17595
|
> **TFalsy** = `false` \| `""` \| `0` \| `null` \| `undefined` \| *typeof* `NaN`
|
|
17514
17596
|
|
|
17515
|
-
Defined in: [lib/text.ts:
|
|
17597
|
+
Defined in: [lib/text.ts:710](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L710)
|
|
17516
17598
|
|
|
17517
17599
|
虚假值类型
|
|
17518
17600
|
|
|
@@ -17529,7 +17611,7 @@ lib/text/variables/REGEXP_ASCII.md
|
|
|
17529
17611
|
|
|
17530
17612
|
> `const` **REGEXP\_ASCII**: `RegExp`
|
|
17531
17613
|
|
|
17532
|
-
Defined in: [lib/text.ts:
|
|
17614
|
+
Defined in: [lib/text.ts:264](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L264)
|
|
17533
17615
|
|
|
17534
17616
|
可打印的 ascii 字符集
|
|
17535
17617
|
|
|
@@ -17546,7 +17628,7 @@ lib/text/variables/REGEXP_DOMAIN.md
|
|
|
17546
17628
|
|
|
17547
17629
|
> `const` **REGEXP\_DOMAIN**: `RegExp`
|
|
17548
17630
|
|
|
17549
|
-
Defined in: [lib/text.ts:
|
|
17631
|
+
Defined in: [lib/text.ts:252](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L252)
|
|
17550
17632
|
|
|
17551
17633
|
lib/text/variables/REGEXP_EMAIL.md
|
|
17552
17634
|
---
|
|
@@ -17561,37 +17643,7 @@ lib/text/variables/REGEXP_EMAIL.md
|
|
|
17561
17643
|
|
|
17562
17644
|
> `const` **REGEXP\_EMAIL**: `RegExp`
|
|
17563
17645
|
|
|
17564
|
-
Defined in: [lib/text.ts:
|
|
17565
|
-
|
|
17566
|
-
lib/text/variables/REGEXP_IPV4.md
|
|
17567
|
-
---
|
|
17568
|
-
|
|
17569
|
-
[**Documents for @maiyunnet/kebab**](../../../index.md)
|
|
17570
|
-
|
|
17571
|
-
***
|
|
17572
|
-
|
|
17573
|
-
[Documents for @maiyunnet/kebab](../../../index.md) / [lib/text](../index.md) / REGEXP\_IPV4
|
|
17574
|
-
|
|
17575
|
-
# Variable: REGEXP\_IPV4
|
|
17576
|
-
|
|
17577
|
-
> `const` **REGEXP\_IPV4**: `RegExp`
|
|
17578
|
-
|
|
17579
|
-
Defined in: [lib/text.ts:235](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L235)
|
|
17580
|
-
|
|
17581
|
-
lib/text/variables/REGEXP_IPV6.md
|
|
17582
|
-
---
|
|
17583
|
-
|
|
17584
|
-
[**Documents for @maiyunnet/kebab**](../../../index.md)
|
|
17585
|
-
|
|
17586
|
-
***
|
|
17587
|
-
|
|
17588
|
-
[Documents for @maiyunnet/kebab](../../../index.md) / [lib/text](../index.md) / REGEXP\_IPV6
|
|
17589
|
-
|
|
17590
|
-
# Variable: REGEXP\_IPV6
|
|
17591
|
-
|
|
17592
|
-
> `const` **REGEXP\_IPV6**: `RegExp`
|
|
17593
|
-
|
|
17594
|
-
Defined in: [lib/text.ts:245](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L245)
|
|
17646
|
+
Defined in: [lib/text.ts:226](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L226)
|
|
17595
17647
|
|
|
17596
17648
|
lib/time/classes/Time.md
|
|
17597
17649
|
---
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* --- 本文件用来定义每个目录实体地址的常量 ---
|
|
7
7
|
*/
|
|
8
8
|
/** --- 当前系统版本号 --- */
|
|
9
|
-
export const VER = '9.14.
|
|
9
|
+
export const VER = '9.14.2';
|
|
10
10
|
// --- 服务端用的路径 ---
|
|
11
11
|
const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
|
|
12
12
|
/** --- /xxx/xxx --- */
|
package/lib/core.d.ts
CHANGED
|
@@ -133,6 +133,23 @@ export declare const REAL_IP_CF = "cf-connecting-ip";
|
|
|
133
133
|
* @param name 输入安全的 header
|
|
134
134
|
*/
|
|
135
135
|
export declare function realIP(ctr: sCtr.Ctr, name?: string): string;
|
|
136
|
+
/**
|
|
137
|
+
* --- 截取 IP 的限速段 ---
|
|
138
|
+
* --- IPv4 原样返回;IPv6 截取前 mask 位(默认 /64),防止同一人使用大量 IPv6 地址绕过限速 ---
|
|
139
|
+
* @param ip IP 地址
|
|
140
|
+
* @param mask IPv6 前缀长度,0-128 的整数,默认 64
|
|
141
|
+
* @returns 限速段,如 192.168.1.1、2001:db8:1234:5678::
|
|
142
|
+
*/
|
|
143
|
+
export declare function ipLimit(ip: string, mask?: number): string;
|
|
144
|
+
/**
|
|
145
|
+
* --- 获取安全 IP 的限速段(用于 ratelimit 库的 key) ---
|
|
146
|
+
* --- IPv4 原样返回;IPv6 截取前 mask 位(默认 /64) ---
|
|
147
|
+
* @param ctr Ctr 实例
|
|
148
|
+
* @param name 输入安全的 header
|
|
149
|
+
* @param mask IPv6 前缀长度,0-128 的整数,默认 64
|
|
150
|
+
* @returns 限速段,如 192.168.1.1、2001:db8:1234:5678::
|
|
151
|
+
*/
|
|
152
|
+
export declare function realIPLimit(ctr: sCtr.Ctr, name?: string, mask?: number): string;
|
|
136
153
|
/**
|
|
137
154
|
* --- 间隔一段时间 ---
|
|
138
155
|
* @param ms 间隔毫秒
|
package/lib/core.js
CHANGED
|
@@ -369,6 +369,145 @@ export function realIP(ctr, name = '') {
|
|
|
369
369
|
const req = ctr.getPrototype('_req');
|
|
370
370
|
return normalizeIP(req.socket.remoteAddress ?? '');
|
|
371
371
|
}
|
|
372
|
+
/**
|
|
373
|
+
* --- 截取 IP 的限速段 ---
|
|
374
|
+
* --- IPv4 原样返回;IPv6 截取前 mask 位(默认 /64),防止同一人使用大量 IPv6 地址绕过限速 ---
|
|
375
|
+
* @param ip IP 地址
|
|
376
|
+
* @param mask IPv6 前缀长度,0-128 的整数,默认 64
|
|
377
|
+
* @returns 限速段,如 192.168.1.1、2001:db8:1234:5678::
|
|
378
|
+
*/
|
|
379
|
+
export function ipLimit(ip, mask = 64) {
|
|
380
|
+
if (!ip) {
|
|
381
|
+
return '';
|
|
382
|
+
}
|
|
383
|
+
const value = ip.trim();
|
|
384
|
+
if (net.isIP(value) === 6) {
|
|
385
|
+
return ipv6Segment(value, mask);
|
|
386
|
+
}
|
|
387
|
+
// --- IPv4 或无法识别的字符串原样返回 ---
|
|
388
|
+
return value;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* --- 获取安全 IP 的限速段(用于 ratelimit 库的 key) ---
|
|
392
|
+
* --- IPv4 原样返回;IPv6 截取前 mask 位(默认 /64) ---
|
|
393
|
+
* @param ctr Ctr 实例
|
|
394
|
+
* @param name 输入安全的 header
|
|
395
|
+
* @param mask IPv6 前缀长度,0-128 的整数,默认 64
|
|
396
|
+
* @returns 限速段,如 192.168.1.1、2001:db8:1234:5678::
|
|
397
|
+
*/
|
|
398
|
+
export function realIPLimit(ctr, name = '', mask = 64) {
|
|
399
|
+
return ipLimit(realIP(ctr, name), mask);
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* --- 截取 IPv6 地址的前缀段 ---
|
|
403
|
+
* @param ip IPv6 地址
|
|
404
|
+
* @param mask 前缀长度,0-128
|
|
405
|
+
*/
|
|
406
|
+
function ipv6Segment(ip, mask) {
|
|
407
|
+
if (mask >= 128) {
|
|
408
|
+
return ip;
|
|
409
|
+
}
|
|
410
|
+
if (mask <= 0) {
|
|
411
|
+
return '::';
|
|
412
|
+
}
|
|
413
|
+
// --- 展开为 8 组 16 进制字符串 ---
|
|
414
|
+
const groups = expandIPv6(ip);
|
|
415
|
+
if (!groups) {
|
|
416
|
+
return ip;
|
|
417
|
+
}
|
|
418
|
+
/** --- 完整保留的组数 --- */
|
|
419
|
+
const full = Math.floor(mask / 16);
|
|
420
|
+
/** --- 下一组需保留的位数 --- */
|
|
421
|
+
const bits = mask % 16;
|
|
422
|
+
const parts = groups.slice(0, full);
|
|
423
|
+
if (bits > 0) {
|
|
424
|
+
// --- 保留下一组的高 bits 位,其余位清零 ---
|
|
425
|
+
const next = parseInt(groups[full], 16);
|
|
426
|
+
parts.push((next & (0xFFFF << (16 - bits))).toString(16));
|
|
427
|
+
}
|
|
428
|
+
// --- 补零到 8 组后按标准压缩 ---
|
|
429
|
+
while (parts.length < 8) {
|
|
430
|
+
parts.push('0');
|
|
431
|
+
}
|
|
432
|
+
return compressIPv6(parts);
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* --- 将 8 组 IPv6 分组压缩为标准 RFC 5952 表示(最长连续零段压缩为 ::) ---
|
|
436
|
+
* @param groups 8 组 16 进制字符串
|
|
437
|
+
*/
|
|
438
|
+
function compressIPv6(groups) {
|
|
439
|
+
/** --- 最长连续零组的起始位置与长度 --- */
|
|
440
|
+
let bestStart = -1;
|
|
441
|
+
let bestLen = 1;
|
|
442
|
+
let curStart = -1;
|
|
443
|
+
let curLen = 0;
|
|
444
|
+
for (let i = 0; i < groups.length; ++i) {
|
|
445
|
+
if (parseInt(groups[i], 16) === 0) {
|
|
446
|
+
if (curStart === -1) {
|
|
447
|
+
curStart = i;
|
|
448
|
+
curLen = 0;
|
|
449
|
+
}
|
|
450
|
+
++curLen;
|
|
451
|
+
if (curLen > bestLen) {
|
|
452
|
+
bestLen = curLen;
|
|
453
|
+
bestStart = curStart;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
else {
|
|
457
|
+
curStart = -1;
|
|
458
|
+
curLen = 0;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
/** --- 统一为小写无前导零 --- */
|
|
462
|
+
const norm = (g) => parseInt(g, 16).toString(16);
|
|
463
|
+
if (bestLen < 2) {
|
|
464
|
+
// --- 无连续零段,直接拼接 ---
|
|
465
|
+
return groups.map(norm).join(':');
|
|
466
|
+
}
|
|
467
|
+
const left = groups.slice(0, bestStart).map(norm);
|
|
468
|
+
const right = groups.slice(bestStart + bestLen).map(norm);
|
|
469
|
+
return (left.length ? left.join(':') : '') + '::' + (right.length ? right.join(':') : '');
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* --- 将 IPv6 地址展开为 8 组 16 进制字符串数组 ---
|
|
473
|
+
* @param ip IPv6 地址
|
|
474
|
+
* @returns 8 组字符串数组,解析失败返回 null
|
|
475
|
+
*/
|
|
476
|
+
function expandIPv6(ip) {
|
|
477
|
+
// --- 处理内嵌 IPv4(如 ::ffff:1.2.3.4、1:2:3:4:5:6:1.2.3.4) ---
|
|
478
|
+
let value = ip;
|
|
479
|
+
const ipv4Match = /^(.*:)(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/.exec(value);
|
|
480
|
+
if (ipv4Match) {
|
|
481
|
+
const v4 = ipv4Match[2].split('.').map((n) => parseInt(n, 10).toString(16).padStart(2, '0'));
|
|
482
|
+
value = ipv4Match[1] + v4[0] + v4[1] + ':' + v4[2] + v4[3];
|
|
483
|
+
}
|
|
484
|
+
// --- 处理 :: 压缩 ---
|
|
485
|
+
const dc = value.indexOf('::');
|
|
486
|
+
let groups;
|
|
487
|
+
if (dc !== -1) {
|
|
488
|
+
const left = value.slice(0, dc);
|
|
489
|
+
const right = value.slice(dc + 2);
|
|
490
|
+
const leftGroups = left ? left.split(':') : [];
|
|
491
|
+
const rightGroups = right ? right.split(':') : [];
|
|
492
|
+
const missing = 8 - leftGroups.length - rightGroups.length;
|
|
493
|
+
if (missing < 1) {
|
|
494
|
+
return null;
|
|
495
|
+
}
|
|
496
|
+
groups = leftGroups.concat(new Array(missing).fill('0'), rightGroups);
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
499
|
+
groups = value.split(':');
|
|
500
|
+
}
|
|
501
|
+
if (groups.length !== 8) {
|
|
502
|
+
return null;
|
|
503
|
+
}
|
|
504
|
+
for (const group of groups) {
|
|
505
|
+
if (!/^[\da-f]{1,4}$/i.test(group)) {
|
|
506
|
+
return null;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
return groups;
|
|
510
|
+
}
|
|
372
511
|
/**
|
|
373
512
|
* --- 间隔一段时间 ---
|
|
374
513
|
* @param ms 间隔毫秒
|
package/lib/db/pool.js
CHANGED
|
@@ -82,11 +82,12 @@ async function checkConnection() {
|
|
|
82
82
|
}
|
|
83
83
|
setTimeout(function () {
|
|
84
84
|
checkConnection().catch(e => { lCore.display('[DB][checkConnection]', e); });
|
|
85
|
-
}, 10_000);
|
|
85
|
+
}, 10_000).unref();
|
|
86
86
|
}
|
|
87
|
+
// --- 模块级巡检定时器,unref 防止在一次性 CLI 进程中阻止退出(服务进程内有其他句柄保持存活,行为不变) ---
|
|
87
88
|
setTimeout(function () {
|
|
88
89
|
checkConnection().catch(e => { lCore.display('[DB][checkConnection]', e); });
|
|
89
|
-
}, 10_000);
|
|
90
|
+
}, 10_000).unref();
|
|
90
91
|
/** --- 数据库连接池对象 --- */
|
|
91
92
|
export class Pool {
|
|
92
93
|
/** --- SQL 执行次数 --- */
|
package/lib/text.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Project: Kebab, User: JianSuoQiYue
|
|
3
|
-
* Date: 2019-5-15 16:49:39
|
|
4
|
-
* Last: 2020-04-06 20:51:06, 2022-9-29 15:18:16, 2022-12-29 00:01:30, 2024-3-6 17:53:14, 2024-5-31 17:29:52, 2025-6-13 15:47:02, 2025-9-23 12:51:49
|
|
5
|
-
*/
|
|
6
1
|
import * as kebab from '#kebab/index.js';
|
|
7
2
|
/**
|
|
8
3
|
* --- 将文件大小格式化为带单位的字符串 ---
|
|
@@ -42,15 +37,13 @@ export declare const REGEXP_EMAIL: RegExp;
|
|
|
42
37
|
* @param email
|
|
43
38
|
*/
|
|
44
39
|
export declare function isEMail(email: string): boolean;
|
|
45
|
-
export declare const REGEXP_IPV4: RegExp;
|
|
46
40
|
/**
|
|
47
|
-
* --- 是否是 IPv4 ---
|
|
41
|
+
* --- 是否是 IPv4(基于 Node 原生 net.isIP,严格校验) ---
|
|
48
42
|
* @param ip
|
|
49
43
|
*/
|
|
50
44
|
export declare function isIPv4(ip: string): boolean;
|
|
51
|
-
export declare const REGEXP_IPV6: RegExp;
|
|
52
45
|
/**
|
|
53
|
-
* --- 是否是 IPv6 ---
|
|
46
|
+
* --- 是否是 IPv6(基于 Node 原生 net.isIP,严格校验) ---
|
|
54
47
|
* @param ip
|
|
55
48
|
*/
|
|
56
49
|
export declare function isIPv6(ip: string): boolean;
|
package/lib/text.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Date: 2019-5-15 16:49:39
|
|
4
4
|
* Last: 2020-04-06 20:51:06, 2022-9-29 15:18:16, 2022-12-29 00:01:30, 2024-3-6 17:53:14, 2024-5-31 17:29:52, 2025-6-13 15:47:02, 2025-9-23 12:51:49
|
|
5
5
|
*/
|
|
6
|
+
import * as net from 'net';
|
|
6
7
|
import * as kebab from '#kebab/index.js';
|
|
7
8
|
import * as lFs from './fs.js';
|
|
8
9
|
import * as lCore from './core.js';
|
|
@@ -219,21 +220,19 @@ export const REGEXP_EMAIL = /^[-_\w.]+@[-_\w.]+\.([a-zA-Z]+)$/i;
|
|
|
219
220
|
export function isEMail(email) {
|
|
220
221
|
return REGEXP_EMAIL.test(email);
|
|
221
222
|
}
|
|
222
|
-
export const REGEXP_IPV4 = /^[0-9]{1,3}(\.[0-9]{1,3}){3}$/i;
|
|
223
223
|
/**
|
|
224
|
-
* --- 是否是 IPv4 ---
|
|
224
|
+
* --- 是否是 IPv4(基于 Node 原生 net.isIP,严格校验) ---
|
|
225
225
|
* @param ip
|
|
226
226
|
*/
|
|
227
227
|
export function isIPv4(ip) {
|
|
228
|
-
return
|
|
228
|
+
return net.isIP(ip) === 4;
|
|
229
229
|
}
|
|
230
|
-
export const REGEXP_IPV6 = /^(\w*?:){2,7}[\w.]*$/i;
|
|
231
230
|
/**
|
|
232
|
-
* --- 是否是 IPv6 ---
|
|
231
|
+
* --- 是否是 IPv6(基于 Node 原生 net.isIP,严格校验) ---
|
|
233
232
|
* @param ip
|
|
234
233
|
*/
|
|
235
234
|
export function isIPv6(ip) {
|
|
236
|
-
return
|
|
235
|
+
return net.isIP(ip) === 6;
|
|
237
236
|
}
|
|
238
237
|
export const REGEXP_DOMAIN = /^.+?\.((?![0-9]).)+$/i;
|
|
239
238
|
/**
|
package/package.json
CHANGED
|
@@ -47,6 +47,8 @@ export default class extends sCtr.Ctr {
|
|
|
47
47
|
coreChecktype(): string;
|
|
48
48
|
coreCheckschema(): string;
|
|
49
49
|
coreMuid(): string;
|
|
50
|
+
coreIplimit(): string;
|
|
51
|
+
coreRealiplimit(): string;
|
|
50
52
|
coreGetlog(): Promise<string>;
|
|
51
53
|
coreLs(): Promise<string>;
|
|
52
54
|
coreUpdatecode(): Promise<string>;
|
package/www/example/ctr/test.js
CHANGED
|
@@ -153,6 +153,8 @@ export default class extends sCtr.Ctr {
|
|
|
153
153
|
`<br><a href="${this._config.const.urlBase}test/core-checktype">View "test/core-checktype"</a>`,
|
|
154
154
|
`<br><a href="${this._config.const.urlBase}test/core-checkschema">View "test/core-checkschema"</a>`,
|
|
155
155
|
`<br><a href="${this._config.const.urlBase}test/core-muid">View "test/core-muid"</a>`,
|
|
156
|
+
`<br><a href="${this._config.const.urlBase}test/core-iplimit">View "test/core-iplimit"</a>`,
|
|
157
|
+
`<br><a href="${this._config.const.urlBase}test/core-realiplimit">View "test/core-realiplimit"</a>`,
|
|
156
158
|
`<br><a href="${this._config.const.urlBase}test/core-getlog">View "test/core-getlog"</a>`,
|
|
157
159
|
`<br><a href="${this._config.const.urlBase}test/core-ls">View "test/core-ls"</a>`,
|
|
158
160
|
`<br><a href="${this._config.const.urlBase}test/core-reload">View "test/core-reload"</a>`,
|
|
@@ -1368,6 +1370,24 @@ for (let i = 0; i < 30000; ++i) {
|
|
|
1368
1370
|
}
|
|
1369
1371
|
return echo.join('') + this._getEnd();
|
|
1370
1372
|
}
|
|
1373
|
+
coreIplimit() {
|
|
1374
|
+
const v6 = '2001:db8:85a3:8d3:1319:8a2e:370:7348';
|
|
1375
|
+
return '<pre>lCore.ipLimit(\'192.168.1.100\');</pre>' + lCore.ipLimit('192.168.1.100') +
|
|
1376
|
+
'<pre>lCore.ipLimit(\'2001:db8:85a3:8d3:1319:8a2e:370:7348\');</pre>' + lCore.ipLimit(v6) +
|
|
1377
|
+
'<pre>lCore.ipLimit(\'2001:db8:85a3:8d3:1319:8a2e:370:7348\', 48);</pre>' + lCore.ipLimit(v6, 48) +
|
|
1378
|
+
'<pre>lCore.ipLimit(\'2001:db8:85a3:8d3:1319:8a2e:370:7348\', 56);</pre>' + lCore.ipLimit(v6, 56) +
|
|
1379
|
+
'<pre>lCore.ipLimit(\'2001:db8:85a3:8d3:1319:8a2e:370:7348\', 128);</pre>' + lCore.ipLimit(v6, 128) +
|
|
1380
|
+
'<pre>lCore.ipLimit(\'::1\');</pre>' + lCore.ipLimit('::1') +
|
|
1381
|
+
'<pre>lCore.ipLimit(\'\');</pre>' + JSON.stringify(lCore.ipLimit('')) +
|
|
1382
|
+
'<br><br>' + this._getEnd();
|
|
1383
|
+
}
|
|
1384
|
+
coreRealiplimit() {
|
|
1385
|
+
return '<pre>lCore.realIP(this);</pre>' + lCore.realIP(this) +
|
|
1386
|
+
'<pre>lCore.realIPLimit(this);</pre>' + lCore.realIPLimit(this) +
|
|
1387
|
+
'<pre>lCore.realIPLimit(this, \'\', 48);</pre>' + lCore.realIPLimit(this, '', 48) +
|
|
1388
|
+
'<pre>lCore.realIPLimit(this, \'\', 56);</pre>' + lCore.realIPLimit(this, '', 56) +
|
|
1389
|
+
'<br><br>' + this._getEnd();
|
|
1390
|
+
}
|
|
1371
1391
|
async coreGetlog() {
|
|
1372
1392
|
const path = lTime.format(null, 'Y/m/d/H');
|
|
1373
1393
|
const log = await lCore.getLog({
|