Merge branch 'release/1.3.1'

This commit is contained in:
Charlie Qiu
2016-10-19 14:32:40 +08:00
9 changed files with 179 additions and 156 deletions

View File

@ -27,6 +27,10 @@ Then I rewrite the GUI code by swift.
- XCode 8.0+
- cocoapod 1.0.1+
## Download
From [here](https://github.com/shadowsocks/ShadowsocksX-NG/releases/)
## Fetures
- Use ss-local from shadowsocks-libev 2.4.6

View File

@ -96,18 +96,6 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
083BF8311D82731900831C68 /* SimplePing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimplePing.h; sourceTree = "<group>"; };
083BF8321D82731900831C68 /* SimplePing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SimplePing.m; sourceTree = "<group>"; };
083BF8341D82742200831C68 /* NetWorkMonitor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetWorkMonitor.swift; sourceTree = "<group>"; };
083BF8351D82742200831C68 /* PingClient.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PingClient.swift; sourceTree = "<group>"; };
083BF8381D82759600831C68 /* StatusItemView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusItemView.swift; sourceTree = "<group>"; };
083BF83A1D8275A800831C68 /* SystemThemeChangeHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SystemThemeChangeHelper.swift; sourceTree = "<group>"; };
085641E91D7188C400116B27 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/Localizable.strings; sourceTree = "<group>"; };
08805F181D878CA5009B53E7 /* PingTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PingTest.swift; sourceTree = "<group>"; };
0880CE3F1D6FE6D900BD39E2 /* example-gui-config.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "example-gui-config.json"; sourceTree = "<group>"; };
088EC3961D5F5B8600E40791 /* whitelist.pac */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = whitelist.pac; sourceTree = "<group>"; };
088EC3981D5F5BA300E40791 /* whiteiplist.pac */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = whiteiplist.pac; sourceTree = "<group>"; };
08AF56C01D6AFA7C00DC4F46 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/PreferencesWindowController.strings"; sourceTree = "<group>"; };
19083CFCED87354F006967FF /* Pods_ShadowsocksX_NGUITests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ShadowsocksX_NGUITests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
1E7783AEDB4A3BDDC9FF16AC /* libPods-proxy_conf_helper.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-proxy_conf_helper.a"; sourceTree = BUILT_PRODUCTS_DIR; };
283ED1A8E9B711AC65670031 /* Pods_ShadowsocksX_NG.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ShadowsocksX_NG.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@ -505,7 +493,6 @@
9B3FFF3A1D08CF110019A709 /* qrcode.htm in Resources */,
C6D429941DA75988002A5711 /* privoxy in Resources */,
C6D429991DA76FBC002A5711 /* privoxy.config.example in Resources */,
0880CE401D6FE6D900BD39E2 /* example-gui-config.json in Resources */,
9BEEF06B1D04D4D500FC52B3 /* stop_ss_local.sh in Resources */,
9B3FFF341D08CEF70019A709 /* SWBQRCodeWindowController.xib in Resources */,
9BEEF06C1D04D4D500FC52B3 /* reload_conf_ss_local.sh in Resources */,

View File

@ -58,7 +58,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
"ShadowsocksRunningMode": "auto",
"LocalSocks5.ListenPort": NSNumber(value: 1086 as UInt16),
"LocalSocks5.ListenAddress": "127.0.0.1",
"PacServer.ListenAddress": "127.0.0.1",
"PacServer.ListenPort":NSNumber(value: 8090 as UInt16),
"LocalSocks5.Timeout": NSNumber(value: 60 as UInt),
"LocalSocks5.EnableUDPRelay": NSNumber(value: false as Bool),
@ -163,6 +162,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
updateLaunchAtLoginMenu()
ProxyConfHelper.install()
ProxyConfHelper.startMonitorPAC()
applyConfig()
SyncSSLocal()
}
@ -171,10 +171,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
// Insert code here to tear down your application
StopSSLocal()
StopPrivoxy()
ProxyConfHelper.disableProxy("hi")
ProxyConfHelper.disableProxy()
let defaults = UserDefaults.standard
defaults.set(false, forKey: "ShadowsocksOn")
ProxyConfHelper.stopPACServer()
}
func applyConfig() {
@ -186,16 +185,16 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
StartSSLocal()
StartPrivoxy()
if mode == "auto" {
ProxyConfHelper.enablePACProxy("hi")
ProxyConfHelper.enablePACProxy()
} else if mode == "global" {
ProxyConfHelper.enableGlobalProxy()
} else if mode == "manual" {
ProxyConfHelper.disableProxy("hi")
ProxyConfHelper.disableProxy()
}
} else {
StopSSLocal()
StopPrivoxy()
ProxyConfHelper.disableProxy("hi")
ProxyConfHelper.disableProxy()
}
}
@ -385,18 +384,17 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
showRunningModeMenuItem.state = defaults.bool(forKey: "ShowRunningModeOnStatusBar") ? 1 : 0
var serverMenuText = "Servers".localized
if let serverProfiles = defaults.array(forKey: "ServerProfiles") {
for v in serverProfiles {
let profile = v as! [String:Any]
if profile["Id"] as! String == defaults.string(forKey: "ActiveServerProfileId")! {
var profileName :String
if profile["Remark"] as! String != "" {
profileName = profile["Remark"] as! String
} else {
profileName = profile["ServerHost"] as! String
}
serverMenuText = "\(serverMenuText) - \(profileName)"
let mgr = ServerProfileManager.instance
for p in mgr.profiles {
if mgr.activeProfileId == p.uuid {
var profileName :String
if !p.remark.isEmpty {
profileName = p.remark
} else {
profileName = p.serverHost
}
serverMenuText = "\(serverMenuText) - \(profileName)"
}
}
serversMenuItem.title = serverMenuText

View File

@ -14,30 +14,19 @@
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="Advance Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" animationBehavior="default" id="F0z-JX-Cv5">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
<rect key="contentRect" x="562" y="415" width="480" height="416"/>
<rect key="contentRect" x="562" y="415" width="480" height="345"/>
<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="416"/>
<rect key="frame" x="0.0" y="0.0" width="480" height="345"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="ayu-Tb-kmf">
<rect key="frame" x="38" y="120" width="405" height="5"/>
<rect key="frame" x="41" y="120" width="405" height="5"/>
</box>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="I4a-N9-Tkv">
<rect key="frame" x="48" y="97" width="192" height="17"/>
<constraints>
<constraint firstAttribute="width" constant="188" id="Tny-lh-gfo"/>
</constraints>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="GFW List URL:" id="dg0-gS-z5V">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="6MD-Ry-R5P">
<rect key="frame" x="49" y="20" width="378" height="69"/>
<rect key="frame" x="54" y="20" width="378" height="69"/>
<constraints>
<constraint firstAttribute="height" constant="69" id="NVe-Ir-JCv"/>
<constraint firstAttribute="height" constant="69" id="yzO-2D-eTT"/>
</constraints>
<textFieldCell key="cell" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="fS7-It-ERD">
<font key="font" metaFont="system"/>
@ -53,7 +42,7 @@
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="wCp-nB-dda">
<rect key="frame" x="18" y="379" width="439" height="17"/>
<rect key="frame" x="18" y="308" width="439" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="Don't change these preferences if you have no idea what are they." id="8wL-qv-5nD">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@ -61,10 +50,10 @@
</textFieldCell>
</textField>
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="JBW-8M-eHP">
<rect key="frame" x="36" y="368" width="405" height="5"/>
<rect key="frame" x="36" y="297" width="403" height="5"/>
</box>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="S5h-Xx-HUG">
<rect key="frame" x="27" y="306" width="204" height="17"/>
<rect key="frame" x="27" y="239" width="204" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Local Socks5 Listen Port:" id="qRs-ow-vVB">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@ -72,7 +61,7 @@
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="xWv-tc-lQe">
<rect key="frame" x="27" y="343" width="204" height="17"/>
<rect key="frame" x="27" y="272" width="204" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Local Socks5 Listen Address:" id="cwr-n0-zwn">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@ -80,7 +69,7 @@
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Q2L-Fh-TW1">
<rect key="frame" x="237" y="340" width="160" height="22"/>
<rect key="frame" x="237" y="269" width="160" height="22"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="iRm-V5-3gu">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
@ -95,7 +84,7 @@
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="e3S-m6-k5Y">
<rect key="frame" x="27" y="190" width="204" height="17"/>
<rect key="frame" x="27" y="175" width="204" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Timeout:" id="i4l-2S-gOQ">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@ -103,7 +92,7 @@
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="sRP-xs-alR">
<rect key="frame" x="237" y="185" width="60" height="22"/>
<rect key="frame" x="237" y="173" width="60" height="22"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="right" drawsBackground="YES" id="wjv-Nc-tjX">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
@ -119,7 +108,7 @@
</connections>
</textField>
<button translatesAutoresizingMaskIntoConstraints="NO" id="DiD-K0-Y43">
<rect key="frame" x="235" y="155" width="219" height="18"/>
<rect key="frame" x="235" y="149" width="219" height="18"/>
<buttonCell key="cell" type="check" title="Enable Udp Replay" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="1C3-4s-Apd">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@ -129,9 +118,9 @@
</connections>
</button>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="XQ5-fw-o8t">
<rect key="frame" x="237" y="303" width="60" height="22"/>
<rect key="frame" x="237" y="237" width="60" height="22"/>
<constraints>
<constraint firstAttribute="width" constant="60" id="reo-ha-VKi"/>
<constraint firstAttribute="width" constant="60" id="S9f-Rp-2gz"/>
</constraints>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="right" drawsBackground="YES" id="rfR-7k-cS8">
<font key="font" metaFont="system"/>
@ -148,10 +137,7 @@
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="eoD-7r-Q85">
<rect key="frame" x="303" y="188" width="96" height="17"/>
<constraints>
<constraint firstAttribute="width" constant="92" id="xw1-XT-mjQ"/>
</constraints>
<rect key="frame" x="303" y="175" width="96" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Seconds" id="Gd3-Fm-sWh">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@ -168,18 +154,16 @@
<binding destination="pR1-Bo-AWz" name="value" keyPath="values.LocalSocks5.EnableVerboseMode" id="Nu9-zu-vUE"/>
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Wsf-gl-dkY">
<rect key="frame" x="90" y="230" width="141" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Wsf-gl-dkY">
<rect key="frame" x="90" y="207" width="141" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Local PAC Listien Port:" id="DiO-6B-ALO">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="FoE-i9-Rfb">
<rect key="frame" x="237" y="227" width="60" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="FoE-i9-Rfb">
<rect key="frame" x="237" y="205" width="60" height="22"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="right" drawsBackground="YES" id="XhZ-XN-MoS">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
@ -194,22 +178,12 @@
<outlet property="formatter" destination="uE9-0u-CJW" id="YNn-yx-cWk"/>
</connections>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="8Co-1p-O4m">
<rect key="frame" x="237" y="265" width="160" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="Z9Z-Tz-7l4">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<binding destination="pR1-Bo-AWz" name="value" keyPath="values.PacServer.ListenAddress" id="MkH-lr-4Q7"/>
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="agk-yO-9kp">
<rect key="frame" x="73" y="268" width="158" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Local PAC listen Address:" id="tIW-Xu-BJd">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="I4a-N9-Tkv">
<rect key="frame" x="52" y="97" width="192" height="17"/>
<constraints>
<constraint firstAttribute="width" constant="188" id="mcl-Uv-Y6n"/>
</constraints>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="GFW List URL:" id="dg0-gS-z5V">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
@ -217,51 +191,57 @@
</textField>
</subviews>
<constraints>
<constraint firstItem="xWv-tc-lQe" firstAttribute="baseline" secondItem="Q2L-Fh-TW1" secondAttribute="baseline" id="0ub-69-rbe"/>
<constraint firstAttribute="bottom" secondItem="6MD-Ry-R5P" secondAttribute="bottom" constant="20" symbolic="YES" id="1VT-Fs-nNp"/>
<constraint firstItem="S5h-Xx-HUG" firstAttribute="leading" secondItem="e3S-m6-k5Y" secondAttribute="leading" id="1Y0-Oh-Ev4"/>
<constraint firstItem="wCp-nB-dda" firstAttribute="top" secondItem="se5-gp-TjO" secondAttribute="top" constant="20" symbolic="YES" id="4af-lJ-vAL"/>
<constraint firstItem="xWv-tc-lQe" firstAttribute="leading" secondItem="S5h-Xx-HUG" secondAttribute="leading" id="7E0-aW-12T"/>
<constraint firstItem="6MD-Ry-R5P" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="49" id="8CU-pQ-jDz"/>
<constraint firstItem="xWv-tc-lQe" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="29" id="8oq-65-XGK"/>
<constraint firstItem="eoD-7r-Q85" firstAttribute="leading" secondItem="sRP-xs-alR" secondAttribute="trailing" constant="8" symbolic="YES" id="GhL-we-2co"/>
<constraint firstItem="sRP-xs-alR" firstAttribute="leading" secondItem="DiD-K0-Y43" secondAttribute="leading" id="H7k-Nh-YHo"/>
<constraint firstAttribute="trailing" secondItem="DiD-K0-Y43" secondAttribute="trailing" constant="28" id="H8a-Jg-72h"/>
<constraint firstItem="XQ5-fw-o8t" firstAttribute="leading" secondItem="sRP-xs-alR" secondAttribute="leading" id="Ij2-mo-WRt"/>
<constraint firstItem="DiD-K0-Y43" firstAttribute="leading" secondItem="qVQ-tJ-cO6" secondAttribute="leading" id="J5O-DE-8O9"/>
<constraint firstItem="Q2L-Fh-TW1" firstAttribute="top" secondItem="JBW-8M-eHP" secondAttribute="bottom" constant="8" symbolic="YES" id="Jkq-uJ-Wv4"/>
<constraint firstAttribute="trailing" secondItem="wCp-nB-dda" secondAttribute="trailing" constant="25" id="Mod-B8-1Yl"/>
<constraint firstItem="wCp-nB-dda" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="20" symbolic="YES" id="R3i-gt-6zg"/>
<constraint firstItem="DiD-K0-Y43" firstAttribute="trailing" secondItem="qVQ-tJ-cO6" secondAttribute="trailing" id="WaY-S9-VQ2"/>
<constraint firstItem="I4a-N9-Tkv" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="50" id="Wd9-qu-Mx8"/>
<constraint firstItem="e3S-m6-k5Y" firstAttribute="top" secondItem="sRP-xs-alR" secondAttribute="top" id="Xmc-dV-VXv"/>
<constraint firstItem="JBW-8M-eHP" firstAttribute="top" secondItem="wCp-nB-dda" secondAttribute="bottom" constant="8" symbolic="YES" id="Ysd-52-5Fn"/>
<constraint firstAttribute="trailing" secondItem="Q2L-Fh-TW1" secondAttribute="trailing" constant="83" id="ZoL-73-xKa"/>
<constraint firstItem="sRP-xs-alR" firstAttribute="leading" secondItem="e3S-m6-k5Y" secondAttribute="trailing" constant="8" symbolic="YES" id="ZvN-ZN-EVZ"/>
<constraint firstItem="sRP-xs-alR" firstAttribute="baseline" secondItem="eoD-7r-Q85" secondAttribute="baseline" id="aXC-g0-ZpB"/>
<constraint firstItem="qVQ-tJ-cO6" firstAttribute="top" secondItem="DiD-K0-Y43" secondAttribute="bottom" constant="12" id="ccj-Fd-7z7"/>
<constraint firstItem="6MD-Ry-R5P" firstAttribute="top" secondItem="I4a-N9-Tkv" secondAttribute="bottom" constant="8" symbolic="YES" id="dPZ-gY-1am"/>
<constraint firstItem="JBW-8M-eHP" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="36" id="dSL-lu-CVv"/>
<constraint firstItem="XQ5-fw-o8t" firstAttribute="top" secondItem="Q2L-Fh-TW1" secondAttribute="bottom" constant="15" id="e6i-xd-BD3"/>
<constraint firstItem="ayu-Tb-kmf" firstAttribute="centerX" secondItem="se5-gp-TjO" secondAttribute="centerX" id="edi-Ij-cuc"/>
<constraint firstItem="Q2L-Fh-TW1" firstAttribute="leading" secondItem="XQ5-fw-o8t" secondAttribute="leading" id="g40-g1-s29"/>
<constraint firstItem="Q2L-Fh-TW1" firstAttribute="trailing" secondItem="eoD-7r-Q85" secondAttribute="trailing" id="g4n-5J-iDi"/>
<constraint firstItem="Q2L-Fh-TW1" firstAttribute="leading" secondItem="xWv-tc-lQe" secondAttribute="trailing" constant="8" symbolic="YES" id="hoH-Lm-ihP"/>
<constraint firstItem="XQ5-fw-o8t" firstAttribute="leading" secondItem="S5h-Xx-HUG" secondAttribute="trailing" constant="8" symbolic="YES" id="ibP-Bc-Xhg"/>
<constraint firstItem="ayu-Tb-kmf" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="38" id="kkG-sj-u3Y"/>
<constraint firstItem="ayu-Tb-kmf" firstAttribute="top" secondItem="qVQ-tJ-cO6" secondAttribute="bottom" constant="8" symbolic="YES" id="lza-Z7-YaI"/>
<constraint firstItem="XQ5-fw-o8t" firstAttribute="trailing" secondItem="sRP-xs-alR" secondAttribute="trailing" id="pfd-Yd-goI"/>
<constraint firstItem="JBW-8M-eHP" firstAttribute="centerX" secondItem="6MD-Ry-R5P" secondAttribute="centerX" id="qbH-5m-epu"/>
<constraint firstItem="I4a-N9-Tkv" firstAttribute="top" secondItem="ayu-Tb-kmf" secondAttribute="bottom" constant="8" symbolic="YES" id="u7y-6r-Vj5"/>
<constraint firstItem="DiD-K0-Y43" firstAttribute="top" secondItem="sRP-xs-alR" secondAttribute="bottom" constant="14" id="xlZ-UD-qns"/>
<constraint firstItem="S5h-Xx-HUG" firstAttribute="baseline" secondItem="XQ5-fw-o8t" secondAttribute="baseline" id="y3b-k3-eBU"/>
<constraint firstItem="wCp-nB-dda" firstAttribute="centerX" secondItem="6MD-Ry-R5P" secondAttribute="centerX" id="yNP-ab-DmI"/>
<constraint firstItem="wCp-nB-dda" firstAttribute="top" secondItem="se5-gp-TjO" secondAttribute="top" constant="20" symbolic="YES" id="1TH-Y5-EN7"/>
<constraint firstItem="Q2L-Fh-TW1" firstAttribute="leading" secondItem="xWv-tc-lQe" secondAttribute="trailing" constant="8" symbolic="YES" id="3JQ-t1-YfQ"/>
<constraint firstItem="FoE-i9-Rfb" firstAttribute="trailing" secondItem="sRP-xs-alR" secondAttribute="trailing" id="5DW-3A-T38"/>
<constraint firstAttribute="trailing" secondItem="DiD-K0-Y43" secondAttribute="trailing" constant="28" id="5Ss-aV-lwl"/>
<constraint firstAttribute="trailing" secondItem="wCp-nB-dda" secondAttribute="trailing" constant="25" id="8Sj-oS-ug5"/>
<constraint firstItem="ayu-Tb-kmf" firstAttribute="centerX" secondItem="6MD-Ry-R5P" secondAttribute="centerX" id="9JX-AU-p9u"/>
<constraint firstItem="sRP-xs-alR" firstAttribute="leading" secondItem="e3S-m6-k5Y" secondAttribute="trailing" constant="8" symbolic="YES" id="9Ln-JB-XKl"/>
<constraint firstItem="Q2L-Fh-TW1" firstAttribute="trailing" secondItem="eoD-7r-Q85" secondAttribute="trailing" id="Ddi-cI-3P7"/>
<constraint firstItem="Wsf-gl-dkY" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="92" id="Drm-DE-zR4"/>
<constraint firstItem="DiD-K0-Y43" firstAttribute="leading" secondItem="qVQ-tJ-cO6" secondAttribute="leading" id="FEU-T2-r8S"/>
<constraint firstItem="xWv-tc-lQe" firstAttribute="leading" secondItem="S5h-Xx-HUG" secondAttribute="leading" id="HDG-YV-pnR"/>
<constraint firstItem="I4a-N9-Tkv" firstAttribute="top" secondItem="ayu-Tb-kmf" secondAttribute="bottom" constant="8" symbolic="YES" id="IFN-Y7-dx7"/>
<constraint firstItem="FoE-i9-Rfb" firstAttribute="top" secondItem="XQ5-fw-o8t" secondAttribute="bottom" constant="10" symbolic="YES" id="Kmf-cm-gih"/>
<constraint firstAttribute="trailing" secondItem="ayu-Tb-kmf" secondAttribute="trailing" constant="34" id="LVk-Xo-yXp"/>
<constraint firstItem="sRP-xs-alR" firstAttribute="centerY" secondItem="eoD-7r-Q85" secondAttribute="centerY" id="Li6-iE-6AU"/>
<constraint firstItem="6MD-Ry-R5P" firstAttribute="top" secondItem="I4a-N9-Tkv" secondAttribute="bottom" constant="8" symbolic="YES" id="M7l-Nl-fbE"/>
<constraint firstItem="sRP-xs-alR" firstAttribute="top" secondItem="FoE-i9-Rfb" secondAttribute="bottom" constant="10" symbolic="YES" id="Nf3-lQ-J7p"/>
<constraint firstItem="FoE-i9-Rfb" firstAttribute="leading" secondItem="Wsf-gl-dkY" secondAttribute="trailing" constant="8" symbolic="YES" id="Q1J-Od-oEq"/>
<constraint firstItem="S5h-Xx-HUG" firstAttribute="leading" secondItem="e3S-m6-k5Y" secondAttribute="leading" id="Rp8-TE-LBs"/>
<constraint firstItem="wCp-nB-dda" firstAttribute="centerX" secondItem="JBW-8M-eHP" secondAttribute="centerX" id="Uf5-d8-VAG"/>
<constraint firstItem="ayu-Tb-kmf" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="41" id="Ujd-dM-d4B"/>
<constraint firstItem="qVQ-tJ-cO6" firstAttribute="top" secondItem="DiD-K0-Y43" secondAttribute="bottom" constant="6" symbolic="YES" id="WUJ-KS-sHp"/>
<constraint firstItem="xWv-tc-lQe" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="29" id="WsH-Rq-EQo"/>
<constraint firstItem="I4a-N9-Tkv" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="54" id="Y5c-vH-Bvw"/>
<constraint firstItem="XQ5-fw-o8t" firstAttribute="top" secondItem="Q2L-Fh-TW1" secondAttribute="bottom" constant="10" symbolic="YES" id="YJa-4z-USU"/>
<constraint firstItem="e3S-m6-k5Y" firstAttribute="baseline" secondItem="eoD-7r-Q85" secondAttribute="baseline" id="Yfx-Hf-red"/>
<constraint firstItem="XQ5-fw-o8t" firstAttribute="leading" secondItem="S5h-Xx-HUG" secondAttribute="trailing" constant="8" symbolic="YES" id="ZSX-Wf-s3b"/>
<constraint firstItem="sRP-xs-alR" firstAttribute="leading" secondItem="DiD-K0-Y43" secondAttribute="leading" id="cP0-4c-2tD"/>
<constraint firstItem="xWv-tc-lQe" firstAttribute="baseline" secondItem="Q2L-Fh-TW1" secondAttribute="baseline" id="cjH-5Y-BPd"/>
<constraint firstItem="I4a-N9-Tkv" firstAttribute="leading" secondItem="6MD-Ry-R5P" secondAttribute="leading" id="fGN-nB-Tp7"/>
<constraint firstItem="Q2L-Fh-TW1" firstAttribute="top" secondItem="JBW-8M-eHP" secondAttribute="bottom" constant="8" symbolic="YES" id="fIf-uU-Dis"/>
<constraint firstItem="Wsf-gl-dkY" firstAttribute="centerY" secondItem="FoE-i9-Rfb" secondAttribute="centerY" id="fSm-ZO-WGT"/>
<constraint firstItem="DiD-K0-Y43" firstAttribute="trailing" secondItem="qVQ-tJ-cO6" secondAttribute="trailing" id="i1K-yN-yvs"/>
<constraint firstItem="S5h-Xx-HUG" firstAttribute="centerY" secondItem="XQ5-fw-o8t" secondAttribute="centerY" id="iv1-8j-dpK"/>
<constraint firstItem="Q2L-Fh-TW1" firstAttribute="leading" secondItem="XQ5-fw-o8t" secondAttribute="leading" id="m95-qm-v0W"/>
<constraint firstItem="XQ5-fw-o8t" firstAttribute="leading" secondItem="FoE-i9-Rfb" secondAttribute="leading" id="q1D-Uw-c6k"/>
<constraint firstItem="JBW-8M-eHP" firstAttribute="top" secondItem="wCp-nB-dda" secondAttribute="bottom" constant="8" symbolic="YES" id="r2h-9S-EeW"/>
<constraint firstItem="JBW-8M-eHP" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="36" id="si5-nv-pTq"/>
<constraint firstItem="DiD-K0-Y43" firstAttribute="top" secondItem="sRP-xs-alR" secondAttribute="bottom" constant="8" symbolic="YES" id="vty-s2-Oei"/>
<constraint firstItem="FoE-i9-Rfb" firstAttribute="leading" secondItem="sRP-xs-alR" secondAttribute="leading" id="xbo-Fv-kdo"/>
<constraint firstItem="wCp-nB-dda" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="20" symbolic="YES" id="xxa-Zo-EGP"/>
<constraint firstItem="XQ5-fw-o8t" firstAttribute="trailing" secondItem="FoE-i9-Rfb" secondAttribute="trailing" id="yOU-d6-kg2"/>
<constraint firstAttribute="trailing" secondItem="Q2L-Fh-TW1" secondAttribute="trailing" constant="83" id="yly-wy-CHR"/>
<constraint firstItem="eoD-7r-Q85" firstAttribute="leading" secondItem="sRP-xs-alR" secondAttribute="trailing" constant="8" symbolic="YES" id="ywe-Ph-kz3"/>
<constraint firstItem="ayu-Tb-kmf" firstAttribute="top" secondItem="qVQ-tJ-cO6" secondAttribute="bottom" constant="8" symbolic="YES" id="zH1-MR-VHw"/>
</constraints>
</view>
<connections>
<outlet property="delegate" destination="-2" id="0bl-1N-AYu"/>
</connections>
<point key="canvasLocation" x="346" y="328"/>
<point key="canvasLocation" x="346" y="292.5"/>
</window>
<numberFormatter formatterBehavior="default10_4" usesGroupingSeparator="NO" groupingSize="0" minimumIntegerDigits="0" maximumIntegerDigits="42" id="uE9-0u-CJW" userLabel="Port Number Formatter">
<real key="minimum" value="128"/>

View File

@ -58,7 +58,7 @@ Gw
<rect key="frame" x="1" y="1" width="423" height="187"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView ambiguous="YES" importsGraphics="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">
<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="423" height="187"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>

View File

@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.3</string>
<string>1.3.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>

View File

@ -14,14 +14,12 @@
+ (void)install;
+ (void)enablePACProxy:(NSString*) PACFilePath;
+ (void)enablePACProxy;
+ (void)enableGlobalProxy;
+ (void)disableProxy:(NSString*) PACFilePath;
+ (void)disableProxy;
+ (NSString*)startPACServer:(NSString*) PACFilePath;
+ (void)stopPACServer;
+ (void)startMonitorPAC;
@end

View File

@ -14,6 +14,7 @@
@implementation ProxyConfHelper
GCDWebServer *webServer =nil;
FSEventStreamRef fsEventStream;
+ (BOOL)isVersionOk {
NSTask *task;
@ -114,14 +115,18 @@ GCDWebServer *webServer =nil;
}
}
+ (void)enablePACProxy:(NSString*) PACFilePath {
+ (NSString*)getPACFilePath {
return [NSString stringWithFormat:@"%@/%@", NSHomeDirectory(), @".ShadowsocksX-NG/gfwlist.js"];
}
+ (void)enablePACProxy {
//start server here and then using the string next line
//next two lines can open gcdwebserver and work around pac file
NSString *PACURLString = [self startPACServer: PACFilePath];//hi pac使
NSURL* url = [NSURL URLWithString: PACURLString];
// NSString* urlString = [NSString stringWithFormat:@"%@/.ShadowsocksX-NG/gfwlist.js", NSHomeDirectory()];
// NSURL* url = [NSURL fileURLWithPath:urlString];
NSString* PACFilePath = [self getPACFilePath];
[self startPACServer: PACFilePath];
NSURL* url = [NSURL URLWithString: [self getHttpPACUrl]];
NSMutableArray* args = [@[@"--mode", @"auto", @"--pac-url", [url absoluteString]]mutableCopy];
[self addArguments4ManualSpecifyNetworkServices:args];
@ -146,12 +151,9 @@ GCDWebServer *webServer =nil;
[self stopPACServer];
}
+ (void)disableProxy:(NSString*) PACFilePath {
// ssx-ng
// NSString* urlString = [NSString stringWithFormat:@"%@/.ShadowsocksX-NG/gfwlist.js", NSHomeDirectory()];
// NSURL* url = [NSURL fileURLWithPath:urlString];
NSString *PACURLString = [self startPACServer: PACFilePath];//hi pac使
NSURL* url = [NSURL URLWithString: PACURLString];
+ (void)disableProxy {
// ssx-ng
NSURL* url = [NSURL URLWithString: [self getHttpPACUrl]];
NSUInteger port = [[NSUserDefaults standardUserDefaults]integerForKey:@"LocalSocks5.ListenPort"];
NSMutableArray* args = [@[@"--mode", @"off"
@ -163,28 +165,41 @@ GCDWebServer *webServer =nil;
[self stopPACServer];
}
+ (NSString*)startPACServer:(NSString*) PACFilePath {
//使PAC
NSData * originalPACData;
+ (NSString*)getHttpPACUrl {
NSString * routerPath = @"/proxy.pac";
if ([PACFilePath isEqual: @"hi"]) {//
PACFilePath = [NSString stringWithFormat:@"%@/%@", NSHomeDirectory(), @".ShadowsocksX-NG/gfwlist.js"];
originalPACData = [NSData dataWithContentsOfFile: [NSString stringWithFormat:@"%@/%@", NSHomeDirectory(), @".ShadowsocksX-NG/gfwlist.js"]];
}else{//
originalPACData = [NSData dataWithContentsOfFile: [NSString stringWithFormat:@"%@/%@/%@", NSHomeDirectory(), @".ShadowsocksX-NG", PACFilePath]];
routerPath = [NSString stringWithFormat:@"/%@",PACFilePath];
}
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString * address = @"127.0.0.1";
int port = (short)[defaults integerForKey:@"PacServer.ListenPort"];
return [NSString stringWithFormat:@"%@%@:%d%@",@"http://",address,port,routerPath];
}
+ (void)startPACServer:(NSString*) PACFilePath {
[self stopPACServer];
NSString * routerPath = @"/proxy.pac";
NSData* originalPACData = [NSData dataWithContentsOfFile:PACFilePath];
webServer = [[GCDWebServer alloc] init];
[webServer addHandlerForMethod:@"GET" path:routerPath requestClass:[GCDWebServerRequest class] processBlock:^GCDWebServerResponse *(GCDWebServerRequest *request) {
return [GCDWebServerDataResponse responseWithData: originalPACData contentType:@"application/x-ns-proxy-autoconfig"];
[webServer addHandlerForMethod:@"GET"
path:routerPath
requestClass:[GCDWebServerRequest class]
processBlock:^GCDWebServerResponse *(GCDWebServerRequest *request)
{
GCDWebServerDataResponse* resp = [GCDWebServerDataResponse responseWithData:originalPACData
contentType:@"application/x-ns-proxy-autoconfig"];
return resp;
}
];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString * address = [defaults stringForKey:@"PacServer.ListenAddress"];
int port = (short)[defaults integerForKey:@"PacServer.ListenPort"];
[webServer startWithOptions:@{@"BindToLocalhost":@YES, @"Port":@(port)} error:nil];
return [NSString stringWithFormat:@"%@%@:%d%@",@"http://",address,port,routerPath];
}
+ (void)stopPACServer {
@ -194,4 +209,45 @@ GCDWebServer *webServer =nil;
}
}
void onPACChange(
ConstFSEventStreamRef streamRef,
void *clientCallBackInfo,
size_t numEvents,
void *eventPaths,
const FSEventStreamEventFlags eventFlags[],
const FSEventStreamEventId eventIds[])
{
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
if ([defaults boolForKey:@"ShadowsocksOn"]) {
if ([[defaults stringForKey:@"ShadowsocksRunningMode"] isEqualToString:@"auto"]) {
[ProxyConfHelper disableProxy];
[ProxyConfHelper enablePACProxy];
}
}
}
+ (void)startMonitorPAC {
NSString* PACFilePath = [self getPACFilePath];
if (fsEventStream) {
return;
}
CFStringRef mypath = (__bridge CFStringRef)(PACFilePath);
CFArrayRef pathsToWatch = CFArrayCreate(NULL, (const void **)&mypath, 1, NULL);
void *callbackInfo = NULL; // could put stream-specific data here.
CFAbsoluteTime latency = 3.0; /* Latency in seconds */
/* Create the stream, passing in a callback */
fsEventStream = FSEventStreamCreate(NULL,
&onPACChange,
callbackInfo,
pathsToWatch,
kFSEventStreamEventIdSinceNow, /* Or a previous event ID */
latency,
kFSEventStreamCreateFlagNone /* Flags explained in reference */
);
FSEventStreamScheduleWithRunLoop(fsEventStream, [[NSRunLoop mainRunLoop] getCFRunLoop], (__bridge CFStringRef)NSDefaultRunLoopMode);
FSEventStreamStart(fsEventStream);
}
@end

View File

@ -37,7 +37,7 @@ class ProxyPreferencesController: NSWindowController, NSTableViewDataSource, NST
}
@IBAction func ok(_ sender: NSObject){
ProxyConfHelper.disableProxy("hi")
ProxyConfHelper.disableProxy()
let defaults = UserDefaults.standard
defaults.setValue(selectedNetworkServices.allObjects, forKeyPath: "Proxy4NetworkServices")