@maiyunnet/kebab 9.29.2 → 9.29.4
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 +27 -27
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/lib/ws.js +11 -3
- package/package.json +1 -1
package/doc/kebab-rag.md
CHANGED
|
@@ -1913,7 +1913,7 @@ index/variables/VER.md
|
|
|
1913
1913
|
|
|
1914
1914
|
# Variable: VER
|
|
1915
1915
|
|
|
1916
|
-
> `const` **VER**: `"9.29.
|
|
1916
|
+
> `const` **VER**: `"9.29.4"` = `'9.29.4'`
|
|
1917
1917
|
|
|
1918
1918
|
Defined in: [index.ts:8](https://github.com/maiyunnet/kebab/blob/master/index.ts#L8)
|
|
1919
1919
|
|
|
@@ -132160,7 +132160,7 @@ lib/ws/classes/Socket.md
|
|
|
132160
132160
|
|
|
132161
132161
|
# Class: Socket
|
|
132162
132162
|
|
|
132163
|
-
Defined in: [lib/ws.ts:
|
|
132163
|
+
Defined in: [lib/ws.ts:167](https://github.com/maiyunnet/kebab/blob/master/lib/ws.ts#L167)
|
|
132164
132164
|
|
|
132165
132165
|
## Constructors
|
|
132166
132166
|
|
|
@@ -132168,7 +132168,7 @@ Defined in: [lib/ws.ts:166](https://github.com/maiyunnet/kebab/blob/master/lib/w
|
|
|
132168
132168
|
|
|
132169
132169
|
> **new Socket**(`request?`, `socket?`, `head?`, `options?`): `Socket`
|
|
132170
132170
|
|
|
132171
|
-
Defined in: [lib/ws.ts:
|
|
132171
|
+
Defined in: [lib/ws.ts:196](https://github.com/maiyunnet/kebab/blob/master/lib/ws.ts#L196)
|
|
132172
132172
|
|
|
132173
132173
|
#### Parameters
|
|
132174
132174
|
|
|
@@ -132206,7 +132206,7 @@ Defined in: [lib/ws.ts:195](https://github.com/maiyunnet/kebab/blob/master/lib/w
|
|
|
132206
132206
|
|
|
132207
132207
|
> **get** **ended**(): `boolean`
|
|
132208
132208
|
|
|
132209
|
-
Defined in: [lib/ws.ts:
|
|
132209
|
+
Defined in: [lib/ws.ts:669](https://github.com/maiyunnet/kebab/blob/master/lib/ws.ts#L669)
|
|
132210
132210
|
|
|
132211
132211
|
当前是否已经结束读取,并且无法继续读取
|
|
132212
132212
|
|
|
@@ -132222,7 +132222,7 @@ Defined in: [lib/ws.ts:667](https://github.com/maiyunnet/kebab/blob/master/lib/w
|
|
|
132222
132222
|
|
|
132223
132223
|
> **get** **finished**(): `boolean`
|
|
132224
132224
|
|
|
132225
|
-
Defined in: [lib/ws.ts:
|
|
132225
|
+
Defined in: [lib/ws.ts:674](https://github.com/maiyunnet/kebab/blob/master/lib/ws.ts#L674)
|
|
132226
132226
|
|
|
132227
132227
|
当前是否已经结束写入,并且无法继续写入
|
|
132228
132228
|
|
|
@@ -132238,7 +132238,7 @@ Defined in: [lib/ws.ts:672](https://github.com/maiyunnet/kebab/blob/master/lib/w
|
|
|
132238
132238
|
|
|
132239
132239
|
> **get** **isServer**(): `boolean`
|
|
132240
132240
|
|
|
132241
|
-
Defined in: [lib/ws.ts:
|
|
132241
|
+
Defined in: [lib/ws.ts:681](https://github.com/maiyunnet/kebab/blob/master/lib/ws.ts#L681)
|
|
132242
132242
|
|
|
132243
132243
|
当前连接是不是服务器连接
|
|
132244
132244
|
|
|
@@ -132254,7 +132254,7 @@ Defined in: [lib/ws.ts:679](https://github.com/maiyunnet/kebab/blob/master/lib/w
|
|
|
132254
132254
|
|
|
132255
132255
|
> **get** **writable**(): `boolean`
|
|
132256
132256
|
|
|
132257
|
-
Defined in: [lib/ws.ts:
|
|
132257
|
+
Defined in: [lib/ws.ts:664](https://github.com/maiyunnet/kebab/blob/master/lib/ws.ts#L664)
|
|
132258
132258
|
|
|
132259
132259
|
当前是否是可写状态
|
|
132260
132260
|
|
|
@@ -132268,7 +132268,7 @@ Defined in: [lib/ws.ts:662](https://github.com/maiyunnet/kebab/blob/master/lib/w
|
|
|
132268
132268
|
|
|
132269
132269
|
> **connect**(`u`, `opt?`): `Promise`\<`Socket` \| `null`\>
|
|
132270
132270
|
|
|
132271
|
-
Defined in: [lib/ws.ts:
|
|
132271
|
+
Defined in: [lib/ws.ts:229](https://github.com/maiyunnet/kebab/blob/master/lib/ws.ts#L229)
|
|
132272
132272
|
|
|
132273
132273
|
以客户端形式发起链接
|
|
132274
132274
|
|
|
@@ -132296,7 +132296,7 @@ Defined in: [lib/ws.ts:228](https://github.com/maiyunnet/kebab/blob/master/lib/w
|
|
|
132296
132296
|
|
|
132297
132297
|
> **destroy**(): `void`
|
|
132298
132298
|
|
|
132299
|
-
Defined in: [lib/ws.ts:
|
|
132299
|
+
Defined in: [lib/ws.ts:581](https://github.com/maiyunnet/kebab/blob/master/lib/ws.ts#L581)
|
|
132300
132300
|
|
|
132301
132301
|
#### Returns
|
|
132302
132302
|
|
|
@@ -132308,7 +132308,7 @@ Defined in: [lib/ws.ts:579](https://github.com/maiyunnet/kebab/blob/master/lib/w
|
|
|
132308
132308
|
|
|
132309
132309
|
> **end**(`code?`, `reason?`): `void`
|
|
132310
132310
|
|
|
132311
|
-
Defined in: [lib/ws.ts:
|
|
132311
|
+
Defined in: [lib/ws.ts:573](https://github.com/maiyunnet/kebab/blob/master/lib/ws.ts#L573)
|
|
132312
132312
|
|
|
132313
132313
|
正常结束 WebSocket 连接
|
|
132314
132314
|
|
|
@@ -132336,7 +132336,7 @@ WebSocket 关闭码
|
|
|
132336
132336
|
|
|
132337
132337
|
> **off**(`event`): `this`
|
|
132338
132338
|
|
|
132339
|
-
Defined in: [lib/ws.ts:
|
|
132339
|
+
Defined in: [lib/ws.ts:563](https://github.com/maiyunnet/kebab/blob/master/lib/ws.ts#L563)
|
|
132340
132340
|
|
|
132341
132341
|
取消监听
|
|
132342
132342
|
|
|
@@ -132358,7 +132358,7 @@ Defined in: [lib/ws.ts:561](https://github.com/maiyunnet/kebab/blob/master/lib/w
|
|
|
132358
132358
|
|
|
132359
132359
|
> **on**(`event`, `cb`): `this`
|
|
132360
132360
|
|
|
132361
|
-
Defined in: [lib/ws.ts:
|
|
132361
|
+
Defined in: [lib/ws.ts:517](https://github.com/maiyunnet/kebab/blob/master/lib/ws.ts#L517)
|
|
132362
132362
|
|
|
132363
132363
|
绑定监听
|
|
132364
132364
|
|
|
@@ -132380,7 +132380,7 @@ Defined in: [lib/ws.ts:515](https://github.com/maiyunnet/kebab/blob/master/lib/w
|
|
|
132380
132380
|
|
|
132381
132381
|
> **on**(`event`, `cb`): `this`
|
|
132382
132382
|
|
|
132383
|
-
Defined in: [lib/ws.ts:
|
|
132383
|
+
Defined in: [lib/ws.ts:521](https://github.com/maiyunnet/kebab/blob/master/lib/ws.ts#L521)
|
|
132384
132384
|
|
|
132385
132385
|
绑定监听
|
|
132386
132386
|
|
|
@@ -132402,7 +132402,7 @@ Defined in: [lib/ws.ts:519](https://github.com/maiyunnet/kebab/blob/master/lib/w
|
|
|
132402
132402
|
|
|
132403
132403
|
> **on**(`event`, `cb`): `this`
|
|
132404
132404
|
|
|
132405
|
-
Defined in: [lib/ws.ts:
|
|
132405
|
+
Defined in: [lib/ws.ts:522](https://github.com/maiyunnet/kebab/blob/master/lib/ws.ts#L522)
|
|
132406
132406
|
|
|
132407
132407
|
绑定监听
|
|
132408
132408
|
|
|
@@ -132424,7 +132424,7 @@ Defined in: [lib/ws.ts:520](https://github.com/maiyunnet/kebab/blob/master/lib/w
|
|
|
132424
132424
|
|
|
132425
132425
|
> **on**(`event`, `cb`): `this`
|
|
132426
132426
|
|
|
132427
|
-
Defined in: [lib/ws.ts:
|
|
132427
|
+
Defined in: [lib/ws.ts:523](https://github.com/maiyunnet/kebab/blob/master/lib/ws.ts#L523)
|
|
132428
132428
|
|
|
132429
132429
|
绑定监听
|
|
132430
132430
|
|
|
@@ -132448,7 +132448,7 @@ Defined in: [lib/ws.ts:521](https://github.com/maiyunnet/kebab/blob/master/lib/w
|
|
|
132448
132448
|
|
|
132449
132449
|
> **pause**(): `void`
|
|
132450
132450
|
|
|
132451
|
-
Defined in: [lib/ws.ts:
|
|
132451
|
+
Defined in: [lib/ws.ts:587](https://github.com/maiyunnet/kebab/blob/master/lib/ws.ts#L587)
|
|
132452
132452
|
|
|
132453
132453
|
暂停向消息监听器派发数据,并暂停底层 TCP 读取
|
|
132454
132454
|
|
|
@@ -132462,7 +132462,7 @@ Defined in: [lib/ws.ts:585](https://github.com/maiyunnet/kebab/blob/master/lib/w
|
|
|
132462
132462
|
|
|
132463
132463
|
> **ping**(`data?`): `boolean`
|
|
132464
132464
|
|
|
132465
|
-
Defined in: [lib/ws.ts:
|
|
132465
|
+
Defined in: [lib/ws.ts:686](https://github.com/maiyunnet/kebab/blob/master/lib/ws.ts#L686)
|
|
132466
132466
|
|
|
132467
132467
|
发送 ping
|
|
132468
132468
|
|
|
@@ -132482,7 +132482,7 @@ Defined in: [lib/ws.ts:684](https://github.com/maiyunnet/kebab/blob/master/lib/w
|
|
|
132482
132482
|
|
|
132483
132483
|
> **pong**(`data?`): `boolean`
|
|
132484
132484
|
|
|
132485
|
-
Defined in: [lib/ws.ts:
|
|
132485
|
+
Defined in: [lib/ws.ts:691](https://github.com/maiyunnet/kebab/blob/master/lib/ws.ts#L691)
|
|
132486
132486
|
|
|
132487
132487
|
发送 ping
|
|
132488
132488
|
|
|
@@ -132502,7 +132502,7 @@ Defined in: [lib/ws.ts:689](https://github.com/maiyunnet/kebab/blob/master/lib/w
|
|
|
132502
132502
|
|
|
132503
132503
|
> **resume**(): `void`
|
|
132504
132504
|
|
|
132505
|
-
Defined in: [lib/ws.ts:
|
|
132505
|
+
Defined in: [lib/ws.ts:593](https://github.com/maiyunnet/kebab/blob/master/lib/ws.ts#L593)
|
|
132506
132506
|
|
|
132507
132507
|
恢复派发缓存消息,并恢复底层 TCP 读取
|
|
132508
132508
|
|
|
@@ -132516,7 +132516,7 @@ Defined in: [lib/ws.ts:591](https://github.com/maiyunnet/kebab/blob/master/lib/w
|
|
|
132516
132516
|
|
|
132517
132517
|
> **writeBinary**(`data`): `boolean`
|
|
132518
132518
|
|
|
132519
|
-
Defined in: [lib/ws.ts:
|
|
132519
|
+
Defined in: [lib/ws.ts:612](https://github.com/maiyunnet/kebab/blob/master/lib/ws.ts#L612)
|
|
132520
132520
|
|
|
132521
132521
|
发送二进制
|
|
132522
132522
|
|
|
@@ -132536,7 +132536,7 @@ Defined in: [lib/ws.ts:610](https://github.com/maiyunnet/kebab/blob/master/lib/w
|
|
|
132536
132536
|
|
|
132537
132537
|
> **writeResult**(`data`): `boolean`
|
|
132538
132538
|
|
|
132539
|
-
Defined in: [lib/ws.ts:
|
|
132539
|
+
Defined in: [lib/ws.ts:607](https://github.com/maiyunnet/kebab/blob/master/lib/ws.ts#L607)
|
|
132540
132540
|
|
|
132541
132541
|
发送结果对象字符串
|
|
132542
132542
|
|
|
@@ -132556,7 +132556,7 @@ Defined in: [lib/ws.ts:605](https://github.com/maiyunnet/kebab/blob/master/lib/w
|
|
|
132556
132556
|
|
|
132557
132557
|
> **writeText**(`data`): `boolean`
|
|
132558
132558
|
|
|
132559
|
-
Defined in: [lib/ws.ts:
|
|
132559
|
+
Defined in: [lib/ws.ts:602](https://github.com/maiyunnet/kebab/blob/master/lib/ws.ts#L602)
|
|
132560
132560
|
|
|
132561
132561
|
发送文本
|
|
132562
132562
|
|
|
@@ -132685,7 +132685,7 @@ lib/ws/functions/connect.md
|
|
|
132685
132685
|
|
|
132686
132686
|
> **connect**(`u`, `opt?`): `Promise`\<[`Socket`](../classes/Socket.md) \| `null`\>
|
|
132687
132687
|
|
|
132688
|
-
Defined in: [lib/ws.ts:
|
|
132688
|
+
Defined in: [lib/ws.ts:734](https://github.com/maiyunnet/kebab/blob/master/lib/ws.ts#L734)
|
|
132689
132689
|
|
|
132690
132690
|
创建一个 ws 客户端发起 ws 请求
|
|
132691
132691
|
|
|
@@ -132720,7 +132720,7 @@ lib/ws/functions/createServer.md
|
|
|
132720
132720
|
|
|
132721
132721
|
> **createServer**(`request`, `socket`, `head?`, `options?`): [`Socket`](../classes/Socket.md)
|
|
132722
132722
|
|
|
132723
|
-
Defined in: [lib/ws.ts:
|
|
132723
|
+
Defined in: [lib/ws.ts:744](https://github.com/maiyunnet/kebab/blob/master/lib/ws.ts#L744)
|
|
132724
132724
|
|
|
132725
132725
|
创建一个 ws 服务器接收处理器
|
|
132726
132726
|
|
|
@@ -132769,7 +132769,7 @@ lib/ws/functions/mproxy.md
|
|
|
132769
132769
|
|
|
132770
132770
|
> **mproxy**(`ctr`, `auth`, `opt?`): `Promise`\<`number`\>
|
|
132771
132771
|
|
|
132772
|
-
Defined in: [lib/ws.ts:
|
|
132772
|
+
Defined in: [lib/ws.ts:970](https://github.com/maiyunnet/kebab/blob/master/lib/ws.ts#L970)
|
|
132773
132773
|
|
|
132774
132774
|
正向 mproxy 代理,读取 get 的 url 为实际请求地址
|
|
132775
132775
|
get: url, auth
|
|
@@ -132811,7 +132811,7 @@ lib/ws/functions/rproxy.md
|
|
|
132811
132811
|
|
|
132812
132812
|
> **rproxy**(`ctr`, `url`, `opt?`): `Promise`\<`boolean`\>
|
|
132813
132813
|
|
|
132814
|
-
Defined in: [lib/ws.ts:
|
|
132814
|
+
Defined in: [lib/ws.ts:1007](https://github.com/maiyunnet/kebab/blob/master/lib/ws.ts#L1007)
|
|
132815
132815
|
|
|
132816
132816
|
反向代理,将本 socket 连接反代到其他网址,在 ws 的 onLoad 事件中使用
|
|
132817
132817
|
|
|
@@ -132852,7 +132852,7 @@ lib/ws/functions/rsocket.md
|
|
|
132852
132852
|
|
|
132853
132853
|
> **rsocket**(`ctr`, `host`, `port`): `Promise`\<`boolean`\>
|
|
132854
132854
|
|
|
132855
|
-
Defined in: [lib/ws.ts:
|
|
132855
|
+
Defined in: [lib/ws.ts:1053](https://github.com/maiyunnet/kebab/blob/master/lib/ws.ts#L1053)
|
|
132856
132856
|
|
|
132857
132857
|
反向代理,将本 websocket 连接反代到其他真正的 socket,在 ws 的 onLoad 事件中使用
|
|
132858
132858
|
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* --- 本文件用来定义每个目录实体地址的常量 ---
|
|
5
5
|
*/
|
|
6
6
|
/** --- 当前系统版本号 --- */
|
|
7
|
-
export const VER = '9.29.
|
|
7
|
+
export const VER = '9.29.4';
|
|
8
8
|
// --- 服务端用的路径 ---
|
|
9
9
|
const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
|
|
10
10
|
/** --- /xxx/xxx --- */
|
package/lib/ws.js
CHANGED
|
@@ -34,6 +34,7 @@ const wsServer = new WebSocketServer({
|
|
|
34
34
|
'maxPayload': MAX_MESSAGE_BYTES,
|
|
35
35
|
'noServer': true,
|
|
36
36
|
'perMessageDeflate': false,
|
|
37
|
+
'skipUTF8Validation': true,
|
|
37
38
|
});
|
|
38
39
|
wsServer.on('headers', (headers, request) => {
|
|
39
40
|
const extra = upgradeHeaders.get(request);
|
|
@@ -150,6 +151,7 @@ export class Socket {
|
|
|
150
151
|
'maxPayload': MAX_MESSAGE_BYTES,
|
|
151
152
|
'perMessageDeflate': false,
|
|
152
153
|
'servername': connectUrl.protocol === 'wss:' ? host : undefined,
|
|
154
|
+
'skipUTF8Validation': true,
|
|
153
155
|
};
|
|
154
156
|
const cli = new WebSocket(connectUrl, clientOptions);
|
|
155
157
|
this._ws = cli;
|
|
@@ -656,7 +658,7 @@ function bindPipe(s1, s2, closeReason) {
|
|
|
656
658
|
s1.on('message', (msg) => {
|
|
657
659
|
switch (msg.opcode) {
|
|
658
660
|
case EOpcode.TEXT: {
|
|
659
|
-
if (!s2.writeText(msg.data
|
|
661
|
+
if (!s2.writeText(msg.data)) {
|
|
660
662
|
s1.pause();
|
|
661
663
|
}
|
|
662
664
|
break;
|
|
@@ -708,7 +710,7 @@ function bindPipe(s1, s2, closeReason) {
|
|
|
708
710
|
s2.on('message', (msg) => {
|
|
709
711
|
switch (msg.opcode) {
|
|
710
712
|
case EOpcode.TEXT: {
|
|
711
|
-
if (!s1.writeText(msg.data
|
|
713
|
+
if (!s1.writeText(msg.data)) {
|
|
712
714
|
s2.pause();
|
|
713
715
|
}
|
|
714
716
|
break;
|
|
@@ -844,6 +846,11 @@ export async function rsocket(ctr, host, port) {
|
|
|
844
846
|
const ws = ctr.getPrototype('_socket');
|
|
845
847
|
/** --- 对端真实 tcp socket --- */
|
|
846
848
|
const socket = new net.Socket();
|
|
849
|
+
ws.on('error', (error) => {
|
|
850
|
+
lCore.log(ctr, `[WS][RSOCKET][SOURCE ERROR] ${host}:${port}: ${lText.stringifyError(error)}`, '-error');
|
|
851
|
+
}).on('timeout', () => {
|
|
852
|
+
lCore.log(ctr, `[WS][RSOCKET][SOURCE TIMEOUT] ${host}:${port}`, '-error');
|
|
853
|
+
});
|
|
847
854
|
socket.connect(port, host, () => {
|
|
848
855
|
socket.setKeepAlive(true);
|
|
849
856
|
// --- 连接成功 ---
|
|
@@ -882,7 +889,8 @@ export async function rsocket(ctr, host, port) {
|
|
|
882
889
|
ws.end();
|
|
883
890
|
resolve(true);
|
|
884
891
|
});
|
|
885
|
-
}).on('error', () => {
|
|
892
|
+
}).on('error', (error) => {
|
|
893
|
+
lCore.log(ctr, `[WS][RSOCKET][TARGET ERROR] ${host}:${port}: ${lText.stringifyError(error)}`, '-error');
|
|
886
894
|
resolve(false);
|
|
887
895
|
});
|
|
888
896
|
});
|