Merge branch 'pr/44' into develop

This commit is contained in:
Charlie Qiu
2016-10-02 00:08:33 +08:00
58 changed files with 13931 additions and 278 deletions

View File

@ -54,6 +54,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
"ShadowsocksRunningMode": "auto",
"LocalSocks5.ListenPort": NSNumber(unsignedShort: 1086),
"LocalSocks5.ListenAddress": "127.0.0.1",
"PacServer.ListenAddress": "127.0.0.1",
"PacServer.ListenPort":NSNumber(unsignedShort: 8090),
"LocalSocks5.Timeout": NSNumber(unsignedInteger: 60),
"LocalSocks5.EnableUDPRelay": NSNumber(bool: false),
"LocalSocks5.EnableVerboseMode": NSNumber(bool: false),
@ -93,6 +95,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
, usingBlock: {
(note) in
SyncSSLocal()
self.applyConfig()
}
)
notifyCenter.addObserverForName("NOTIFY_FOUND_SS_URL", object: nil, queue: nil) {
@ -151,6 +154,11 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
func applicationWillTerminate(aNotification: NSNotification) {
// Insert code here to tear down your application
StopSSLocal()
ProxyConfHelper.disableProxy("hi")
let defaults = NSUserDefaults.standardUserDefaults()
defaults.setBool(false, forKey: "ShadowsocksOn")
ProxyConfHelper.stopPACServer()
}
func applyConfig() {
@ -161,15 +169,15 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
if isOn {
StartSSLocal()
if mode == "auto" {
ProxyConfHelper.enablePACProxy()
ProxyConfHelper.enablePACProxy("hi")
} else if mode == "global" {
ProxyConfHelper.enableGlobalProxy()
} else if mode == "manual" {
ProxyConfHelper.disableProxy()
ProxyConfHelper.disableProxy("hi")
}
} else {
StopSSLocal()
ProxyConfHelper.disableProxy()
ProxyConfHelper.disableProxy("hi")
}
}