fix: http_proxy is not supported.

This commit is contained in:
zhzy0077 2024-02-26 16:39:39 +08:00
parent 3a99cc56b7
commit 0669338ede
6 changed files with 20 additions and 12 deletions

View file

@ -22,6 +22,7 @@ const UID = process.env.AUDIOBOOKSHELF_UID
const GID = process.env.AUDIOBOOKSHELF_GID
const SOURCE = process.env.SOURCE || 'docker'
const ROUTER_BASE_PATH = process.env.ROUTER_BASE_PATH || ''
const DISABLE_SSRF = process.env.DISABLE_SSRF || false
console.log('Config', CONFIG_PATH, METADATA_PATH)

20
package-lock.json generated
View file

@ -9,7 +9,7 @@
"version": "2.8.0",
"license": "GPL-3.0",
"dependencies": {
"axios": "^0.27.2",
"axios": "^1.6.7",
"cookie-parser": "^1.4.6",
"express": "^4.17.1",
"express-session": "^1.17.3",
@ -1134,12 +1134,13 @@
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
},
"node_modules/axios": {
"version": "0.27.2",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz",
"integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==",
"version": "1.6.7",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.6.7.tgz",
"integrity": "sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==",
"dependencies": {
"follow-redirects": "^1.14.9",
"form-data": "^4.0.0"
"follow-redirects": "^1.15.4",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
},
"node_modules/balanced-match": {
@ -4276,6 +4277,11 @@
"node": ">= 0.10"
}
},
"node_modules/proxy-from-env": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
},
"node_modules/pstree.remy": {
"version": "1.1.8",
"resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz",
@ -5554,4 +5560,4 @@
}
}
}
}
}

View file

@ -35,7 +35,7 @@
"author": "advplyr",
"license": "GPL-3.0",
"dependencies": {
"axios": "^0.27.2",
"axios": "^1.6.7",
"cookie-parser": "^1.4.6",
"express": "^4.17.1",
"express-session": "^1.17.3",

View file

@ -52,6 +52,7 @@ class Server {
global.MetadataPath = fileUtils.filePathToPOSIX(Path.normalize(METADATA_PATH))
global.RouterBasePath = ROUTER_BASE_PATH
global.XAccel = process.env.USE_X_ACCEL
global.DisableSSRF = process.env.DISABLE_SSRF
if (!fs.pathExistsSync(global.ConfigPath)) {
fs.mkdirSync(global.ConfigPath)

View file

@ -251,8 +251,8 @@ module.exports.downloadFile = (url, filepath, contentTypeFilter = null) => {
method: 'GET',
responseType: 'stream',
timeout: 30000,
httpAgent: ssrfFilter(url),
httpsAgent: ssrfFilter(url)
httpAgent: !global.DisableSSRF ? ssrfFilter(url) : undefined,
httpsAgent: !global.DisableSSRF ? ssrfFilter(url) : undefined
}).then((response) => {
// Validate content type
if (contentTypeFilter && !contentTypeFilter?.(response.headers?.['content-type'])) {

View file

@ -234,8 +234,8 @@ module.exports.getPodcastFeed = (feedUrl, excludeEpisodeMetadata = false) => {
timeout: 12000,
responseType: 'arraybuffer',
headers: { Accept: 'application/rss+xml, application/xhtml+xml, application/xml, */*;q=0.8' },
httpAgent: ssrfFilter(feedUrl),
httpsAgent: ssrfFilter(feedUrl)
httpAgent: !global.DisableSSRF ? ssrfFilter(feedUrl) : undefined,
httpsAgent: !global.DisableSSRF ? ssrfFilter(feedUrl) : undefined
}).then(async (data) => {
// Adding support for ios-8859-1 encoded RSS feeds.