Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
antSword
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
HuangJunbo
antSword
Commits
035ddb5d
Commit
035ddb5d
authored
Jul 13, 2022
by
Medicean
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code(Modules/request): 调整 superagent ignoreHTTPS 注入,避免 npm upgrade之后引发问题
parent
6607a2d2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
54 deletions
+75
-54
CHANGELOG.md
CHANGELOG.md
+12
-0
database.js
modules/database.js
+51
-53
request.js
modules/request.js
+12
-1
No files found.
CHANGELOG.md
View file @
035ddb5d
...
...
@@ -66,10 +66,22 @@
*
支持自定义 Content-Type, 默认是
`form`
*
Fix #307
*
重新规整
`modules/request.js`
代码结构
### 设置模块
*
优化了新增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)`
...
...
modules/database.js
View file @
035ddb5d
...
...
@@ -10,7 +10,7 @@ const fs = require('fs'),
path
=
require
(
'path'
),
CONF
=
require
(
'./config'
),
Datastore
=
require
(
'nedb'
),
qqwry
=
require
(
"geoips"
).
info
();
qqwry
=
require
(
"geoips"
).
info
(
path
.
join
(
__dirname
,
'../static/libs/qqwry.dat'
)
);
var
logger
;
...
...
@@ -50,15 +50,13 @@ class Database {
}
convertOptstoNedbQuery
(
opts
=
{})
{
var
self
=
this
;
if
(
opts
instanceof
Array
)
{
for
(
let
i
=
0
;
i
<
opts
.
length
;
i
++
)
{
opts
[
i
]
=
self
.
convertOptstoNedbQuery
(
opts
[
i
]);
}
}
else
if
(
opts
instanceof
Object
)
{
Object
.
keys
(
opts
)
.
map
((
f
)
=>
{
var
self
=
this
;
if
(
opts
instanceof
Array
)
{
for
(
let
i
=
0
;
i
<
opts
.
length
;
i
++
)
{
opts
[
i
]
=
self
.
convertOptstoNedbQuery
(
opts
[
i
]);
}
}
else
if
(
opts
instanceof
Object
)
{
Object
.
keys
(
opts
).
map
((
f
)
=>
{
if
(
opts
[
f
]
instanceof
Object
)
{
opts
[
f
]
=
self
.
convertOptstoNedbQuery
(
opts
[
f
]);
}
...
...
@@ -69,15 +67,15 @@ class Database {
opts
[
f
]
=
new
RegExp
(
opts
[
f
],
'i'
);
}
});
}
return
opts
;
}
return
opts
;
}
/**
* 查询shell数据
* @param {Object} event ipcMain对象
* @param {Object} opts 查询配置
* @return {[type]} [description]
*/
/**
* 查询shell数据
* @param {Object} event ipcMain对象
* @param {Object} opts 查询配置
* @return {[type]} [description]
*/
findShell
(
event
,
opts
=
{})
{
opts
=
this
.
convertOptstoNedbQuery
(
opts
);
logger
.
debug
(
'findShell'
,
opts
);
...
...
@@ -460,42 +458,42 @@ class Database {
* @param {Object} opts 配置(_id,data
*/
addPluginDataConf
(
event
,
plugin
,
opts
)
{
logger
.
info
(
'addPluginDataConf'
,
plugin
,
opts
);
// 1. 获取原配置列表
this
.
cursor
.
findOne
({
_id
:
opts
[
'_id'
]
},
(
err
,
ret
)
=>
{
ret
[
'plugins'
]
=
ret
[
'plugins'
]
||
{};
let
confs
=
ret
[
'plugins'
][
plugin
]
||
{};
// 随机Id(顺序增长
const
random_id
=
parseInt
(
+
new
Date
+
Math
.
random
()
*
1000
).
toString
(
16
);
// 添加到配置
confs
[
random_id
]
=
opts
[
'data'
];
let
setdata
=
{
utime
:
+
new
Date
}
setdata
[
`plugins.
${
plugin
}
`
]
=
confs
;
logger
.
info
(
'addPluginDataConf'
,
plugin
,
opts
);
// 1. 获取原配置列表
this
.
cursor
.
findOne
({
_id
:
opts
[
'_id'
]
},
(
err
,
ret
)
=>
{
ret
[
'plugins'
]
=
ret
[
'plugins'
]
||
{};
let
confs
=
ret
[
'plugins'
][
plugin
]
||
{};
// 随机Id(顺序增长
const
random_id
=
parseInt
(
+
new
Date
+
Math
.
random
()
*
1000
).
toString
(
16
);
// 添加到配置
confs
[
random_id
]
=
opts
[
'data'
];
let
setdata
=
{
utime
:
+
new
Date
}
setdata
[
`plugins.
${
plugin
}
`
]
=
confs
;
// 更新
this
.
cursor
.
update
({
_id
:
opts
[
'_id'
]
},
{
$set
:
setdata
},
(
_err
,
_ret
)
=>
{
event
.
returnValue
=
random_id
;
});
});
}
/**
* 修改插件数据配置
* @param {Object} event ipcMain对象
* @param {string} plugin 插件注册的名称
* @param {Object} opts 配置(_id,id,data
*/
// 更新
this
.
cursor
.
update
({
_id
:
opts
[
'_id'
]
},
{
$set
:
setdata
},
(
_err
,
_ret
)
=>
{
event
.
returnValue
=
random_id
;
});
});
}
/**
* 修改插件数据配置
* @param {Object} event ipcMain对象
* @param {string} plugin 插件注册的名称
* @param {Object} opts 配置(_id,id,data
*/
editPluginDataConf
(
event
,
plugin
,
opts
)
{
logger
.
info
(
'editPluginDataConf'
,
plugin
,
opts
);
// 1. 获取原配置列表
...
...
modules/request.js
View file @
035ddb5d
...
...
@@ -30,6 +30,17 @@ const APROXY_CONF = {
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
{
constructor
(
electron
)
{
...
...
@@ -176,7 +187,7 @@ class Request {
.
type
(
self
.
reqContentType
)
// .set('Content-Type', 'application/x-www-form-urlencoded')
.
timeout
(
opts
.
timeout
||
REQ_TIMEOUT
)
.
ignoreHTTPS
(
opts
[
'ignoreHTTPS'
])
.
ignoreHTTPS
(
opts
[
'ignoreHTTPS'
])
;
if
(
opts
[
'useChunk'
]
==
1
)
{
logger
.
debug
(
"request with Chunked"
);
let
antstream
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment