@maiyunnet/kebab 9.4.0 → 9.4.1
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 +3 -3
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/lib/core.d.ts +1 -1
- package/lib/undici/response.d.ts +1 -1
- package/package.json +1 -1
- package/sys/master.js +38 -22
- package/www/example/ctr/test.js +13 -3
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.4.
|
|
1363
|
+
> `const` **VER**: `"9.4.1"` = `'9.4.1'`
|
|
1364
1364
|
|
|
1365
1365
|
Defined in: [index.ts:10](https://github.com/maiyunnet/kebab/blob/master/index.ts#L10)
|
|
1366
1366
|
|
|
@@ -3460,7 +3460,7 @@ lib/core/functions/getLog.md
|
|
|
3460
3460
|
|
|
3461
3461
|
# Function: getLog()
|
|
3462
3462
|
|
|
3463
|
-
> **getLog**(`opt`): `Promise`\<`false` \| `string`[][] \| `null`\>
|
|
3463
|
+
> **getLog**(`opt`): `Promise`\<`false` \| `any`[] \| `string`[][] \| `null`\>
|
|
3464
3464
|
|
|
3465
3465
|
Defined in: [lib/core.ts:1031](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1031)
|
|
3466
3466
|
|
|
@@ -3522,7 +3522,7 @@ Defined in: [lib/core.ts:1031](https://github.com/maiyunnet/kebab/blob/master/li
|
|
|
3522
3522
|
|
|
3523
3523
|
## Returns
|
|
3524
3524
|
|
|
3525
|
-
`Promise`\<`false` \| `string`[][] \| `null`\>
|
|
3525
|
+
`Promise`\<`false` \| `any`[] \| `string`[][] \| `null`\>
|
|
3526
3526
|
|
|
3527
3527
|
lib/core/functions/ip.md
|
|
3528
3528
|
---
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* --- 本文件用来定义每个目录实体地址的常量 ---
|
|
7
7
|
*/
|
|
8
8
|
/** --- 当前系统版本号 --- */
|
|
9
|
-
export const VER = '9.4.
|
|
9
|
+
export const VER = '9.4.1';
|
|
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
|
@@ -268,7 +268,7 @@ export declare function getLog(opt: {
|
|
|
268
268
|
'limit'?: number;
|
|
269
269
|
/** --- 获取局域网服务器的日志,为空代表获取本机的 --- */
|
|
270
270
|
'host'?: string;
|
|
271
|
-
}): Promise<string[][] | null | false>;
|
|
271
|
+
}): Promise<string[][] | kebab.Json[] | null | false>;
|
|
272
272
|
/**
|
|
273
273
|
* --- 获取目录内文件/文件夹列表 ---
|
|
274
274
|
* @param opt 参数
|
package/lib/undici/response.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export declare class Response {
|
|
|
31
31
|
/**
|
|
32
32
|
* --- 获取响应读取流对象 ---
|
|
33
33
|
*/
|
|
34
|
-
getStream():
|
|
34
|
+
getStream(): (import("undici/types/readable").default & undici.Dispatcher.BodyMixin) | zlib.Gunzip | zlib.Inflate | zlib.BrotliDecompress | null;
|
|
35
35
|
/**
|
|
36
36
|
* --- 获取原生响应读取流对象 ---
|
|
37
37
|
*/
|
package/package.json
CHANGED
package/sys/master.js
CHANGED
|
@@ -523,9 +523,15 @@ function createRpcListener() {
|
|
|
523
523
|
let limit = msg.limit ?? 100;
|
|
524
524
|
/** --- 剩余 offset --- */
|
|
525
525
|
let offset = msg.offset ?? 0;
|
|
526
|
+
/**
|
|
527
|
+
* --- csv 格式:string[][] 每行是字段数组,顺序与表头一致 ---
|
|
528
|
+
* --- [['H:i:s', unix, url, cookie, session, userAgent, realIp, cfIp, xIp, osMem, procMem, message], ...] ---
|
|
529
|
+
* --- jsonl 格式:object[] 每行是解析后的 JSON 对象 ---
|
|
530
|
+
* --- [{ time, unix, url, cookie, session, userAgent, realIp, cfIp, xIp, osMem, procMem, message }, ...] ---
|
|
531
|
+
*/
|
|
526
532
|
const rtn = await new Promise(resolve => {
|
|
527
533
|
const list = [];
|
|
528
|
-
/** ---
|
|
534
|
+
/** --- 当前行号(jsonl 无表头,csv 有表头,两者处理逻辑不同)--- */
|
|
529
535
|
let line = 0;
|
|
530
536
|
/** --- 当前行数据 --- */
|
|
531
537
|
let packet = '';
|
|
@@ -552,34 +558,44 @@ function createRpcListener() {
|
|
|
552
558
|
buf = buf.slice(index + 1);
|
|
553
559
|
++line;
|
|
554
560
|
// --- 先执行下本次完成的 ---
|
|
555
|
-
|
|
561
|
+
// --- csv:line > 1 跳过表头行;jsonl:无表头,line >= 1 即可处理 ---
|
|
562
|
+
if (format === 'jsonl' ? line >= 1 : line > 1) {
|
|
556
563
|
if (offset === 0) {
|
|
557
564
|
if (!msg.search || packet.includes(msg.search)) {
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
565
|
+
if (format === 'jsonl') {
|
|
566
|
+
const obj = lText.parseJson(packet);
|
|
567
|
+
if (obj) {
|
|
568
|
+
list.push(obj);
|
|
569
|
+
--limit;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
573
|
+
const result = [];
|
|
574
|
+
let currentField = '';
|
|
575
|
+
let inQuotes = false;
|
|
576
|
+
for (let i = 0; i < packet.length; ++i) {
|
|
577
|
+
const char = packet[i];
|
|
578
|
+
if (char === '"') {
|
|
579
|
+
if (inQuotes && packet[i + 1] === '"') {
|
|
580
|
+
currentField += '"';
|
|
581
|
+
++i;
|
|
582
|
+
}
|
|
583
|
+
else {
|
|
584
|
+
inQuotes = !inQuotes;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
else if (char === ',' && !inQuotes) {
|
|
588
|
+
result.push(currentField);
|
|
589
|
+
currentField = '';
|
|
567
590
|
}
|
|
568
591
|
else {
|
|
569
|
-
|
|
592
|
+
currentField += char;
|
|
570
593
|
}
|
|
571
594
|
}
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
}
|
|
576
|
-
else {
|
|
577
|
-
currentField += char;
|
|
578
|
-
}
|
|
595
|
+
result.push(currentField);
|
|
596
|
+
list.push(result);
|
|
597
|
+
--limit;
|
|
579
598
|
}
|
|
580
|
-
result.push(currentField);
|
|
581
|
-
list.push(result);
|
|
582
|
-
--limit;
|
|
583
599
|
}
|
|
584
600
|
}
|
|
585
601
|
else {
|
package/www/example/ctr/test.js
CHANGED
|
@@ -1395,11 +1395,21 @@ for (let i = 0; i < 30000; ++i) {
|
|
|
1395
1395
|
const echo = [];
|
|
1396
1396
|
echo.push('<table style="width: 100%;">');
|
|
1397
1397
|
if (list) {
|
|
1398
|
-
echo.push('<tr><th>TIME</th><th>UNIX</th><th>URL</th><th>COOKIE</th><th>SESSION</th><th>USER_AGENT</th><th>REALIP</th><th>
|
|
1398
|
+
echo.push('<tr><th>TIME</th><th>UNIX</th><th>URL</th><th>COOKIE</th><th>SESSION</th><th>USER_AGENT</th><th>REALIP</th><th>CFIP</th><th>XIP</th><th>OS</th><th>PROCESS</th><th>MESSAGE</th></tr>');
|
|
1399
1399
|
for (const row of list) {
|
|
1400
1400
|
echo.push('<tr>');
|
|
1401
|
-
|
|
1402
|
-
|
|
1401
|
+
if (Array.isArray(row)) {
|
|
1402
|
+
// --- csv 格式:string[] ---
|
|
1403
|
+
for (const item of row) {
|
|
1404
|
+
echo.push('<td>' + lText.htmlescape(item) + '</td>');
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
else {
|
|
1408
|
+
// --- jsonl 格式:object ---
|
|
1409
|
+
const r = row;
|
|
1410
|
+
for (const val of [r.time, r.unix, r.url, r.cookie, r.session, r.userAgent, r.realIp, r.cfIp, r.xIp, r.osMem, r.procMem, r.message]) {
|
|
1411
|
+
echo.push('<td>' + lText.htmlescape(typeof val === 'string' ? val : lText.stringifyJson(val) ?? '') + '</td>');
|
|
1412
|
+
}
|
|
1403
1413
|
}
|
|
1404
1414
|
echo.push('</tr>');
|
|
1405
1415
|
}
|