mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-04 02:58:08 +08:00
support proxy-uri
This commit is contained in:
@@ -85,6 +85,7 @@ const calculateValue = () => {
|
||||
},
|
||||
puppeteerWSEndpoint: envs.PUPPETEER_WS_ENDPOINT,
|
||||
loggerLevel: envs.LOGGER_LEVEL || 'info',
|
||||
proxyUri: envs.PROXY_URI,
|
||||
proxy: {
|
||||
protocol: envs.PROXY_PROTOCOL,
|
||||
host: envs.PROXY_HOST,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const config = require('@/config').value;
|
||||
const HttpsProxyAgent = require('https-proxy-agent');
|
||||
const SocksProxyAgent = require('socks-proxy-agent');
|
||||
const tunnel = require('tunnel');
|
||||
const logger = require('./logger');
|
||||
@@ -6,7 +7,21 @@ const http = require('http');
|
||||
const https = require('https');
|
||||
|
||||
let agent = null;
|
||||
if (config.proxy && config.proxy.protocol && config.proxy.host && config.proxy.port) {
|
||||
if (config.proxyUri && typeof config.proxyUri === 'string') {
|
||||
let proxy = null;
|
||||
if (config.proxyUri.startsWith('http')) {
|
||||
proxy = new HttpsProxyAgent(config.proxyUri);
|
||||
} else if (config.proxyUri.startsWith('socks')) {
|
||||
proxy = new SocksProxyAgent(config.proxyUri);
|
||||
} else {
|
||||
throw 'Unknown proxy-uri format';
|
||||
}
|
||||
|
||||
agent = {
|
||||
http: proxy,
|
||||
https: proxy,
|
||||
};
|
||||
} else if (config.proxy && config.proxy.protocol && config.proxy.host && config.proxy.port) {
|
||||
agent = {};
|
||||
const proxyUrl = `${config.proxy.protocol}://${config.proxy.host}:${config.proxy.port}`;
|
||||
|
||||
|
||||
@@ -79,6 +79,7 @@
|
||||
"googleapis": "49.0.0",
|
||||
"got": "11.0.3",
|
||||
"he": "1.2.0",
|
||||
"https-proxy-agent": "5.0.0",
|
||||
"iconv-lite": "0.5.1",
|
||||
"jsdom": "16.2.2",
|
||||
"json-bigint": "0.3.0",
|
||||
|
||||
16
yarn.lock
16
yarn.lock
@@ -6175,6 +6175,14 @@ https-browserify@^1.0.0:
|
||||
resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73"
|
||||
integrity sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=
|
||||
|
||||
https-proxy-agent@5.0.0, https-proxy-agent@^5.0.0:
|
||||
version "5.0.0"
|
||||
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz#e2a90542abb68a762e0a0850f6c9edadfd8506b2"
|
||||
integrity sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==
|
||||
dependencies:
|
||||
agent-base "6"
|
||||
debug "4"
|
||||
|
||||
https-proxy-agent@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-4.0.0.tgz#702b71fb5520a132a66de1f67541d9e62154d82b"
|
||||
@@ -6183,14 +6191,6 @@ https-proxy-agent@^4.0.0:
|
||||
agent-base "5"
|
||||
debug "4"
|
||||
|
||||
https-proxy-agent@^5.0.0:
|
||||
version "5.0.0"
|
||||
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz#e2a90542abb68a762e0a0850f6c9edadfd8506b2"
|
||||
integrity sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==
|
||||
dependencies:
|
||||
agent-base "6"
|
||||
debug "4"
|
||||
|
||||
human-signals@^1.1.1:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3"
|
||||
|
||||
Reference in New Issue
Block a user