Refactor apply config.
This commit is contained in:
@ -176,7 +176,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
|||||||
|
|
||||||
ProxyConfHelper.install()
|
ProxyConfHelper.install()
|
||||||
ProxyConfHelper.startMonitorPAC()
|
ProxyConfHelper.startMonitorPAC()
|
||||||
SyncSSLocal()
|
|
||||||
applyConfig()
|
applyConfig()
|
||||||
|
|
||||||
// Register global hotkey
|
// Register global hotkey
|
||||||
@ -192,14 +191,13 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
|||||||
}
|
}
|
||||||
|
|
||||||
func applyConfig() {
|
func applyConfig() {
|
||||||
|
SyncSSLocal()
|
||||||
|
|
||||||
let defaults = UserDefaults.standard
|
let defaults = UserDefaults.standard
|
||||||
let isOn = defaults.bool(forKey: "ShadowsocksOn")
|
let isOn = defaults.bool(forKey: "ShadowsocksOn")
|
||||||
let mode = defaults.string(forKey: "ShadowsocksRunningMode")
|
let mode = defaults.string(forKey: "ShadowsocksRunningMode")
|
||||||
|
|
||||||
if isOn {
|
if isOn {
|
||||||
StartSSLocal()
|
|
||||||
StartKcptun()
|
|
||||||
StartPrivoxy()
|
|
||||||
if mode == "auto" {
|
if mode == "auto" {
|
||||||
ProxyConfHelper.enablePACProxy()
|
ProxyConfHelper.enablePACProxy()
|
||||||
} else if mode == "global" {
|
} else if mode == "global" {
|
||||||
@ -208,9 +206,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
|||||||
ProxyConfHelper.disableProxy()
|
ProxyConfHelper.disableProxy()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
StopSSLocal()
|
|
||||||
StopKcptun()
|
|
||||||
StopPrivoxy()
|
|
||||||
ProxyConfHelper.disableProxy()
|
ProxyConfHelper.disableProxy()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user