@maiyunnet/kebab 3.2.16 → 3.2.17

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/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * --- 本文件用来定义每个目录实体地址的常量 ---
6
6
  */
7
7
  /** --- 当前系统版本号 --- */
8
- export declare const VER = "3.2.16";
8
+ export declare const VER = "3.2.17";
9
9
  /** --- 框架根目录,以 / 结尾 --- */
10
10
  export declare const ROOT_PATH: string;
11
11
  export declare const LIB_PATH: string;
package/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * --- 本文件用来定义每个目录实体地址的常量 ---
7
7
  */
8
8
  /** --- 当前系统版本号 --- */
9
- export const VER = '3.2.16';
9
+ export const VER = '3.2.17';
10
10
  // --- 服务端用的路径 ---
11
11
  const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
12
12
  /** --- /xxx/xxx --- */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maiyunnet/kebab",
3
- "version": "3.2.16",
3
+ "version": "3.2.17",
4
4
  "description": "Simple, easy-to-use, and fully-featured Node.js framework that is ready-to-use out of the box.",
5
5
  "type": "module",
6
6
  "keywords": [
package/sys/child.js CHANGED
@@ -89,7 +89,8 @@ async function run() {
89
89
  }, function (req, res) {
90
90
  const host = (req.headers[':authority'] ?? req.headers['host'] ?? '');
91
91
  if (!host) {
92
- req.socket.destroy();
92
+ res.statusCode = 403;
93
+ res.end();
93
94
  return;
94
95
  }
95
96
  const key = host + req.url;
@@ -115,7 +116,7 @@ async function run() {
115
116
  }).on('upgrade', function (req, socket) {
116
117
  const host = (req.headers['host'] ?? '');
117
118
  if (!host) {
118
- req.socket.destroy();
119
+ socket.destroy();
119
120
  return;
120
121
  }
121
122
  const key = host + (req.url ?? '');
@@ -140,7 +141,8 @@ async function run() {
140
141
  httpServer = http.createServer(function (req, res) {
141
142
  const host = (req.headers['host'] ?? '');
142
143
  if (!host) {
143
- req.socket.destroy();
144
+ res.statusCode = 403;
145
+ res.end();
144
146
  return;
145
147
  }
146
148
  const key = host + (req.url ?? '');
@@ -164,7 +166,7 @@ async function run() {
164
166
  }).on('upgrade', function (req, socket) {
165
167
  const host = (req.headers['host'] ?? '');
166
168
  if (!host) {
167
- req.socket.destroy();
169
+ socket.destroy();
168
170
  return;
169
171
  }
170
172
  const key = host + (req.url ?? '');
@@ -222,7 +224,7 @@ async function requestHandler(req, res, https) {
222
224
  if (host === undefined || typeof host !== 'string') {
223
225
  host = req.headers['host'];
224
226
  if (host === undefined) {
225
- req.socket.destroy();
227
+ res.end();
226
228
  return;
227
229
  }
228
230
  }
@@ -230,7 +232,8 @@ async function requestHandler(req, res, https) {
230
232
  /** --- 当前的 vhost 配置文件 --- */
231
233
  const vhost = await getVhostByHostname(uri.hostname ?? '');
232
234
  if (!vhost) {
233
- req.socket.destroy();
235
+ res.statusCode = 403;
236
+ res.end();
234
237
  return;
235
238
  /*
236
239
  const text = '<h1>Kebab: No permissions</h1>host: ' + (req.headers[':authority'] as string | undefined ?? req.headers['host'] ?? '') + '<br>url: ' + (lText.htmlescape(req.url ?? ''));
package/sys/route.js CHANGED
@@ -218,7 +218,7 @@ export async function run(data) {
218
218
  headers['authorization'] ??= '';
219
219
  /** --- 开发者返回值 --- */
220
220
  let rtn;
221
- if (data.socket && data.req instanceof http.IncomingMessage) {
221
+ if (data.socket && (data.req instanceof http.IncomingMessage)) {
222
222
  // --- socket 模式 ---
223
223
  // --- 判断真实控制器文件是否存在 ---
224
224
  let filePath = config.const.wsPath + pathLeft + '.js';
@@ -245,7 +245,7 @@ export async function run(data) {
245
245
  }
246
246
  catch (e) {
247
247
  lCore.log(cctr, lText.stringifyJson(e.stack).slice(1, -1), '-error');
248
- data.socket.destroy();
248
+ data.socket?.destroy();
249
249
  return true;
250
250
  }
251
251
  cctr.setPrototype('_param', param);
@@ -259,7 +259,7 @@ export async function run(data) {
259
259
  }
260
260
  catch (e) {
261
261
  lCore.log(cctr, lText.stringifyJson(e.stack).slice(1, -1), '-error');
262
- data.socket.destroy();
262
+ data.socket?.destroy();
263
263
  return true;
264
264
  }
265
265
  if (rtn === undefined || rtn === true) {
@@ -268,7 +268,7 @@ export async function run(data) {
268
268
  }
269
269
  catch (e) {
270
270
  lCore.log(cctr, lText.stringifyJson(e.stack).slice(1, -1), '-error');
271
- data.socket.destroy();
271
+ data.socket?.destroy();
272
272
  return true;
273
273
  }
274
274
  if (rtn === undefined || rtn === true) {