fix: do not recover proxy on exit if proxy is set by other process

This commit is contained in:
yicheng 2021-02-20 11:20:01 +08:00
parent 8f3cd2146b
commit 95154b3250
No known key found for this signature in database
GPG Key ID: 7CF411A6623B1C0A
2 changed files with 4 additions and 3 deletions

View File

@ -133,7 +133,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
Logger.log("ClashX quit need clean proxy setting")
shouldWait = true
group.enter()
SystemProxyManager.shared.disableProxy {
SystemProxyManager.shared.disableProxy(forceDisable: ConfigManager.shared.isProxySetByOtherVariable.value) {
group.leave()
}
}

View File

@ -68,10 +68,10 @@ class SystemProxyManager: NSObject {
})
}
func disableProxy(complete: (() -> Void)? = nil) {
func disableProxy(forceDisable: Bool = false, complete: (() -> Void)? = nil) {
let port = ConfigManager.shared.currentConfig?.usedHttpPort ?? 0
let socketPort = ConfigManager.shared.currentConfig?.usedSocksPort ?? 0
SystemProxyManager.shared.disableProxy(port: port, socksPort: socketPort, complete: complete)
SystemProxyManager.shared.disableProxy(port: port, socksPort: socketPort, forceDisable: forceDisable, complete: complete)
}
func disableProxy(port: Int, socksPort: Int, forceDisable: Bool = false, complete: (() -> Void)? = nil) {