Bugfix: error setting socks5 port.

This commit is contained in:
yicheng 2018-08-10 20:58:20 +08:00
parent b0f7232f7a
commit e5f9ed5346
2 changed files with 9 additions and 6 deletions

View File

@ -2,7 +2,7 @@
import Foundation
class ProxyConfigManager {
static let kProxyConfigFolder = (NSHomeDirectory() as NSString).appendingPathComponent("/.config/clash")
static let kVersion = "0.1.0"
static let kVersion = "0.1.1"
open static func vaildHelper() -> Bool {
@ -28,10 +28,13 @@ class ProxyConfigManager {
let proxyHelperPath = Bundle.main.path(forResource: "ProxyConfig", ofType: nil)
let targetPath = "\(kProxyConfigFolder)/ProxyConfig"
if (!FileManager.default.fileExists(atPath: targetPath)) {
try? FileManager.default.copyItem(at: URL(fileURLWithPath: proxyHelperPath!), to: URL(fileURLWithPath: targetPath))
}
if !vaildHelper() {
if (FileManager.default.fileExists(atPath: targetPath)) {
try? FileManager.default.removeItem(atPath: targetPath)
}
try? FileManager.default.copyItem(at: URL(fileURLWithPath: proxyHelperPath!), to: URL(fileURLWithPath: targetPath))
let scriptPath = "\(Bundle.main.resourcePath!)/install_proxy_helper.sh"
let appleScriptStr = "do shell script \"bash \(scriptPath) \(kProxyConfigFolder) \" with administrator privileges"
let appleScript = NSAppleScript(source: appleScriptStr)

View File

@ -1,7 +1,7 @@
import Foundation
import SystemConfiguration
let version = "0.1.0"
let version = "0.1.1"
func main(_ args: [String]) {
var port: Int = 0
@ -66,7 +66,7 @@ func main(_ args: [String]) {
if flag {
proxySettings[kCFNetworkProxiesHTTPPort as String] = port as AnyObject
proxySettings[kCFNetworkProxiesHTTPSPort as String] = port as AnyObject
proxySettings[kCFNetworkProxiesSOCKSPort as String] = port + 1 as AnyObject
proxySettings[kCFNetworkProxiesSOCKSPort as String] = socksPort as AnyObject
} else {
proxySettings[kCFNetworkProxiesHTTPPort as String] = nil
proxySettings[kCFNetworkProxiesHTTPSPort as String] = nil