diff --git a/ShadowsocksX-NG/Base.lproj/PreferencesWindowController.xib b/ShadowsocksX-NG/Base.lproj/PreferencesWindowController.xib index f03790f..ace1a31 100644 --- a/ShadowsocksX-NG/Base.lproj/PreferencesWindowController.xib +++ b/ShadowsocksX-NG/Base.lproj/PreferencesWindowController.xib @@ -10,6 +10,7 @@ + @@ -237,49 +238,22 @@ - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - + @@ -287,9 +261,9 @@ - + - + @@ -301,9 +275,9 @@ - + - + @@ -315,7 +289,7 @@ - + @@ -336,7 +310,7 @@ - + @@ -350,48 +324,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + + + + + - diff --git a/ShadowsocksX-NG/KcptunProfile.swift b/ShadowsocksX-NG/KcptunProfile.swift index 5e661cf..287764c 100644 --- a/ShadowsocksX-NG/KcptunProfile.swift +++ b/ShadowsocksX-NG/KcptunProfile.swift @@ -19,6 +19,7 @@ class KcptunProfile: NSObject, NSCopying { var datashard: uint = 10 var parityshard: uint = 3 var mtu: uint = 1350 + var arguments: String = "" public func copy(with zone: NSZone? = nil) -> Any { @@ -42,6 +43,7 @@ class KcptunProfile: NSObject, NSCopying { "datashard": NSNumber(value: self.datashard), "parityshard": NSNumber(value: self.parityshard), "mtu": NSNumber(value: self.mtu), + "arguments": self.arguments as AnyObject, ] return conf } @@ -57,6 +59,9 @@ class KcptunProfile: NSObject, NSCopying { if let v = data["mtu"] as? NSNumber { profile.mtu = uint(v.uintValue) } + if let arguments = data["arguments"] as? String { + profile.arguments = arguments + } return profile } @@ -90,6 +95,7 @@ class KcptunProfile: NSObject, NSCopying { URLQueryItem(name: "parityshard", value: "\(parityshard)"), URLQueryItem(name: "nocomp", value: nocomp.description), URLQueryItem(name: "mtu", value: "\(mtu)"), + URLQueryItem(name: "argumetns", value: arguments), ] } @@ -132,6 +138,10 @@ class KcptunProfile: NSObject, NSCopying { 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 712f297..5cbfff5 100644 --- a/ShadowsocksX-NG/LaunchAgentUtils.swift +++ b/ShadowsocksX-NG/LaunchAgentUtils.swift @@ -337,7 +337,19 @@ func generateKcptunLauchAgentPlist() -> Bool { let oldSha1Sum = getFileSHA1Sum(plistFilepath) - let arguments = [sslocalPath, "-c", "kcptun-config.json"] + 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 = [ diff --git a/ShadowsocksX-NG/PreferencesWindowController.swift b/ShadowsocksX-NG/PreferencesWindowController.swift index 4a6d936..9cb0ddb 100644 --- a/ShadowsocksX-NG/PreferencesWindowController.swift +++ b/ShadowsocksX-NG/PreferencesWindowController.swift @@ -36,6 +36,7 @@ class PreferencesWindowController: NSWindowController @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" @@ -269,6 +270,9 @@ class PreferencesWindowController: NSWindowController kcptunMTUTextField.bind("value", to: editingProfile, withKeyPath: "kcptunProfile.mtu" , options: [NSContinuouslyUpdatesValueBindingOption: true]) + kcptunArgumentsTextField.bind("value", to: editingProfile, withKeyPath: "kcptunProfile.arguments" + , options: [NSContinuouslyUpdatesValueBindingOption: true]) + } else { editingProfile = nil hostTextField.unbind("value")