Merge branch 'release/1.4.0' into develop

This commit is contained in:
Charlie Qiu
2017-03-10 21:55:58 +08:00
16 changed files with 248 additions and 6094 deletions
+37 -6
View File
@@ -44,6 +44,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
@IBOutlet var exportAllServerProfileItem: NSMenuItem!
@IBOutlet var serversPreferencesMenuItem: NSMenuItem!
@IBOutlet weak var copyHttpProxyExportCmdLineMenuItem: NSMenuItem!
@IBOutlet weak var lanchAtLoginMenuItem: NSMenuItem!
@IBOutlet weak var hudWindow: NSPanel!
@@ -84,7 +86,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
"ShadowsocksRunningMode": "auto",
"LocalSocks5.ListenPort": NSNumber(value: 1086 as UInt16),
"LocalSocks5.ListenAddress": "127.0.0.1",
"PacServer.ListenPort":NSNumber(value: 8090 as UInt16),
"PacServer.ListenPort":NSNumber(value: 1089 as UInt16),
"LocalSocks5.Timeout": NSNumber(value: 60 as UInt),
"LocalSocks5.EnableUDPRelay": NSNumber(value: false as Bool),
"LocalSocks5.EnableVerboseMode": NSNumber(value: false as Bool),
@@ -140,6 +142,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
(note) in
SyncPrivoxy()
self.applyConfig()
self.updateCopyHttpProxyExportMenu()
}
)
notifyCenter.addObserver(forName: NSNotification.Name(rawValue: "NOTIFY_FOUND_SS_URL"), object: nil, queue: nil) {
@@ -195,6 +198,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
, forEventClass: AEEventClass(kInternetEventClass), andEventID: AEEventID(kAEGetURL))
updateMainMenu()
updateCopyHttpProxyExportMenu()
updateServersMenu()
updateRunningModeMenu()
updateLaunchAtLoginMenu()
@@ -244,7 +248,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()
}
@@ -284,7 +288,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
case .pac:
Globals.proxyType = .global
UserDefaults.standard.setValue("global", forKey: "ShadowsocksRunningMode")
mySelf.isNameTextField.stringValue = "Gobal Mode"
mySelf.isNameTextField.stringValue = "Global Mode"
mySelf.updateRunningModeMenu()
mySelf.applyConfig()
case .global:
@@ -481,10 +485,31 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
spMgr.setActiveProfiledId(newProfile.uuid)
updateServersMenu()
SyncSSLocal()
applyConfig()
}
updateRunningModeMenu()
}
@IBAction func copyExportCommand(_ sender: NSMenuItem) {
// Get the Http proxy config.
let defaults = UserDefaults.standard
let address = defaults.string(forKey: "LocalHTTP.ListenAddress")!
let port = defaults.integer(forKey: "LocalHTTP.ListenPort")
// Format an export string.
let command = "export http_proxy=http://\(address):\(port);export https_proxy=http://\(address):\(port);"
// Copy to paste board.
NSPasteboard.general().clearContents()
NSPasteboard.general().setString(command, forType: NSStringPboardType)
// Give a system notification.
let notification = NSUserNotification()
notification.title = "Export Command Copied.".localized
NSUserNotificationCenter.default
.deliver(notification)
}
@IBAction func showLogs(_ sender: NSMenuItem) {
let ws = NSWorkspace.shared()
if let appUrl = ws.urlForApplication(withBundleIdentifier: "com.apple.Console") {
@@ -564,11 +589,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
@@ -594,6 +619,12 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
}
}
func updateCopyHttpProxyExportMenu() {
let defaults = UserDefaults.standard
let isOn = defaults.bool(forKey: "LocalHTTPOn")
copyHttpProxyExportCmdLineMenuItem.isHidden = !isOn
}
func updateServersMenu() {
let mgr = ServerProfileManager.instance
serversMenuItem.submenu?.removeAllItems()
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11542" systemVersion="16B2657" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11542"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
@@ -15,15 +15,15 @@
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="HTTP Proxy Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" frameAutosaveName="" animationBehavior="default" id="vS3-DL-Nq3">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<rect key="contentRect" x="109" y="131" width="253" height="219"/>
<rect key="screenRect" x="0.0" y="0.0" width="1280" height="777"/>
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
<rect key="contentRect" x="109" y="131" width="253" height="190"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1057"/>
<view key="contentView" id="Qef-Mj-9z1">
<rect key="frame" x="0.0" y="0.0" width="253" height="219"/>
<rect key="frame" x="0.0" y="0.0" width="253" height="190"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button translatesAutoresizingMaskIntoConstraints="NO" id="hgn-81-fsH">
<rect key="frame" x="18" y="183" width="138" height="18"/>
<rect key="frame" x="18" y="154" width="138" height="18"/>
<buttonCell key="cell" type="check" title="HTTP Proxy Enable" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="dqU-MG-Sum">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@@ -33,7 +33,7 @@
</connections>
</button>
<button translatesAutoresizingMaskIntoConstraints="NO" id="P4f-0N-7JI">
<rect key="frame" x="18" y="133" width="141" height="18"/>
<rect key="frame" x="18" y="126" width="141" height="18"/>
<buttonCell key="cell" type="check" title="Follow Global Mode" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="ofk-Pc-c8f">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@@ -43,7 +43,7 @@
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="CKF-K9-m8X">
<rect key="frame" x="18" y="132" width="217" height="17"/>
<rect key="frame" x="18" y="103" width="217" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="HTTP Proxy Listen Address:" id="qd0-kc-ttB">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@@ -51,7 +51,7 @@
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Ecd-cS-zUI">
<rect key="frame" x="18" y="79" width="217" height="17"/>
<rect key="frame" x="18" y="50" width="217" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="HTTP Proxy Listen Port:" id="2Sd-yn-gdY">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@@ -59,7 +59,7 @@
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="vsw-6L-eh3">
<rect key="frame" x="20" y="102" width="213" height="22"/>
<rect key="frame" x="20" y="73" width="213" height="22"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="chf-Id-e5F">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
@@ -74,7 +74,7 @@
</connections>
</textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="lD1-xm-Qy3">
<rect key="frame" x="20" y="49" width="213" height="22"/>
<rect key="frame" x="20" y="20" width="213" height="22"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="KR0-Ey-wq8">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
@@ -89,56 +89,35 @@
<outlet property="formatter" destination="ji3-e7-HNW" id="xWV-vJ-7eq"/>
</connections>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="PvN-Sl-Y1x">
<rect key="frame" x="14" y="13" width="225" height="32"/>
<buttonCell key="cell" type="push" title="Copy Shell Export Command" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="ySG-BC-5r0">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="copyExportCommand:" target="-2" id="qzS-ny-TI2"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="lD1-xm-Qy3" firstAttribute="leading" secondItem="PvN-Sl-Y1x" secondAttribute="leading" id="0y9-Yy-bwC"/>
<constraint firstItem="hgn-81-fsH" firstAttribute="leading" secondItem="P4f-0N-7JI" secondAttribute="leading" id="1R6-Zi-ctk"/>
<constraint firstItem="lD1-xm-Qy3" firstAttribute="top" secondItem="Ecd-cS-zUI" secondAttribute="bottom" constant="8" id="1nm-UH-kh1"/>
<constraint firstItem="P4f-0N-7JI" firstAttribute="top" secondItem="hgn-81-fsH" secondAttribute="bottom" constant="14" id="45x-uF-HIp"/>
<constraint firstItem="lD1-xm-Qy3" firstAttribute="trailing" secondItem="PvN-Sl-Y1x" secondAttribute="trailing" id="7sa-J6-wkh"/>
<constraint firstItem="CKF-K9-m8X" firstAttribute="leading" secondItem="vsw-6L-eh3" secondAttribute="leading" id="AHk-aI-egi"/>
<constraint firstAttribute="bottom" secondItem="PvN-Sl-Y1x" secondAttribute="bottom" constant="20" id="DbT-3u-ZkF"/>
<constraint firstItem="PvN-Sl-Y1x" firstAttribute="leading" secondItem="Qef-Mj-9z1" secondAttribute="leading" constant="20" id="E9Q-5h-emd"/>
<constraint firstItem="hgn-81-fsH" firstAttribute="top" secondItem="Qef-Mj-9z1" secondAttribute="top" constant="20" symbolic="YES" id="Frc-hf-qrH"/>
<constraint firstItem="vsw-6L-eh3" firstAttribute="leading" secondItem="Ecd-cS-zUI" secondAttribute="leading" id="LrJ-ar-6wM"/>
<constraint firstItem="Ecd-cS-zUI" firstAttribute="leading" secondItem="lD1-xm-Qy3" secondAttribute="leading" id="OKR-LY-EGz"/>
<constraint firstItem="CKF-K9-m8X" firstAttribute="trailing" secondItem="vsw-6L-eh3" secondAttribute="trailing" id="Pd5-7w-ckb"/>
<constraint firstAttribute="trailing" secondItem="PvN-Sl-Y1x" secondAttribute="trailing" constant="20" id="PnS-gu-hdu"/>
<constraint firstItem="hgn-81-fsH" firstAttribute="leading" secondItem="Qef-Mj-9z1" secondAttribute="leading" constant="20" symbolic="YES" id="Ybz-LX-Dja"/>
<constraint firstItem="PvN-Sl-Y1x" firstAttribute="top" secondItem="lD1-xm-Qy3" secondAttribute="bottom" constant="8" id="f3P-0R-9gv"/>
<constraint firstItem="Ecd-cS-zUI" firstAttribute="trailing" secondItem="lD1-xm-Qy3" secondAttribute="trailing" id="fB5-qO-5nl"/>
<constraint firstItem="vsw-6L-eh3" firstAttribute="trailing" secondItem="Ecd-cS-zUI" secondAttribute="trailing" id="gjk-JO-7i3"/>
<constraint firstItem="Ecd-cS-zUI" firstAttribute="top" secondItem="vsw-6L-eh3" secondAttribute="bottom" constant="6" id="pcf-ni-T4y"/>
<constraint firstItem="vsw-6L-eh3" firstAttribute="top" secondItem="CKF-K9-m8X" secondAttribute="bottom" constant="8" id="sXF-aR-Xnj"/>
<constraint firstItem="CKF-K9-m8X" firstAttribute="top" secondItem="P4f-0N-7JI" secondAttribute="bottom" constant="8" symbolic="YES" id="3JQ-SJ-TSN"/>
<constraint firstItem="Ecd-cS-zUI" firstAttribute="trailing" secondItem="lD1-xm-Qy3" secondAttribute="trailing" id="7gU-3r-116"/>
<constraint firstItem="hgn-81-fsH" firstAttribute="leading" secondItem="P4f-0N-7JI" secondAttribute="leading" id="9a5-Oj-c36"/>
<constraint firstItem="P4f-0N-7JI" firstAttribute="leading" secondItem="CKF-K9-m8X" secondAttribute="leading" id="FNT-X2-Wjy"/>
<constraint firstItem="hgn-81-fsH" firstAttribute="top" secondItem="Qef-Mj-9z1" secondAttribute="top" constant="20" symbolic="YES" id="G6a-3j-ZVI"/>
<constraint firstItem="vsw-6L-eh3" firstAttribute="trailing" secondItem="Ecd-cS-zUI" secondAttribute="trailing" id="Imt-lq-XHl"/>
<constraint firstItem="CKF-K9-m8X" firstAttribute="trailing" secondItem="vsw-6L-eh3" secondAttribute="trailing" id="V0q-XV-Mui"/>
<constraint firstAttribute="trailing" secondItem="CKF-K9-m8X" secondAttribute="trailing" constant="20" symbolic="YES" id="WhC-Dm-ETJ"/>
<constraint firstItem="hgn-81-fsH" firstAttribute="leading" secondItem="Qef-Mj-9z1" secondAttribute="leading" constant="20" symbolic="YES" id="XKp-Ug-dvt"/>
<constraint firstItem="vsw-6L-eh3" firstAttribute="leading" secondItem="Ecd-cS-zUI" secondAttribute="leading" id="bep-WS-ThG"/>
<constraint firstItem="lD1-xm-Qy3" firstAttribute="top" secondItem="Ecd-cS-zUI" secondAttribute="bottom" constant="8" symbolic="YES" id="fap-29-XS4"/>
<constraint firstAttribute="bottom" secondItem="lD1-xm-Qy3" secondAttribute="bottom" constant="20" symbolic="YES" id="nDF-aL-c9J"/>
<constraint firstItem="CKF-K9-m8X" firstAttribute="leading" secondItem="vsw-6L-eh3" secondAttribute="leading" id="o6R-dQ-3gq"/>
<constraint firstItem="Ecd-cS-zUI" firstAttribute="leading" secondItem="lD1-xm-Qy3" secondAttribute="leading" id="oWo-gR-cua"/>
<constraint firstItem="vsw-6L-eh3" firstAttribute="top" secondItem="CKF-K9-m8X" secondAttribute="bottom" constant="8" symbolic="YES" id="q8d-OA-Ea2"/>
<constraint firstItem="Ecd-cS-zUI" firstAttribute="top" secondItem="vsw-6L-eh3" secondAttribute="bottom" constant="6" id="zdB-fb-Nth"/>
</constraints>
</view>
<connections>
<outlet property="delegate" destination="-2" id="mD3-X9-VEN"/>
</connections>
<point key="canvasLocation" x="2.5" y="120.5"/>
<point key="canvasLocation" x="2.5" y="106"/>
</window>
<userDefaultsController representsSharedInstance="YES" id="Adn-6l-wm4"/>
<numberFormatter formatterBehavior="default10_4" usesGroupingSeparator="NO" groupingSize="0" minimumIntegerDigits="0" maximumIntegerDigits="42" id="ji3-e7-HNW" userLabel="Port Number Formatter">
<real key="minimum" value="128"/>
<real key="maximum" value="65535"/>
</numberFormatter>
<button verticalHuggingPriority="750" id="XMF-lp-tgg">
<rect key="frame" x="0.0" y="0.0" width="82" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Button" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="iOs-ut-Dj4">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
</objects>
</document>
+9 -2
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="16C67" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
@@ -16,6 +16,7 @@
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="ShadowsocksX_NG" customModuleProvider="target">
<connections>
<outlet property="autoModeMenuItem" destination="r07-Gu-aEz" id="9aH-pQ-Rgi"/>
<outlet property="copyHttpProxyExportCmdLineMenuItem" destination="lg6-To-GZA" id="VTb-he-dg4"/>
<outlet property="exportAllServerProfileItem" destination="6k0-gn-DQv" id="W2x-96-ISj"/>
<outlet property="globalModeMenuItem" destination="Mw3-Jm-eXA" id="ar5-Yx-3ze"/>
<outlet property="hudWindow" destination="QWV-F6-ac1" id="K6D-a4-oqE"/>
@@ -103,6 +104,12 @@
</menu>
</menuItem>
<menuItem isSeparatorItem="YES" id="vwY-hQ-ZIz"/>
<menuItem title="Copy HTTP Proxy Shell Export Line" id="lg6-To-GZA">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="copyExportCommand:" target="Voe-Tx-rLC" id="2U4-3M-sAK"/>
</connections>
</menuItem>
<menuItem title="Scan QR Code From Screen ..." id="Qe6-bF-paT">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
@@ -212,7 +219,7 @@
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" oneShot="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="QWV-F6-ac1" customClass="NSPanel">
<windowStyleMask key="styleMask" closable="YES" miniaturizable="YES" resizable="YES" utility="YES"/>
<rect key="contentRect" x="139" y="81" width="200" height="100"/>
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1057"/>
<value key="minSize" type="size" width="200" height="100"/>
<value key="maxSize" type="size" width="200" height="100"/>
<view key="contentView" id="rai-SH-9tZ" userLabel="Panel View">
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="16C67" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
@@ -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="1680" height="1027"/>
<view key="contentView" id="se5-gp-TjO">
<rect key="frame" x="0.0" y="0.0" width="590" height="504"/>
<autoresizingMask key="autoresizingMask"/>
@@ -123,7 +123,7 @@
<constraints>
<constraint firstAttribute="width" constant="46" id="zGr-QU-b7G"/>
</constraints>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="e1F-jd-e0J">
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" placeholderString="port" drawsBackground="YES" id="e1F-jd-e0J">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -188,7 +188,7 @@
</textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="R4F-j7-GkK">
<rect key="frame" x="111" y="381" width="122" height="22"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="MWO-hQ-nMt">
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" placeholderString="ip" drawsBackground="YES" id="MWO-hQ-nMt">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -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"/>
@@ -1,7 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="ProxyPreferencesController" customModule="ShadowsocksX_NG" customModuleProvider="target">
@@ -16,12 +18,12 @@
<window title="Advanced Proxy Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" animationBehavior="default" id="F0z-JX-Cv5">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<rect key="contentRect" x="503" y="308" width="298" height="311"/>
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
<view key="contentView" id="se5-gp-TjO">
<rect key="frame" x="0.0" y="0.0" width="298" height="311"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="al4-wo-BVS">
<button translatesAutoresizingMaskIntoConstraints="NO" id="al4-wo-BVS">
<rect key="frame" x="18" y="275" width="262" height="18"/>
<buttonCell key="cell" type="check" title="Auto Configure" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="FLv-D9-CRw">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
@@ -31,9 +33,9 @@
<binding destination="-2" name="value" keyPath="autoConfigureNetworkServices" id="SgV-RH-wUe"/>
</connections>
</button>
<scrollView fixedFrame="YES" autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="657-dv-Val">
<scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="657-dv-Val">
<rect key="frame" x="20" y="61" width="258" height="199"/>
<clipView key="contentView" ambiguous="YES" id="i6C-d3-Rpb">
<clipView key="contentView" id="i6C-d3-Rpb">
<rect key="frame" x="1" y="1" width="256" height="197"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
@@ -70,7 +72,6 @@
</connections>
</tableView>
</subviews>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="3sC-hI-IvB">
<rect key="frame" x="-7" y="-14" width="0.0" height="15"/>
@@ -81,8 +82,11 @@
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ulk-V7-E4w">
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ulk-V7-E4w">
<rect key="frame" x="203" y="13" width="81" height="32"/>
<constraints>
<constraint firstAttribute="width" constant="69" id="pKr-lK-BZO"/>
</constraints>
<buttonCell key="cell" type="push" title="OK" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="rWE-M6-TvV">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
@@ -94,8 +98,11 @@ DQ
<action selector="ok:" target="-2" id="GTx-sb-ino"/>
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="NVO-zo-7QI">
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="NVO-zo-7QI">
<rect key="frame" x="122" y="13" width="81" height="32"/>
<constraints>
<constraint firstAttribute="width" constant="69" id="tMt-LA-r5K"/>
</constraints>
<buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="lsQ-1C-OhG">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
@@ -108,6 +115,19 @@ Gw
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="657-dv-Val" firstAttribute="trailing" secondItem="ulk-V7-E4w" secondAttribute="trailing" id="CY9-DO-bdj"/>
<constraint firstItem="NVO-zo-7QI" firstAttribute="baseline" secondItem="ulk-V7-E4w" secondAttribute="baseline" id="Eyr-b9-ZtL"/>
<constraint firstAttribute="bottom" secondItem="NVO-zo-7QI" secondAttribute="bottom" constant="20" symbolic="YES" id="FlW-Sa-FEZ"/>
<constraint firstItem="NVO-zo-7QI" firstAttribute="top" secondItem="657-dv-Val" secondAttribute="bottom" constant="20" symbolic="YES" id="Rmy-NH-TYr"/>
<constraint firstItem="al4-wo-BVS" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="20" symbolic="YES" id="VgE-Fh-JP4"/>
<constraint firstItem="657-dv-Val" firstAttribute="top" secondItem="al4-wo-BVS" secondAttribute="bottom" constant="17" id="YZs-QN-ABC"/>
<constraint firstItem="ulk-V7-E4w" firstAttribute="leading" secondItem="NVO-zo-7QI" secondAttribute="trailing" constant="12" symbolic="YES" id="YdW-u1-0yB"/>
<constraint firstItem="al4-wo-BVS" firstAttribute="leading" secondItem="657-dv-Val" secondAttribute="leading" id="de4-mH-svX"/>
<constraint firstItem="al4-wo-BVS" firstAttribute="trailing" secondItem="657-dv-Val" secondAttribute="trailing" id="fnP-5p-dPB"/>
<constraint firstAttribute="trailing" secondItem="al4-wo-BVS" secondAttribute="trailing" constant="20" symbolic="YES" id="nxt-Hr-6YP"/>
<constraint firstItem="al4-wo-BVS" firstAttribute="top" secondItem="se5-gp-TjO" secondAttribute="top" constant="20" symbolic="YES" id="tBQ-Gd-Hhr"/>
</constraints>
</view>
<connections>
<outlet property="delegate" destination="-2" id="0bl-1N-AYu"/>
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11542" systemVersion="16B2657" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11542"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
@@ -18,14 +18,16 @@
<window title="User Rules" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" animationBehavior="default" id="F0z-JX-Cv5">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<rect key="contentRect" x="196" y="240" width="480" height="270"/>
<rect key="screenRect" x="0.0" y="0.0" width="1280" height="777"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
<view key="contentView" id="se5-gp-TjO">
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="N2T-OG-SO9">
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="N2T-OG-SO9">
<rect key="frame" x="385" y="13" width="81" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<constraints>
<constraint firstAttribute="width" constant="69" id="aO3-kK-V9p"/>
</constraints>
<buttonCell key="cell" type="push" title="OK" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="0Sc-cm-Vyu">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
@@ -38,9 +40,11 @@ DQ
<action selector="didOK:" target="-2" id="216-18-SFI"/>
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2bi-hW-nd9">
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="2bi-hW-nd9">
<rect key="frame" x="304" y="13" width="81" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<constraints>
<constraint firstAttribute="width" constant="69" id="jXL-pY-uDw"/>
</constraints>
<buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="QAR-9i-kmv">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
@@ -52,18 +56,17 @@ Gw
<action selector="didCancel:" target="-2" id="SFh-eD-YLV"/>
</connections>
</button>
<scrollView fixedFrame="YES" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="J3L-MK-p8I">
<scrollView horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="J3L-MK-p8I">
<rect key="frame" x="20" y="61" width="440" height="189"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<clipView key="contentView" ambiguous="YES" id="fO6-Dc-ZUL">
<rect key="frame" x="1" y="1" width="438" height="187"/>
<clipView key="contentView" id="fO6-Dc-ZUL">
<rect key="frame" x="1" y="1" width="423" height="187"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView ambiguous="YES" importsGraphics="NO" richText="NO" usesFontPanel="YES" findStyle="panel" continuousSpellChecking="YES" allowsUndo="YES" usesRuler="YES" allowsNonContiguousLayout="YES" quoteSubstitution="YES" dashSubstitution="YES" spellingCorrection="YES" smartInsertDelete="YES" id="4yV-hS-knY">
<rect key="frame" x="0.0" y="0.0" width="438" height="187"/>
<textView importsGraphics="NO" richText="NO" usesFontPanel="YES" findStyle="panel" continuousSpellChecking="YES" allowsUndo="YES" usesRuler="YES" allowsNonContiguousLayout="YES" quoteSubstitution="YES" dashSubstitution="YES" spellingCorrection="YES" smartInsertDelete="YES" id="4yV-hS-knY">
<rect key="frame" x="0.0" y="0.0" width="423" height="187"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<size key="minSize" width="438" height="187"/>
<size key="minSize" width="423" height="187"/>
<size key="maxSize" width="463" height="10000000"/>
<color key="insertionPointColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
</textView>
@@ -75,11 +78,21 @@ Gw
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" verticalHuggingPriority="750" horizontal="NO" id="Us9-yx-gj4">
<rect key="frame" x="423" y="1" width="16" height="187"/>
<rect key="frame" x="424" y="1" width="15" height="187"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
</subviews>
<constraints>
<constraint firstItem="N2T-OG-SO9" firstAttribute="leading" secondItem="2bi-hW-nd9" secondAttribute="trailing" constant="12" symbolic="YES" id="aMv-5A-H00"/>
<constraint firstItem="2bi-hW-nd9" firstAttribute="baseline" secondItem="N2T-OG-SO9" secondAttribute="baseline" id="bCp-AI-xph"/>
<constraint firstItem="J3L-MK-p8I" firstAttribute="trailing" secondItem="N2T-OG-SO9" secondAttribute="trailing" id="ceZ-Kz-tzP"/>
<constraint firstItem="J3L-MK-p8I" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="20" symbolic="YES" id="jkN-Yi-047"/>
<constraint firstItem="2bi-hW-nd9" firstAttribute="top" secondItem="J3L-MK-p8I" secondAttribute="bottom" constant="20" symbolic="YES" id="n5u-fC-X85"/>
<constraint firstItem="J3L-MK-p8I" firstAttribute="top" secondItem="se5-gp-TjO" secondAttribute="top" constant="20" symbolic="YES" id="nm4-yK-hmi"/>
<constraint firstAttribute="bottom" secondItem="2bi-hW-nd9" secondAttribute="bottom" constant="20" symbolic="YES" id="tqM-nL-hC0"/>
<constraint firstAttribute="trailing" secondItem="J3L-MK-p8I" secondAttribute="trailing" constant="20" symbolic="YES" id="ziG-gJ-Fcg"/>
</constraints>
</view>
<connections>
<outlet property="delegate" destination="-2" id="0bl-1N-AYu"/>
@@ -27,13 +27,4 @@ class HTTPPreferencesWindowController: NSWindowController, NSWindowDelegate {
.post(name: Notification.Name(rawValue: NOTIFY_HTTP_CONF_CHANGED), object: nil)
}
@IBAction func copyExportCommand(_ sender: Any) {
let command = "export http_proxy=http://\(address.stringValue):\(port.stringValue);export https_proxy=http://\(address.stringValue):\(port.stringValue);"
NSPasteboard.general().clearContents()
NSPasteboard.general().setString(command, forType: NSStringPboardType)
let notification = NSUserNotification()
notification.title = "Export Command Copied.".localized
NSUserNotificationCenter.default
.deliver(notification)
}
}
+1 -1
View File
@@ -36,7 +36,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>2</string>
<string>4</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
+2 -1
View File
@@ -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;
}
+39 -7
View File
@@ -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,19 @@ func SyncSSLocal() {
let on = UserDefaults.standard.bool(forKey: "ShadowsocksOn")
if on {
if changed {
StopSSLocal()
DispatchQueue.main.asyncAfter(
deadline: DispatchTime.now() + DispatchTimeInterval.seconds(1),
execute: {
() in
StartSSLocal()
})
} else {
StartSSLocal()
}
} else {
StopSSLocal()
StartSSLocal()
}
} else {
removeSSLocalConfFile()
@@ -291,14 +302,24 @@ func SyncPrivoxy() {
let on = UserDefaults.standard.bool(forKey: "LocalHTTPOn")
if on {
if changed {
StopPrivoxy()
DispatchQueue.main.asyncAfter(
deadline: DispatchTime.now() + DispatchTimeInterval.seconds(1),
execute: {
() in
StartPrivoxy()
})
} else {
StartPrivoxy()
}
} else {
StopPrivoxy()
StartPrivoxy()
}
else {
} else {
removePrivoxyConfFile()
StopPrivoxy()
}
}
}
// --------------------------------------------------------------------------------
@@ -429,10 +450,21 @@ func SyncKcptun() {
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()
StartKcptun()
return
}
return
}
}
StopKcptun()
@@ -187,7 +187,7 @@ class PreferencesWindowController: NSWindowController
}
func updateProfileBoxVisible() {
if profileMgr.profiles.count <= 1 {
if profileMgr.profiles.count <= 0 {
removeButton.isEnabled = false
}else{
removeButton.isEnabled = true
+5 -1
View File
@@ -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;
}
+54 -44
View File
@@ -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)
}
}
+3 -3
View File
@@ -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