Add support for HTTP agents in proxy configurations across multiple modules
This commit is contained in:
@@ -48,6 +48,7 @@ const createAIClient = (baseURL, apiKey, proxy, authHeaderName) => {
|
||||
// Add proxy agent if proxy is provided
|
||||
const agent = proxy ? createProxyAgent(proxy) : null
|
||||
if (agent) {
|
||||
config.httpAgent = agent
|
||||
config.httpsAgent = agent
|
||||
config.proxy = false // Disable default proxy behavior when using agent
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ function getReleaseInfo (
|
||||
timeout: 15000
|
||||
}
|
||||
if (agent) {
|
||||
conf.httpAgent = agent
|
||||
conf.httpsAgent = agent
|
||||
}
|
||||
return rp(conf)
|
||||
@@ -90,6 +91,7 @@ class Upgrade {
|
||||
this.localPath = localPath
|
||||
const readSteam = await rp({
|
||||
url: remotePath,
|
||||
httpAgent: agent,
|
||||
httpsAgent: agent,
|
||||
responseType: 'stream'
|
||||
})
|
||||
|
||||
@@ -22,6 +22,7 @@ async function wsFetchHandler (ws, msg) {
|
||||
const { id, options, proxy } = msg
|
||||
const agent = createProxyAgent(proxy)
|
||||
if (agent) {
|
||||
options.httpAgent = agent
|
||||
options.httpsAgent = agent
|
||||
}
|
||||
const res = await fetch(options)
|
||||
|
||||
@@ -21,6 +21,7 @@ async function doSync (type, func, args, token, proxy) {
|
||||
const agent = createProxyAgent(proxy)
|
||||
const conf = agent
|
||||
? {
|
||||
httpAgent: agent,
|
||||
httpsAgent: agent
|
||||
}
|
||||
: {
|
||||
|
||||
@@ -22,12 +22,16 @@ function createClient (serverUrl, username, password, proxy, skipVerify = false)
|
||||
const Cls = proxy.startsWith('http')
|
||||
? require('https-proxy-agent').HttpsProxyAgent
|
||||
: require('socks-proxy-agent').SocksProxyAgent
|
||||
conf = { httpsAgent: new Cls(proxy, { keepAlive: true, rejectUnauthorized: false }) }
|
||||
const agent = new Cls(proxy, { keepAlive: true, rejectUnauthorized: false })
|
||||
conf = { httpAgent: agent, httpsAgent: agent }
|
||||
} else {
|
||||
conf = { httpsAgent: proxyAgent }
|
||||
conf = { httpAgent: proxyAgent, httpsAgent: proxyAgent }
|
||||
}
|
||||
} else if (skipVerify) {
|
||||
conf = { httpsAgent: new https.Agent({ rejectUnauthorized: false }) }
|
||||
conf = {
|
||||
httpAgent: new https.Agent({ rejectUnauthorized: false }),
|
||||
httpsAgent: new https.Agent({ rejectUnauthorized: false })
|
||||
}
|
||||
} else {
|
||||
conf = { proxy: false }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user