cgserver 9.1.2 → 9.1.5
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/README.md +5 -0
- package/dist/lib/Framework/Database/Decorator/DBCache.js +2 -1
- package/dist/lib/Framework/Database/MongoBaseService.js +0 -2
- package/dist/lib/Framework/Logic/HttpTool.js +6 -6
- package/dist/lib/Framework/SocketServer/IWebSocket.js +10 -3
- package/dist/lib/Framework/SocketServer/ProtoFilter/JsonProtoFilter.js +2 -1
- package/dist/lib/Framework/ThirdParty/QQTool.js +2 -1
- package/dist/lib/Framework/WebServer/Engine/Engine.js +13 -7
- package/dist/lib/Framework/WebServer/Engine/Request.js +2 -21
- package/dist/lib/Framework/index.js +3 -5
- package/dist/types/Framework/Logic/HttpTool.d.ts +2 -0
- package/dist/types/Framework/SocketServer/IWebSocket.d.ts +1 -0
- package/dist/types/Framework/index.d.ts +0 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.GDBCache = exports.VersionModel = void 0;
|
|
4
4
|
const Log_1 = require("./../../Logic/Log");
|
|
5
5
|
const fs = require("fs");
|
|
6
|
+
const lossless_json_1 = require("lossless-json");
|
|
6
7
|
class VersionModel {
|
|
7
8
|
table = "";
|
|
8
9
|
version = 0;
|
|
@@ -24,7 +25,7 @@ class DBCache {
|
|
|
24
25
|
if (fs.existsSync(this._path)) {
|
|
25
26
|
try {
|
|
26
27
|
let table = fs.readFileSync(this._path);
|
|
27
|
-
this._versions =
|
|
28
|
+
this._versions = (0, lossless_json_1.parse)(table.toString());
|
|
28
29
|
}
|
|
29
30
|
catch (e) {
|
|
30
31
|
Log_1.GLog.info("error:" + this._path);
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MongoBaseService = void 0;
|
|
4
4
|
const MongoManager_1 = require("./MongoManager");
|
|
5
|
-
const MongoServiceManager_1 = require("./MongoServiceManager");
|
|
6
5
|
class MongoBaseService {
|
|
7
6
|
_table = "";
|
|
8
7
|
get table() {
|
|
@@ -27,7 +26,6 @@ class MongoBaseService {
|
|
|
27
26
|
this._t_type = type;
|
|
28
27
|
this._table = table;
|
|
29
28
|
this._dbname = dbname;
|
|
30
|
-
MongoServiceManager_1.GMongoSerMgr.add(this);
|
|
31
29
|
}
|
|
32
30
|
async getNextId(key = "") {
|
|
33
31
|
if (!key) {
|
|
@@ -18,7 +18,7 @@ class HttpTool {
|
|
|
18
18
|
}
|
|
19
19
|
return new Promise((resolve, reject) => {
|
|
20
20
|
request.get(options, (error, response, body) => {
|
|
21
|
-
let
|
|
21
|
+
let originbody = body;
|
|
22
22
|
if (error) {
|
|
23
23
|
Log_1.GLog.error("get:" + options.url);
|
|
24
24
|
Log_1.GLog.error(error);
|
|
@@ -33,10 +33,10 @@ class HttpTool {
|
|
|
33
33
|
body = qs.parse(body);
|
|
34
34
|
}
|
|
35
35
|
catch (e) {
|
|
36
|
-
body =
|
|
36
|
+
body = originbody;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
resolve({ error, response, body });
|
|
39
|
+
resolve({ error, response, body, originbody });
|
|
40
40
|
});
|
|
41
41
|
});
|
|
42
42
|
}
|
|
@@ -50,7 +50,7 @@ class HttpTool {
|
|
|
50
50
|
}
|
|
51
51
|
return new Promise((resolve, reject) => {
|
|
52
52
|
request.post(options, (error, response, body) => {
|
|
53
|
-
let
|
|
53
|
+
let originbody = body;
|
|
54
54
|
if (error) {
|
|
55
55
|
Log_1.GLog.error("post:" + options.url);
|
|
56
56
|
Log_1.GLog.error(error);
|
|
@@ -65,10 +65,10 @@ class HttpTool {
|
|
|
65
65
|
body = qs.parse(body);
|
|
66
66
|
}
|
|
67
67
|
catch (e) {
|
|
68
|
-
body =
|
|
68
|
+
body = originbody;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
resolve({ error, response, body });
|
|
71
|
+
resolve({ error, response, body, originbody });
|
|
72
72
|
});
|
|
73
73
|
});
|
|
74
74
|
}
|
|
@@ -165,18 +165,25 @@ class IWebSocket {
|
|
|
165
165
|
onClose(reasonCode, description) {
|
|
166
166
|
Log_1.GLog.info(this.tipKey + " onClose resonCode=" + reasonCode + " des=" + description);
|
|
167
167
|
}
|
|
168
|
-
|
|
168
|
+
filterSendMsg(msg) {
|
|
169
169
|
if (!this.connected) {
|
|
170
|
-
return;
|
|
170
|
+
return false;
|
|
171
171
|
}
|
|
172
172
|
if (!msg) {
|
|
173
173
|
Log_1.GLog.error(this.tipKey + " Send Message warning:null data!");
|
|
174
|
-
return;
|
|
174
|
+
return false;
|
|
175
175
|
}
|
|
176
176
|
if (this._debug_msg
|
|
177
177
|
&& msg.cmd != "heartbeat") {
|
|
178
178
|
Log_1.GLog.info({ tipKey: this.tipKey, action: "send", msg });
|
|
179
179
|
}
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
send(msg) {
|
|
183
|
+
let ret = this.filterSendMsg(msg);
|
|
184
|
+
if (!ret) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
180
187
|
let data = this._onEncode(msg);
|
|
181
188
|
this._ws.send(data);
|
|
182
189
|
}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.JsonProtoFilter = void 0;
|
|
4
4
|
const Core_1 = require("../../Core/Core");
|
|
5
5
|
const Log_1 = require("../../Logic/Log");
|
|
6
|
+
const lossless_json_1 = require("lossless-json");
|
|
6
7
|
class JsonProtoFilter {
|
|
7
8
|
init(path) {
|
|
8
9
|
return true;
|
|
@@ -16,7 +17,7 @@ class JsonProtoFilter {
|
|
|
16
17
|
decode(data) {
|
|
17
18
|
try {
|
|
18
19
|
if (Core_1.core.isString(data)) {
|
|
19
|
-
data =
|
|
20
|
+
data = (0, lossless_json_1.parse)(data);
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
catch (e) {
|
|
@@ -6,6 +6,7 @@ const URLEncode = require("urlencode");
|
|
|
6
6
|
const IServerConfig_1 = require("../Config/IServerConfig");
|
|
7
7
|
const HttpTool_1 = require("../Logic/HttpTool");
|
|
8
8
|
const Log_1 = require("../Logic/Log");
|
|
9
|
+
const lossless_json_1 = require("lossless-json");
|
|
9
10
|
class QQUserInfo {
|
|
10
11
|
ret = 0;
|
|
11
12
|
msg = "";
|
|
@@ -92,7 +93,7 @@ class QQTool {
|
|
|
92
93
|
body = body.replace("callback( ", "");
|
|
93
94
|
body = body.replace(" );\n", "");
|
|
94
95
|
try {
|
|
95
|
-
body =
|
|
96
|
+
body = (0, lossless_json_1.parse)(body);
|
|
96
97
|
}
|
|
97
98
|
catch (e) { }
|
|
98
99
|
if (!body.openid) {
|
|
@@ -5,6 +5,7 @@ const Response_1 = require("./Response");
|
|
|
5
5
|
const Request_1 = require("./Request");
|
|
6
6
|
const ControllerManager_1 = require("./ControllerManager");
|
|
7
7
|
const http = require("http");
|
|
8
|
+
const https = require("https");
|
|
8
9
|
const Log_1 = require("../../Logic/Log");
|
|
9
10
|
const cors = require("cors");
|
|
10
11
|
const Express = require("express");
|
|
@@ -29,25 +30,30 @@ class Engine {
|
|
|
29
30
|
}
|
|
30
31
|
start() {
|
|
31
32
|
let port = this._cfg.port;
|
|
32
|
-
let https = require("https");
|
|
33
|
+
//let https = require("https");
|
|
33
34
|
let fs = require("fs");
|
|
34
35
|
if (!port) {
|
|
35
36
|
Log_1.GLog.error(this._cfg);
|
|
36
37
|
return;
|
|
37
38
|
}
|
|
38
|
-
http.createServer(this._app).listen(port, () => {
|
|
39
|
-
this._is_running = true;
|
|
40
|
-
Log_1.GLog.info("Server(" + this._cfg.web_name + ") running at http://127.0.0.1:" + port + "/");
|
|
41
|
-
});
|
|
42
39
|
if (this._cfg.ssl) {
|
|
43
40
|
const httpsOption = {
|
|
44
41
|
key: fs.readFileSync(this._cfg.ssl.key),
|
|
45
42
|
cert: fs.readFileSync(this._cfg.ssl.crt)
|
|
46
43
|
};
|
|
47
|
-
https.createServer(httpsOption, this._app).listen(port
|
|
48
|
-
|
|
44
|
+
https.createServer(httpsOption, this._app).listen(port, () => {
|
|
45
|
+
this._is_running = true;
|
|
46
|
+
Log_1.GLog.info("Server(" + this._cfg.web_name + ") running at https://127.0.0.1:" + port + "/");
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
http.createServer(this._app).listen(port, () => {
|
|
51
|
+
this._is_running = true;
|
|
52
|
+
Log_1.GLog.info("Server(" + this._cfg.web_name + ") running at http://127.0.0.1:" + port + "/");
|
|
53
|
+
});
|
|
49
54
|
}
|
|
50
55
|
this._app.use(cookieParser());
|
|
56
|
+
this._app.use(Express.raw());
|
|
51
57
|
this._app.use(Express.json({ limit: '10mb', verify(req, res, buf, encoding) {
|
|
52
58
|
req["rawBody"] = buf;
|
|
53
59
|
}, }));
|
|
@@ -4,6 +4,7 @@ exports.Request = void 0;
|
|
|
4
4
|
const url_1 = require("url");
|
|
5
5
|
const Core_1 = require("../../Core/Core");
|
|
6
6
|
const Log_1 = require("../../Logic/Log");
|
|
7
|
+
const lossless_json_1 = require("lossless-json");
|
|
7
8
|
class Request {
|
|
8
9
|
_req = null;
|
|
9
10
|
get baseReq() {
|
|
@@ -70,32 +71,13 @@ class Request {
|
|
|
70
71
|
}
|
|
71
72
|
if (Core_1.core.isString(body)) {
|
|
72
73
|
try {
|
|
73
|
-
body =
|
|
74
|
+
body = (0, lossless_json_1.parse)(body);
|
|
74
75
|
}
|
|
75
76
|
catch (e) {
|
|
76
77
|
Log_1.GLog.error("post data--" + body + "--parse error");
|
|
77
78
|
body = {};
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
|
-
// 暂时去掉强制数值转换
|
|
81
|
-
// //服务器会有一层空key的json解析
|
|
82
|
-
// for(let k in body)
|
|
83
|
-
// {
|
|
84
|
-
// var v = body[k]
|
|
85
|
-
// if(!core.isString(v))
|
|
86
|
-
// {
|
|
87
|
-
// continue
|
|
88
|
-
// }
|
|
89
|
-
// let intv = parseInt(v)
|
|
90
|
-
// if(intv==v)
|
|
91
|
-
// {
|
|
92
|
-
// body[k]=intv
|
|
93
|
-
// }
|
|
94
|
-
// else if(parseFloat(v)==v)
|
|
95
|
-
// {
|
|
96
|
-
// body[k]==parseFloat(v)
|
|
97
|
-
// }
|
|
98
|
-
// }
|
|
99
81
|
return body;
|
|
100
82
|
}
|
|
101
83
|
get url() {
|
|
@@ -124,7 +106,6 @@ class Request {
|
|
|
124
106
|
ip = ips;
|
|
125
107
|
}
|
|
126
108
|
ip = ip ||
|
|
127
|
-
this._req.connection.remoteAddress ||
|
|
128
109
|
this._req.socket.remoteAddress ||
|
|
129
110
|
this._req.ip || "";
|
|
130
111
|
ip = ip.replace("::ffff:", "");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MongoUserModel = exports.MysqlUserModel = exports.MongoUserService = exports.MysqlUserService = exports.MongoAccountService = exports.MysqlAccountService = exports.EAccountFrom = exports.EUserState = exports.ERoleGroup = exports.GLog = exports.GHttpTool = exports.GCacheTool = exports.
|
|
4
|
-
exports.Rpc = exports.RpcBaseMsg = exports.EAccountState = exports.GEventTool = exports.GSyncQueueTool = exports.WebServerConfig = exports.Response = exports.Request = exports.RazorJs = exports.Engine = exports.GCtrMgr = exports.JsonCreatorValidate = exports.JsonAuthorityValidate = exports.JsonAdminValidate = exports.CreatorValidate = exports.AuthorityValidate = exports.AdminValidate = exports.MongoAccountModel = exports.MysqlAccountModel = exports.MongoBaseUserController = exports.MysqlBaseUserController = exports.BaseController = exports.IWebServer = exports.GWechatTool = exports.GWechatOATool = exports.GQQTool = exports.GQiniuTool = exports.GOpenSocial = exports.GEmailTool = exports.GAppleTool = exports.GSmsTool = exports.AlipayCallBack = exports.AlipayResult = exports.GAlipayTool = exports.BaseMsg = exports.IWebSocket = exports.ISocketServer = exports.IClientWebSocket = exports.IServerWebSocket = exports.JsonProtoFilter = exports.GoogleProtoFilter = exports.EProtoType = exports.GProtoFactory = exports.RedisConfig = exports.MysqlConfig = exports.MongoConfig = exports.MSSqlConfig = exports.DbConfig = exports.MongoCacheModel =
|
|
5
|
-
exports.GByteTool = exports.SyncCallServer2 = exports.SyncCallServer = exports.SyncCall2 = exports.SyncCall = exports.IRpcClientWebSocket = exports.IRpcServerWebSocket = exports.RpcConfig =
|
|
3
|
+
exports.GMongoCacheSer = exports.MongoUserModel = exports.MysqlUserModel = exports.MongoUserService = exports.MysqlUserService = exports.MongoAccountService = exports.MysqlAccountService = exports.EAccountFrom = exports.EUserState = exports.ERoleGroup = exports.GLog = exports.GHttpTool = exports.GCacheTool = exports.RedisManager = exports.GRedisMgr = exports.SqlReturns = exports.SqlReturn = exports.SqlResult = exports.GMysqlMgr = exports.MysqlBaseService = exports.GMSSqlMgr = exports.GMongoMgr = exports.MongoExt = exports.MongoManager = exports.MongoBaseModel = exports.MysqlBaseModel = exports.MongoBaseService = exports.EPropertyType = exports.Type = exports.Table = exports.Property = exports.PrimaryKey = exports.NotNull = exports.AutoIncrement = exports.Timer = exports.core = exports.GServerCfg = exports.IServerConfig = exports.FrameworkConfig = exports.Config = exports.FrameworkErrorCode = exports.GTriggerMgr = exports.Trigger = exports.Point = exports.Entity = exports.BehaviorAI = exports.AStar = exports.AiObject = exports.GDBCache = exports.GCgServer = void 0;
|
|
4
|
+
exports.CgMq = exports.Rpc = exports.RpcBaseMsg = exports.EAccountState = exports.GEventTool = exports.GSyncQueueTool = exports.WebServerConfig = exports.Response = exports.Request = exports.RazorJs = exports.Engine = exports.GCtrMgr = exports.JsonCreatorValidate = exports.JsonAuthorityValidate = exports.JsonAdminValidate = exports.CreatorValidate = exports.AuthorityValidate = exports.AdminValidate = exports.MongoAccountModel = exports.MysqlAccountModel = exports.MongoBaseUserController = exports.MysqlBaseUserController = exports.BaseController = exports.IWebServer = exports.GWechatTool = exports.GWechatOATool = exports.GQQTool = exports.GQiniuTool = exports.GOpenSocial = exports.GEmailTool = exports.GAppleTool = exports.GSmsTool = exports.AlipayCallBack = exports.AlipayResult = exports.GAlipayTool = exports.BaseMsg = exports.IWebSocket = exports.ISocketServer = exports.IClientWebSocket = exports.IServerWebSocket = exports.JsonProtoFilter = exports.GoogleProtoFilter = exports.EProtoType = exports.GProtoFactory = exports.RedisConfig = exports.MysqlConfig = exports.MongoConfig = exports.MSSqlConfig = exports.DbConfig = exports.MongoCacheModel = void 0;
|
|
5
|
+
exports.GByteTool = exports.SyncCallServer2 = exports.SyncCallServer = exports.SyncCall2 = exports.SyncCall = exports.IRpcClientWebSocket = exports.IRpcServerWebSocket = exports.RpcConfig = void 0;
|
|
6
6
|
var cgserver_1 = require("./cgserver");
|
|
7
7
|
Object.defineProperty(exports, "GCgServer", { enumerable: true, get: function () { return cgserver_1.GCgServer; } });
|
|
8
8
|
var DBCache_1 = require("./Database/Decorator/DBCache");
|
|
@@ -70,8 +70,6 @@ Object.defineProperty(exports, "SqlReturns", { enumerable: true, get: function (
|
|
|
70
70
|
var RedisManager_1 = require("./Database/RedisManager");
|
|
71
71
|
Object.defineProperty(exports, "GRedisMgr", { enumerable: true, get: function () { return RedisManager_1.GRedisMgr; } });
|
|
72
72
|
Object.defineProperty(exports, "RedisManager", { enumerable: true, get: function () { return RedisManager_1.RedisManager; } });
|
|
73
|
-
var MongoServiceManager_1 = require("./Database/MongoServiceManager");
|
|
74
|
-
Object.defineProperty(exports, "GMongoSerMgr", { enumerable: true, get: function () { return MongoServiceManager_1.GMongoSerMgr; } });
|
|
75
73
|
var CacheTool_1 = require("./Logic/CacheTool");
|
|
76
74
|
Object.defineProperty(exports, "GCacheTool", { enumerable: true, get: function () { return CacheTool_1.GCacheTool; } });
|
|
77
75
|
var HttpTool_1 = require("./Logic/HttpTool");
|
|
@@ -5,11 +5,13 @@ declare class HttpTool {
|
|
|
5
5
|
error: any;
|
|
6
6
|
response: any;
|
|
7
7
|
body: any;
|
|
8
|
+
originbody: any;
|
|
8
9
|
}>;
|
|
9
10
|
post(options_url: request.OptionsWithUrl | string): Promise<{
|
|
10
11
|
error: any;
|
|
11
12
|
response: any;
|
|
12
13
|
body: any;
|
|
14
|
+
originbody: any;
|
|
13
15
|
}>;
|
|
14
16
|
}
|
|
15
17
|
export {};
|
|
@@ -55,6 +55,7 @@ export declare class IWebSocket {
|
|
|
55
55
|
onOpen(e?: any): void;
|
|
56
56
|
onError(e: Error): void;
|
|
57
57
|
onClose(reasonCode: number, description: string): void;
|
|
58
|
+
filterSendMsg(msg: BaseMsg): boolean;
|
|
58
59
|
send(msg: BaseMsg): void;
|
|
59
60
|
close(): void;
|
|
60
61
|
getServerNameFromCmd(cmd: any): any;
|
|
@@ -27,7 +27,6 @@ export { GMSSqlMgr } from './Database/MSSqlManager';
|
|
|
27
27
|
export { MysqlBaseService } from './Database/MysqlBaseService';
|
|
28
28
|
export { GMysqlMgr, SqlResult, SqlReturn, SqlReturns } from './Database/MysqlManager';
|
|
29
29
|
export { GRedisMgr, RedisManager } from './Database/RedisManager';
|
|
30
|
-
export { GMongoSerMgr } from './Database/MongoServiceManager';
|
|
31
30
|
export { GCacheTool } from './Logic/CacheTool';
|
|
32
31
|
export { GHttpTool } from './Logic/HttpTool';
|
|
33
32
|
export { GLog } from './Logic/Log';
|