@maiyunnet/kebab 2.0.14 → 2.0.15
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 +1 -1
- package/index.js +1 -1
- package/lib/captcha.js +2 -2
- package/lib/consistent.js +1 -1
- package/lib/core.d.ts +42 -18
- package/lib/core.js +147 -152
- package/lib/crypto.js +2 -2
- package/lib/db.d.ts +3 -3
- package/lib/db.js +32 -73
- package/lib/dns.d.ts +1 -1
- package/lib/dns.js +5 -5
- package/lib/fs.js +17 -9
- package/lib/jwt.d.ts +3 -3
- package/lib/jwt.js +5 -5
- package/lib/kv.d.ts +2 -2
- package/lib/kv.js +2 -2
- package/lib/lan.js +1 -1
- package/lib/net/formdata.js +2 -2
- package/lib/net/request.d.ts +1 -1
- package/lib/net/request.js +1 -1
- package/lib/net/response.d.ts +1 -1
- package/lib/net.d.ts +2 -2
- package/lib/net.js +4 -4
- package/lib/s3.d.ts +1 -1
- package/lib/s3.js +2 -2
- package/lib/scan.d.ts +3 -3
- package/lib/scan.js +6 -6
- package/lib/session.d.ts +3 -3
- package/lib/session.js +7 -7
- package/lib/sql.d.ts +3 -3
- package/lib/sql.js +7 -37
- package/lib/ssh/sftp.js +2 -2
- package/lib/ssh/shell.js +1 -1
- package/lib/text.d.ts +6 -1
- package/lib/text.js +9 -1
- package/lib/time.d.ts +1 -1
- package/lib/time.js +1 -1
- package/lib/turnstile.d.ts +1 -1
- package/lib/turnstile.js +2 -2
- package/lib/ws.d.ts +2 -2
- package/lib/ws.js +3 -3
- package/lib/zip.d.ts +1 -1
- package/lib/zip.js +1 -1
- package/package.json +5 -4
- package/sys/child.js +43 -84
- package/sys/cmd.js +7 -6
- package/sys/ctr.d.ts +2 -2
- package/sys/master.js +131 -9
- package/sys/mod.d.ts +4 -4
- package/sys/mod.js +5 -5
- package/sys/route.d.ts +1 -1
- package/sys/route.js +20 -20
- package/www/example/ctr/main.d.ts +1 -1
- package/www/example/ctr/main.js +1 -1
- package/www/example/ctr/middle.d.ts +2 -2
- package/www/example/ctr/middle.js +1 -1
- package/www/example/ctr/test.d.ts +3 -2
- package/www/example/ctr/test.js +83 -30
- package/www/example/mod/test.d.ts +2 -2
- package/www/example/mod/test.js +2 -2
- package/www/example/mod/testdata.d.ts +1 -1
- package/www/example/mod/testdata.js +1 -1
- package/www/example/ws/mproxy.d.ts +1 -1
- package/www/example/ws/mproxy.js +2 -2
- package/www/example/ws/rproxy.d.ts +1 -1
- package/www/example/ws/rproxy.js +2 -2
- package/www/example/ws/test.d.ts +1 -1
- package/www/example/ws/test.js +4 -3
package/sys/mod.js
CHANGED
|
@@ -38,11 +38,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
38
38
|
* Date: 2019-6-4 21:35
|
|
39
39
|
* Last: 2020-4-14 13:33:51, 2022-07-23 16:01:34, 2022-09-06 22:59:26, 2023-5-24 19:11:37, 2023-6-13 21:47:58, 2023-7-10 18:54:03, 2023-8-23 17:03:16, 2023-12-11 15:21:22, 2023-12-20 23:12:03, 2024-3-8 16:05:29, 2024-3-20 19:58:15, 2024-8-11 21:14:54, 2024-10-5 14:00:22, 2024-12-14 19:58:34
|
|
40
40
|
*/
|
|
41
|
-
const lSql = __importStar(require("
|
|
42
|
-
const lTime = __importStar(require("
|
|
43
|
-
const lCore = __importStar(require("
|
|
44
|
-
const lText = __importStar(require("
|
|
45
|
-
const sCtr = __importStar(require("
|
|
41
|
+
const lSql = __importStar(require("~/lib/sql"));
|
|
42
|
+
const lTime = __importStar(require("~/lib/time"));
|
|
43
|
+
const lCore = __importStar(require("~/lib/core"));
|
|
44
|
+
const lText = __importStar(require("~/lib/text"));
|
|
45
|
+
const sCtr = __importStar(require("~/sys/ctr"));
|
|
46
46
|
/** --- 条数列表 --- */
|
|
47
47
|
class Rows {
|
|
48
48
|
constructor(initialItems = []) {
|
package/sys/route.d.ts
CHANGED
package/sys/route.js
CHANGED
|
@@ -49,15 +49,15 @@ const stream = __importStar(require("stream"));
|
|
|
49
49
|
// --- 第三方 ---
|
|
50
50
|
const ws = __importStar(require("@litert/websocket"));
|
|
51
51
|
// --- 库和定义 ---
|
|
52
|
-
const lFs = __importStar(require("
|
|
53
|
-
const lZlib = __importStar(require("
|
|
54
|
-
const lCore = __importStar(require("
|
|
55
|
-
const lText = __importStar(require("
|
|
56
|
-
const lTime = __importStar(require("
|
|
57
|
-
const lResponse = __importStar(require("
|
|
58
|
-
const lWs = __importStar(require("
|
|
52
|
+
const lFs = __importStar(require("~/lib/fs"));
|
|
53
|
+
const lZlib = __importStar(require("~/lib/zlib"));
|
|
54
|
+
const lCore = __importStar(require("~/lib/core"));
|
|
55
|
+
const lText = __importStar(require("~/lib/text"));
|
|
56
|
+
const lTime = __importStar(require("~/lib/time"));
|
|
57
|
+
const lResponse = __importStar(require("~/lib/net/response"));
|
|
58
|
+
const lWs = __importStar(require("~/lib/ws"));
|
|
59
59
|
const sCtr = __importStar(require("./ctr"));
|
|
60
|
-
const kebab = __importStar(require("
|
|
60
|
+
const kebab = __importStar(require("~/index"));
|
|
61
61
|
/** --- 动态层 kebab.json 缓存(文件路径: 最终合并值) --- */
|
|
62
62
|
let kebabConfigs = {};
|
|
63
63
|
/**
|
|
@@ -303,7 +303,7 @@ async function run(data) {
|
|
|
303
303
|
cctr.setPrototype('_socket', wsSocket);
|
|
304
304
|
}
|
|
305
305
|
catch (e) {
|
|
306
|
-
|
|
306
|
+
lCore.log(cctr, lText.stringifyJson(e.stack).slice(1, -1), '-error');
|
|
307
307
|
data.socket.destroy();
|
|
308
308
|
return true;
|
|
309
309
|
}
|
|
@@ -312,12 +312,12 @@ async function run(data) {
|
|
|
312
312
|
cctr.setPrototype('_headers', headers);
|
|
313
313
|
cctr.setPrototype('_get', get);
|
|
314
314
|
cctr.setPrototype('_cookie', cookies);
|
|
315
|
-
|
|
315
|
+
lCore.log(cctr, '', '-visit');
|
|
316
316
|
try {
|
|
317
317
|
rtn = await cctr.onLoad();
|
|
318
318
|
}
|
|
319
319
|
catch (e) {
|
|
320
|
-
|
|
320
|
+
lCore.log(cctr, lText.stringifyJson(e.stack).slice(1, -1), '-error');
|
|
321
321
|
data.socket.destroy();
|
|
322
322
|
return true;
|
|
323
323
|
}
|
|
@@ -374,7 +374,7 @@ async function run(data) {
|
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
376
|
catch (e) {
|
|
377
|
-
|
|
377
|
+
lCore.log(cctr, lText.stringifyJson(e.stack).slice(1, -1), '-error');
|
|
378
378
|
}
|
|
379
379
|
break;
|
|
380
380
|
}
|
|
@@ -387,16 +387,16 @@ async function run(data) {
|
|
|
387
387
|
await cctr['onDrain']();
|
|
388
388
|
}
|
|
389
389
|
catch (e) {
|
|
390
|
-
|
|
390
|
+
lCore.log(cctr, lText.stringifyJson(e.stack).slice(1, -1), '-error');
|
|
391
391
|
}
|
|
392
|
-
}).on('error',
|
|
393
|
-
|
|
392
|
+
}).on('error', (e) => {
|
|
393
|
+
lCore.log(cctr, lText.stringifyJson(e.stack).slice(1, -1), '-error');
|
|
394
394
|
}).on('close', async () => {
|
|
395
395
|
try {
|
|
396
396
|
await cctr['onClose']();
|
|
397
397
|
}
|
|
398
398
|
catch (e) {
|
|
399
|
-
|
|
399
|
+
lCore.log(cctr, lText.stringifyJson(e.stack).slice(1, -1), '-error');
|
|
400
400
|
}
|
|
401
401
|
resolve();
|
|
402
402
|
});
|
|
@@ -443,7 +443,7 @@ async function run(data) {
|
|
|
443
443
|
rtn = await middle.onLoad();
|
|
444
444
|
}
|
|
445
445
|
catch (e) {
|
|
446
|
-
|
|
446
|
+
lCore.log(middle, '(E03)' + lText.stringifyJson(e.stack).slice(1, -1), '-error');
|
|
447
447
|
data.res.setHeader('content-type', 'text/html; charset=utf-8');
|
|
448
448
|
data.res.setHeader('content-length', 25);
|
|
449
449
|
data.res.writeHead(500);
|
|
@@ -495,7 +495,7 @@ async function run(data) {
|
|
|
495
495
|
cctr.setPrototype('_cacheTTL', middle.getPrototype('_cacheTTL'));
|
|
496
496
|
cctr.setPrototype('_xsrf', middle.getPrototype('_xsrf'));
|
|
497
497
|
cctr.setPrototype('_httpCode', middle.getPrototype('_httpCode'));
|
|
498
|
-
|
|
498
|
+
lCore.log(cctr, '', '-visit');
|
|
499
499
|
// --- 强制 HTTPS ---
|
|
500
500
|
if (config.set.mustHttps && !config.const.https) {
|
|
501
501
|
data.res.setHeader('location', data.req.url ?? '');
|
|
@@ -553,7 +553,7 @@ async function run(data) {
|
|
|
553
553
|
httpCode = cctr.getPrototype('_httpCode');
|
|
554
554
|
}
|
|
555
555
|
catch (e) {
|
|
556
|
-
|
|
556
|
+
lCore.log(cctr, '(E04)' + lText.stringifyJson(e.stack).slice(1, -1), '-error');
|
|
557
557
|
data.res.setHeader('content-type', 'text/html; charset=utf-8');
|
|
558
558
|
data.res.setHeader('content-length', 25);
|
|
559
559
|
data.res.writeHead(500);
|
|
@@ -820,7 +820,7 @@ async function waitCtr(cctr) {
|
|
|
820
820
|
// --- 有事务未关闭 ---
|
|
821
821
|
const msg = 'transaction(' + waitInfo.transaction + ') not be closed';
|
|
822
822
|
lCore.display('[ERROR][ROUTE][WAITCTR] ' + msg + ': ', cctr.getPrototype('_config').const.path);
|
|
823
|
-
|
|
823
|
+
lCore.log(cctr, msg, '-error');
|
|
824
824
|
}
|
|
825
825
|
// --- 彻底结束,删除文件 ---
|
|
826
826
|
await unlinkUploadFiles(cctr);
|
package/www/example/ctr/main.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
const ctr = __importStar(require("
|
|
36
|
+
const ctr = __importStar(require("~/sys/ctr"));
|
|
37
37
|
class default_1 extends ctr.Ctr {
|
|
38
38
|
index() {
|
|
39
39
|
return `<a href="${this._config.const.urlBase}test">Hello world! Click here to visit demo.</a>`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as ctr from '
|
|
2
|
-
import * as types from '
|
|
1
|
+
import * as ctr from '~/sys/ctr';
|
|
2
|
+
import * as types from '~/types';
|
|
3
3
|
export default class extends ctr.Ctr {
|
|
4
4
|
onLoad(): string | boolean;
|
|
5
5
|
onUnload(rtn: string | boolean | types.DbValue[]): string | boolean | types.DbValue[];
|
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
const ctr = __importStar(require("
|
|
36
|
+
const ctr = __importStar(require("~/sys/ctr"));
|
|
37
37
|
class default_1 extends ctr.Ctr {
|
|
38
38
|
onLoad() {
|
|
39
39
|
if (this._config.const.path !== 'test/middle') {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
|
-
import * as sCtr from '
|
|
3
|
-
import * as types from '
|
|
2
|
+
import * as sCtr from '~/sys/ctr';
|
|
3
|
+
import * as types from '~/types';
|
|
4
4
|
export default class extends sCtr.Ctr {
|
|
5
5
|
private _internalUrl;
|
|
6
6
|
onLoad(): Array<string | number> | boolean;
|
|
@@ -37,6 +37,7 @@ export default class extends sCtr.Ctr {
|
|
|
37
37
|
coreChecktype(): string;
|
|
38
38
|
coreMuid(): string;
|
|
39
39
|
coreGetlog(): Promise<string>;
|
|
40
|
+
coreLs(): Promise<string>;
|
|
40
41
|
coreUpdatecode(): Promise<string>;
|
|
41
42
|
coreReload(): Promise<string>;
|
|
42
43
|
coreRestart(): Promise<string>;
|
package/www/example/ctr/test.js
CHANGED
|
@@ -37,27 +37,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
// --- 库和定义 ---
|
|
40
|
-
const lCore = __importStar(require("
|
|
41
|
-
const lNet = __importStar(require("
|
|
42
|
-
const lDb = __importStar(require("
|
|
43
|
-
const lFs = __importStar(require("
|
|
44
|
-
const lText = __importStar(require("
|
|
45
|
-
const lCrypto = __importStar(require("
|
|
46
|
-
const lKv = __importStar(require("
|
|
47
|
-
const lCaptcha = __importStar(require("
|
|
48
|
-
const lTime = __importStar(require("
|
|
49
|
-
const lScan = __importStar(require("
|
|
50
|
-
const lSql = __importStar(require("
|
|
51
|
-
const lConsistent = __importStar(require("
|
|
52
|
-
const lSsh = __importStar(require("
|
|
53
|
-
const lJwt = __importStar(require("
|
|
54
|
-
const lWs = __importStar(require("
|
|
55
|
-
const lS3 = __importStar(require("
|
|
56
|
-
const lZip = __importStar(require("
|
|
57
|
-
const lBuffer = __importStar(require("
|
|
58
|
-
const lLan = __importStar(require("
|
|
59
|
-
const sCtr = __importStar(require("
|
|
60
|
-
const kebab = __importStar(require("
|
|
40
|
+
const lCore = __importStar(require("~/lib/core"));
|
|
41
|
+
const lNet = __importStar(require("~/lib/net"));
|
|
42
|
+
const lDb = __importStar(require("~/lib/db"));
|
|
43
|
+
const lFs = __importStar(require("~/lib/fs"));
|
|
44
|
+
const lText = __importStar(require("~/lib/text"));
|
|
45
|
+
const lCrypto = __importStar(require("~/lib/crypto"));
|
|
46
|
+
const lKv = __importStar(require("~/lib/kv"));
|
|
47
|
+
const lCaptcha = __importStar(require("~/lib/captcha"));
|
|
48
|
+
const lTime = __importStar(require("~/lib/time"));
|
|
49
|
+
const lScan = __importStar(require("~/lib/scan"));
|
|
50
|
+
const lSql = __importStar(require("~/lib/sql"));
|
|
51
|
+
const lConsistent = __importStar(require("~/lib/consistent"));
|
|
52
|
+
const lSsh = __importStar(require("~/lib/ssh"));
|
|
53
|
+
const lJwt = __importStar(require("~/lib/jwt"));
|
|
54
|
+
const lWs = __importStar(require("~/lib/ws"));
|
|
55
|
+
const lS3 = __importStar(require("~/lib/s3"));
|
|
56
|
+
const lZip = __importStar(require("~/lib/zip"));
|
|
57
|
+
const lBuffer = __importStar(require("~/lib/buffer"));
|
|
58
|
+
const lLan = __importStar(require("~/lib/lan"));
|
|
59
|
+
const sCtr = __importStar(require("~/sys/ctr"));
|
|
60
|
+
const kebab = __importStar(require("~/index"));
|
|
61
61
|
// --- mod ---
|
|
62
62
|
const test_1 = __importDefault(require("../mod/test"));
|
|
63
63
|
const testdata_1 = __importDefault(require("../mod/testdata"));
|
|
@@ -165,6 +165,7 @@ class default_1 extends sCtr.Ctr {
|
|
|
165
165
|
`<br><a href="${this._config.const.urlBase}test/core-checktype">View "test/core-checktype"</a>`,
|
|
166
166
|
`<br><a href="${this._config.const.urlBase}test/core-muid">View "test/core-muid"</a>`,
|
|
167
167
|
`<br><a href="${this._config.const.urlBase}test/core-getlog">View "test/core-getlog"</a>`,
|
|
168
|
+
`<br><a href="${this._config.const.urlBase}test/core-ls">View "test/core-ls"</a>`,
|
|
168
169
|
`<br><a href="${this._config.const.urlBase}test/core-reload">View "test/core-reload"</a>`,
|
|
169
170
|
`<br><a href="${this._config.const.urlBase}test/core-restart">View "test/core-restart"</a>`,
|
|
170
171
|
`<br><a href="${this._config.const.urlBase}test/core-global">View "test/core-global"</a>`,
|
|
@@ -1030,13 +1031,14 @@ for (let i = 0; i < 30000; ++i) {
|
|
|
1030
1031
|
async coreGetlog() {
|
|
1031
1032
|
const path = lTime.format(null, 'Y/m/d/H');
|
|
1032
1033
|
const list = await lCore.getLog({
|
|
1033
|
-
'
|
|
1034
|
+
'hostname': this._config.const.hostname,
|
|
1034
1035
|
'path': path,
|
|
1035
1036
|
'fend': '-visit',
|
|
1036
1037
|
});
|
|
1037
1038
|
const echo = [];
|
|
1038
|
-
echo.push('<table style="width: 100%;"
|
|
1039
|
+
echo.push('<table style="width: 100%;">');
|
|
1039
1040
|
if (list) {
|
|
1041
|
+
echo.push('<tr><th>TIME</th><th>UNIX</th><th>URL</th><th>COOKIE</th><th>SESSION</th><th>JWT</th><th>USER_AGENT</th><th>REALIP</th><th>CLIENTIP</th><th>MESSAGE</th></tr>');
|
|
1040
1042
|
for (const row of list) {
|
|
1041
1043
|
echo.push('<tr>');
|
|
1042
1044
|
for (const item of row) {
|
|
@@ -1046,7 +1048,41 @@ for (let i = 0; i < 30000; ++i) {
|
|
|
1046
1048
|
}
|
|
1047
1049
|
}
|
|
1048
1050
|
else {
|
|
1049
|
-
echo.push('<th>' + JSON.stringify(list) + '</th></tr>');
|
|
1051
|
+
echo.push('<tr><th>' + JSON.stringify(list) + '</th></tr>');
|
|
1052
|
+
}
|
|
1053
|
+
echo.push('</table>');
|
|
1054
|
+
return echo.join('') + '<br>' + this._getEnd();
|
|
1055
|
+
}
|
|
1056
|
+
async coreLs() {
|
|
1057
|
+
const echo = [
|
|
1058
|
+
'./'
|
|
1059
|
+
];
|
|
1060
|
+
const list = await lCore.ls({
|
|
1061
|
+
'path': './',
|
|
1062
|
+
});
|
|
1063
|
+
echo.push('<table style="width: 100%;">');
|
|
1064
|
+
for (const item of list) {
|
|
1065
|
+
echo.push('<tr>');
|
|
1066
|
+
echo.push('<td>' + lText.htmlescape(item.name) + '</td>');
|
|
1067
|
+
echo.push('<td>isDirectory:' + (item.isDirectory ? 'true' : 'false') + '</td>');
|
|
1068
|
+
echo.push('<td>isFile:' + (item.isFile ? 'true' : 'false') + '</td>');
|
|
1069
|
+
echo.push('<td>isSymbolicLink:' + (item.isSymbolicLink ? 'true' : 'false') + '</td>');
|
|
1070
|
+
echo.push('</tr>');
|
|
1071
|
+
}
|
|
1072
|
+
echo.push('</table>');
|
|
1073
|
+
// --- source/ ---
|
|
1074
|
+
echo.push('source/');
|
|
1075
|
+
const list2 = await lCore.ls({
|
|
1076
|
+
'path': 'source/',
|
|
1077
|
+
});
|
|
1078
|
+
echo.push('<table style="width: 100%;">');
|
|
1079
|
+
for (const item of list2) {
|
|
1080
|
+
echo.push('<tr>');
|
|
1081
|
+
echo.push('<td>' + lText.htmlescape(item.name) + '</td>');
|
|
1082
|
+
echo.push('<td>isDirectory:' + (item.isDirectory ? 'true' : 'false') + '</td>');
|
|
1083
|
+
echo.push('<td>isFile:' + (item.isFile ? 'true' : 'false') + '</td>');
|
|
1084
|
+
echo.push('<td>isSymbolicLink:' + (item.isSymbolicLink ? 'true' : 'false') + '</td>');
|
|
1085
|
+
echo.push('</tr>');
|
|
1050
1086
|
}
|
|
1051
1087
|
echo.push('</table>');
|
|
1052
1088
|
return echo.join('') + '<br>' + this._getEnd();
|
|
@@ -2620,6 +2656,7 @@ ${lTime.format(null, 'd|D|j|l|N|w|Y|y|F|M|m|H|h|i|s|T')}`;
|
|
|
2620
2656
|
<div style="margin-top: 10px; display: flex;">
|
|
2621
2657
|
<input id="text" style="flex: 1;">
|
|
2622
2658
|
<input id="send" type="button" value="Send" onclick="send()" disabled style="margin-left: 10px;">
|
|
2659
|
+
<input type="button" value="!Ping" onclick="pinging = !pinging; this.value = pinging ? 'Ping' : '!Ping';" style="margin-left: 10px;">
|
|
2623
2660
|
</div>
|
|
2624
2661
|
<script>
|
|
2625
2662
|
var ws = null;
|
|
@@ -2630,6 +2667,12 @@ var stopEl = document.getElementById('stop');
|
|
|
2630
2667
|
|
|
2631
2668
|
var textEl = document.getElementById('text');
|
|
2632
2669
|
var sendEl = document.getElementById('send');
|
|
2670
|
+
|
|
2671
|
+
function dateStr() {
|
|
2672
|
+
const date = new Date();
|
|
2673
|
+
return date.getHours().toString().padStart(2, '0') + ':' + date.getMinutes().toString().padStart(2, '0') + ':' + date.getSeconds().toString().padStart(2, '0');
|
|
2674
|
+
}
|
|
2675
|
+
|
|
2633
2676
|
function enter() {
|
|
2634
2677
|
var nick = nickEl.value.trim();
|
|
2635
2678
|
if (nick === '') {
|
|
@@ -2638,27 +2681,27 @@ function enter() {
|
|
|
2638
2681
|
}
|
|
2639
2682
|
nickEl.disabled = true;
|
|
2640
2683
|
btnEl.disabled = true;
|
|
2641
|
-
listEl.insertAdjacentHTML('afterbegin', '<div>Connecting...</div>');
|
|
2684
|
+
listEl.insertAdjacentHTML('afterbegin', '<div>[' + dateStr() + '] Connecting...</div>');
|
|
2642
2685
|
ws = new WebSocket('ws${this._config.const.https ? 's' : ''}://${this._config.const.host}/${this._get['ac'] === 'rproxy' ? 'rproxy' : 'test'}');
|
|
2643
2686
|
ws.onopen = function() {
|
|
2644
|
-
listEl.insertAdjacentHTML('afterbegin', '<div>Event: onOpen.</div>');
|
|
2687
|
+
listEl.insertAdjacentHTML('afterbegin', '<div>[' + dateStr() + '] Event: onOpen.</div>');
|
|
2645
2688
|
ws.send('Hello: ' + nick);
|
|
2646
|
-
listEl.insertAdjacentHTML('afterbegin', '<div>Client: send "Hello: ' + nick + '".</div>');
|
|
2689
|
+
listEl.insertAdjacentHTML('afterbegin', '<div>[' + dateStr() + '] Client: send "Hello: ' + nick + '".</div>');
|
|
2647
2690
|
stopEl.disabled = false;
|
|
2648
2691
|
sendEl.disabled = false;
|
|
2649
2692
|
};
|
|
2650
2693
|
ws.onmessage = function(ev) {
|
|
2651
|
-
listEl.insertAdjacentHTML('afterbegin', '<div>Server: ' + ev.data + '.</div>');
|
|
2694
|
+
listEl.insertAdjacentHTML('afterbegin', '<div>[' + dateStr() + '] Server: ' + ev.data + '.</div>');
|
|
2652
2695
|
};
|
|
2653
2696
|
ws.onclose = function() {
|
|
2654
|
-
listEl.insertAdjacentHTML('afterbegin', '<div>Event: onClose.</div>');
|
|
2697
|
+
listEl.insertAdjacentHTML('afterbegin', '<div>[' + dateStr() + '] Event: onClose.</div>');
|
|
2655
2698
|
nickEl.disabled = false;
|
|
2656
2699
|
btnEl.disabled = false;
|
|
2657
2700
|
stopEl.disabled = true;
|
|
2658
2701
|
sendEl.disabled = true;
|
|
2659
2702
|
};
|
|
2660
2703
|
ws.onerror = function(ev) {
|
|
2661
|
-
listEl.insertAdjacentHTML('afterbegin', '<div>Event: onError.</div>');
|
|
2704
|
+
listEl.insertAdjacentHTML('afterbegin', '<div>[' + dateStr() + '] Event: onError.</div>');
|
|
2662
2705
|
nickEl.disabled = false;
|
|
2663
2706
|
btnEl.disabled = false;
|
|
2664
2707
|
stopEl.disabled = true;
|
|
@@ -2673,6 +2716,16 @@ function send() {
|
|
|
2673
2716
|
ws.send(textEl.value);
|
|
2674
2717
|
textEl.value = '';
|
|
2675
2718
|
}
|
|
2719
|
+
var pinging = false;
|
|
2720
|
+
setInterval(() => {
|
|
2721
|
+
if (!ws) {
|
|
2722
|
+
return;
|
|
2723
|
+
}
|
|
2724
|
+
if (!pinging) {
|
|
2725
|
+
return;
|
|
2726
|
+
}
|
|
2727
|
+
ws.send('ping');
|
|
2728
|
+
}, 5_000);
|
|
2676
2729
|
</script>`;
|
|
2677
2730
|
return echo + '<br>' + this._getEnd();
|
|
2678
2731
|
}
|
package/www/example/mod/test.js
CHANGED
|
@@ -36,8 +36,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
const lCore = __importStar(require("
|
|
40
|
-
const mod_1 = __importDefault(require("
|
|
39
|
+
const lCore = __importStar(require("~/lib/core"));
|
|
40
|
+
const mod_1 = __importDefault(require("~/sys/mod"));
|
|
41
41
|
/*
|
|
42
42
|
CREATE TABLE `m_test` (
|
|
43
43
|
`id` int NOT NULL AUTO_INCREMENT,
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const mod_1 = __importDefault(require("
|
|
6
|
+
const mod_1 = __importDefault(require("~/sys/mod"));
|
|
7
7
|
/*
|
|
8
8
|
CREATE TABLE `m_test_data_0` (
|
|
9
9
|
`id` bigint NOT NULL AUTO_INCREMENT,
|
package/www/example/ws/mproxy.js
CHANGED
|
@@ -33,8 +33,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
const sCtr = __importStar(require("
|
|
37
|
-
const lWs = __importStar(require("
|
|
36
|
+
const sCtr = __importStar(require("~/sys/ctr"));
|
|
37
|
+
const lWs = __importStar(require("~/lib/ws"));
|
|
38
38
|
class default_1 extends sCtr.Ctr {
|
|
39
39
|
async onLoad() {
|
|
40
40
|
console.log('WebSocket mproxy test onLoad.');
|
package/www/example/ws/rproxy.js
CHANGED
|
@@ -33,8 +33,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
const sCtr = __importStar(require("
|
|
37
|
-
const lWs = __importStar(require("
|
|
36
|
+
const sCtr = __importStar(require("~/sys/ctr"));
|
|
37
|
+
const lWs = __importStar(require("~/lib/ws"));
|
|
38
38
|
class default_1 extends sCtr.Ctr {
|
|
39
39
|
async onLoad() {
|
|
40
40
|
console.log('WebSocket rproxy test onLoad.');
|
package/www/example/ws/test.d.ts
CHANGED
package/www/example/ws/test.js
CHANGED
|
@@ -33,8 +33,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
const sCtr = __importStar(require("
|
|
37
|
-
const lCrypto = __importStar(require("
|
|
36
|
+
const sCtr = __importStar(require("~/sys/ctr"));
|
|
37
|
+
const lCrypto = __importStar(require("~/lib/crypto"));
|
|
38
38
|
class default_1 extends sCtr.Ctr {
|
|
39
39
|
constructor() {
|
|
40
40
|
super(...arguments);
|
|
@@ -47,7 +47,7 @@ class default_1 extends sCtr.Ctr {
|
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
49
|
this._writeText('Other message, host: ' + this._config.const.host);
|
|
50
|
-
},
|
|
50
|
+
}, 2_000);
|
|
51
51
|
return true;
|
|
52
52
|
}
|
|
53
53
|
onData(data) {
|
|
@@ -59,6 +59,7 @@ class default_1 extends sCtr.Ctr {
|
|
|
59
59
|
return 'Base64: ' + lCrypto.base64Encode(data);
|
|
60
60
|
}
|
|
61
61
|
// --- 用户消息 ---
|
|
62
|
+
console.log('[' + Date.now() + '] WebSocket test onData, data: ' + data);
|
|
62
63
|
return '<b>' + this._nick + ':</b> ' + data;
|
|
63
64
|
}
|
|
64
65
|
onClose() {
|