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:
@@ -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}`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user