mirror of
https://github.com/qinyuhang/ShadowsocksX-NG-R.git
synced 2026-11-05 09:04:59 +00:00
Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e481860075 | ||
|
|
c28be0134c | ||
|
|
0e8098c631 | ||
|
|
41a02b41ae | ||
|
|
196e48ddd0 | ||
|
|
568eabd5cc | ||
|
|
546fca160a | ||
|
|
fe2df2c5b7 | ||
|
|
f730c5cba2 | ||
|
|
e5c8e965d4 | ||
|
|
d4aa0f7b47 |
@@ -244,7 +244,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
||||
// MARK: - Hotkey Methods
|
||||
func registerHotkey() -> Void {
|
||||
registerEventHotKey(keyCode: UInt32(keyCodeP)) // to toggle PAC and Global Mode
|
||||
registerEventHotKey(keyCode: UInt32(keyCodeS)) // to toggle SS on or off
|
||||
// registerEventHotKey(keyCode: UInt32(keyCodeS)) // to toggle SS on or off
|
||||
registerEventHandler()
|
||||
}
|
||||
|
||||
@@ -564,11 +564,11 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
||||
let defaults = UserDefaults.standard
|
||||
let mode = defaults.string(forKey: "ShadowsocksRunningMode")
|
||||
if mode == "auto" {
|
||||
statusItem.title = "Auto".localized
|
||||
statusItem.title = "A"
|
||||
} else if mode == "global" {
|
||||
statusItem.title = "Global".localized
|
||||
statusItem.title = "G"
|
||||
} else if mode == "manual" {
|
||||
statusItem.title = "Manual".localized
|
||||
statusItem.title = "M"
|
||||
}
|
||||
let titleWidth = statusItem.title!.size(withAttributes: [NSFontAttributeName: statusItem.button!.font!]).width
|
||||
let imageWidth:CGFloat = AppDelegate.StatusItemIconWidth
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<window title="Server Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" oneShot="NO" animationBehavior="default" id="F0z-JX-Cv5">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
|
||||
<rect key="contentRect" x="423" y="365" width="590" height="504"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1057"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>
|
||||
<view key="contentView" id="se5-gp-TjO">
|
||||
<rect key="frame" x="0.0" y="0.0" width="590" height="504"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
@@ -250,8 +250,8 @@
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<button translatesAutoresizingMaskIntoConstraints="NO" id="WiD-LX-WHu">
|
||||
<rect key="frame" x="117" y="117" width="151" height="18"/>
|
||||
<buttonCell key="cell" type="check" title="Disable Compressing" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="ezp-Vb-ouI">
|
||||
<rect key="frame" x="117" y="117" width="148" height="18"/>
|
||||
<buttonCell key="cell" type="check" title="Disable compression" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="ezp-Vb-ouI">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
@@ -481,9 +481,12 @@ DQ
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="69" id="QPa-bs-qw0"/>
|
||||
</constraints>
|
||||
<buttonCell key="cell" type="push" title="Cacnel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="j03-9E-uHW">
|
||||
<buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="j03-9E-uHW">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
<string key="keyEquivalent" base64-UTF8="YES">
|
||||
Gw
|
||||
</string>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="cancel:" target="-2" id="514-4D-a6S"/>
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>2</string>
|
||||
<string>3</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.utilities</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import Foundation
|
||||
|
||||
|
||||
class KcptunProfile: NSObject {
|
||||
class KcptunProfile: NSObject, NSCopying {
|
||||
|
||||
var mode: String = "fast"
|
||||
|
||||
@@ -29,6 +29,7 @@ class KcptunProfile: NSObject {
|
||||
copy.nocomp = self.nocomp
|
||||
copy.datashard = self.datashard
|
||||
copy.parityshard = self.parityshard
|
||||
copy.mtu = self.mtu
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import Foundation
|
||||
|
||||
let SS_LOCAL_VERSION = "2.5.6"
|
||||
let KCPTUN_CLIENT_VERSION = "20161222"
|
||||
let KCPTUN_CLIENT_VERSION = "20170117"
|
||||
let PRIVOXY_VERSION = "3.0.26.static"
|
||||
let APP_SUPPORT_DIR = "/Library/Application Support/ShadowsocksX-NG/"
|
||||
let LAUNCH_AGENT_DIR = "/Library/LaunchAgents/"
|
||||
@@ -156,8 +156,12 @@ func SyncSSLocal() {
|
||||
|
||||
let on = UserDefaults.standard.bool(forKey: "ShadowsocksOn")
|
||||
if on {
|
||||
StopSSLocal()
|
||||
if changed {
|
||||
StopSSLocal()
|
||||
}
|
||||
StartSSLocal()
|
||||
} else {
|
||||
StopSSLocal()
|
||||
}
|
||||
} else {
|
||||
removeSSLocalConfFile()
|
||||
@@ -291,14 +295,17 @@ func SyncPrivoxy() {
|
||||
|
||||
let on = UserDefaults.standard.bool(forKey: "LocalHTTPOn")
|
||||
if on {
|
||||
StopPrivoxy()
|
||||
if changed {
|
||||
StopPrivoxy()
|
||||
}
|
||||
StartPrivoxy()
|
||||
} else {
|
||||
StopPrivoxy()
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
removePrivoxyConfFile()
|
||||
StopPrivoxy()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
@@ -429,10 +436,14 @@ func SyncKcptun() {
|
||||
|
||||
let on = UserDefaults.standard.bool(forKey: "ShadowsocksOn")
|
||||
if on {
|
||||
StopKcptun()
|
||||
if changed {
|
||||
StopKcptun()
|
||||
}
|
||||
StartKcptun()
|
||||
return
|
||||
} else {
|
||||
StopKcptun()
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
StopKcptun()
|
||||
|
||||
@@ -56,7 +56,8 @@ class ServerProfile: NSObject, NSCopying {
|
||||
guard let decoded = String(data: data, encoding: String.Encoding.utf8) else {
|
||||
return nil
|
||||
}
|
||||
return "ss://\(decoded)"
|
||||
let s = decoded.trimmingCharacters(in: CharacterSet(charactersIn: "\n"))
|
||||
return "ss://\(s)"
|
||||
}
|
||||
|
||||
guard let decodedUrl = decodeUrl(url: url) else {
|
||||
@@ -101,6 +102,9 @@ class ServerProfile: NSObject, NSCopying {
|
||||
copy.password = self.password
|
||||
copy.remark = self.remark
|
||||
copy.ota = self.ota
|
||||
|
||||
copy.enabledKcptun = self.enabledKcptun
|
||||
copy.kcptunProfile = self.kcptunProfile.copy() as! KcptunProfile
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
||||
@@ -79,42 +79,48 @@ class ServerProfileManager: NSObject {
|
||||
openPanel.canCreateDirectories = false
|
||||
openPanel.canChooseFiles = true
|
||||
openPanel.becomeKey()
|
||||
openPanel.begin { (result) -> Void in
|
||||
if (result == NSFileHandlingPanelOKButton && (openPanel.url) != nil) {
|
||||
let fileManager = FileManager.default
|
||||
let filePath:String = (openPanel.url?.path)!
|
||||
if (fileManager.fileExists(atPath: filePath) && filePath.hasSuffix("json")) {
|
||||
let data = fileManager.contents(atPath: filePath)
|
||||
let readString = NSString(data: data!, encoding: String.Encoding.utf8.rawValue)!
|
||||
let readStringData = readString.data(using: String.Encoding.utf8.rawValue)
|
||||
let result = openPanel.runModal()
|
||||
if (result == NSFileHandlingPanelOKButton && (openPanel.url) != nil) {
|
||||
let fileManager = FileManager.default
|
||||
let filePath:String = (openPanel.url?.path)!
|
||||
if (fileManager.fileExists(atPath: filePath) && filePath.hasSuffix("json")) {
|
||||
let data = fileManager.contents(atPath: filePath)
|
||||
let readString = NSString(data: data!, encoding: String.Encoding.utf8.rawValue)!
|
||||
let readStringData = readString.data(using: String.Encoding.utf8.rawValue)
|
||||
|
||||
let jsonArr1 = try! JSONSerialization.jsonObject(with: readStringData!, options: JSONSerialization.ReadingOptions.mutableContainers) as! NSDictionary
|
||||
|
||||
for item in jsonArr1.object(forKey: "configs") as! [[String: AnyObject]]{
|
||||
let profile = ServerProfile()
|
||||
profile.serverHost = item["server"] as! String
|
||||
profile.serverPort = UInt16((item["server_port"]?.integerValue)!)
|
||||
profile.method = item["method"] as! String
|
||||
profile.password = item["password"] as! String
|
||||
profile.remark = item["remarks"] as! String
|
||||
|
||||
let jsonArr1 = try! JSONSerialization.jsonObject(with: readStringData!, options: JSONSerialization.ReadingOptions.mutableContainers) as! NSDictionary
|
||||
|
||||
for item in jsonArr1.object(forKey: "configs") as! [[String: AnyObject]]{
|
||||
let profile = ServerProfile()
|
||||
profile.serverHost = item["server"] as! String
|
||||
profile.serverPort = UInt16((item["server_port"]?.integerValue)!)
|
||||
profile.method = item["method"] as! String
|
||||
profile.password = item["password"] as! String
|
||||
profile.remark = item["remarks"] as! String
|
||||
self.profiles.append(profile)
|
||||
self.save()
|
||||
// Kcptun
|
||||
profile.enabledKcptun = item["enabled_kcptun"]?.boolValue ?? false
|
||||
if let kcptun = item["kcptun"] {
|
||||
profile.kcptunProfile = KcptunProfile.fromDictionary(kcptun as! [String : Any?])
|
||||
}
|
||||
NotificationCenter.default.post(name: NSNotification.Name(rawValue: NOTIFY_SERVER_PROFILES_CHANGED), object: nil)
|
||||
let configsCount = (jsonArr1.object(forKey: "configs") as! [[String: AnyObject]]).count
|
||||
let notification = NSUserNotification()
|
||||
notification.title = "Import Server Profile succeed!".localized
|
||||
notification.informativeText = "Successful import \(configsCount) items".localized
|
||||
NSUserNotificationCenter.default
|
||||
.deliver(notification)
|
||||
}else{
|
||||
let notification = NSUserNotification()
|
||||
notification.title = "Import Server Profile failed!".localized
|
||||
notification.informativeText = "Invalid config file!".localized
|
||||
NSUserNotificationCenter.default
|
||||
.deliver(notification)
|
||||
return
|
||||
|
||||
self.profiles.append(profile)
|
||||
self.save()
|
||||
}
|
||||
NotificationCenter.default.post(name: NSNotification.Name(rawValue: NOTIFY_SERVER_PROFILES_CHANGED), object: nil)
|
||||
let configsCount = (jsonArr1.object(forKey: "configs") as! [[String: AnyObject]]).count
|
||||
let notification = NSUserNotification()
|
||||
notification.title = "Import Server Profile succeed!".localized
|
||||
notification.informativeText = "Successful import \(configsCount) items".localized
|
||||
NSUserNotificationCenter.default
|
||||
.deliver(notification)
|
||||
}else{
|
||||
let notification = NSUserNotification()
|
||||
notification.title = "Import Server Profile failed!".localized
|
||||
notification.informativeText = "Invalid config file!".localized
|
||||
NSUserNotificationCenter.default
|
||||
.deliver(notification)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -141,6 +147,11 @@ class ServerProfileManager: NSObject {
|
||||
configProfile.setValue(profile.method, forKey: "method")
|
||||
configProfile.setValue(profile.remark, forKey: "remarks")
|
||||
configProfile.setValue(profile.remark.data(using: String.Encoding.utf8)?.base64EncodedString(options: NSData.Base64EncodingOptions(rawValue: 0)), forKey: "remarks_base64")
|
||||
|
||||
// Kcptun
|
||||
configProfile.setValue(profile.enabledKcptun, forKey: "enabled_kcptun")
|
||||
configProfile.setValue(profile.kcptunProfile.toDictionary(), forKey: "kcptun")
|
||||
|
||||
configsArray.add(configProfile)
|
||||
}
|
||||
jsonArr1.setValue(configsArray, forKey: "configs")
|
||||
@@ -152,17 +163,16 @@ class ServerProfileManager: NSObject {
|
||||
savePanel.allowedFileTypes = ["json"]
|
||||
savePanel.nameFieldStringValue = "export.json"
|
||||
savePanel.becomeKey()
|
||||
savePanel.begin { (result) -> Void in
|
||||
if (result == NSFileHandlingPanelOKButton && (savePanel.url) != nil) {
|
||||
//write jsonArr1 back to file
|
||||
try! jsonString.write(toFile: (savePanel.url?.path)!, atomically: true, encoding: String.Encoding.utf8)
|
||||
NSWorkspace.shared().selectFile((savePanel.url?.path)!, inFileViewerRootedAtPath: (savePanel.directoryURL?.path)!)
|
||||
let notification = NSUserNotification()
|
||||
notification.title = "Export Server Profile succeed!".localized
|
||||
notification.informativeText = "Successful Export \(self.profiles.count) items".localized
|
||||
NSUserNotificationCenter.default
|
||||
.deliver(notification)
|
||||
}
|
||||
let result = savePanel.runModal()
|
||||
if (result == NSFileHandlingPanelOKButton && (savePanel.url) != nil) {
|
||||
//write jsonArr1 back to file
|
||||
try! jsonString.write(toFile: (savePanel.url?.path)!, atomically: true, encoding: String.Encoding.utf8)
|
||||
NSWorkspace.shared().selectFile((savePanel.url?.path)!, inFileViewerRootedAtPath: (savePanel.directoryURL?.path)!)
|
||||
let notification = NSUserNotification()
|
||||
notification.title = "Export Server Profile succeed!".localized
|
||||
notification.informativeText = "Successful Export \(self.profiles.count) items".localized
|
||||
NSUserNotificationCenter.default
|
||||
.deliver(notification)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
# Copyright © 2017年 qiuyuzhou. All rights reserved.
|
||||
|
||||
cd `dirname "${BASH_SOURCE[0]}"`
|
||||
mkdir -p "$HOME/Library/Application Support/ShadowsocksX-NG/kcptun_20161222"
|
||||
cp -f kcptun_client "$HOME/Library/Application Support/ShadowsocksX-NG/kcptun_20161222/"
|
||||
mkdir -p "$HOME/Library/Application Support/ShadowsocksX-NG/kcptun_20170117"
|
||||
cp -f kcptun_client "$HOME/Library/Application Support/ShadowsocksX-NG/kcptun_20170117/"
|
||||
rm -f "$HOME/Library/Application Support/ShadowsocksX-NG/kcptun_client"
|
||||
ln -s "$HOME/Library/Application Support/ShadowsocksX-NG/kcptun_20161222/kcptun_client" "$HOME/Library/Application Support/ShadowsocksX-NG/kcptun_client"
|
||||
ln -s "$HOME/Library/Application Support/ShadowsocksX-NG/kcptun_20170117/kcptun_client" "$HOME/Library/Application Support/ShadowsocksX-NG/kcptun_client"
|
||||
|
||||
echo "install kcptun done"
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user