@maiyunnet/kebab 9.22.5 → 9.24.0
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/abox/master-vhost.d.ts +2 -0
- package/abox/master-vhost.js +97 -0
- package/doc/kebab-rag.md +158 -101
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/lib/core.d.ts +10 -0
- package/lib/core.js +35 -0
- package/lib/undici.d.ts +5 -5
- package/lib/undici.js +7 -6
- package/package.json +1 -1
- package/sys/master.js +33 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import * as fs from 'fs/promises';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import * as lText from '#kebab/lib/text.js';
|
|
4
|
+
let pending = Promise.resolve('Done');
|
|
5
|
+
export function isFiles(files) {
|
|
6
|
+
if (!files || typeof files !== 'object' || Array.isArray(files)) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
const entries = Object.entries(files);
|
|
10
|
+
if (!entries.length) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
const names = new Set();
|
|
14
|
+
for (const [name, content] of entries) {
|
|
15
|
+
if (!name.endsWith('.json') || /[/\\\0:]/.test(name) || names.has(name.toLowerCase()) || typeof content !== 'string') {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
names.add(name.toLowerCase());
|
|
19
|
+
const config = lText.parseJson(content);
|
|
20
|
+
const list = Array.isArray(config) ? config : [config];
|
|
21
|
+
for (const item of list) {
|
|
22
|
+
if (!item || typeof item !== 'object' || Array.isArray(item)) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
const vhost = item;
|
|
26
|
+
if (!Array.isArray(vhost['domains']) || vhost['domains'].some(domain => typeof domain !== 'string') ||
|
|
27
|
+
typeof vhost['root'] !== 'string' ||
|
|
28
|
+
vhost['name'] !== undefined && typeof vhost['name'] !== 'string' ||
|
|
29
|
+
vhost['remark'] !== undefined && typeof vhost['remark'] !== 'string') {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
export function replace(directory, files, report) {
|
|
37
|
+
pending = pending.catch(() => '').then(() => replaceOnce(path.resolve(directory), files, report));
|
|
38
|
+
return pending;
|
|
39
|
+
}
|
|
40
|
+
async function replaceOnce(directory, files, report) {
|
|
41
|
+
let temporary = '';
|
|
42
|
+
let moved = false;
|
|
43
|
+
let committed = false;
|
|
44
|
+
let preserveBackup = false;
|
|
45
|
+
try {
|
|
46
|
+
let current;
|
|
47
|
+
try {
|
|
48
|
+
current = await fs.lstat(directory);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
if (error.code !== 'ENOENT') {
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (current && !current.isDirectory()) {
|
|
56
|
+
return 'Invalid vhost directory';
|
|
57
|
+
}
|
|
58
|
+
temporary = await fs.mkdtemp(path.join(path.dirname(directory), '.vhost-'));
|
|
59
|
+
const staged = path.join(temporary, 'new');
|
|
60
|
+
const backup = path.join(temporary, 'old');
|
|
61
|
+
await fs.mkdir(staged, { mode: current ? current.mode & 0o777 : 0o755 });
|
|
62
|
+
for (const [name, content] of Object.entries(files)) {
|
|
63
|
+
await fs.writeFile(path.join(staged, name), content, { encoding: 'utf8', flag: 'wx' });
|
|
64
|
+
}
|
|
65
|
+
if (current) {
|
|
66
|
+
await fs.rename(directory, backup);
|
|
67
|
+
moved = true;
|
|
68
|
+
}
|
|
69
|
+
await fs.rename(staged, directory);
|
|
70
|
+
committed = true;
|
|
71
|
+
return 'Done';
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
report('Directory replacement failed.', error);
|
|
75
|
+
if (moved && !committed) {
|
|
76
|
+
try {
|
|
77
|
+
await fs.rename(path.join(temporary, 'old'), directory);
|
|
78
|
+
}
|
|
79
|
+
catch (restoreError) {
|
|
80
|
+
preserveBackup = true;
|
|
81
|
+
report('Directory restore failed.', restoreError);
|
|
82
|
+
return `Failed to restore vhost directory; backup: ${path.join(temporary, 'old')}`;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return 'Failed to replace vhost directory';
|
|
86
|
+
}
|
|
87
|
+
finally {
|
|
88
|
+
if (temporary && !preserveBackup) {
|
|
89
|
+
try {
|
|
90
|
+
await fs.rm(temporary, { recursive: true, force: true });
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
report(`Temporary directory cleanup failed: ${temporary}`, error);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
package/doc/kebab-rag.md
CHANGED
|
@@ -33,6 +33,25 @@ quick-start.md
|
|
|
33
33
|
- `view/`: 视图目录,存放 ejs 文件
|
|
34
34
|
- `ws/`: WebSocket 目录
|
|
35
35
|
|
|
36
|
+
## 全量更新虚拟主机配置
|
|
37
|
+
|
|
38
|
+
`lCore.sendVhost(files, hosts?)` 全量替换目标节点的 `conf/vhost/`,未提交的旧文件及子目录会被移除。`files` 是文件名到 JSON 原文的非空集合,仅接受直接 `.json` 文件名,不允许路径及大小写重名;每份 JSON 为 `IVhost` 或 `IVhost[]`。文件原文会被保留。
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import * as lCore from '@maiyunnet/kebab/lib/core.js';
|
|
42
|
+
|
|
43
|
+
const results = await lCore.sendVhost({
|
|
44
|
+
'default.json': '{"domains":["*"],"root":"default/"}',
|
|
45
|
+
'sites.json': '[{"domains":["example.com"],"root":"example.com/"}]',
|
|
46
|
+
}, 'config');
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
省略 `hosts` 或传入空列表时更新本机;传入 `'config'` 使用全局 `hosts`,也可指定节点列表。各节点独立返回 `{ result, return }`,失败节点可单独重试。接收端复用 RPC 鉴权,通过 POST body 接收配置(上限为现有 POST 解析的 50 MiB),不传输证书或全局配置。
|
|
50
|
+
|
|
51
|
+
同一节点串行执行替换。全部文件校验、写入临时目录成功后,才备份旧目录并切换;切换失败会恢复旧目录。若恢复也失败,返回信息会给出保留的备份目录,需人工恢复;目标 `vhost` 本身是软链接或普通文件时拒绝更新。替换包含两次目录重命名,过程中不要同时执行 reload 或手动修改该目录。
|
|
52
|
+
|
|
53
|
+
此方法不自动 reload,成功仅表示磁盘目录替换完成。确认各节点结果后,自行调用 `sendReload()`;部分节点失败时只向成功节点发送 reload。现有 reload 返回成功表示通知已发送,不代表所有 worker 已加载完成。
|
|
54
|
+
|
|
36
55
|
## 请求主机与完整 URL
|
|
37
56
|
|
|
38
57
|
控制器通过 `this._config.const.hostCanonical` 获取用于 URL 的主机地址:HTTPS 的 443 和 HTTP 的 80 端口会省略,其余端口及 IPv6 方括号保留。`host`、`hostname` 和 `hostport` 保留原有含义。`urlOrigin`、`urlFull` 和 `urlStcFull` 使用 `hostCanonical` 生成,SSR 注入的 `_urlFull`、默认 `_staticPathFull` 同步省略默认端口。
|
|
@@ -1737,7 +1756,7 @@ index/variables/VER.md
|
|
|
1737
1756
|
|
|
1738
1757
|
# Variable: VER
|
|
1739
1758
|
|
|
1740
|
-
> `const` **VER**: `"9.
|
|
1759
|
+
> `const` **VER**: `"9.24.0"` = `'9.24.0'`
|
|
1741
1760
|
|
|
1742
1761
|
Defined in: [index.ts:10](https://github.com/maiyunnet/kebab/blob/master/index.ts#L10)
|
|
1743
1762
|
|
|
@@ -3727,7 +3746,7 @@ lib/core/functions/clone.md
|
|
|
3727
3746
|
|
|
3728
3747
|
> **clone**\<`T`\>(`obj`): `T`
|
|
3729
3748
|
|
|
3730
|
-
Defined in: [lib/core.ts:
|
|
3749
|
+
Defined in: [lib/core.ts:1509](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1509)
|
|
3731
3750
|
|
|
3732
3751
|
完整的克隆一份数组/对象
|
|
3733
3752
|
|
|
@@ -3791,7 +3810,7 @@ lib/core/functions/debug.md
|
|
|
3791
3810
|
|
|
3792
3811
|
> **debug**(`message?`, ...`optionalParams`): `void`
|
|
3793
3812
|
|
|
3794
|
-
Defined in: [lib/core.ts:
|
|
3813
|
+
Defined in: [lib/core.ts:1555](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1555)
|
|
3795
3814
|
|
|
3796
3815
|
打印调试信息,线上环境不会打印
|
|
3797
3816
|
|
|
@@ -3826,7 +3845,7 @@ lib/core/functions/display.md
|
|
|
3826
3845
|
|
|
3827
3846
|
> **display**(`message?`, ...`optionalParams`): `void`
|
|
3828
3847
|
|
|
3829
|
-
Defined in: [lib/core.ts:
|
|
3848
|
+
Defined in: [lib/core.ts:1568](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1568)
|
|
3830
3849
|
|
|
3831
3850
|
向控制台直接显示内容,一般情况下禁止使用
|
|
3832
3851
|
|
|
@@ -3938,7 +3957,7 @@ lib/core/functions/getLog.md
|
|
|
3938
3957
|
|
|
3939
3958
|
> **getLog**(`opt`): `Promise`\<`false` \| \{ `list`: `any`[] \| `string`[][]; `total`: `number`; \}\>
|
|
3940
3959
|
|
|
3941
|
-
Defined in: [lib/core.ts:
|
|
3960
|
+
Defined in: [lib/core.ts:1289](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1289)
|
|
3942
3961
|
|
|
3943
3962
|
获取日志内容为一个数组
|
|
3944
3963
|
|
|
@@ -4007,7 +4026,7 @@ lib/core/functions/getMonitorEvent.md
|
|
|
4007
4026
|
|
|
4008
4027
|
> **getMonitorEvent**(`opt`): `Promise`\<`false` \| [`IMonitorEvent`](../interfaces/IMonitorEvent.md) \| `null`\>
|
|
4009
4028
|
|
|
4010
|
-
Defined in: [lib/core.ts:
|
|
4029
|
+
Defined in: [lib/core.ts:1425](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1425)
|
|
4011
4030
|
|
|
4012
4031
|
读取事件详情和文件清单;只解析事件记录,不解析 Profile 或堆快照
|
|
4013
4032
|
|
|
@@ -4044,7 +4063,7 @@ lib/core/functions/getMonitorEvents.md
|
|
|
4044
4063
|
|
|
4045
4064
|
> **getMonitorEvents**(`opt?`): `Promise`\<`false` \| \{ `list`: [`IMonitorEventSummary`](../interfaces/IMonitorEventSummary.md)[]; `total`: `number`; \}\>
|
|
4046
4065
|
|
|
4047
|
-
Defined in: [lib/core.ts:
|
|
4066
|
+
Defined in: [lib/core.ts:1398](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1398)
|
|
4048
4067
|
|
|
4049
4068
|
获取某天已保存的监控事件,按目录时间倒序分页
|
|
4050
4069
|
|
|
@@ -4091,7 +4110,7 @@ lib/core/functions/getMonitorFile.md
|
|
|
4091
4110
|
|
|
4092
4111
|
> **getMonitorFile**(`opt`): `Promise`\<`false` \| [`Response`](../../undici/response/classes/Response.md) \| `null`\>
|
|
4093
4112
|
|
|
4094
|
-
Defined in: [lib/core.ts:
|
|
4113
|
+
Defined in: [lib/core.ts:1449](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1449)
|
|
4095
4114
|
|
|
4096
4115
|
获取监控原始文件的响应,可使用 getStream() 下载;小文件可用 getText()/getJson() 预览
|
|
4097
4116
|
|
|
@@ -4236,7 +4255,7 @@ lib/core/functions/loadEnv.md
|
|
|
4236
4255
|
|
|
4237
4256
|
> **loadEnv**(`dir`): `Promise`\<`void`\>
|
|
4238
4257
|
|
|
4239
|
-
Defined in: [lib/core.ts:
|
|
4258
|
+
Defined in: [lib/core.ts:1639](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1639)
|
|
4240
4259
|
|
|
4241
4260
|
加载 .env 文件到 process.env,若文件不存在则跳过
|
|
4242
4261
|
|
|
@@ -4265,7 +4284,7 @@ lib/core/functions/log.md
|
|
|
4265
4284
|
|
|
4266
4285
|
> **log**(`opt`, `msg`, `fend?`): `void`
|
|
4267
4286
|
|
|
4268
|
-
Defined in: [lib/core.ts:
|
|
4287
|
+
Defined in: [lib/core.ts:1176](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1176)
|
|
4269
4288
|
|
|
4270
4289
|
写入文件日志
|
|
4271
4290
|
|
|
@@ -4306,7 +4325,7 @@ lib/core/functions/ls.md
|
|
|
4306
4325
|
|
|
4307
4326
|
> **ls**(`opt`): `Promise`\<`object`[]\>
|
|
4308
4327
|
|
|
4309
|
-
Defined in: [lib/core.ts:
|
|
4328
|
+
Defined in: [lib/core.ts:1470](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1470)
|
|
4310
4329
|
|
|
4311
4330
|
获取目录内文件/文件夹列表
|
|
4312
4331
|
|
|
@@ -4711,7 +4730,7 @@ lib/core/functions/resolveEnvVars.md
|
|
|
4711
4730
|
|
|
4712
4731
|
> **resolveEnvVars**(`obj`): `void`
|
|
4713
4732
|
|
|
4714
|
-
Defined in: [lib/core.ts:
|
|
4733
|
+
Defined in: [lib/core.ts:1669](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1669)
|
|
4715
4734
|
|
|
4716
4735
|
将配置对象中的 ${ENV_VAR} 占位符替换为 process.env 的值
|
|
4717
4736
|
|
|
@@ -4974,6 +4993,43 @@ Defined in: [lib/core.ts:799](https://github.com/maiyunnet/kebab/blob/master/lib
|
|
|
4974
4993
|
|
|
4975
4994
|
各主机发送结果
|
|
4976
4995
|
|
|
4996
|
+
lib/core/functions/sendVhost.md
|
|
4997
|
+
---
|
|
4998
|
+
|
|
4999
|
+
[**Documents for @maiyunnet/kebab**](../../../index.md)
|
|
5000
|
+
|
|
5001
|
+
***
|
|
5002
|
+
|
|
5003
|
+
[Documents for @maiyunnet/kebab](../../../index.md) / [lib/core](../index.md) / sendVhost
|
|
5004
|
+
|
|
5005
|
+
# Function: sendVhost()
|
|
5006
|
+
|
|
5007
|
+
> **sendVhost**(`files`, `hosts?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
|
|
5008
|
+
|
|
5009
|
+
Defined in: [lib/core.ts:1123](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1123)
|
|
5010
|
+
|
|
5011
|
+
全量替换各节点 conf/vhost/ 中的文件,不自动 reload
|
|
5012
|
+
|
|
5013
|
+
## Parameters
|
|
5014
|
+
|
|
5015
|
+
### files
|
|
5016
|
+
|
|
5017
|
+
`Record`\<`string`, `string`\>
|
|
5018
|
+
|
|
5019
|
+
文件名与 JSON 原文的非空集合;仅允许直接 .json 文件名,内容为 IVhost 或 IVhost[]
|
|
5020
|
+
|
|
5021
|
+
### hosts?
|
|
5022
|
+
|
|
5023
|
+
`string`[] \| `"config"`
|
|
5024
|
+
|
|
5025
|
+
节点列表,config 使用全局 hosts;省略或列表为空时更新本机
|
|
5026
|
+
|
|
5027
|
+
## Returns
|
|
5028
|
+
|
|
5029
|
+
`Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
|
|
5030
|
+
|
|
5031
|
+
各节点的写入结果;成功表示目录替换完成,需自行调用 sendReload 生效
|
|
5032
|
+
|
|
4977
5033
|
lib/core/functions/setCookie.md
|
|
4978
5034
|
---
|
|
4979
5035
|
|
|
@@ -5186,7 +5242,7 @@ lib/core/functions/writeEventStreamHead.md
|
|
|
5186
5242
|
|
|
5187
5243
|
> **writeEventStreamHead**(`res`): `void`
|
|
5188
5244
|
|
|
5189
|
-
Defined in: [lib/core.ts:
|
|
5245
|
+
Defined in: [lib/core.ts:1609](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1609)
|
|
5190
5246
|
|
|
5191
5247
|
提交服务器发送事件(SSE)响应头
|
|
5192
5248
|
|
|
@@ -5221,7 +5277,7 @@ lib/core/functions/writeHead.md
|
|
|
5221
5277
|
|
|
5222
5278
|
> **writeHead**(`res`, `statusCode`, `headers?`): `void`
|
|
5223
5279
|
|
|
5224
|
-
Defined in: [lib/core.ts:
|
|
5280
|
+
Defined in: [lib/core.ts:1588](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1588)
|
|
5225
5281
|
|
|
5226
5282
|
提交 HTTP 响应状态和头部,兼容 HTTP/1.1 与 HTTP/2
|
|
5227
5283
|
|
|
@@ -5271,7 +5327,7 @@ lib/core/functions/write.md
|
|
|
5271
5327
|
|
|
5272
5328
|
> **write**(`res`, `data`): `void`
|
|
5273
5329
|
|
|
5274
|
-
Defined in: [lib/core.ts:
|
|
5330
|
+
Defined in: [lib/core.ts:1621](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1621)
|
|
5275
5331
|
|
|
5276
5332
|
向 res 发送数据
|
|
5277
5333
|
|
|
@@ -5374,6 +5430,7 @@ lib/core/index.md
|
|
|
5374
5430
|
- [sendReload](functions/sendReload.md)
|
|
5375
5431
|
- [sendRestart](functions/sendRestart.md)
|
|
5376
5432
|
- [sendStop](functions/sendStop.md)
|
|
5433
|
+
- [sendVhost](functions/sendVhost.md)
|
|
5377
5434
|
- [setCookie](functions/setCookie.md)
|
|
5378
5435
|
- [setGlobal](functions/setGlobal.md)
|
|
5379
5436
|
- [sleep](functions/sleep.md)
|
|
@@ -5457,7 +5514,7 @@ lib/core/interfaces/ILogOptions.md
|
|
|
5457
5514
|
|
|
5458
5515
|
# Interface: ILogOptions
|
|
5459
5516
|
|
|
5460
|
-
Defined in: [lib/core.ts:
|
|
5517
|
+
Defined in: [lib/core.ts:1159](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1159)
|
|
5461
5518
|
|
|
5462
5519
|
log 设置的选项
|
|
5463
5520
|
|
|
@@ -5467,7 +5524,7 @@ log 设置的选项
|
|
|
5467
5524
|
|
|
5468
5525
|
> `optional` **cookie?**: `Record`\<`string`, `string`\>
|
|
5469
5526
|
|
|
5470
|
-
Defined in: [lib/core.ts:
|
|
5527
|
+
Defined in: [lib/core.ts:1165](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1165)
|
|
5471
5528
|
|
|
5472
5529
|
***
|
|
5473
5530
|
|
|
@@ -5475,7 +5532,7 @@ Defined in: [lib/core.ts:1124](https://github.com/maiyunnet/kebab/blob/master/li
|
|
|
5475
5532
|
|
|
5476
5533
|
> `optional` **get?**: `Record`\<`string`, `any`\>
|
|
5477
5534
|
|
|
5478
|
-
Defined in: [lib/core.ts:
|
|
5535
|
+
Defined in: [lib/core.ts:1164](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1164)
|
|
5479
5536
|
|
|
5480
5537
|
***
|
|
5481
5538
|
|
|
@@ -5483,7 +5540,7 @@ Defined in: [lib/core.ts:1123](https://github.com/maiyunnet/kebab/blob/master/li
|
|
|
5483
5540
|
|
|
5484
5541
|
> `optional` **headers?**: `IncomingHttpHeaders`
|
|
5485
5542
|
|
|
5486
|
-
Defined in: [lib/core.ts:
|
|
5543
|
+
Defined in: [lib/core.ts:1167](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1167)
|
|
5487
5544
|
|
|
5488
5545
|
***
|
|
5489
5546
|
|
|
@@ -5491,7 +5548,7 @@ Defined in: [lib/core.ts:1126](https://github.com/maiyunnet/kebab/blob/master/li
|
|
|
5491
5548
|
|
|
5492
5549
|
> `optional` **hostname?**: `string`
|
|
5493
5550
|
|
|
5494
|
-
Defined in: [lib/core.ts:
|
|
5551
|
+
Defined in: [lib/core.ts:1162](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1162)
|
|
5495
5552
|
|
|
5496
5553
|
***
|
|
5497
5554
|
|
|
@@ -5499,7 +5556,7 @@ Defined in: [lib/core.ts:1121](https://github.com/maiyunnet/kebab/blob/master/li
|
|
|
5499
5556
|
|
|
5500
5557
|
> `optional` **path?**: `string`
|
|
5501
5558
|
|
|
5502
|
-
Defined in: [lib/core.ts:
|
|
5559
|
+
Defined in: [lib/core.ts:1160](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1160)
|
|
5503
5560
|
|
|
5504
5561
|
***
|
|
5505
5562
|
|
|
@@ -5507,7 +5564,7 @@ Defined in: [lib/core.ts:1119](https://github.com/maiyunnet/kebab/blob/master/li
|
|
|
5507
5564
|
|
|
5508
5565
|
> `optional` **req?**: `IncomingMessage` \| `Http2ServerRequest` \| `null`
|
|
5509
5566
|
|
|
5510
|
-
Defined in: [lib/core.ts:
|
|
5567
|
+
Defined in: [lib/core.ts:1163](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1163)
|
|
5511
5568
|
|
|
5512
5569
|
***
|
|
5513
5570
|
|
|
@@ -5515,7 +5572,7 @@ Defined in: [lib/core.ts:1122](https://github.com/maiyunnet/kebab/blob/master/li
|
|
|
5515
5572
|
|
|
5516
5573
|
> `optional` **session?**: `Record`\<`string`, `any`\>
|
|
5517
5574
|
|
|
5518
|
-
Defined in: [lib/core.ts:
|
|
5575
|
+
Defined in: [lib/core.ts:1166](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1166)
|
|
5519
5576
|
|
|
5520
5577
|
***
|
|
5521
5578
|
|
|
@@ -5523,7 +5580,7 @@ Defined in: [lib/core.ts:1125](https://github.com/maiyunnet/kebab/blob/master/li
|
|
|
5523
5580
|
|
|
5524
5581
|
> `optional` **urlFull?**: `string`
|
|
5525
5582
|
|
|
5526
|
-
Defined in: [lib/core.ts:
|
|
5583
|
+
Defined in: [lib/core.ts:1161](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1161)
|
|
5527
5584
|
|
|
5528
5585
|
lib/core/interfaces/IMonitorEvent.md
|
|
5529
5586
|
---
|
|
@@ -5536,7 +5593,7 @@ lib/core/interfaces/IMonitorEvent.md
|
|
|
5536
5593
|
|
|
5537
5594
|
# Interface: IMonitorEvent
|
|
5538
5595
|
|
|
5539
|
-
Defined in: [lib/core.ts:
|
|
5596
|
+
Defined in: [lib/core.ts:1355](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1355)
|
|
5540
5597
|
|
|
5541
5598
|
事件原始数据与可读取的文件;data 为 null 时可下载原始记录复盘
|
|
5542
5599
|
|
|
@@ -5546,7 +5603,7 @@ Defined in: [lib/core.ts:1314](https://github.com/maiyunnet/kebab/blob/master/li
|
|
|
5546
5603
|
|
|
5547
5604
|
> **data**: `Record`\<`string`, `unknown`\> \| `null`
|
|
5548
5605
|
|
|
5549
|
-
Defined in: [lib/core.ts:
|
|
5606
|
+
Defined in: [lib/core.ts:1357](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1357)
|
|
5550
5607
|
|
|
5551
5608
|
***
|
|
5552
5609
|
|
|
@@ -5554,7 +5611,7 @@ Defined in: [lib/core.ts:1316](https://github.com/maiyunnet/kebab/blob/master/li
|
|
|
5554
5611
|
|
|
5555
5612
|
> **files**: [`IMonitorFile`](IMonitorFile.md)[]
|
|
5556
5613
|
|
|
5557
|
-
Defined in: [lib/core.ts:
|
|
5614
|
+
Defined in: [lib/core.ts:1359](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1359)
|
|
5558
5615
|
|
|
5559
5616
|
***
|
|
5560
5617
|
|
|
@@ -5562,7 +5619,7 @@ Defined in: [lib/core.ts:1318](https://github.com/maiyunnet/kebab/blob/master/li
|
|
|
5562
5619
|
|
|
5563
5620
|
> **recordStatus**: `"loaded"` \| `"invalid"` \| `"missing"` \| `"too-large"` \| `"unreadable"`
|
|
5564
5621
|
|
|
5565
|
-
Defined in: [lib/core.ts:
|
|
5622
|
+
Defined in: [lib/core.ts:1358](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1358)
|
|
5566
5623
|
|
|
5567
5624
|
***
|
|
5568
5625
|
|
|
@@ -5570,7 +5627,7 @@ Defined in: [lib/core.ts:1317](https://github.com/maiyunnet/kebab/blob/master/li
|
|
|
5570
5627
|
|
|
5571
5628
|
> **summary**: [`IMonitorEventSummary`](IMonitorEventSummary.md)
|
|
5572
5629
|
|
|
5573
|
-
Defined in: [lib/core.ts:
|
|
5630
|
+
Defined in: [lib/core.ts:1356](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1356)
|
|
5574
5631
|
|
|
5575
5632
|
lib/core/interfaces/IMonitorEventSummary.md
|
|
5576
5633
|
---
|
|
@@ -5583,7 +5640,7 @@ lib/core/interfaces/IMonitorEventSummary.md
|
|
|
5583
5640
|
|
|
5584
5641
|
# Interface: IMonitorEventSummary
|
|
5585
5642
|
|
|
5586
|
-
Defined in: [lib/core.ts:
|
|
5643
|
+
Defined in: [lib/core.ts:1335](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1335)
|
|
5587
5644
|
|
|
5588
5645
|
已保存监控事件的简短摘要,path 相对于 log/monitor/
|
|
5589
5646
|
|
|
@@ -5593,7 +5650,7 @@ Defined in: [lib/core.ts:1294](https://github.com/maiyunnet/kebab/blob/master/li
|
|
|
5593
5650
|
|
|
5594
5651
|
> **path**: `string`
|
|
5595
5652
|
|
|
5596
|
-
Defined in: [lib/core.ts:
|
|
5653
|
+
Defined in: [lib/core.ts:1336](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1336)
|
|
5597
5654
|
|
|
5598
5655
|
***
|
|
5599
5656
|
|
|
@@ -5601,7 +5658,7 @@ Defined in: [lib/core.ts:1295](https://github.com/maiyunnet/kebab/blob/master/li
|
|
|
5601
5658
|
|
|
5602
5659
|
> **pid**: `number`
|
|
5603
5660
|
|
|
5604
|
-
Defined in: [lib/core.ts:
|
|
5661
|
+
Defined in: [lib/core.ts:1337](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1337)
|
|
5605
5662
|
|
|
5606
5663
|
***
|
|
5607
5664
|
|
|
@@ -5609,7 +5666,7 @@ Defined in: [lib/core.ts:1296](https://github.com/maiyunnet/kebab/blob/master/li
|
|
|
5609
5666
|
|
|
5610
5667
|
> **reasons**: `string`[]
|
|
5611
5668
|
|
|
5612
|
-
Defined in: [lib/core.ts:
|
|
5669
|
+
Defined in: [lib/core.ts:1341](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1341)
|
|
5613
5670
|
|
|
5614
5671
|
***
|
|
5615
5672
|
|
|
@@ -5617,7 +5674,7 @@ Defined in: [lib/core.ts:1300](https://github.com/maiyunnet/kebab/blob/master/li
|
|
|
5617
5674
|
|
|
5618
5675
|
> **source**: `"main"` \| `"watchdog"`
|
|
5619
5676
|
|
|
5620
|
-
Defined in: [lib/core.ts:
|
|
5677
|
+
Defined in: [lib/core.ts:1339](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1339)
|
|
5621
5678
|
|
|
5622
5679
|
***
|
|
5623
5680
|
|
|
@@ -5625,7 +5682,7 @@ Defined in: [lib/core.ts:1298](https://github.com/maiyunnet/kebab/blob/master/li
|
|
|
5625
5682
|
|
|
5626
5683
|
> **status**: `string`
|
|
5627
5684
|
|
|
5628
|
-
Defined in: [lib/core.ts:
|
|
5685
|
+
Defined in: [lib/core.ts:1340](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1340)
|
|
5629
5686
|
|
|
5630
5687
|
***
|
|
5631
5688
|
|
|
@@ -5633,7 +5690,7 @@ Defined in: [lib/core.ts:1299](https://github.com/maiyunnet/kebab/blob/master/li
|
|
|
5633
5690
|
|
|
5634
5691
|
> **time**: `number`
|
|
5635
5692
|
|
|
5636
|
-
Defined in: [lib/core.ts:
|
|
5693
|
+
Defined in: [lib/core.ts:1338](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1338)
|
|
5637
5694
|
|
|
5638
5695
|
lib/core/interfaces/IMonitorFile.md
|
|
5639
5696
|
---
|
|
@@ -5646,7 +5703,7 @@ lib/core/interfaces/IMonitorFile.md
|
|
|
5646
5703
|
|
|
5647
5704
|
# Interface: IMonitorFile
|
|
5648
5705
|
|
|
5649
|
-
Defined in: [lib/core.ts:
|
|
5706
|
+
Defined in: [lib/core.ts:1345](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1345)
|
|
5650
5707
|
|
|
5651
5708
|
监控文件元数据;复杂格式或超过 1 MiB 的文件不提供预览
|
|
5652
5709
|
|
|
@@ -5656,7 +5713,7 @@ Defined in: [lib/core.ts:1304](https://github.com/maiyunnet/kebab/blob/master/li
|
|
|
5656
5713
|
|
|
5657
5714
|
> **mtime**: `number`
|
|
5658
5715
|
|
|
5659
|
-
Defined in: [lib/core.ts:
|
|
5716
|
+
Defined in: [lib/core.ts:1350](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1350)
|
|
5660
5717
|
|
|
5661
5718
|
最后修改时间,单位 ms
|
|
5662
5719
|
|
|
@@ -5666,7 +5723,7 @@ Defined in: [lib/core.ts:1309](https://github.com/maiyunnet/kebab/blob/master/li
|
|
|
5666
5723
|
|
|
5667
5724
|
> **name**: `string`
|
|
5668
5725
|
|
|
5669
|
-
Defined in: [lib/core.ts:
|
|
5726
|
+
Defined in: [lib/core.ts:1347](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1347)
|
|
5670
5727
|
|
|
5671
5728
|
***
|
|
5672
5729
|
|
|
@@ -5674,7 +5731,7 @@ Defined in: [lib/core.ts:1306](https://github.com/maiyunnet/kebab/blob/master/li
|
|
|
5674
5731
|
|
|
5675
5732
|
> **path**: `string`
|
|
5676
5733
|
|
|
5677
|
-
Defined in: [lib/core.ts:
|
|
5734
|
+
Defined in: [lib/core.ts:1346](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1346)
|
|
5678
5735
|
|
|
5679
5736
|
***
|
|
5680
5737
|
|
|
@@ -5682,7 +5739,7 @@ Defined in: [lib/core.ts:1305](https://github.com/maiyunnet/kebab/blob/master/li
|
|
|
5682
5739
|
|
|
5683
5740
|
> **preview**: `"text"` \| `"json"` \| `null`
|
|
5684
5741
|
|
|
5685
|
-
Defined in: [lib/core.ts:
|
|
5742
|
+
Defined in: [lib/core.ts:1351](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1351)
|
|
5686
5743
|
|
|
5687
5744
|
***
|
|
5688
5745
|
|
|
@@ -5690,7 +5747,7 @@ Defined in: [lib/core.ts:1310](https://github.com/maiyunnet/kebab/blob/master/li
|
|
|
5690
5747
|
|
|
5691
5748
|
> **size**: `number`
|
|
5692
5749
|
|
|
5693
|
-
Defined in: [lib/core.ts:
|
|
5750
|
+
Defined in: [lib/core.ts:1348](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1348)
|
|
5694
5751
|
|
|
5695
5752
|
lib/core/namespaces/v/classes/ValiError.md
|
|
5696
5753
|
---
|
|
@@ -128699,7 +128756,7 @@ lib/undici/functions/fetch.md
|
|
|
128699
128756
|
|
|
128700
128757
|
> **fetch**(`input`, `init?`): `Promise`\<`Response`\>
|
|
128701
128758
|
|
|
128702
|
-
Defined in: [lib/undici.ts:
|
|
128759
|
+
Defined in: [lib/undici.ts:293](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L293)
|
|
128703
128760
|
|
|
128704
128761
|
发起一个完全兼容 fetch 的请求
|
|
128705
128762
|
|
|
@@ -128734,7 +128791,7 @@ lib/undici/functions/filterHeaders.md
|
|
|
128734
128791
|
|
|
128735
128792
|
> **filterHeaders**(`headers`, `res?`, `filter?`): `Record`\<`string`, `string` \| `string`[]\>
|
|
128736
128793
|
|
|
128737
|
-
Defined in: [lib/undici.ts:
|
|
128794
|
+
Defined in: [lib/undici.ts:673](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L673)
|
|
128738
128795
|
|
|
128739
128796
|
剔除不代理的 header,返回新的 header
|
|
128740
128797
|
|
|
@@ -128775,7 +128832,7 @@ lib/undici/functions/getFormData.md
|
|
|
128775
128832
|
|
|
128776
128833
|
> **getFormData**(): [`FormData`](../formdata/classes/FormData.md)
|
|
128777
128834
|
|
|
128778
|
-
Defined in: [lib/undici.ts:
|
|
128835
|
+
Defined in: [lib/undici.ts:657](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L657)
|
|
128779
128836
|
|
|
128780
128837
|
创建 FormData 对象
|
|
128781
128838
|
|
|
@@ -128858,7 +128915,7 @@ lib/undici/functions/getResponseJson.md
|
|
|
128858
128915
|
|
|
128859
128916
|
> **getResponseJson**(`u`, `opt?`): `Promise`\<`any`\>
|
|
128860
128917
|
|
|
128861
|
-
Defined in: [lib/undici.ts:
|
|
128918
|
+
Defined in: [lib/undici.ts:281](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L281)
|
|
128862
128919
|
|
|
128863
128920
|
发起 GET 请求并解析 JSON 响应
|
|
128864
128921
|
|
|
@@ -128880,7 +128937,7 @@ Defined in: [lib/undici.ts:280](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
128880
128937
|
|
|
128881
128938
|
`Promise`\<`any`\>
|
|
128882
128939
|
|
|
128883
|
-
JSON
|
|
128940
|
+
最后一次响应的 JSON 数据,重试验证未通过也保留;请求或读取失败返回 null;JSON 解析失败返回 false
|
|
128884
128941
|
|
|
128885
128942
|
lib/undici/functions/mproxyData.md
|
|
128886
128943
|
---
|
|
@@ -128895,7 +128952,7 @@ lib/undici/functions/mproxyData.md
|
|
|
128895
128952
|
|
|
128896
128953
|
> **mproxyData**(`ctr`): `any`
|
|
128897
128954
|
|
|
128898
|
-
Defined in: [lib/undici.ts:
|
|
128955
|
+
Defined in: [lib/undici.ts:779](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L779)
|
|
128899
128956
|
|
|
128900
128957
|
获取 mproxy 的附加数据
|
|
128901
128958
|
|
|
@@ -128924,7 +128981,7 @@ lib/undici/functions/mproxy.md
|
|
|
128924
128981
|
|
|
128925
128982
|
> **mproxy**(`ctr`, `auth`, `opt?`): `Promise`\<`number`\>
|
|
128926
128983
|
|
|
128927
|
-
Defined in: [lib/undici.ts:
|
|
128984
|
+
Defined in: [lib/undici.ts:713](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L713)
|
|
128928
128985
|
|
|
128929
128986
|
正向 mproxy 代理,注意提前处理不要自动处理 post 数据,读取 get 的 url 为实际请求地址
|
|
128930
128987
|
get: url, auth
|
|
@@ -129034,7 +129091,7 @@ lib/undici/functions/postJsonResponseJson.md
|
|
|
129034
129091
|
|
|
129035
129092
|
> **postJsonResponseJson**(`u`, `data`, `opt?`): `Promise`\<`any`\>
|
|
129036
129093
|
|
|
129037
|
-
Defined in: [lib/undici.ts:
|
|
129094
|
+
Defined in: [lib/undici.ts:253](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L253)
|
|
129038
129095
|
|
|
129039
129096
|
发起 JSON 请求并解析 JSON 响应
|
|
129040
129097
|
|
|
@@ -129062,7 +129119,7 @@ Defined in: [lib/undici.ts:252](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129062
129119
|
|
|
129063
129120
|
`Promise`\<`any`\>
|
|
129064
129121
|
|
|
129065
|
-
JSON
|
|
129122
|
+
最后一次响应的 JSON 数据,重试验证未通过也保留;请求或读取失败返回 null;JSON 解析失败返回 false
|
|
129066
129123
|
|
|
129067
129124
|
lib/undici/functions/post.md
|
|
129068
129125
|
---
|
|
@@ -129118,7 +129175,7 @@ lib/undici/functions/postResponseJson.md
|
|
|
129118
129175
|
|
|
129119
129176
|
> **postResponseJson**(`u`, `data`, `opt?`): `Promise`\<`any`\>
|
|
129120
129177
|
|
|
129121
|
-
Defined in: [lib/undici.ts:
|
|
129178
|
+
Defined in: [lib/undici.ts:268](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L268)
|
|
129122
129179
|
|
|
129123
129180
|
发起 POST 请求并解析 JSON 响应
|
|
129124
129181
|
|
|
@@ -129146,7 +129203,7 @@ Defined in: [lib/undici.ts:267](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129146
129203
|
|
|
129147
129204
|
`Promise`\<`any`\>
|
|
129148
129205
|
|
|
129149
|
-
JSON
|
|
129206
|
+
最后一次响应的 JSON 数据,重试验证未通过也保留;请求或读取失败返回 null;JSON 解析失败返回 false
|
|
129150
129207
|
|
|
129151
129208
|
lib/undici/functions/request.md
|
|
129152
129209
|
---
|
|
@@ -129161,7 +129218,7 @@ lib/undici/functions/request.md
|
|
|
129161
129218
|
|
|
129162
129219
|
> **request**(`u`, `data?`, `opt?`): `Promise`\<[`Response`](../response/classes/Response.md)\>
|
|
129163
129220
|
|
|
129164
|
-
Defined in: [lib/undici.ts:
|
|
129221
|
+
Defined in: [lib/undici.ts:471](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L471)
|
|
129165
129222
|
|
|
129166
129223
|
发起一个请求
|
|
129167
129224
|
|
|
@@ -129198,7 +129255,7 @@ lib/undici/functions/rproxy.md
|
|
|
129198
129255
|
|
|
129199
129256
|
> **rproxy**(`ctr`, `route`, `opt?`): `Promise`\<`boolean`\>
|
|
129200
129257
|
|
|
129201
|
-
Defined in: [lib/undici.ts:
|
|
129258
|
+
Defined in: [lib/undici.ts:809](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L809)
|
|
129202
129259
|
|
|
129203
129260
|
反向代理,将本服务器的某个路由反代到其他网址
|
|
129204
129261
|
|
|
@@ -129287,7 +129344,7 @@ lib/undici/interfaces/IMproxyOptions.md
|
|
|
129287
129344
|
|
|
129288
129345
|
# Interface: IMproxyOptions
|
|
129289
129346
|
|
|
129290
|
-
Defined in: [lib/undici.ts:
|
|
129347
|
+
Defined in: [lib/undici.ts:944](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L944)
|
|
129291
129348
|
|
|
129292
129349
|
正向代理请求的传入参数选项
|
|
129293
129350
|
|
|
@@ -129297,7 +129354,7 @@ Defined in: [lib/undici.ts:943](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129297
129354
|
|
|
129298
129355
|
> `optional` **filter?**: (`h`) => `boolean`
|
|
129299
129356
|
|
|
129300
|
-
Defined in: [lib/undici.ts:
|
|
129357
|
+
Defined in: [lib/undici.ts:957](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L957)
|
|
129301
129358
|
|
|
129302
129359
|
过滤 header,返回 true 则留下
|
|
129303
129360
|
|
|
@@ -129317,7 +129374,7 @@ Defined in: [lib/undici.ts:956](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129317
129374
|
|
|
129318
129375
|
> `optional` **follow?**: `number`
|
|
129319
129376
|
|
|
129320
|
-
Defined in: [lib/undici.ts:
|
|
129377
|
+
Defined in: [lib/undici.ts:947](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L947)
|
|
129321
129378
|
|
|
129322
129379
|
***
|
|
129323
129380
|
|
|
@@ -129325,7 +129382,7 @@ Defined in: [lib/undici.ts:946](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129325
129382
|
|
|
129326
129383
|
> `optional` **headers?**: [`THttpHeaders`](../type-aliases/THttpHeaders.md)
|
|
129327
129384
|
|
|
129328
|
-
Defined in: [lib/undici.ts:
|
|
129385
|
+
Defined in: [lib/undici.ts:951](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L951)
|
|
129329
129386
|
|
|
129330
129387
|
***
|
|
129331
129388
|
|
|
@@ -129333,7 +129390,7 @@ Defined in: [lib/undici.ts:950](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129333
129390
|
|
|
129334
129391
|
> `optional` **hosts?**: `string` \| `Record`\<`string`, `string`\>
|
|
129335
129392
|
|
|
129336
|
-
Defined in: [lib/undici.ts:
|
|
129393
|
+
Defined in: [lib/undici.ts:949](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L949)
|
|
129337
129394
|
|
|
129338
129395
|
自定义 host 映射,如 {'www.maiyun.net': '127.0.0.1'},或全部映射到一个 host
|
|
129339
129396
|
|
|
@@ -129343,7 +129400,7 @@ Defined in: [lib/undici.ts:948](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129343
129400
|
|
|
129344
129401
|
> `optional` **keepAliveTimeout?**: `number`
|
|
129345
129402
|
|
|
129346
|
-
Defined in: [lib/undici.ts:
|
|
129403
|
+
Defined in: [lib/undici.ts:953](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L953)
|
|
129347
129404
|
|
|
129348
129405
|
空闲连接允许复用的最长秒数;非正数或无效值按未设置处理;默认无服务端提示时为 4 秒,有提示时采用提示值减 2 秒且最多 600 秒
|
|
129349
129406
|
|
|
@@ -129353,7 +129410,7 @@ Defined in: [lib/undici.ts:952](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129353
129410
|
|
|
129354
129411
|
> `optional` **local?**: `string`
|
|
129355
129412
|
|
|
129356
|
-
Defined in: [lib/undici.ts:
|
|
129413
|
+
Defined in: [lib/undici.ts:950](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L950)
|
|
129357
129414
|
|
|
129358
129415
|
***
|
|
129359
129416
|
|
|
@@ -129361,7 +129418,7 @@ Defined in: [lib/undici.ts:949](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129361
129418
|
|
|
129362
129419
|
> `optional` **reuse?**: `string` \| `Agent` \| `ProxyAgent`
|
|
129363
129420
|
|
|
129364
|
-
Defined in: [lib/undici.ts:
|
|
129421
|
+
Defined in: [lib/undici.ts:959](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L959)
|
|
129365
129422
|
|
|
129366
129423
|
默认为 default
|
|
129367
129424
|
|
|
@@ -129371,7 +129428,7 @@ Defined in: [lib/undici.ts:958](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129371
129428
|
|
|
129372
129429
|
> `optional` **reuseTimeout?**: `number`
|
|
129373
129430
|
|
|
129374
|
-
Defined in: [lib/undici.ts:
|
|
129431
|
+
Defined in: [lib/undici.ts:955](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L955)
|
|
129375
129432
|
|
|
129376
129433
|
连接建立后允许承接新请求的最长秒数;非正数或无效值按未设置处理;达到后不再复用但不会中断在途请求,默认不限制
|
|
129377
129434
|
|
|
@@ -129381,7 +129438,7 @@ Defined in: [lib/undici.ts:954](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129381
129438
|
|
|
129382
129439
|
> `optional` **timeout?**: `number`
|
|
129383
129440
|
|
|
129384
|
-
Defined in: [lib/undici.ts:
|
|
129441
|
+
Defined in: [lib/undici.ts:946](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L946)
|
|
129385
129442
|
|
|
129386
129443
|
秒数,默认 300 秒
|
|
129387
129444
|
|
|
@@ -129396,7 +129453,7 @@ lib/undici/interfaces/IRequestOptions.md
|
|
|
129396
129453
|
|
|
129397
129454
|
# Interface: IRequestOptions
|
|
129398
129455
|
|
|
129399
|
-
Defined in: [lib/undici.ts:
|
|
129456
|
+
Defined in: [lib/undici.ts:901](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L901)
|
|
129400
129457
|
|
|
129401
129458
|
请求的传入参数选项
|
|
129402
129459
|
|
|
@@ -129406,7 +129463,7 @@ Defined in: [lib/undici.ts:900](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129406
129463
|
|
|
129407
129464
|
> `optional` **cookie?**: `Record`\<`string`, [`ICookie`](../../cookie/interfaces/ICookie.md)\>
|
|
129408
129465
|
|
|
129409
|
-
Defined in: [lib/undici.ts:
|
|
129466
|
+
Defined in: [lib/undici.ts:936](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L936)
|
|
129410
129467
|
|
|
129411
129468
|
cookie 托管对象
|
|
129412
129469
|
|
|
@@ -129416,7 +129473,7 @@ cookie 托管对象
|
|
|
129416
129473
|
|
|
129417
129474
|
> `optional` **follow?**: `number`
|
|
129418
129475
|
|
|
129419
|
-
Defined in: [lib/undici.ts:
|
|
129476
|
+
Defined in: [lib/undici.ts:913](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L913)
|
|
129420
129477
|
|
|
129421
129478
|
追踪 location 次数,0 为不追踪,默认为 0
|
|
129422
129479
|
|
|
@@ -129426,7 +129483,7 @@ Defined in: [lib/undici.ts:912](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129426
129483
|
|
|
129427
129484
|
> `optional` **headers?**: [`THttpHeaders`](../type-aliases/THttpHeaders.md)
|
|
129428
129485
|
|
|
129429
|
-
Defined in: [lib/undici.ts:
|
|
129486
|
+
Defined in: [lib/undici.ts:918](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L918)
|
|
129430
129487
|
|
|
129431
129488
|
***
|
|
129432
129489
|
|
|
@@ -129434,7 +129491,7 @@ Defined in: [lib/undici.ts:917](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129434
129491
|
|
|
129435
129492
|
> `optional` **hosts?**: `string` \| `Record`\<`string`, `string`\>
|
|
129436
129493
|
|
|
129437
|
-
Defined in: [lib/undici.ts:
|
|
129494
|
+
Defined in: [lib/undici.ts:915](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L915)
|
|
129438
129495
|
|
|
129439
129496
|
自定义 host 映射,如 {'www.maiyun.net': '127.0.0.1'},或全部映射到一个 host
|
|
129440
129497
|
|
|
@@ -129444,7 +129501,7 @@ Defined in: [lib/undici.ts:914](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129444
129501
|
|
|
129445
129502
|
> `optional` **keep?**: `boolean`
|
|
129446
129503
|
|
|
129447
|
-
Defined in: [lib/undici.ts:
|
|
129504
|
+
Defined in: [lib/undici.ts:928](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L928)
|
|
129448
129505
|
|
|
129449
129506
|
连接是否保持长连接(即是否允许复用),默认为 true
|
|
129450
129507
|
|
|
@@ -129454,7 +129511,7 @@ Defined in: [lib/undici.ts:927](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129454
129511
|
|
|
129455
129512
|
> `optional` **keepAliveTimeout?**: `number`
|
|
129456
129513
|
|
|
129457
|
-
Defined in: [lib/undici.ts:
|
|
129514
|
+
Defined in: [lib/undici.ts:930](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L930)
|
|
129458
129515
|
|
|
129459
129516
|
空闲连接允许复用的最长秒数;非正数或无效值按未设置处理;默认无服务端提示时为 4 秒,有提示时采用提示值减 2 秒且最多 600 秒;自定义 Agent 由其自身配置
|
|
129460
129517
|
|
|
@@ -129464,7 +129521,7 @@ Defined in: [lib/undici.ts:929](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129464
129521
|
|
|
129465
129522
|
> `optional` **local?**: `string`
|
|
129466
129523
|
|
|
129467
|
-
Defined in: [lib/undici.ts:
|
|
129524
|
+
Defined in: [lib/undici.ts:917](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L917)
|
|
129468
129525
|
|
|
129469
129526
|
***
|
|
129470
129527
|
|
|
@@ -129472,7 +129529,7 @@ Defined in: [lib/undici.ts:916](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129472
129529
|
|
|
129473
129530
|
> `optional` **log?**: `boolean`
|
|
129474
129531
|
|
|
129475
|
-
Defined in: [lib/undici.ts:
|
|
129532
|
+
Defined in: [lib/undici.ts:938](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L938)
|
|
129476
129533
|
|
|
129477
129534
|
若有异常写入文件日志,默认为 true
|
|
129478
129535
|
|
|
@@ -129482,7 +129539,7 @@ Defined in: [lib/undici.ts:937](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129482
129539
|
|
|
129483
129540
|
> `optional` **method?**: `"GET"` \| `"POST"` \| `"PUT"` \| `"DELETE"` \| `"OPTIONS"`
|
|
129484
129541
|
|
|
129485
|
-
Defined in: [lib/undici.ts:
|
|
129542
|
+
Defined in: [lib/undici.ts:902](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L902)
|
|
129486
129543
|
|
|
129487
129544
|
***
|
|
129488
129545
|
|
|
@@ -129490,7 +129547,7 @@ Defined in: [lib/undici.ts:901](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129490
129547
|
|
|
129491
129548
|
> `optional` **mproxy?**: `object`
|
|
129492
129549
|
|
|
129493
|
-
Defined in: [lib/undici.ts:
|
|
129550
|
+
Defined in: [lib/undici.ts:920](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L920)
|
|
129494
129551
|
|
|
129495
129552
|
正向 mproxy 代理,url 如 https://xxx/abc
|
|
129496
129553
|
|
|
@@ -129518,7 +129575,7 @@ Defined in: [lib/undici.ts:919](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129518
129575
|
|
|
129519
129576
|
> `optional` **retry?**: `number`
|
|
129520
129577
|
|
|
129521
|
-
Defined in: [lib/undici.ts:
|
|
129578
|
+
Defined in: [lib/undici.ts:907](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L907)
|
|
129522
129579
|
|
|
129523
129580
|
网络异常后的重试次数,默认 0;流式请求体不可重试,非幂等请求需由调用方保证安全
|
|
129524
129581
|
|
|
@@ -129528,9 +129585,9 @@ Defined in: [lib/undici.ts:906](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129528
129585
|
|
|
129529
129586
|
> `optional` **retryJson?**: `number`
|
|
129530
129587
|
|
|
129531
|
-
Defined in: [lib/undici.ts:
|
|
129588
|
+
Defined in: [lib/undici.ts:909](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L909)
|
|
129532
129589
|
|
|
129533
|
-
JSON
|
|
129590
|
+
JSON 解析失败或重试验证未通过后的重试次数,默认 0;仅适用于 ResponseJson 快捷方法,非幂等请求需由调用方保证安全
|
|
129534
129591
|
|
|
129535
129592
|
***
|
|
129536
129593
|
|
|
@@ -129538,9 +129595,9 @@ JSON 解析失败后的重试次数,默认 0;仅适用于 ResponseJson 快
|
|
|
129538
129595
|
|
|
129539
129596
|
> `optional` **retryJsonHandler?**: (`json`) => `boolean`
|
|
129540
129597
|
|
|
129541
|
-
Defined in: [lib/undici.ts:
|
|
129598
|
+
Defined in: [lib/undici.ts:911](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L911)
|
|
129542
129599
|
|
|
129543
|
-
JSON 重试验证方法;返回 false 时按 retryJson
|
|
129600
|
+
JSON 重试验证方法;返回 false 时按 retryJson 的设置重试,耗尽后仍返回最后一次解析结果,业务结果由调用方判断;仅适用于 ResponseJson 快捷方法
|
|
129544
129601
|
|
|
129545
129602
|
#### Parameters
|
|
129546
129603
|
|
|
@@ -129558,7 +129615,7 @@ JSON 重试验证方法;返回 false 时按 retryJson 的设置重试,仅适
|
|
|
129558
129615
|
|
|
129559
129616
|
> `optional` **reuse?**: `string` \| `Agent` \| `ProxyAgent`
|
|
129560
129617
|
|
|
129561
|
-
Defined in: [lib/undici.ts:
|
|
129618
|
+
Defined in: [lib/undici.ts:934](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L934)
|
|
129562
129619
|
|
|
129563
129620
|
复用池名/Agent,默认为 default
|
|
129564
129621
|
|
|
@@ -129568,7 +129625,7 @@ Defined in: [lib/undici.ts:933](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129568
129625
|
|
|
129569
129626
|
> `optional` **reuseTimeout?**: `number`
|
|
129570
129627
|
|
|
129571
|
-
Defined in: [lib/undici.ts:
|
|
129628
|
+
Defined in: [lib/undici.ts:932](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L932)
|
|
129572
129629
|
|
|
129573
129630
|
连接建立后允许承接新请求的最长秒数;非正数或无效值按未设置处理;达到后不再复用但不会中断在途请求,默认不限制;自定义 Agent 由其自身配置
|
|
129574
129631
|
|
|
@@ -129578,7 +129635,7 @@ Defined in: [lib/undici.ts:931](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129578
129635
|
|
|
129579
129636
|
> `optional` **save?**: `string`
|
|
129580
129637
|
|
|
129581
|
-
Defined in: [lib/undici.ts:
|
|
129638
|
+
Defined in: [lib/undici.ts:916](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L916)
|
|
129582
129639
|
|
|
129583
129640
|
***
|
|
129584
129641
|
|
|
@@ -129586,7 +129643,7 @@ Defined in: [lib/undici.ts:915](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129586
129643
|
|
|
129587
129644
|
> `optional` **signal?**: `AbortSignal`
|
|
129588
129645
|
|
|
129589
|
-
Defined in: [lib/undici.ts:
|
|
129646
|
+
Defined in: [lib/undici.ts:940](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L940)
|
|
129590
129647
|
|
|
129591
129648
|
请求中止信号
|
|
129592
129649
|
|
|
@@ -129596,7 +129653,7 @@ Defined in: [lib/undici.ts:939](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129596
129653
|
|
|
129597
129654
|
> `optional` **timeout?**: `number`
|
|
129598
129655
|
|
|
129599
|
-
Defined in: [lib/undici.ts:
|
|
129656
|
+
Defined in: [lib/undici.ts:905](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L905)
|
|
129600
129657
|
|
|
129601
129658
|
秒数,默认 300 秒
|
|
129602
129659
|
|
|
@@ -129606,7 +129663,7 @@ Defined in: [lib/undici.ts:904](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129606
129663
|
|
|
129607
129664
|
> `optional` **type?**: `"form"` \| `"json"`
|
|
129608
129665
|
|
|
129609
|
-
Defined in: [lib/undici.ts:
|
|
129666
|
+
Defined in: [lib/undici.ts:903](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L903)
|
|
129610
129667
|
|
|
129611
129668
|
lib/undici/interfaces/IRproxyOptions.md
|
|
129612
129669
|
---
|
|
@@ -129619,7 +129676,7 @@ lib/undici/interfaces/IRproxyOptions.md
|
|
|
129619
129676
|
|
|
129620
129677
|
# Interface: IRproxyOptions
|
|
129621
129678
|
|
|
129622
|
-
Defined in: [lib/undici.ts:
|
|
129679
|
+
Defined in: [lib/undici.ts:963](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L963)
|
|
129623
129680
|
|
|
129624
129681
|
反向代理请求的传入参数选项
|
|
129625
129682
|
|
|
@@ -129629,7 +129686,7 @@ Defined in: [lib/undici.ts:962](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129629
129686
|
|
|
129630
129687
|
> `optional` **body?**: `string` \| `Buffer`\<`ArrayBufferLike`\> \| `Readable`
|
|
129631
129688
|
|
|
129632
|
-
Defined in: [lib/undici.ts:
|
|
129689
|
+
Defined in: [lib/undici.ts:986](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L986)
|
|
129633
129690
|
|
|
129634
129691
|
手动传入请求体(优先于原始 req 流),用于 req 流已消费后仍需转发 body 的场景
|
|
129635
129692
|
|
|
@@ -129639,7 +129696,7 @@ Defined in: [lib/undici.ts:985](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129639
129696
|
|
|
129640
129697
|
> `optional` **filter?**: (`h`) => `boolean`
|
|
129641
129698
|
|
|
129642
|
-
Defined in: [lib/undici.ts:
|
|
129699
|
+
Defined in: [lib/undici.ts:976](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L976)
|
|
129643
129700
|
|
|
129644
129701
|
过滤 header,返回 true 则留下
|
|
129645
129702
|
|
|
@@ -129659,7 +129716,7 @@ Defined in: [lib/undici.ts:975](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129659
129716
|
|
|
129660
129717
|
> `optional` **follow?**: `number`
|
|
129661
129718
|
|
|
129662
|
-
Defined in: [lib/undici.ts:
|
|
129719
|
+
Defined in: [lib/undici.ts:966](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L966)
|
|
129663
129720
|
|
|
129664
129721
|
***
|
|
129665
129722
|
|
|
@@ -129667,7 +129724,7 @@ Defined in: [lib/undici.ts:965](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129667
129724
|
|
|
129668
129725
|
> `optional` **headers?**: [`THttpHeaders`](../type-aliases/THttpHeaders.md)
|
|
129669
129726
|
|
|
129670
|
-
Defined in: [lib/undici.ts:
|
|
129727
|
+
Defined in: [lib/undici.ts:970](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L970)
|
|
129671
129728
|
|
|
129672
129729
|
***
|
|
129673
129730
|
|
|
@@ -129675,7 +129732,7 @@ Defined in: [lib/undici.ts:969](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129675
129732
|
|
|
129676
129733
|
> `optional` **hosts?**: `string` \| `Record`\<`string`, `string`\>
|
|
129677
129734
|
|
|
129678
|
-
Defined in: [lib/undici.ts:
|
|
129735
|
+
Defined in: [lib/undici.ts:968](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L968)
|
|
129679
129736
|
|
|
129680
129737
|
自定义 host 映射,如 {'www.maiyun.net': '127.0.0.1'},或全部映射到一个 host
|
|
129681
129738
|
|
|
@@ -129685,7 +129742,7 @@ Defined in: [lib/undici.ts:967](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129685
129742
|
|
|
129686
129743
|
> `optional` **keepAliveTimeout?**: `number`
|
|
129687
129744
|
|
|
129688
|
-
Defined in: [lib/undici.ts:
|
|
129745
|
+
Defined in: [lib/undici.ts:972](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L972)
|
|
129689
129746
|
|
|
129690
129747
|
空闲连接允许复用的最长秒数;非正数或无效值按未设置处理;默认无服务端提示时为 4 秒,有提示时采用提示值减 2 秒且最多 600 秒
|
|
129691
129748
|
|
|
@@ -129695,7 +129752,7 @@ Defined in: [lib/undici.ts:971](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129695
129752
|
|
|
129696
129753
|
> `optional` **local?**: `string`
|
|
129697
129754
|
|
|
129698
|
-
Defined in: [lib/undici.ts:
|
|
129755
|
+
Defined in: [lib/undici.ts:969](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L969)
|
|
129699
129756
|
|
|
129700
129757
|
***
|
|
129701
129758
|
|
|
@@ -129703,7 +129760,7 @@ Defined in: [lib/undici.ts:968](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129703
129760
|
|
|
129704
129761
|
> `optional` **mproxy?**: `object`
|
|
129705
129762
|
|
|
129706
|
-
Defined in: [lib/undici.ts:
|
|
129763
|
+
Defined in: [lib/undici.ts:978](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L978)
|
|
129707
129764
|
|
|
129708
129765
|
正向 mproxy 代理,url 如 https://xxx/abc
|
|
129709
129766
|
|
|
@@ -129731,7 +129788,7 @@ Defined in: [lib/undici.ts:977](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129731
129788
|
|
|
129732
129789
|
> `optional` **querys?**: `Record`\<`string`, `any`\>
|
|
129733
129790
|
|
|
129734
|
-
Defined in: [lib/undici.ts:
|
|
129791
|
+
Defined in: [lib/undici.ts:988](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L988)
|
|
129735
129792
|
|
|
129736
129793
|
自定义 GET 查询参数,传入后直接替换代理目标 URL 的整个 query string
|
|
129737
129794
|
|
|
@@ -129741,7 +129798,7 @@ Defined in: [lib/undici.ts:987](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129741
129798
|
|
|
129742
129799
|
> `optional` **reuse?**: `string` \| `Agent` \| `ProxyAgent`
|
|
129743
129800
|
|
|
129744
|
-
Defined in: [lib/undici.ts:
|
|
129801
|
+
Defined in: [lib/undici.ts:990](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L990)
|
|
129745
129802
|
|
|
129746
129803
|
默认为 default
|
|
129747
129804
|
|
|
@@ -129751,7 +129808,7 @@ Defined in: [lib/undici.ts:989](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129751
129808
|
|
|
129752
129809
|
> `optional` **reuseTimeout?**: `number`
|
|
129753
129810
|
|
|
129754
|
-
Defined in: [lib/undici.ts:
|
|
129811
|
+
Defined in: [lib/undici.ts:974](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L974)
|
|
129755
129812
|
|
|
129756
129813
|
连接建立后允许承接新请求的最长秒数;非正数或无效值按未设置处理;达到后不再复用但不会中断在途请求,默认不限制
|
|
129757
129814
|
|
|
@@ -129761,7 +129818,7 @@ Defined in: [lib/undici.ts:973](https://github.com/maiyunnet/kebab/blob/master/l
|
|
|
129761
129818
|
|
|
129762
129819
|
> `optional` **timeout?**: `number`
|
|
129763
129820
|
|
|
129764
|
-
Defined in: [lib/undici.ts:
|
|
129821
|
+
Defined in: [lib/undici.ts:965](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L965)
|
|
129765
129822
|
|
|
129766
129823
|
秒数,默认 300 秒
|
|
129767
129824
|
|
|
@@ -130316,7 +130373,7 @@ lib/undici/type-aliases/THttpHeaders.md
|
|
|
130316
130373
|
|
|
130317
130374
|
> **THttpHeaders** = `http.IncomingHttpHeaders` & `object`
|
|
130318
130375
|
|
|
130319
|
-
Defined in: [lib/undici.ts:
|
|
130376
|
+
Defined in: [lib/undici.ts:995](https://github.com/maiyunnet/kebab/blob/master/lib/undici.ts#L995)
|
|
130320
130377
|
|
|
130321
130378
|
http headers
|
|
130322
130379
|
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* --- 本文件用来定义每个目录实体地址的常量 ---
|
|
7
7
|
*/
|
|
8
8
|
/** --- 当前系统版本号 --- */
|
|
9
|
-
export const VER = '9.
|
|
9
|
+
export const VER = '9.24.0';
|
|
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
|
@@ -290,6 +290,16 @@ export declare function sendPackage(content: string, hosts?: string[] | 'config'
|
|
|
290
290
|
'result': boolean;
|
|
291
291
|
'return': string;
|
|
292
292
|
}>>;
|
|
293
|
+
/**
|
|
294
|
+
* --- 全量替换各节点 conf/vhost/ 中的文件,不自动 reload ---
|
|
295
|
+
* @param files 文件名与 JSON 原文的非空集合;仅允许直接 .json 文件名,内容为 IVhost 或 IVhost[]
|
|
296
|
+
* @param hosts 节点列表,config 使用全局 hosts;省略或列表为空时更新本机
|
|
297
|
+
* @returns 各节点的写入结果;成功表示目录替换完成,需自行调用 sendReload 生效
|
|
298
|
+
*/
|
|
299
|
+
export declare function sendVhost(files: Record<string, string>, hosts?: string[] | 'config'): Promise<Record<string, {
|
|
300
|
+
'result': boolean;
|
|
301
|
+
'return': string;
|
|
302
|
+
}>>;
|
|
293
303
|
/** --- log 设置的选项 --- */
|
|
294
304
|
export interface ILogOptions {
|
|
295
305
|
'path'?: string;
|
package/lib/core.js
CHANGED
|
@@ -971,6 +971,41 @@ export async function sendPackage(content, hosts) {
|
|
|
971
971
|
}));
|
|
972
972
|
return Object.fromEntries(results);
|
|
973
973
|
}
|
|
974
|
+
/**
|
|
975
|
+
* --- 全量替换各节点 conf/vhost/ 中的文件,不自动 reload ---
|
|
976
|
+
* @param files 文件名与 JSON 原文的非空集合;仅允许直接 .json 文件名,内容为 IVhost 或 IVhost[]
|
|
977
|
+
* @param hosts 节点列表,config 使用全局 hosts;省略或列表为空时更新本机
|
|
978
|
+
* @returns 各节点的写入结果;成功表示目录替换完成,需自行调用 sendReload 生效
|
|
979
|
+
*/
|
|
980
|
+
export async function sendVhost(files, hosts) {
|
|
981
|
+
if (hosts === 'config') {
|
|
982
|
+
hosts = globalConfig.hosts;
|
|
983
|
+
}
|
|
984
|
+
if (!hosts?.length) {
|
|
985
|
+
hosts = ['127.0.0.1'];
|
|
986
|
+
}
|
|
987
|
+
// --- 每个节点独立发送和返回,失败节点可单独重试 ---
|
|
988
|
+
const results = await Promise.all(hosts.map(async (host) => {
|
|
989
|
+
try {
|
|
990
|
+
const res = await lUndici.postJson(`http://${host}:${globalConfig.rpcPort}/${lCrypto.aesEncrypt(lText.stringifyJson({
|
|
991
|
+
'action': 'vhost',
|
|
992
|
+
'time': lTime.stamp(),
|
|
993
|
+
}), globalConfig.rpcSecret)}`, files, {
|
|
994
|
+
'timeout': 30,
|
|
995
|
+
});
|
|
996
|
+
const content = await res.getContent();
|
|
997
|
+
if (!content) {
|
|
998
|
+
return [host, { 'result': false, 'return': 'Network error' }];
|
|
999
|
+
}
|
|
1000
|
+
const str = content.toString();
|
|
1001
|
+
return [host, { 'result': str === 'Done', 'return': str }];
|
|
1002
|
+
}
|
|
1003
|
+
catch {
|
|
1004
|
+
return [host, { 'result': false, 'return': 'Network error' }];
|
|
1005
|
+
}
|
|
1006
|
+
}));
|
|
1007
|
+
return Object.fromEntries(results);
|
|
1008
|
+
}
|
|
974
1009
|
/**
|
|
975
1010
|
* --- 写入文件日志 ---
|
|
976
1011
|
* @param opt 选项
|
package/lib/undici.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export declare function postJson(u: string, data: kebab.Json[] | Record<string,
|
|
|
40
40
|
* @param u 网址
|
|
41
41
|
* @param data 数据
|
|
42
42
|
* @param opt 选项
|
|
43
|
-
* @returns JSON
|
|
43
|
+
* @returns 最后一次响应的 JSON 数据,重试验证未通过也保留;请求或读取失败返回 null;JSON 解析失败返回 false
|
|
44
44
|
*/
|
|
45
45
|
export declare function postJsonResponseJson(u: string, data: kebab.Json[] | Record<string, kebab.Json>, opt?: IRequestOptions): Promise<kebab.Json | null | false>;
|
|
46
46
|
/**
|
|
@@ -48,14 +48,14 @@ export declare function postJsonResponseJson(u: string, data: kebab.Json[] | Rec
|
|
|
48
48
|
* @param u 网址
|
|
49
49
|
* @param data 数据
|
|
50
50
|
* @param opt 选项
|
|
51
|
-
* @returns JSON
|
|
51
|
+
* @returns 最后一次响应的 JSON 数据,重试验证未通过也保留;请求或读取失败返回 null;JSON 解析失败返回 false
|
|
52
52
|
*/
|
|
53
53
|
export declare function postResponseJson(u: string, data: Record<string, kebab.Json>, opt?: IRequestOptions): Promise<kebab.Json | null | false>;
|
|
54
54
|
/**
|
|
55
55
|
* --- 发起 GET 请求并解析 JSON 响应 ---
|
|
56
56
|
* @param u 网址
|
|
57
57
|
* @param opt 选项
|
|
58
|
-
* @returns JSON
|
|
58
|
+
* @returns 最后一次响应的 JSON 数据,重试验证未通过也保留;请求或读取失败返回 null;JSON 解析失败返回 false
|
|
59
59
|
*/
|
|
60
60
|
export declare function getResponseJson(u: string, opt?: IRequestOptions): Promise<kebab.Json | null | false>;
|
|
61
61
|
/**
|
|
@@ -135,9 +135,9 @@ export interface IRequestOptions {
|
|
|
135
135
|
'timeout'?: number;
|
|
136
136
|
/** --- 网络异常后的重试次数,默认 0;流式请求体不可重试,非幂等请求需由调用方保证安全 --- */
|
|
137
137
|
'retry'?: number;
|
|
138
|
-
/** --- JSON
|
|
138
|
+
/** --- JSON 解析失败或重试验证未通过后的重试次数,默认 0;仅适用于 ResponseJson 快捷方法,非幂等请求需由调用方保证安全 --- */
|
|
139
139
|
'retryJson'?: number;
|
|
140
|
-
/** --- JSON 重试验证方法;返回 false 时按 retryJson
|
|
140
|
+
/** --- JSON 重试验证方法;返回 false 时按 retryJson 的设置重试,耗尽后仍返回最后一次解析结果,业务结果由调用方判断;仅适用于 ResponseJson 快捷方法 --- */
|
|
141
141
|
'retryJsonHandler'?: (json: kebab.Json) => boolean;
|
|
142
142
|
/** --- 追踪 location 次数,0 为不追踪,默认为 0 --- */
|
|
143
143
|
'follow'?: number;
|
package/lib/undici.js
CHANGED
|
@@ -165,12 +165,12 @@ export async function postJson(u, data, opt = {}) {
|
|
|
165
165
|
return request(u, data, opt);
|
|
166
166
|
}
|
|
167
167
|
/**
|
|
168
|
-
* --- 发起请求并解析 JSON
|
|
168
|
+
* --- 发起请求并解析 JSON 响应,解析失败或重试验证未通过时重新请求 ---
|
|
169
169
|
* @param u 网址
|
|
170
170
|
* @param data 请求数据
|
|
171
171
|
* @param opt 请求选项
|
|
172
172
|
* @param action 日志动作名
|
|
173
|
-
* @returns JSON
|
|
173
|
+
* @returns 最后一次响应的 JSON 数据,重试验证未通过也保留;请求或读取失败返回 null;JSON 解析失败返回 false
|
|
174
174
|
*/
|
|
175
175
|
async function requestResponseJson(u, data, opt, action) {
|
|
176
176
|
const retryJson = normalizeRetry(opt.retryJson);
|
|
@@ -195,7 +195,8 @@ async function requestResponseJson(u, data, opt, action) {
|
|
|
195
195
|
const reason = json ? 'retry json handler returned false' : 'parse json failed';
|
|
196
196
|
lCore.log({}, `[UNDICI][${action}] ${reason}, url: ${u}${requestData}, content: ${rtnStr}`, '-neterror');
|
|
197
197
|
}
|
|
198
|
-
|
|
198
|
+
// --- 重试耗尽仍保留本次解析结果,交给调用方判断业务错误 ---
|
|
199
|
+
return json;
|
|
199
200
|
}
|
|
200
201
|
return false;
|
|
201
202
|
}
|
|
@@ -204,7 +205,7 @@ async function requestResponseJson(u, data, opt, action) {
|
|
|
204
205
|
* @param u 网址
|
|
205
206
|
* @param data 数据
|
|
206
207
|
* @param opt 选项
|
|
207
|
-
* @returns JSON
|
|
208
|
+
* @returns 最后一次响应的 JSON 数据,重试验证未通过也保留;请求或读取失败返回 null;JSON 解析失败返回 false
|
|
208
209
|
*/
|
|
209
210
|
export async function postJsonResponseJson(u, data, opt = {}) {
|
|
210
211
|
opt.method = 'POST';
|
|
@@ -216,7 +217,7 @@ export async function postJsonResponseJson(u, data, opt = {}) {
|
|
|
216
217
|
* @param u 网址
|
|
217
218
|
* @param data 数据
|
|
218
219
|
* @param opt 选项
|
|
219
|
-
* @returns JSON
|
|
220
|
+
* @returns 最后一次响应的 JSON 数据,重试验证未通过也保留;请求或读取失败返回 null;JSON 解析失败返回 false
|
|
220
221
|
*/
|
|
221
222
|
export async function postResponseJson(u, data, opt = {}) {
|
|
222
223
|
opt.method = 'POST';
|
|
@@ -226,7 +227,7 @@ export async function postResponseJson(u, data, opt = {}) {
|
|
|
226
227
|
* --- 发起 GET 请求并解析 JSON 响应 ---
|
|
227
228
|
* @param u 网址
|
|
228
229
|
* @param opt 选项
|
|
229
|
-
* @returns JSON
|
|
230
|
+
* @returns 最后一次响应的 JSON 数据,重试验证未通过也保留;请求或读取失败返回 null;JSON 解析失败返回 false
|
|
230
231
|
*/
|
|
231
232
|
export async function getResponseJson(u, opt = {}) {
|
|
232
233
|
return requestResponseJson(u, undefined, opt, 'GETRESPONSEJSON');
|
package/package.json
CHANGED
package/sys/master.js
CHANGED
|
@@ -20,12 +20,28 @@ import * as lCrypto from '#kebab/lib/crypto.js';
|
|
|
20
20
|
import * as lTime from '#kebab/lib/time.js';
|
|
21
21
|
import * as lZip from '#kebab/lib/zip.js';
|
|
22
22
|
import * as masterLog from '#kebab/abox/master-log.js';
|
|
23
|
+
import * as masterVhost from '#kebab/abox/master-vhost.js';
|
|
23
24
|
/**
|
|
24
25
|
* --- 解析一行 CSV,保留空字段,并处理字段里的逗号和引号 ---
|
|
25
26
|
* @param line 不含换行符的 CSV 行
|
|
26
27
|
* @returns 按原顺序排列的字段
|
|
27
28
|
*/
|
|
28
29
|
const parseCsvLine = masterLog.parseCsvLine;
|
|
30
|
+
/**
|
|
31
|
+
* --- 串行替换 vhost 目录;先写临时目录,切换失败时恢复旧目录 ---
|
|
32
|
+
* @param directory 固定的 vhost 目录
|
|
33
|
+
* @param files 已通过校验的文件名与 JSON 原文
|
|
34
|
+
* @param report 记录替换、恢复或临时目录清理失败
|
|
35
|
+
* @returns 成功返回 Done;失败返回错误信息,恢复失败时包含备份目录
|
|
36
|
+
*/
|
|
37
|
+
const replaceVhost = masterVhost.replace;
|
|
38
|
+
/**
|
|
39
|
+
* --- 校验非空 vhost 文件集合:仅直接 .json 文件名,不允许路径或大小写重名 ---
|
|
40
|
+
* --- 每份 JSON 为 IVhost 或其数组:domains 为字符串数组,root 为字符串,name/remark 可选字符串 ---
|
|
41
|
+
* @param files POST 中的文件集合
|
|
42
|
+
* @returns true 表示所有文件可写入;false 表示整批拒绝,不修改旧配置
|
|
43
|
+
*/
|
|
44
|
+
const isVhostFiles = masterVhost.isFiles;
|
|
29
45
|
/** --- 当前运行中的子进程列表 --- */
|
|
30
46
|
const workerList = {};
|
|
31
47
|
/** --- 是否已开始停止整个服务 --- */
|
|
@@ -425,6 +441,23 @@ function createRpcListener() {
|
|
|
425
441
|
}
|
|
426
442
|
break;
|
|
427
443
|
}
|
|
444
|
+
case 'vhost': {
|
|
445
|
+
if (req.method !== 'POST') {
|
|
446
|
+
res.end('Invalid method');
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
const body = await sRoute.getPost(req);
|
|
450
|
+
if (body === false || !isVhostFiles(body.raw)) {
|
|
451
|
+
res.end('Invalid vhost files');
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
// --- 仅更新磁盘配置,是否 reload 由调用方决定 ---
|
|
455
|
+
const result = await replaceVhost(kebab.VHOST_CWD, body.raw, (message, error) => {
|
|
456
|
+
lCore.display(`[master] [vhost] ${message}`, error);
|
|
457
|
+
});
|
|
458
|
+
res.end(result);
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
428
461
|
case 'code': {
|
|
429
462
|
// --- 更新 code 代码包 ---
|
|
430
463
|
const rtn = await sRoute.getFormData(req);
|