Add support for HTTP agents in proxy configurations across multiple modules

This commit is contained in:
ZHAO Xudong
2026-08-21 19:39:00 +08:00
parent e9097981d5
commit 4ee9e170a7
5 changed files with 12 additions and 3 deletions
+1
View File
@@ -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
}
+2
View File
@@ -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'
})
+1
View File
@@ -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)
+1
View File
@@ -21,6 +21,7 @@ async function doSync (type, func, args, token, proxy) {
const agent = createProxyAgent(proxy)
const conf = agent
? {
httpAgent: agent,
httpsAgent: agent
}
: {
+7 -3
View File
@@ -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 }
}