xshell 1.0.205 → 1.0.206
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/package.json +8 -8
- package/server.js +20 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xshell",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.206",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"bin": {
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
"@svgr/webpack": "^8.1.0",
|
|
58
58
|
"@types/sass-loader": "^8.0.9",
|
|
59
59
|
"@types/ws": "^8.5.13",
|
|
60
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
61
|
-
"@typescript-eslint/parser": "^8.
|
|
62
|
-
"@typescript-eslint/utils": "^8.
|
|
60
|
+
"@typescript-eslint/eslint-plugin": "^8.17.0",
|
|
61
|
+
"@typescript-eslint/parser": "^8.17.0",
|
|
62
|
+
"@typescript-eslint/utils": "^8.17.0",
|
|
63
63
|
"@xterm/addon-fit": "^0.10.0",
|
|
64
64
|
"@xterm/addon-web-links": "^0.11.0",
|
|
65
65
|
"@xterm/addon-webgl": "^0.18.0",
|
|
@@ -75,13 +75,13 @@
|
|
|
75
75
|
"commander": "^12.1.0",
|
|
76
76
|
"css-loader": "^7.1.2",
|
|
77
77
|
"emoji-regex": "^10.4.0",
|
|
78
|
-
"eslint": "^9.
|
|
78
|
+
"eslint": "^9.16.0",
|
|
79
79
|
"eslint-plugin-import": "^2.31.0",
|
|
80
80
|
"eslint-plugin-react": "^7.37.2",
|
|
81
81
|
"gulp-sort": "^2.0.0",
|
|
82
82
|
"hash-string": "^1.0.0",
|
|
83
83
|
"https-proxy-agent": "^7.0.5",
|
|
84
|
-
"i18next": "^24.0.
|
|
84
|
+
"i18next": "^24.0.5",
|
|
85
85
|
"i18next-scanner": "^4.6.0",
|
|
86
86
|
"koa": "^2.15.3",
|
|
87
87
|
"koa-compress": "^5.1.1",
|
|
@@ -91,10 +91,10 @@
|
|
|
91
91
|
"mime-types": "^2.1.35",
|
|
92
92
|
"ora": "^8.1.1",
|
|
93
93
|
"react": "^18.3.1",
|
|
94
|
-
"react-i18next": "^15.1.
|
|
94
|
+
"react-i18next": "^15.1.3",
|
|
95
95
|
"react-object-model": "^1.2.18",
|
|
96
96
|
"resolve-path": "^1.4.0",
|
|
97
|
-
"sass": "^1.81.
|
|
97
|
+
"sass": "^1.81.1",
|
|
98
98
|
"sass-loader": "^16.0.3",
|
|
99
99
|
"source-map-loader": "^5.0.0",
|
|
100
100
|
"strip-ansi": "^7.1.0",
|
package/server.js
CHANGED
|
@@ -148,8 +148,16 @@ export class Server {
|
|
|
148
148
|
maxPayload: 2 ** 30 // 1 GB
|
|
149
149
|
});
|
|
150
150
|
this.websocket_server.on('connection', (ws, request) => {
|
|
151
|
-
ws.addEventListener('message', ({ data }) => {
|
|
152
|
-
|
|
151
|
+
ws.addEventListener('message', async ({ data }) => {
|
|
152
|
+
// 处理 funcs 中已经注册的 handlers
|
|
153
|
+
try {
|
|
154
|
+
await this.remote.handle(new Uint8Array(data), ws);
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
this.on_error(error);
|
|
158
|
+
// 这里再往上扔会成为 uncaughtException 使进程退出,
|
|
159
|
+
// 通过上面的处理应该足够了
|
|
160
|
+
}
|
|
153
161
|
});
|
|
154
162
|
});
|
|
155
163
|
const on_upgrade = this.on_upgrade.bind(this);
|
|
@@ -248,11 +256,12 @@ export class Server {
|
|
|
248
256
|
}
|
|
249
257
|
/** 可被子类重写定义错误处理逻辑 */
|
|
250
258
|
on_error(error, ctx) {
|
|
251
|
-
|
|
259
|
+
const code = error?.code;
|
|
260
|
+
if (code === 'EPIPE' || code === 'ECONNRESET')
|
|
252
261
|
console.log(`${error.code}:`, ctx?.request?.url);
|
|
253
262
|
else {
|
|
254
263
|
console.error(error);
|
|
255
|
-
console.log(ctx);
|
|
264
|
+
console.log('ctx:', ctx);
|
|
256
265
|
}
|
|
257
266
|
}
|
|
258
267
|
on_upgrade(request, socket, head) {
|
|
@@ -359,7 +368,7 @@ export class Server {
|
|
|
359
368
|
logger(ctx) {
|
|
360
369
|
const { colors } = this;
|
|
361
370
|
const { request } = ctx;
|
|
362
|
-
const { query, body, path, _path, protocol, host, req: { httpVersion: http_version }, ip, headers, } = request;
|
|
371
|
+
const { query: queries, body, path, _path, protocol, host, req: { httpVersion: http_version }, ip, headers, } = request;
|
|
363
372
|
let { method } = request;
|
|
364
373
|
let s = '';
|
|
365
374
|
// 时间
|
|
@@ -396,9 +405,9 @@ export class Server {
|
|
|
396
405
|
end = Number(end).to_fsize_str();
|
|
397
406
|
s += ` (${start} - ${end || ''})`;
|
|
398
407
|
}
|
|
399
|
-
//
|
|
400
|
-
if (Object.keys(
|
|
401
|
-
let t = inspect(
|
|
408
|
+
// queries
|
|
409
|
+
if (Object.keys(queries).length) {
|
|
410
|
+
let t = inspect(queries, { compact: true })
|
|
402
411
|
.replace('[Object: null prototype] ', '')
|
|
403
412
|
.strip_if_end('\n');
|
|
404
413
|
s += (s + t).width > output_width ? '\n' : ' ';
|
|
@@ -468,15 +477,15 @@ export class Server {
|
|
|
468
477
|
- timeout?: `1000 * 5` 请求超时时间,可以传入 0 禁用超时
|
|
469
478
|
- throw_error?: `false` 在遇到 request 请求错误时直接 throw 出来,而不是自动设置到 response */
|
|
470
479
|
async request(ctx, path_url, { headers: headers_, redirect = 'manual', queries, timeout, throw_error } = {}) {
|
|
471
|
-
const { request: { method, headers, query, body, ip } } = ctx;
|
|
480
|
+
const { request: { method, headers, query: _queries, body, ip } } = ctx;
|
|
472
481
|
let { response } = ctx;
|
|
473
482
|
const x_forwarded_for = headers['x-forwarded-for'] ? `${headers['x-forwarded-for']}, ${ip}` : ip;
|
|
474
483
|
try {
|
|
475
484
|
const response_ = await _request(path_url, {
|
|
476
485
|
method: method,
|
|
477
486
|
queries: queries
|
|
478
|
-
? filter_values({ ...
|
|
479
|
-
:
|
|
487
|
+
? filter_values({ ..._queries, ...queries })
|
|
488
|
+
: _queries,
|
|
480
489
|
body,
|
|
481
490
|
headers: (headers_
|
|
482
491
|
? filter_values({
|