mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-12 00:49:14 +08:00
fix(ProxyManager): store original Axios adapter for proxy management (#8875)
This commit is contained in:
parent
ef208bf9e5
commit
12051811fc
@ -72,6 +72,8 @@ export class ProxyManager {
|
|||||||
private originalHttpsGet: typeof https.get
|
private originalHttpsGet: typeof https.get
|
||||||
private originalHttpsRequest: typeof https.request
|
private originalHttpsRequest: typeof https.request
|
||||||
|
|
||||||
|
private originalAxiosAdapter
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.originalGlobalDispatcher = getGlobalDispatcher()
|
this.originalGlobalDispatcher = getGlobalDispatcher()
|
||||||
this.originalSocksDispatcher = global[Symbol.for('undici.globalDispatcher.1')]
|
this.originalSocksDispatcher = global[Symbol.for('undici.globalDispatcher.1')]
|
||||||
@ -79,6 +81,7 @@ export class ProxyManager {
|
|||||||
this.originalHttpRequest = http.request
|
this.originalHttpRequest = http.request
|
||||||
this.originalHttpsGet = https.get
|
this.originalHttpsGet = https.get
|
||||||
this.originalHttpsRequest = https.request
|
this.originalHttpsRequest = https.request
|
||||||
|
this.originalAxiosAdapter = axios.defaults.adapter
|
||||||
}
|
}
|
||||||
|
|
||||||
private async monitorSystemProxy(): Promise<void> {
|
private async monitorSystemProxy(): Promise<void> {
|
||||||
@ -246,9 +249,9 @@ export class ProxyManager {
|
|||||||
if (config.mode === 'direct' || !proxyUrl) {
|
if (config.mode === 'direct' || !proxyUrl) {
|
||||||
setGlobalDispatcher(this.originalGlobalDispatcher)
|
setGlobalDispatcher(this.originalGlobalDispatcher)
|
||||||
global[Symbol.for('undici.globalDispatcher.1')] = this.originalSocksDispatcher
|
global[Symbol.for('undici.globalDispatcher.1')] = this.originalSocksDispatcher
|
||||||
axios.defaults.adapter = 'http'
|
|
||||||
this.proxyDispatcher?.close()
|
this.proxyDispatcher?.close()
|
||||||
this.proxyDispatcher = null
|
this.proxyDispatcher = null
|
||||||
|
axios.defaults.adapter = this.originalAxiosAdapter
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user