mirror of
https://gitlab.com/Binaryify/neteasecloudmusicapi.git
synced 2025-07-03 15:02:08 +08:00
Add pac proxy support
This commit is contained in:
parent
3bf65d8233
commit
87dbf1d35e
@ -17,6 +17,7 @@
|
||||
"dependencies": {
|
||||
"apicache": "^1.2.1",
|
||||
"express": "^4.16.3",
|
||||
"pac-proxy-agent": "^3.0.0",
|
||||
"request": "^2.85.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -1,6 +1,7 @@
|
||||
const encrypt = require('./crypto')
|
||||
const request = require('request')
|
||||
const queryString = require('querystring')
|
||||
const PacProxyAgent = require('pac-proxy-agent')
|
||||
|
||||
// request.debug = true // 开启可看到更详细信息
|
||||
|
||||
@ -67,14 +68,21 @@ const createRequest = (method, url, data, options) => {
|
||||
}
|
||||
|
||||
const answer = { status: 500, body: {}, cookie: [] }
|
||||
request(
|
||||
{
|
||||
const settings = {
|
||||
method: method,
|
||||
url: url,
|
||||
headers: headers,
|
||||
body: queryString.stringify(data),
|
||||
proxy: options.proxy
|
||||
},
|
||||
body: queryString.stringify(data)
|
||||
}
|
||||
|
||||
if (/\.pac$/i.test(options.proxy)) {
|
||||
settings.agent = new PacProxyAgent(options.proxy)
|
||||
} else {
|
||||
settings.proxy = options.proxy
|
||||
}
|
||||
|
||||
request(
|
||||
settings,
|
||||
(err, res, body) => {
|
||||
if (err) {
|
||||
answer.status = 502
|
||||
|
Loading…
x
Reference in New Issue
Block a user