From bbb7981ee89cd9757983d07b6a2bd86aaa675fb8 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Sun, 5 Nov 2017 09:21:57 +0800 Subject: [PATCH] Removes default bypass rules in proxy_conf_helper --- ShadowsocksX-NG/AppDelegate.swift | 9 +++++++ .../Base.lproj/PreferencesWinController.xib | 24 ++++++++++++++----- .../PreferencesWinController.swift | 5 ++++ proxy_conf_helper/main.m | 6 ----- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/ShadowsocksX-NG/AppDelegate.swift b/ShadowsocksX-NG/AppDelegate.swift index a8a9e4b..a545ec7 100755 --- a/ShadowsocksX-NG/AppDelegate.swift +++ b/ShadowsocksX-NG/AppDelegate.swift @@ -103,6 +103,15 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele "Kcptun.LocalPort": NSNumber(value: 8388), "Kcptun.Conn": NSNumber(value: 1), ]) + + // To keep the default exception values backward compatible, we set it + // to the previously hardcoded value if the key doesn't exist. + // Registering defaults won't work because the empty state is a valid + // value, and Cocoa Bindings won't distinguish between empty and string + // values. + if defaults.string(forKey: "ProxyExceptions") == nil { + defaults.set("127.0.0.1, localhost, 192.168.0.0/16, 10.0.0.0/8", forKey: "ProxyExceptions") + } statusItem = NSStatusBar.system.statusItem(withLength: AppDelegate.StatusItemIconWidth) let image : NSImage = NSImage(named: NSImage.Name(rawValue: "menu_icon"))! diff --git a/ShadowsocksX-NG/Base.lproj/PreferencesWinController.xib b/ShadowsocksX-NG/Base.lproj/PreferencesWinController.xib index 5978286..8d868fa 100644 --- a/ShadowsocksX-NG/Base.lproj/PreferencesWinController.xib +++ b/ShadowsocksX-NG/Base.lproj/PreferencesWinController.xib @@ -1,8 +1,8 @@ - + - + @@ -19,7 +19,7 @@ - + @@ -504,7 +504,7 @@ - + @@ -553,7 +553,7 @@ - + @@ -578,16 +578,28 @@ + - + + + diff --git a/ShadowsocksX-NG/PreferencesWinController.swift b/ShadowsocksX-NG/PreferencesWinController.swift index 268d739..8102190 100644 --- a/ShadowsocksX-NG/PreferencesWinController.swift +++ b/ShadowsocksX-NG/PreferencesWinController.swift @@ -30,5 +30,10 @@ class PreferencesWinController: NSWindowController { @IBAction func toolbarAction(sender: NSToolbarItem) { tabView.selectTabViewItem(withIdentifier: sender.itemIdentifier) } + + @IBAction func resetProxyExceptions(sender: NSButton) { + let defaults = UserDefaults.standard + defaults.set("127.0.0.1, localhost, 192.168.0.0/16, 10.0.0.0/8", forKey: "ProxyExceptions") + } } diff --git a/proxy_conf_helper/main.m b/proxy_conf_helper/main.m index 9b5421b..dfab595 100644 --- a/proxy_conf_helper/main.m +++ b/proxy_conf_helper/main.m @@ -97,12 +97,6 @@ int main(int argc, const char * argv[]) return 1; } } - - // Bypass these Hosts & Domains if not specified - if ([proxyExceptions count] == 0) { - NSArray* bypass = @[@"127.0.0.1", @"localhost", @"192.168.0.0/16", @"10.0.0.0/8"]; - [proxyExceptions addObjectsFromArray:bypass]; - } static AuthorizationRef authRef; static AuthorizationFlags authFlags;