diff --git a/README.md b/README.md index ce09263..feeb44c 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,6 @@ From [here](https://github.com/shadowsocks/ShadowsocksX-NG/releases/) - User rules for PAC. - Support for [AEAD Ciphers](https://shadowsocks.org/en/spec/AEAD-Ciphers.html) - HTTP Proxy by [privoxy](http://www.privoxy.org/) -- Over [kcptun](https://github.com/xtaci/kcptun). Version 20170322. [Deprecated - Please use kcptun by SIP003 plugin.This would be removed in future.] - An advanced preferences panel for configuring: - Local SOCKS5 listen address. - Local SOCKS5 listen port. diff --git a/ShadowsocksX-NG.xcodeproj/project.pbxproj b/ShadowsocksX-NG.xcodeproj/project.pbxproj index 0d39456..73e0f11 100755 --- a/ShadowsocksX-NG.xcodeproj/project.pbxproj +++ b/ShadowsocksX-NG.xcodeproj/project.pbxproj @@ -57,12 +57,7 @@ 9B938D9C1E864B38005F5636 /* menu_m_icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 9B938D961E864B38005F5636 /* menu_m_icon@2x.png */; }; 9B938D9D1E864B38005F5636 /* menu_p_icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 9B938D971E864B38005F5636 /* menu_p_icon.png */; }; 9B938D9E1E864B38005F5636 /* menu_p_icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 9B938D981E864B38005F5636 /* menu_p_icon@2x.png */; }; - 9B9CBCA61E25E1DB00FC61AA /* KcptunProfile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B9CBCA51E25E1DB00FC61AA /* KcptunProfile.swift */; }; - 9B9CBCA81E26312E00FC61AA /* install_kcptun.sh in Resources */ = {isa = PBXBuildFile; fileRef = 9B9CBCA71E26310E00FC61AA /* install_kcptun.sh */; }; - 9B9CBCAA1E2633CB00FC61AA /* kcptun_client in Resources */ = {isa = PBXBuildFile; fileRef = 9B9CBCA91E2633CB00FC61AA /* kcptun_client */; }; 9B9CBCAF1E263B1600FC61AA /* libpcre.1.dylib in Resources */ = {isa = PBXBuildFile; fileRef = 9B9CBCAD1E263A6600FC61AA /* libpcre.1.dylib */; }; - 9B9CBCB41E26453C00FC61AA /* start_kcptun.sh in Resources */ = {isa = PBXBuildFile; fileRef = 9B9CBCB01E2644DC00FC61AA /* start_kcptun.sh */; }; - 9B9CBCB51E26453C00FC61AA /* stop_kcptun.sh in Resources */ = {isa = PBXBuildFile; fileRef = 9B9CBCB11E26450D00FC61AA /* stop_kcptun.sh */; }; 9B9F13A71E8A28B300DE4794 /* LaunchHelper.app in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9B9F13A61E8A282D00DE4794 /* LaunchHelper.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 9BA04B231D23D5A5005AAD7F /* ProxyConfTool.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BA04B221D23D5A5005AAD7F /* ProxyConfTool.m */; }; 9BAFE2E21E83ED7F00F71CCE /* PreferencesWinController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9BAFE2E41E83ED7F00F71CCE /* PreferencesWinController.xib */; }; @@ -213,12 +208,7 @@ 9B938D961E864B38005F5636 /* menu_m_icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "menu_m_icon@2x.png"; sourceTree = ""; }; 9B938D971E864B38005F5636 /* menu_p_icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = menu_p_icon.png; sourceTree = ""; }; 9B938D981E864B38005F5636 /* menu_p_icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "menu_p_icon@2x.png"; sourceTree = ""; }; - 9B9CBCA51E25E1DB00FC61AA /* KcptunProfile.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KcptunProfile.swift; sourceTree = ""; }; - 9B9CBCA71E26310E00FC61AA /* install_kcptun.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = install_kcptun.sh; sourceTree = ""; }; - 9B9CBCA91E2633CB00FC61AA /* kcptun_client */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = kcptun_client; sourceTree = ""; }; 9B9CBCAD1E263A6600FC61AA /* libpcre.1.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libpcre.1.dylib; sourceTree = ""; }; - 9B9CBCB01E2644DC00FC61AA /* start_kcptun.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = start_kcptun.sh; sourceTree = ""; }; - 9B9CBCB11E26450D00FC61AA /* stop_kcptun.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = stop_kcptun.sh; sourceTree = ""; }; 9B9F13A11E8A282C00DE4794 /* LaunchHelper.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = LaunchHelper.xcodeproj; path = LaunchHelper/LaunchHelper.xcodeproj; sourceTree = ""; }; 9BA04B211D23D5A5005AAD7F /* ProxyConfTool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProxyConfTool.h; sourceTree = ""; }; 9BA04B221D23D5A5005AAD7F /* ProxyConfTool.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProxyConfTool.m; sourceTree = ""; }; @@ -308,7 +298,6 @@ isa = PBXGroup; children = ( 9B5AA0A9209C41EC00E8B659 /* ss-local */, - 9B5AA0A8209C41B400E8B659 /* kcptun */, 1C82DBA31FA96C7400B32551 /* simple-obfs */, 9B16E5991F99FD0700E54DC5 /* icons8-Blind Filled-50.png */, 9B5AA0AA209C42A900E8B659 /* privoxy */, @@ -379,7 +368,6 @@ 9B0BFFEC1D0460A70040E62B /* MainMenu.xib */, 9B0BFFEF1D0460A70040E62B /* Info.plist */, 9BEEF06D1D04DCE400FC52B3 /* ServerProfile.swift */, - 9B9CBCA51E25E1DB00FC61AA /* KcptunProfile.swift */, 9BEEF06F1D04DDB100FC52B3 /* ServerProfileManager.swift */, 9BEEF0771D04FE8A00FC52B3 /* LaunchAgentUtils.swift */, 9B3FFF0C1D05FEB30019A709 /* Utils.swift */, @@ -435,17 +423,6 @@ path = proxy_conf_helper; sourceTree = ""; }; - 9B5AA0A8209C41B400E8B659 /* kcptun */ = { - isa = PBXGroup; - children = ( - 9B9CBCA71E26310E00FC61AA /* install_kcptun.sh */, - 9B9CBCB01E2644DC00FC61AA /* start_kcptun.sh */, - 9B9CBCB11E26450D00FC61AA /* stop_kcptun.sh */, - 9B9CBCA91E2633CB00FC61AA /* kcptun_client */, - ); - name = kcptun; - sourceTree = ""; - }; 9B5AA0A9209C41EC00E8B659 /* ss-local */ = { isa = PBXGroup; children = ( @@ -633,14 +610,10 @@ 9BBE7B751F508A0E00E8FFE5 /* fix_dir_owner.sh in Resources */, 9B3F7BFF1E82BF5B00C68B75 /* libev.4.dylib in Resources */, 1C82DBAA1FA96FB600B32551 /* install_simple_obfs.sh in Resources */, - 9B9CBCB41E26453C00FC61AA /* start_kcptun.sh in Resources */, - 9B9CBCB51E26453C00FC61AA /* stop_kcptun.sh in Resources */, 9B938D9A1E864B38005F5636 /* menu_g_icon@2x.png in Resources */, 9B938D9E1E864B38005F5636 /* menu_p_icon@2x.png in Resources */, 9B9CBCAF1E263B1600FC61AA /* libpcre.1.dylib in Resources */, - 9B9CBCA81E26312E00FC61AA /* install_kcptun.sh in Resources */, 9B5832031E741F8D009D5B7D /* command-512.png in Resources */, - 9B9CBCAA1E2633CB00FC61AA /* kcptun_client in Resources */, 9B3FFF541D09E2D10019A709 /* proxy_conf_helper in Resources */, 9B5832071E7421B2009D5B7D /* virtual-server-icon-3.png in Resources */, 9BEEF0691D04D4D500FC52B3 /* install_ss_local.sh in Resources */, @@ -857,7 +830,6 @@ 9B5831FF1E741969009D5B7D /* PreferencesWinController.swift in Sources */, 9BEEF0781D04FE8A00FC52B3 /* LaunchAgentUtils.swift in Sources */, 9B3546721E802B1200B510B4 /* ToastWindowController.swift in Sources */, - 9B9CBCA61E25E1DB00FC61AA /* KcptunProfile.swift in Sources */, C8E42A6C1D4F270A0074C7EA /* UserRulesController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/ShadowsocksX-NG/AppDelegate.swift b/ShadowsocksX-NG/AppDelegate.swift index e56013e..8286d15 100755 --- a/ShadowsocksX-NG/AppDelegate.swift +++ b/ShadowsocksX-NG/AppDelegate.swift @@ -80,7 +80,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele // Prepare ss-local InstallSSLocal() - InstallKcptunClient() InstallPrivoxy() InstallSimpleObfs() // Prepare defaults @@ -188,7 +187,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele func applicationWillTerminate(_ aNotification: Notification) { // Insert code here to tear down your application StopSSLocal() - StopKcptun() StopPrivoxy() ProxyConfHelper.disableProxy() } diff --git a/ShadowsocksX-NG/Base.lproj/PreferencesWindowController.xib b/ShadowsocksX-NG/Base.lproj/PreferencesWindowController.xib index a448a0f..2ed12ad 100644 --- a/ShadowsocksX-NG/Base.lproj/PreferencesWindowController.xib +++ b/ShadowsocksX-NG/Base.lproj/PreferencesWindowController.xib @@ -1,8 +1,8 @@ - + - + @@ -10,19 +10,7 @@ - - - - - - - - - - - - @@ -42,7 +30,7 @@ - + @@ -114,7 +102,7 @@ - + @@ -181,7 +169,7 @@ - + @@ -189,244 +177,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - NSAllRomanInputSourcesLocaleIdentifier - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - NSAllRomanInputSourcesLocaleIdentifier - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -540,12 +291,9 @@ - - - @@ -554,16 +302,11 @@ - - - - - @@ -578,7 +321,6 @@ - diff --git a/ShadowsocksX-NG/KcptunProfile.swift b/ShadowsocksX-NG/KcptunProfile.swift deleted file mode 100644 index f874c52..0000000 --- a/ShadowsocksX-NG/KcptunProfile.swift +++ /dev/null @@ -1,150 +0,0 @@ -// -// KcptunProfile.swift -// ShadowsocksX-NG -// -// Created by 邱宇舟 on 2017/1/11. -// Copyright © 2017年 qiuyuzhou. All rights reserved. -// - -import Foundation - - -class KcptunProfile: NSObject, NSCopying { - - @objc var mode: String = "fast" - - @objc var key: String = "it's a secrect" - @objc var crypt: String = "aes" - @objc var nocomp: Bool = false - @objc var datashard: uint = 10 - @objc var parityshard: uint = 3 - @objc var mtu: uint = 1350 - @objc var arguments: String = "" - - - public func copy(with zone: NSZone? = nil) -> Any { - let copy = KcptunProfile() - copy.mode = self.mode - copy.key = self.key - copy.crypt = self.crypt - copy.nocomp = self.nocomp - copy.datashard = self.datashard - copy.parityshard = self.parityshard - copy.mtu = self.mtu - return copy; - } - - func toDictionary() -> [String:AnyObject] { - let conf: [String: AnyObject] = [ - "mode": self.mode as AnyObject, - "key": self.key as AnyObject, - "crypt": self.crypt as AnyObject, - "nocomp": NSNumber(value: self.nocomp), - "datashard": NSNumber(value: self.datashard), - "parityshard": NSNumber(value: self.parityshard), - "mtu": NSNumber(value: self.mtu), - "arguments": self.arguments as AnyObject, - ] - return conf - } - - static func fromDictionary(_ data:[String:Any?]) -> KcptunProfile { - let profile = KcptunProfile() - profile.mode = data["mode"] as! String - profile.key = data["key"] as! String - profile.crypt = data["crypt"] as! String - profile.nocomp = (data["nocomp"] as! NSNumber).boolValue - profile.datashard = uint((data["datashard"] as! NSNumber).uintValue) - profile.parityshard = uint((data["parityshard"] as! NSNumber).uintValue) - if let v = data["mtu"] as? NSNumber { - profile.mtu = uint(v.uintValue) - } - if let arguments = data["arguments"] as? String { - profile.arguments = arguments - } - - return profile - } - - func toJsonConfig() -> [String: AnyObject] { - let defaults = UserDefaults.standard - let localHost = defaults.string(forKey: "Kcptun.LocalHost")! as String - let localPort = defaults.integer(forKey: "Kcptun.LocalPort") - let connNum = defaults.integer(forKey: "Kcptun.Conn") - - let conf: [String: AnyObject] = [ - "localaddr": "\(localHost):\(localPort)" as AnyObject, - "mode": self.mode as AnyObject, - "key": self.key as AnyObject, - "crypt": self.crypt as AnyObject, - "nocomp": NSNumber(value: self.nocomp), - "datashard": NSNumber(value: self.datashard), - "parityshard": NSNumber(value: self.parityshard), - "mtu": NSNumber(value: self.mtu), - "conn": NSNumber(value: connNum), - ] - return conf - } - - func urlQueryItems() -> [URLQueryItem] { - return [ - URLQueryItem(name: "mode", value: mode), - URLQueryItem(name: "key", value: key), - URLQueryItem(name: "crypt", value: crypt), - URLQueryItem(name: "datashard", value: "\(datashard)"), - URLQueryItem(name: "parityshard", value: "\(parityshard)"), - URLQueryItem(name: "nocomp", value: nocomp.description), - URLQueryItem(name: "mtu", value: "\(mtu)"), - URLQueryItem(name: "arguments", value: arguments), - ] - } - - func loadUrlQueryItems(items: [URLQueryItem]) { - for item in items { - switch item.name { - case "mode": - if let v = item.value { - mode = v - } - case "key": - if let v = item.value { - key = v - } - case "crypt": - if let v = item.value { - crypt = v - } - case "datashard": - if let v = item.value { - if let vv = uint(v) { - datashard = vv - } - } - case "parityshard": - if let v = item.value { - if let vv = uint(v) { - parityshard = vv - } - } - case "nocomp": - if let v = item.value { - if let vv = Bool(v) { - nocomp = vv - } - } - case "mtu": - if let v = item.value { - if let vv = uint(v) { - mtu = vv - } - } - case "arguments": - if let v = item.value { - arguments = v - } - default: - continue - } - } - } -} diff --git a/ShadowsocksX-NG/LaunchAgentUtils.swift b/ShadowsocksX-NG/LaunchAgentUtils.swift index 318afad..9b410aa 100644 --- a/ShadowsocksX-NG/LaunchAgentUtils.swift +++ b/ShadowsocksX-NG/LaunchAgentUtils.swift @@ -187,7 +187,6 @@ func SyncSSLocal() { } SyncPac() SyncPrivoxy() - SyncKcptun() } // -------------------------------------------------------------------------------- @@ -352,163 +351,3 @@ func SyncPrivoxy() { StopPrivoxy() } } - -// -------------------------------------------------------------------------------- -// kcptun - -func generateKcptunLauchAgentPlist() -> Bool { - let sslocalPath = NSHomeDirectory() + APP_SUPPORT_DIR + "kcptun_client" - let logFilePath = NSHomeDirectory() + "/Library/Logs/kcptun_client.log" - let launchAgentDirPath = NSHomeDirectory() + LAUNCH_AGENT_DIR - let plistFilepath = launchAgentDirPath + LAUNCH_AGENT_CONF_KCPTUN_NAME - - // Ensure launch agent directory is existed. - let fileMgr = FileManager.default - if !fileMgr.fileExists(atPath: launchAgentDirPath) { - try! fileMgr.createDirectory(atPath: launchAgentDirPath, withIntermediateDirectories: true, attributes: nil) - } - - let oldSha1Sum = getFileSHA1Sum(plistFilepath) - - var arguments = [sslocalPath, "-c", "kcptun-config.json"] - - let mgr = ServerProfileManager.instance - if let profile = mgr.getActiveProfile() { - if profile.enabledKcptun { - let otherArgumentsLine = profile.kcptunProfile.arguments.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) - if !otherArgumentsLine.isEmpty { - // TOFIX: Don't support space between quotation marks - let otherArguments = otherArgumentsLine.components(separatedBy: " ") - arguments.append(contentsOf: otherArguments.filter { !$0.isEmpty }) - } - } - } - - // For a complete listing of the keys, see the launchd.plist manual page. - let dict: NSMutableDictionary = [ - "Label": "com.qiuyuzhou.shadowsocksX-NG.kcptun", - "WorkingDirectory": NSHomeDirectory() + APP_SUPPORT_DIR, - "StandardOutPath": logFilePath, - "StandardErrorPath": logFilePath, - "ProgramArguments": arguments, - "EnvironmentVariables": ["DYLD_LIBRARY_PATH": NSHomeDirectory() + APP_SUPPORT_DIR] - ] - dict.write(toFile: plistFilepath, atomically: true) - let Sha1Sum = getFileSHA1Sum(plistFilepath) - if oldSha1Sum != Sha1Sum { - return true - } else { - return false - } -} - -func InstallKcptunClient() { - let fileMgr = FileManager.default - let homeDir = NSHomeDirectory() - let appSupportDir = homeDir+APP_SUPPORT_DIR - if !fileMgr.fileExists(atPath: appSupportDir + "kcptun_\(KCPTUN_CLIENT_VERSION)/kcptun_client") { - let bundle = Bundle.main - let installerPath = bundle.path(forResource: "install_kcptun", ofType: "sh") - let task = Process.launchedProcess(launchPath: installerPath!, arguments: [""]) - task.waitUntilExit() - if task.terminationStatus == 0 { - NSLog("Install kcptun succeeded.") - } else { - NSLog("Install kcptun failed.") - } - } -} - -func writeKcptunConfFile(_ conf:[String:AnyObject]) -> Bool { - do { - let filepath = NSHomeDirectory() + APP_SUPPORT_DIR + "kcptun-config.json" - let data: Data = try JSONSerialization.data(withJSONObject: conf, options: .prettyPrinted) - - let oldSum = getFileSHA1Sum(filepath) - try data.write(to: URL(fileURLWithPath: filepath), options: .atomic) - let newSum = getFileSHA1Sum(filepath) - - if oldSum == newSum { - return false - } - - return true - } catch { - NSLog("Write kcptun config file failed.") - } - return false -} - -func isEnabledKcptun() -> Bool { - let mgr = ServerProfileManager.instance - if let profile = mgr.getActiveProfile() { - return profile.enabledKcptun - } - return false -} - -func removeKcptunConfFile() { - do { - let filepath = NSHomeDirectory() + APP_SUPPORT_DIR + "kcptun-config.json" - try FileManager.default.removeItem(atPath: filepath) - } catch { - - } -} - -func StartKcptun() { - if isEnabledKcptun() { - let bundle = Bundle.main - let installerPath = bundle.path(forResource: "start_kcptun.sh", ofType: nil) - let task = Process.launchedProcess(launchPath: installerPath!, arguments: [""]) - task.waitUntilExit() - if task.terminationStatus == 0 { - NSLog("Start kcptun succeeded.") - } else { - NSLog("Start kcptun failed.") - } - } -} - -func StopKcptun() { - let bundle = Bundle.main - let installerPath = bundle.path(forResource: "stop_kcptun.sh", ofType: nil) - let task = Process.launchedProcess(launchPath: installerPath!, arguments: [""]) - task.waitUntilExit() - if task.terminationStatus == 0 { - NSLog("Stop kcptun succeeded.") - } else { - NSLog("Stop kcptun failed.") - } -} - -func SyncKcptun() { - var changed: Bool = false - changed = changed || generateKcptunLauchAgentPlist() - let mgr = ServerProfileManager.instance - if let profile = mgr.getActiveProfile() { - if profile.enabledKcptun { - changed = changed || writeKcptunConfFile(profile.toKcptunJsonConfig()) - - let on = UserDefaults.standard.bool(forKey: "ShadowsocksOn") - if on { - if changed { - StopKcptun() - DispatchQueue.main.asyncAfter( - deadline: DispatchTime.now() + DispatchTimeInterval.seconds(1), - execute: { - () in - StartKcptun() - }) - } else { - StartKcptun() - } - } else { - StopKcptun() - } - return - } - } - StopKcptun() - removeKcptunConfFile() -} diff --git a/ShadowsocksX-NG/PreferencesWindowController.swift b/ShadowsocksX-NG/PreferencesWindowController.swift index 3be7a7e..20e4cc4 100644 --- a/ShadowsocksX-NG/PreferencesWindowController.swift +++ b/ShadowsocksX-NG/PreferencesWindowController.swift @@ -16,11 +16,9 @@ class PreferencesWindowController: NSWindowController @IBOutlet weak var profilesTableView: NSTableView! @IBOutlet weak var profileBox: NSBox! - @IBOutlet weak var kcptunProfileBox: NSBox! @IBOutlet weak var hostTextField: NSTextField! @IBOutlet weak var portTextField: NSTextField! - @IBOutlet weak var kcptunPortTextField: NSTextField! @IBOutlet weak var methodTextField: NSComboBox! @IBOutlet weak var passwordTabView: NSTabView! @@ -29,22 +27,9 @@ class PreferencesWindowController: NSWindowController @IBOutlet weak var togglePasswordVisibleButton: NSButton! @IBOutlet weak var pluginTextField: NSTextField! @IBOutlet weak var pluginOptionsTextField: NSTextField! - @IBOutlet weak var remarkTextField: NSTextField! - - @IBOutlet weak var otaCheckBoxBtn: NSButton! - - @IBOutlet weak var kcptunCheckBoxBtn: NSButton! - @IBOutlet weak var kcptunCryptComboBox: NSComboBox! - @IBOutlet weak var kcptunKeyTextField: NSTextField! - @IBOutlet weak var kcptunModeComboBox: NSComboBox! - @IBOutlet weak var kcptunNocompCheckBoxBtn: NSButton! - @IBOutlet weak var kcptunDatashardTextField: NSTextField! - @IBOutlet weak var kcptunParityshardTextField: NSTextField! - @IBOutlet weak var kcptunMTUTextField: NSTextField! - @IBOutlet weak var kcptunArgumentsTextField: NSTextField! - @IBOutlet weak var removeButton: NSButton! + let tableViewDragType: String = "ss.server.profile.data" var defaults: UserDefaults! @@ -85,29 +70,6 @@ class PreferencesWindowController: NSWindowController "rc4-md5", ]) - kcptunCryptComboBox.addItems(withObjectValues: [ - "none", - "aes", - "aes-128", - "aes-192", - "salsa20", - "blowfish", - "twofish", - "cast5", - "3des", - "tea", - "xtea", - "xor", - ]) - - kcptunModeComboBox.addItems(withObjectValues: [ - "default", - "normal", - "fast", - "fast2", - "fast3", - ]) - profilesTableView.reloadData() updateProfileBoxVisible() } @@ -165,7 +127,6 @@ class PreferencesWindowController: NSWindowController profileMgr.save() window?.performClose(nil) - NotificationCenter.default .post(name: NOTIFY_SERVER_PROFILES_CHANGED, object: nil) } @@ -253,14 +214,6 @@ class PreferencesWindowController: NSWindowController if index >= 0 && index < profileMgr.profiles.count { editingProfile = profileMgr.profiles[index] - - enabledKcptunSubDisosable = editingProfile.rx.observeWeakly(Bool.self, "enabledKcptun") - .subscribe(onNext: { v in - if let enabled = v { - self.portTextField.isEnabled = !enabled - } - }) - hostTextField.bind(NSBindingName(rawValue: "value"), to: editingProfile, withKeyPath: "serverHost" , options: [NSBindingOption.continuouslyUpdatesValue: true]) portTextField.bind(NSBindingName(rawValue: "value"), to: editingProfile, withKeyPath: "serverPort" @@ -280,43 +233,6 @@ class PreferencesWindowController: NSWindowController remarkTextField.bind(NSBindingName(rawValue: "value"), to: editingProfile, withKeyPath: "remark" , options: [NSBindingOption.continuouslyUpdatesValue: true]) - - otaCheckBoxBtn.bind(NSBindingName(rawValue: "value"), to: editingProfile, withKeyPath: "ota" - , options: [NSBindingOption.continuouslyUpdatesValue: true]) - - // -------------------------------------------------- - // Kcptun - kcptunCheckBoxBtn.bind(NSBindingName(rawValue: "value"), to: editingProfile, withKeyPath: "enabledKcptun" - , options: [NSBindingOption.continuouslyUpdatesValue: true]) - - kcptunPortTextField.bind(NSBindingName(rawValue: "value"), to: editingProfile, withKeyPath: "serverPort" - , options: [NSBindingOption.continuouslyUpdatesValue: true]) - - kcptunProfileBox.bind(NSBindingName(rawValue: "Hidden"), to: editingProfile, withKeyPath: "enabledKcptun" - , options: [NSBindingOption.continuouslyUpdatesValue: false, - NSBindingOption.valueTransformerName: NSValueTransformerName.negateBooleanTransformerName]) - - kcptunNocompCheckBoxBtn.bind(NSBindingName(rawValue: "value"), to: editingProfile, withKeyPath: "kcptunProfile.nocomp", options: nil) - - kcptunModeComboBox.bind(NSBindingName(rawValue: "value"), to: editingProfile, withKeyPath: "kcptunProfile.mode", options: nil) - - kcptunCryptComboBox.bind(NSBindingName(rawValue: "value"), to: editingProfile, withKeyPath: "kcptunProfile.crypt", options: nil) - - kcptunKeyTextField.bind(NSBindingName(rawValue: "value"), to: editingProfile, withKeyPath: "kcptunProfile.key" - , options: [NSBindingOption.continuouslyUpdatesValue: true]) - - kcptunDatashardTextField.bind(NSBindingName(rawValue: "value"), to: editingProfile, withKeyPath: "kcptunProfile.datashard" - , options: [NSBindingOption.continuouslyUpdatesValue: true]) - - kcptunParityshardTextField.bind(NSBindingName(rawValue: "value"), to: editingProfile, withKeyPath: "kcptunProfile.parityshard" - , options: [NSBindingOption.continuouslyUpdatesValue: true]) - - kcptunMTUTextField.bind(NSBindingName(rawValue: "value"), to: editingProfile, withKeyPath: "kcptunProfile.mtu" - , options: [NSBindingOption.continuouslyUpdatesValue: true]) - - kcptunArgumentsTextField.bind(NSBindingName(rawValue: "value"), to: editingProfile, withKeyPath: "kcptunProfile.arguments" - , options: [NSBindingOption.continuouslyUpdatesValue: true]) - } else { editingProfile = nil hostTextField.unbind(NSBindingName(rawValue: "value")) @@ -326,10 +242,6 @@ class PreferencesWindowController: NSWindowController passwordTextField.unbind(NSBindingName(rawValue: "value")) remarkTextField.unbind(NSBindingName(rawValue: "value")) - - otaCheckBoxBtn.unbind(NSBindingName(rawValue: "value")) - - kcptunCheckBoxBtn.unbind(NSBindingName(rawValue: "value")) } } diff --git a/ShadowsocksX-NG/ServerProfile.swift b/ShadowsocksX-NG/ServerProfile.swift index 807a002..bc8d8d9 100644 --- a/ShadowsocksX-NG/ServerProfile.swift +++ b/ShadowsocksX-NG/ServerProfile.swift @@ -18,10 +18,6 @@ class ServerProfile: NSObject, NSCopying { @objc var method:String = "aes-128-gcm" @objc var password:String = "" @objc var remark:String = "" - @objc var ota: Bool = false // onetime authentication - - @objc var enabledKcptun: Bool = false - @objc var kcptunProfile = KcptunProfile() // SIP003 Plugin @objc var plugin: String = "" // empty string disables plugin @@ -103,21 +99,6 @@ class ServerProfile: NSObject, NSCopying { } } - if let otaStr = parsedUrl.queryItems? - .filter({ $0.name == "OTA" }).first?.value { - ota = NSString(string: otaStr).boolValue - } - if let enabledKcptunStr = parsedUrl.queryItems? - .filter({ $0.name == "Kcptun" }).first?.value { - enabledKcptun = NSString(string: enabledKcptunStr).boolValue - } - - if enabledKcptun { - if let items = parsedUrl.queryItems { - self.kcptunProfile.loadUrlQueryItems(items: items) - } - } - if let pluginStr = parsedUrl.queryItems? .filter({ $0.name == "plugin" }).first?.value { let parts = pluginStr.split(separator: ";", maxSplits: 1) @@ -135,10 +116,7 @@ class ServerProfile: NSObject, NSCopying { copy.method = self.method copy.password = self.password copy.remark = self.remark - copy.ota = self.ota - copy.enabledKcptun = self.enabledKcptun - copy.kcptunProfile = self.kcptunProfile.copy() as! KcptunProfile copy.plugin = self.plugin copy.pluginOptions = self.pluginOptions return copy; @@ -154,15 +132,6 @@ class ServerProfile: NSObject, NSCopying { if let remark = data["Remark"] { profile.remark = remark as! String } - if let ota = data["OTA"] { - profile.ota = ota as! Bool - } - if let enabledKcptun = data["EnabledKcptun"] { - profile.enabledKcptun = enabledKcptun as! Bool - } - if let kcptunData = data["KcptunProfile"] { - profile.kcptunProfile = KcptunProfile.fromDictionary(kcptunData as! [String:Any?]) - } if let plugin = data["Plugin"] as? String { profile.plugin = plugin } @@ -190,9 +159,6 @@ class ServerProfile: NSObject, NSCopying { d["Method"] = method as AnyObject? d["Password"] = password as AnyObject? d["Remark"] = remark as AnyObject? - d["OTA"] = ota as AnyObject? - d["EnabledKcptun"] = NSNumber(value: enabledKcptun) - d["KcptunProfile"] = kcptunProfile.toDictionary() as AnyObject d["Plugin"] = plugin as AnyObject d["PluginOptions"] = pluginOptions as AnyObject return d @@ -206,20 +172,8 @@ class ServerProfile: NSObject, NSCopying { conf["local_port"] = NSNumber(value: UInt16(defaults.integer(forKey: "LocalSocks5.ListenPort")) as UInt16) conf["local_address"] = defaults.string(forKey: "LocalSocks5.ListenAddress") as AnyObject? conf["timeout"] = NSNumber(value: UInt32(defaults.integer(forKey: "LocalSocks5.Timeout")) as UInt32) - if ota { - conf["auth"] = NSNumber(value: ota as Bool) - } - - if enabledKcptun { - let localHost = defaults.string(forKey: "Kcptun.LocalHost") - let localPort = uint16(defaults.integer(forKey: "Kcptun.LocalPort")) - - conf["server"] = localHost as AnyObject - conf["server_port"] = NSNumber(value: localPort as UInt16) - } else { - conf["server"] = serverHost as AnyObject - conf["server_port"] = NSNumber(value: serverPort as UInt16) - } + conf["server"] = serverHost as AnyObject + conf["server_port"] = NSNumber(value: serverPort as UInt16) if !plugin.isEmpty { // all plugin binaries should be located in the plugins dir @@ -230,17 +184,6 @@ class ServerProfile: NSObject, NSCopying { return conf } - - func toKcptunJsonConfig() -> [String: AnyObject] { - var conf = kcptunProfile.toJsonConfig() - if serverHost.contains(Character(":")) { - conf["remoteaddr"] = "[\(serverHost)]:\(serverPort)" as AnyObject - } else { - conf["remoteaddr"] = "\(serverHost):\(serverPort)" as AnyObject - } - - return conf - } func isValid() -> Bool { func validateIpAddress(_ ipToValidate: String) -> Bool { @@ -289,14 +232,7 @@ class ServerProfile: NSObject, NSCopying { url.password = password url.port = Int(serverPort) - url.queryItems = [URLQueryItem(name: "Remark", value: remark), - URLQueryItem(name: "OTA", value: ota.description)] - if enabledKcptun { - url.queryItems?.append(contentsOf: [ - URLQueryItem(name: "Kcptun", value: enabledKcptun.description), - ]) - url.queryItems?.append(contentsOf: kcptunProfile.urlQueryItems()) - } + url.queryItems = [URLQueryItem(name: "Remark", value: remark)] let parts = url.string?.replacingOccurrences( of: "//", with: "", @@ -322,11 +258,7 @@ class ServerProfile: NSObject, NSCopying { } let userInfo = rawUserInfo.base64EncodedString() - var items = [URLQueryItem(name: "OTA", value: ota.description)] - if enabledKcptun { - items.append(URLQueryItem(name: "Kcptun", value: enabledKcptun.description)) - items.append(contentsOf: kcptunProfile.urlQueryItems()) - } + var items: [URLQueryItem] = [] if !plugin.isEmpty { let value = "\(plugin);\(pluginOptions)" items.append(URLQueryItem(name: "plugin", value: value)) diff --git a/ShadowsocksX-NG/install_kcptun.sh b/ShadowsocksX-NG/install_kcptun.sh deleted file mode 100755 index 8136b7f..0000000 --- a/ShadowsocksX-NG/install_kcptun.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -# install_kcptun.sh -# ShadowsocksX-NG -# -# Created by 邱宇舟 on 2017/1/11. -# Copyright © 2017年 qiuyuzhou. All rights reserved. - -# https://github.com/shadowsocks/kcptun/releases - -VERSION="v20170718" - -cd `dirname "${BASH_SOURCE[0]}"` - -mkdir -p "$HOME/Library/Application Support/ShadowsocksX-NG/kcptun_$VERSION" -cp -f kcptun_client "$HOME/Library/Application Support/ShadowsocksX-NG/kcptun_$VERSION/" - -ln -sfh "$HOME/Library/Application Support/ShadowsocksX-NG/kcptun_$VERSION/kcptun_client" "$HOME/Library/Application Support/ShadowsocksX-NG/kcptun_client" - -ln -sfh "$HOME/Library/Application Support/ShadowsocksX-NG/kcptun_$VERSION/kcptun_client" "$HOME/Library/Application Support/ShadowsocksX-NG/plugins/kcptun" - -echo "install kcptun done" diff --git a/ShadowsocksX-NG/kcptun_client b/ShadowsocksX-NG/kcptun_client deleted file mode 100755 index ccb973e..0000000 Binary files a/ShadowsocksX-NG/kcptun_client and /dev/null differ diff --git a/ShadowsocksX-NG/start_kcptun.sh b/ShadowsocksX-NG/start_kcptun.sh deleted file mode 100755 index 1118f0b..0000000 --- a/ShadowsocksX-NG/start_kcptun.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -# start_kcptun.sh -# ShadowsocksX-NG -# -# Created by 邱宇舟 on 2017/1/11. -# Copyright © 2017年 qiuyuzhou. All rights reserved. - -chmod 644 "$HOME/Library/LaunchAgents/com.qiuyuzhou.shadowsocksX-NG.kcptun.plist" -launchctl load -wF "$HOME/Library/LaunchAgents/com.qiuyuzhou.shadowsocksX-NG.kcptun.plist" -launchctl start com.qiuyuzhou.shadowsocksX-NG.kcptun diff --git a/ShadowsocksX-NG/stop_kcptun.sh b/ShadowsocksX-NG/stop_kcptun.sh deleted file mode 100755 index 68536fc..0000000 --- a/ShadowsocksX-NG/stop_kcptun.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -# stop_kcptun.sh -# ShadowsocksX-NG -# -# Created by 邱宇舟 on 2017/1/11. -# Copyright © 2017年 qiuyuzhou. All rights reserved. - -launchctl stop com.qiuyuzhou.shadowsocksX-NG.kcptun -launchctl unload "$HOME/Library/LaunchAgents/com.qiuyuzhou.shadowsocksX-NG.kcptun.plist"