cgserver 6.2.1 → 6.2.6

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.
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.core = void 0;
4
4
  let os = require('os');
5
5
  let request = require('request');
6
- const CryptoJS = require("crypto-js");
7
6
  const _ = require("underscore");
7
+ const crypto = require("crypto");
8
8
  /**
9
9
  * 常用的工具函数类
10
10
  */
@@ -322,17 +322,13 @@ class core {
322
322
  return newStr;
323
323
  }
324
324
  static md5(str) {
325
- let md5_str = CryptoJS.MD5(str).toString(CryptoJS.enc.Hex);
325
+ let md5_str = crypto.createHash('md5').update(str).digest('hex');
326
326
  return md5_str;
327
327
  }
328
328
  static sha1(str) {
329
- let sha1_str = CryptoJS.SHA1(str).toString(CryptoJS.enc.Hex);
329
+ let sha1_str = crypto.createHash('sha1').update(str).digest('hex');
330
330
  return sha1_str;
331
331
  }
332
- static sha3(str) {
333
- let sha3_str = CryptoJS.SHA3(str).toString(CryptoJS.enc.Hex);
334
- return sha3_str;
335
- }
336
332
  static getLocalIP = function () {
337
333
  let iptable = {};
338
334
  let ifaces = os.networkInterfaces();
@@ -72,7 +72,7 @@ class BaseService {
72
72
  return rs;
73
73
  }
74
74
  aggregate(pipeline, options) {
75
- let ret = MongoManager_1.GMongoMgr.aggregate(this._table);
75
+ let ret = MongoManager_1.GMongoMgr.aggregate(this._table, pipeline, options);
76
76
  return ret;
77
77
  }
78
78
  }
@@ -133,12 +133,7 @@ class MongoManager {
133
133
  let one = null;
134
134
  try {
135
135
  let col = this._mongo.collection(collection);
136
- if (!sort) {
137
- one = await col.findOne(where, property);
138
- }
139
- else {
140
- one = await (col.find(where, property).sort(sort).limit(1).next());
141
- }
136
+ one = await col.findOne(where, { projection: property });
142
137
  }
143
138
  catch (e) {
144
139
  Log_1.GLog.error(e.stack);
@@ -99,7 +99,7 @@ class IWebSocket {
99
99
  }
100
100
  }
101
101
  catch (e) {
102
- Log_1.GLog.error('Received Message Handle Error: ' + e);
102
+ Log_1.GLog.error(this.tipKey + ' Received Message Handle Error: ' + e);
103
103
  }
104
104
  }
105
105
  _onDecode(message, ...params) {
@@ -135,11 +135,11 @@ class IWebSocket {
135
135
  && jsonData
136
136
  && jsonData.cmd != "heartbeat") {
137
137
  Log_1.GLog.info(this.tipKey + " receive:--------", true);
138
- Log_1.GLog.info(jsonData, true);
138
+ Log_1.GLog.info({ tipKey: this.tipKey, jsonData }, true);
139
139
  }
140
140
  if (!jsonData.cmd || jsonData.cmd == "") {
141
- Log_1.GLog.error('Received Message warning: no cmd param,data=');
142
- Log_1.GLog.error(jsonData);
141
+ Log_1.GLog.error(this.tipKey + ' Received Message warning: no cmd param,data=');
142
+ Log_1.GLog.error({ tipKey: this.tipKey, jsonData });
143
143
  return false;
144
144
  }
145
145
  return true;
@@ -156,16 +156,11 @@ class IWebSocket {
156
156
  await this["receive_other_all"](jsonData); //默认支持其他所有处理消息
157
157
  }
158
158
  catch (e) {
159
- if (e && e.stack) {
160
- Log_1.GLog.error(e.stack);
161
- }
162
- else {
163
- Log_1.GLog.error(e + " msg:data=" + JSON.stringify(jsonData));
164
- }
159
+ Log_1.GLog.error(this.tipKey + e.stack);
165
160
  }
166
161
  }
167
162
  else {
168
- Log_1.GLog.error('Received Message warning: no cmd handle,cmd=' + jsonData.cmd);
163
+ Log_1.GLog.error(this.tipKey + ' Received Message warning: no cmd handle,cmd=' + jsonData.cmd);
169
164
  }
170
165
  }
171
166
  else {
@@ -173,35 +168,30 @@ class IWebSocket {
173
168
  await this["receive_" + jsonData.cmd](jsonData);
174
169
  }
175
170
  catch (e) {
176
- if (e && e.stack) {
177
- Log_1.GLog.error("error msg:data=" + JSON.stringify(jsonData) + "\n" + e.stack);
178
- }
179
- else {
180
- Log_1.GLog.error(e + " msg:data=" + JSON.stringify(jsonData));
181
- }
171
+ Log_1.GLog.error(this.tipKey + " error msg:data=" + JSON.stringify(jsonData) + "\n" + e.stack);
182
172
  }
183
173
  }
184
174
  }
185
175
  onOpen(e) {
186
176
  }
187
177
  onError(e) {
188
- Log_1.GLog.info("onError:" + e.message);
178
+ Log_1.GLog.error(this.tipKey + " onError:" + e.message);
189
179
  }
190
180
  onClose(reasonCode, description) {
191
- Log_1.GLog.info("onClose resonCode=" + reasonCode + " des=" + description);
181
+ Log_1.GLog.info(this.tipKey + " onClose resonCode=" + reasonCode + " des=" + description);
192
182
  }
193
183
  send(data) {
194
184
  if (!this.connected) {
195
185
  return;
196
186
  }
197
187
  if (!data) {
198
- Log_1.GLog.error("Send Message warning:null data!");
188
+ Log_1.GLog.error(this.tipKey + " Send Message warning:null data!");
199
189
  return;
200
190
  }
201
191
  if (this._debug_msg
202
192
  && data.cmd != "heartbeat") {
203
193
  Log_1.GLog.info(this.tipKey + " send:-----------------------------------", true);
204
- Log_1.GLog.info(data, true);
194
+ Log_1.GLog.info({ tipKey: this.tipKey, data }, true);
205
195
  }
206
196
  let msg = this._onEncode(data);
207
197
  this._ws.send(msg);
@@ -157,3 +157,4 @@ var Response_1 = require("./WebServer/Engine/Response");
157
157
  Object.defineProperty(exports, "Response", { enumerable: true, get: function () { return Response_1.Response; } });
158
158
  var FrameworkConfig_2 = require("./Config/FrameworkConfig");
159
159
  Object.defineProperty(exports, "WebServerConfig", { enumerable: true, get: function () { return FrameworkConfig_2.WebServerConfig; } });
160
+ process.env.TZ = "Asia/Shanghai";
@@ -40,7 +40,6 @@ export declare class core {
40
40
  static fuzzy(str: string): string;
41
41
  static md5(str: string): string;
42
42
  static sha1(str: string): string;
43
- static sha3(str: string): string;
44
43
  static getLocalIP: () => any;
45
44
  static getIP: () => Promise<string>;
46
45
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cgserver",
3
- "version": "6.2.1",
3
+ "version": "6.2.6",
4
4
  "author": "trojan",
5
5
  "type": "commonjs",
6
6
  "description": "free for all.Websocket or Http",
@@ -33,7 +33,6 @@
33
33
  "@alicloud/sms-sdk": "^1.1.6",
34
34
  "@types/cookie-parser": "^1.4.2",
35
35
  "@types/cors": "^2.8.12",
36
- "@types/crypto-js": "^4.1.1",
37
36
  "@types/express": "^4.17.13",
38
37
  "@types/formidable": "^2.0.0",
39
38
  "@types/mime": "^2.0.3",
@@ -52,7 +51,6 @@
52
51
  "colors": "^1.4.0",
53
52
  "cookie-parser": "^1.4.5",
54
53
  "cors": "^2.8.5",
55
- "crypto-js": "^4.1.1",
56
54
  "ec-key": "0.0.4",
57
55
  "express": "^4.17.1",
58
56
  "fast-xml-parser": "^3.21.1",