diff --git a/ShadowsocksX-dummy.xcodeproj/xcuserdata/khu.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/ShadowsocksX-dummy.xcodeproj/xcuserdata/khu.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
deleted file mode 100644
index e48cb43..0000000
--- a/ShadowsocksX-dummy.xcodeproj/xcuserdata/khu.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
+++ /dev/null
@@ -1,183 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/ShadowsocksX-dummy.xcodeproj/xcuserdata/khu.xcuserdatad/xcschemes/xcschememanagement.plist b/ShadowsocksX-dummy.xcodeproj/xcuserdata/khu.xcuserdatad/xcschemes/xcschememanagement.plist
deleted file mode 100644
index e1a8be4..0000000
--- a/ShadowsocksX-dummy.xcodeproj/xcuserdata/khu.xcuserdatad/xcschemes/xcschememanagement.plist
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
- SchemeUserState
-
- ShadowsocksX-dummy.xcscheme_^#shared#^_
-
- orderHint
- 0
-
- proxy_conf_helper.xcscheme_^#shared#^_
-
- orderHint
- 1
-
-
- SuppressBuildableAutocreation
-
- BA4F725920BE677C006417EA
-
- primary
-
-
- BA4F726B20BE677E006417EA
-
- primary
-
-
- BA4F72C320BE7E04006417EA
-
- primary
-
-
-
-
-
diff --git a/ShadowsocksX-dummy/Base.lproj/Main.storyboard b/ShadowsocksX-dummy/Base.lproj/Main.storyboard
index edf774d..d61f91b 100644
--- a/ShadowsocksX-dummy/Base.lproj/Main.storyboard
+++ b/ShadowsocksX-dummy/Base.lproj/Main.storyboard
@@ -1,7 +1,7 @@
-
+
-
+
@@ -684,7 +684,7 @@
-
+
@@ -709,16 +709,8 @@
-
-
+
@@ -727,7 +719,7 @@
-
+
@@ -736,7 +728,7 @@
-
+
@@ -745,7 +737,7 @@
-
+
@@ -754,7 +746,7 @@
-
+
@@ -763,7 +755,7 @@
-
+
@@ -772,7 +764,7 @@
-
+
@@ -781,7 +773,7 @@
-
+
@@ -790,7 +782,7 @@
-
+
@@ -799,7 +791,7 @@
-
+
@@ -808,7 +800,7 @@
-
+
@@ -817,7 +809,7 @@
-
+
@@ -825,8 +817,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -844,6 +873,8 @@
+
+
diff --git a/ShadowsocksX-dummy/ProxyConfHelper.h b/ShadowsocksX-dummy/ProxyConfHelper.h
index ccb8c19..198be96 100644
--- a/ShadowsocksX-dummy/ProxyConfHelper.h
+++ b/ShadowsocksX-dummy/ProxyConfHelper.h
@@ -15,4 +15,5 @@
+ (void)enableGlobalProxy;
+ (void)disableProxy;
++ (void)enablePACProxy;
@end
diff --git a/ShadowsocksX-dummy/ProxyConfHelper.m b/ShadowsocksX-dummy/ProxyConfHelper.m
index ca7927b..15d67d5 100644
--- a/ShadowsocksX-dummy/ProxyConfHelper.m
+++ b/ShadowsocksX-dummy/ProxyConfHelper.m
@@ -131,6 +131,16 @@ + (void)addArguments4ManualSpecifyProxyExceptions:(NSMutableArray*) args {
}
}
++ (void)enablePACProxy {
+ NSString* path = [[NSUserDefaults standardUserDefaults] valueForKey:@"PAC.URL"];
+ NSURL* url = [NSURL URLWithString:path];
+ NSMutableArray* args = [@[@"--mode", @"auto", @"--pac-url",
+ [url absoluteString]] mutableCopy];
+ [self addArguments4ManualSpecifyNetworkServices:args];
+ [self addArguments4ManualSpecifyProxyExceptions:args];
+ [self callHelper:args];
+}
+
+ (void)enableGlobalProxy {
NSUInteger port = [[NSUserDefaults standardUserDefaults]integerForKey:@"LocalSocks5.ListenPort"];
diff --git a/ShadowsocksX-dummy/ViewController.swift b/ShadowsocksX-dummy/ViewController.swift
index 34f400d..0e9aead 100644
--- a/ShadowsocksX-dummy/ViewController.swift
+++ b/ShadowsocksX-dummy/ViewController.swift
@@ -15,6 +15,7 @@ class ViewController: NSViewController {
static let LOCAL_ADDRESS: String = "local_address"
static let LOCAL_PORT: String = "local_port"
static let SERVER_PORT: String = "server_port"
+ static let PAC: String = "pac_url"
@IBOutlet weak var host: NSTextField!
@IBOutlet weak var port: NSTextField!
@@ -23,10 +24,32 @@ class ViewController: NSViewController {
@IBOutlet weak var localPort: NSTextField!
@IBOutlet weak var method: NSTextField!
@IBOutlet weak var remember: NSButton!
+ @IBOutlet weak var pacBox: NSButton!
+
+ @IBOutlet weak var pac: NSTextField!
+
@IBOutlet weak var connect: NSButton!
let ud = UserDefaults.standard
+ @IBAction func autoPacTapped(_ sender: Any) {
+ updateUI()
+ }
+
+ func updateUI() {
+ if pacBox.state == NSControl.StateValue.on {
+ localIP.isEnabled = true
+ localPort.isEnabled = true
+ pac.isEnabled = true
+ } else {
+ localIP.isEnabled = false
+ localPort.isEnabled = false
+ pac.isEnabled = false
+ }
+
+ }
+
+
@IBAction func connectTapped(_ sender: Any) {
if connect.title == "Disconnect" {
ProxyConfHelper.disableProxy()
@@ -39,12 +62,19 @@ class ViewController: NSViewController {
ud.set(localIP.stringValue, forKey: ViewController.LOCAL_ADDRESS)
ud.set(Int(localPort.stringValue), forKey: ViewController.LOCAL_PORT)
ud.set(Int(port.stringValue), forKey: ViewController.SERVER_PORT)
+ ud.set(pac.stringValue, forKey: ViewController.PAC)
}
ServerProfileManager.shared.currentProfile = ServerProfile(sessionId: UUID().uuidString, serverAddress: host.stringValue, serverPort: Int(port.stringValue)!, password: password.stringValue, localAddress: localIP.stringValue, method: method.stringValue, localPort: Int(localPort.stringValue)!)
UserDefaults.standard.set(Int(localPort.stringValue)!, forKey: "LocalSocks5.ListenPort")
+ UserDefaults.standard.set(pac.stringValue, forKey: "PAC.URL")
InstallSSLocal()
ProxyConfHelper.install()
- ProxyConfHelper.enableGlobalProxy()
+ if pacBox.state == NSControl.StateValue.on {
+ ProxyConfHelper.enablePACProxy()
+ } else {
+ ProxyConfHelper.enableGlobalProxy()
+ }
+
SyncSSLocal()
connect.title = "Disconnect"
}
@@ -57,6 +87,7 @@ class ViewController: NSViewController {
let password = ud.value(forKey: ViewController.PASSWORD) as? String,
let serverPort = ud.value(forKey: ViewController.SERVER_PORT) as? Int,
let localPort = ud.value(forKey: ViewController.LOCAL_PORT) as? Int,
+ let pac = ud.value(forKey: ViewController.PAC) as? String,
let localIp = ud.value(forKey: ViewController.LOCAL_ADDRESS) as? String {
self.host.stringValue = host
self.method.stringValue = method
@@ -64,11 +95,9 @@ class ViewController: NSViewController {
self.port.stringValue = "\(serverPort)"
self.localPort.stringValue = "\(localPort)"
self.localIP.stringValue = localIp
-
+ self.pac.stringValue = pac
}
-
-
- // Do any additional setup after loading the view.
+ updateUI()
}
override var representedObject: Any? {