Commit 0c8ef7ab authored by Medicean's avatar Medicean Committed by Medicean

Code(Modules/request): 调整 superagent ignoreHTTPS 注入,避免 npm upgrade之后引发问题

parent 57aa049b
...@@ -66,10 +66,22 @@ ...@@ -66,10 +66,22 @@
* 支持自定义 Content-Type, 默认是 `form` * 支持自定义 Content-Type, 默认是 `form`
* Fix #307 * Fix #307
* 重新规整 `modules/request.js` 代码结构
### 设置模块 ### 设置模块
* 优化了新增Core类型时,编码设置解析逻辑, 现在不需要再改该模块的源代码了 * 优化了新增Core类型时,编码设置解析逻辑, 现在不需要再改该模块的源代码了
* 优化全局代理设置, 代理在设置完后不需要再重启了
### 其它
* 更新纯真IP数据库为 2022/04/20 (https://github.com/out0fmemory/qqwry.dat)
> 如需自己更新请下载后替换 `static/libs/qqwry.dat` 文件
* 升级 superagent 到 6.1.0 (再高的版本需要高版本Electron支持)
* 升级 superagent-proxy 到 v3.0.0
## 2021/07/25 `v(2.1.14)` ## 2021/07/25 `v(2.1.14)`
......
...@@ -10,7 +10,7 @@ const fs = require('fs'), ...@@ -10,7 +10,7 @@ const fs = require('fs'),
path = require('path'), path = require('path'),
CONF = require('./config'), CONF = require('./config'),
Datastore = require('nedb'), Datastore = require('nedb'),
qqwry = require("geoips").info(); qqwry = require("geoips").info(path.join(__dirname, '../static/libs/qqwry.dat'));
var logger; var logger;
...@@ -56,9 +56,7 @@ class Database { ...@@ -56,9 +56,7 @@ class Database {
opts[i] = self.convertOptstoNedbQuery(opts[i]); opts[i] = self.convertOptstoNedbQuery(opts[i]);
} }
} else if (opts instanceof Object) { } else if (opts instanceof Object) {
Object Object.keys(opts).map((f) => {
.keys(opts)
.map((f) => {
if (opts[f] instanceof Object) { if (opts[f] instanceof Object) {
opts[f] = self.convertOptstoNedbQuery(opts[f]); opts[f] = self.convertOptstoNedbQuery(opts[f]);
} }
......
...@@ -30,6 +30,17 @@ const APROXY_CONF = { ...@@ -30,6 +30,17 @@ const APROXY_CONF = {
uri: '' uri: ''
} }
/**
* 忽略 HTTPS 证书校验 SuperAgent patch
* @param {bool} ignore
* @api public
*/
superagent.Request.prototype.ignoreHTTPS = function(ignore) {
this._ignoreHttps = !ignore;
process.env.NODE_TLS_REJECT_UNAUTHORIZED = ignore ? '0' : undefined;
return this;
};
class Request { class Request {
constructor(electron) { constructor(electron) {
...@@ -176,7 +187,7 @@ class Request { ...@@ -176,7 +187,7 @@ class Request {
.type(self.reqContentType) .type(self.reqContentType)
// .set('Content-Type', 'application/x-www-form-urlencoded') // .set('Content-Type', 'application/x-www-form-urlencoded')
.timeout(opts.timeout || REQ_TIMEOUT) .timeout(opts.timeout || REQ_TIMEOUT)
.ignoreHTTPS(opts['ignoreHTTPS']) .ignoreHTTPS(opts['ignoreHTTPS']);
if (opts['useChunk'] == 1) { if (opts['useChunk'] == 1) {
logger.debug("request with Chunked"); logger.debug("request with Chunked");
let antstream; let antstream;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment