cgserver 8.9.9 → 8.9.11
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.
|
@@ -331,12 +331,28 @@ class core {
|
|
|
331
331
|
newStr += last;
|
|
332
332
|
return newStr;
|
|
333
333
|
}
|
|
334
|
-
static md5(str) {
|
|
335
|
-
let
|
|
334
|
+
static md5(str, inputEncoding = null, encoding = "hex") {
|
|
335
|
+
let _md5 = crypto.createHash('md5');
|
|
336
|
+
let hash = null;
|
|
337
|
+
if (inputEncoding) {
|
|
338
|
+
hash = _md5.update(str, inputEncoding);
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
hash = _md5.update(str);
|
|
342
|
+
}
|
|
343
|
+
let md5_str = hash.digest(encoding);
|
|
336
344
|
return md5_str;
|
|
337
345
|
}
|
|
338
|
-
static sha1(str) {
|
|
339
|
-
let
|
|
346
|
+
static sha1(str, inputEncoding = null, encoding = "hex") {
|
|
347
|
+
let _sha1 = crypto.createHash('sha1');
|
|
348
|
+
let hash = null;
|
|
349
|
+
if (inputEncoding) {
|
|
350
|
+
hash = _sha1.update(str, inputEncoding);
|
|
351
|
+
}
|
|
352
|
+
else {
|
|
353
|
+
hash = _sha1.update(str);
|
|
354
|
+
}
|
|
355
|
+
let sha1_str = hash.digest(encoding);
|
|
340
356
|
return sha1_str;
|
|
341
357
|
}
|
|
342
358
|
static getLocalIP = function () {
|
|
@@ -64,7 +64,7 @@ class Engine {
|
|
|
64
64
|
}
|
|
65
65
|
this._app.use(cors({
|
|
66
66
|
origin: origin,
|
|
67
|
-
methods: this._cfg.cors.methods || 'GET,HEAD,PUT,PATCH,POST,DELETE',
|
|
67
|
+
methods: this._cfg.cors.methods || 'GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS',
|
|
68
68
|
allowedHeaders: this._cfg.cors.allowedHeaders || ['Content-Type'],
|
|
69
69
|
credentials: this._cfg.cors.credentials || false
|
|
70
70
|
}));
|
|
@@ -87,11 +87,12 @@ class Engine {
|
|
|
87
87
|
let req = new Request_1.Request(_req, this._cfg);
|
|
88
88
|
let res = new Response_1.Response(_res, this._cfg);
|
|
89
89
|
let method = req.method.toLowerCase();
|
|
90
|
+
if (method == "options") {
|
|
91
|
+
_res.sendStatus(200);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
90
94
|
if (method == "head") {
|
|
91
|
-
_res.
|
|
92
|
-
Log_1.GLog.info(_req.headers);
|
|
93
|
-
Log_1.GLog.info(_req.rawHeaders);
|
|
94
|
-
Log_1.GLog.info(_req.body);
|
|
95
|
+
_res.sendStatus(200);
|
|
95
96
|
return;
|
|
96
97
|
}
|
|
97
98
|
if (method != "get" && method != "post") {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as crypto from "crypto";
|
|
1
3
|
/**
|
|
2
4
|
* 常用的工具函数类
|
|
3
5
|
*/
|
|
@@ -39,8 +41,8 @@ export declare class core {
|
|
|
39
41
|
* @param str
|
|
40
42
|
*/
|
|
41
43
|
static fuzzy(str: string): string;
|
|
42
|
-
static md5(str: string): string;
|
|
43
|
-
static sha1(str: string): string;
|
|
44
|
+
static md5(str: string, inputEncoding?: crypto.Encoding, encoding?: crypto.BinaryToTextEncoding): string;
|
|
45
|
+
static sha1(str: string, inputEncoding?: crypto.Encoding, encoding?: crypto.BinaryToTextEncoding): string;
|
|
44
46
|
static getLocalIP: () => any;
|
|
45
47
|
static getIP: () => Promise<string>;
|
|
46
48
|
/**
|