mirror of
https://github.com/qinyuhang/ShadowsocksX-NG-R.git
synced 2026-10-28 03:34:02 +00:00
FIX ACL Path bug
This commit is contained in:
@@ -88,7 +88,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
||||
"LocalHTTPOn": true,
|
||||
"LocalHTTP.FollowGlobal": true,
|
||||
"AutoCheckUpdate": false,
|
||||
"ACLPath": "chn.acl"
|
||||
"ACLFileName": "chn.acl"
|
||||
])
|
||||
|
||||
setUpMenu(defaults.bool(forKey: "enable_showSpeed"))
|
||||
@@ -238,7 +238,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
||||
ProxyConfHelper.disableProxy("hi")
|
||||
} else if mode == "whiteList" {
|
||||
ProxyConfHelper.disableProxy("hi")
|
||||
ProxyConfHelper.enableGlobalProxy()//新白名单基于GlobalMode
|
||||
ProxyConfHelper.enableWhiteListProxy()//新白名单基于GlobalMode
|
||||
}
|
||||
} else {
|
||||
StopSSLocal()
|
||||
@@ -367,21 +367,21 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
||||
@IBAction func selectACLAutoMode(_ sender: NSMenuItem) {
|
||||
let defaults = UserDefaults.standard
|
||||
defaults.setValue("whiteList", forKey: "ShadowsocksRunningMode")
|
||||
defaults.setValue("gfw.acl", forKey: "ACLPath")
|
||||
defaults.setValue("gfw.acl", forKey: "ACLFileName")
|
||||
updateRunningModeMenu()
|
||||
applyConfig()
|
||||
}
|
||||
@IBAction func selectACLBackCHNMode(_ sender: NSMenuItem) {
|
||||
let defaults = UserDefaults.standard
|
||||
defaults.setValue("whiteList", forKey: "ShadowsocksRunningMode")
|
||||
defaults.setValue("backchn.acl", forKey: "ACLPath")
|
||||
defaults.setValue("backchn.acl", forKey: "ACLFileName")
|
||||
updateRunningModeMenu()
|
||||
applyConfig()
|
||||
}
|
||||
@IBAction func selectWhiteListMode(_ sender: NSMenuItem) {
|
||||
let defaults = UserDefaults.standard
|
||||
defaults.setValue("whiteList", forKey: "ShadowsocksRunningMode")
|
||||
defaults.setValue("chn.acl", forKey: "ACLPath")
|
||||
defaults.setValue("chn.acl", forKey: "ACLFileName")
|
||||
updateRunningModeMenu()
|
||||
applyConfig()
|
||||
}
|
||||
@@ -526,15 +526,17 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
|
||||
whiteListModeMenuItem.state = 0
|
||||
ACLBackChinaMenuItem.state = 0
|
||||
ACLAutoModeMenuItem.state = 0
|
||||
let aclMode = defaults.value(forKey: "ACLPath") as! String
|
||||
let aclMode = defaults.string(forKey: "ACLFileName")!
|
||||
switch aclMode {
|
||||
case "backchn.acl":
|
||||
ACLModeMenuItem.state = 1
|
||||
ACLBackChinaMenuItem.state = 1
|
||||
ACLModeMenuItem.title = "Proxy Back China".localized
|
||||
break
|
||||
case "gfw.acl":
|
||||
ACLModeMenuItem.state = 1
|
||||
ACLAutoModeMenuItem.state = 1
|
||||
ACLModeMenuItem.title = "ACL Auto".localized
|
||||
break
|
||||
default:
|
||||
whiteListModeMenuItem.state = 1
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="ACL Mode" id="tEB-59-fCx">
|
||||
<items>
|
||||
<menuItem title="Auto" id="sDG-YV-yuQ">
|
||||
<menuItem title="ACL Auto" id="sDG-YV-yuQ">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="selectACLAutoMode:" target="Voe-Tx-rLC" id="0PY-wQ-9KI"/>
|
||||
|
||||
@@ -33,7 +33,8 @@ func generateSSLocalLauchAgentPlist() -> Bool {
|
||||
let logFilePath = NSHomeDirectory() + "/Library/Logs/ss-local.log"
|
||||
let launchAgentDirPath = NSHomeDirectory() + LAUNCH_AGENT_DIR
|
||||
let plistFilepath = launchAgentDirPath + LAUNCH_AGENT_CONF_SSLOCAL_NAME
|
||||
var ACLPath = ""
|
||||
var ACLFileName = ""
|
||||
|
||||
// Ensure launch agent directory is existed.
|
||||
let fileMgr = FileManager.default
|
||||
if !fileMgr.fileExists(atPath: launchAgentDirPath) {
|
||||
@@ -45,7 +46,7 @@ func generateSSLocalLauchAgentPlist() -> Bool {
|
||||
let defaults = UserDefaults.standard
|
||||
let enableUdpRelay = defaults.bool(forKey: "LocalSocks5.EnableUDPRelay")
|
||||
let enableVerboseMode = defaults.bool(forKey: "LocalSocks5.EnableVerboseMode")
|
||||
let enabelWhiteListMode = defaults.value(forKey: "ShadowsocksRunningMode") as! String
|
||||
let enabelWhiteListMode = defaults.string(forKey: "ShadowsocksRunningMode")
|
||||
|
||||
var arguments = [sslocalPath, "-c", "ss-local-config.json"]
|
||||
if enableUdpRelay {
|
||||
@@ -54,8 +55,9 @@ func generateSSLocalLauchAgentPlist() -> Bool {
|
||||
if enableVerboseMode {
|
||||
arguments.append("-v")
|
||||
}
|
||||
if String(describing: enabelWhiteListMode) == "whiteList" {
|
||||
ACLPath = defaults.value(forKey: "ACLPath") as! String
|
||||
if enabelWhiteListMode == "whiteList" {
|
||||
ACLFileName = defaults.string(forKey: "ACLFileName")!
|
||||
let ACLPath = NSHomeDirectory() + "/.ShadowsocksX-NG/" + ACLFileName
|
||||
arguments.append("--acl")
|
||||
arguments.append(ACLPath)
|
||||
}
|
||||
|
||||
@@ -15,9 +15,10 @@ let PACRulesDirPath = NSHomeDirectory() + "/.ShadowsocksX-NG/"
|
||||
let PACUserRuleFilePath = PACRulesDirPath + "user-rule.txt"
|
||||
let PACFilePath = PACRulesDirPath + "gfwlist.js"
|
||||
let GFWListFilePath = PACRulesDirPath + "gfwlist.txt"
|
||||
let WhiteListDomainPACFilePath = PACRulesDirPath + "whitelist.pac"
|
||||
let WhiteListIPPACFilePath = PACRulesDirPath + "whiteiplist.pac"
|
||||
|
||||
let ACLWhiteListFilePath = PACRulesDirPath + "chn.acl"
|
||||
let ACLBackCHNFilePath = PACRulesDirPath + "backchn.acl"
|
||||
let ACLGFWListFilePath = PACRulesDirPath + "gfwlist.acl"
|
||||
|
||||
// Because of LocalSocks5.ListenPort may be changed
|
||||
func SyncPac() {
|
||||
@@ -35,7 +36,7 @@ func SyncPac() {
|
||||
needGenerate = true
|
||||
}
|
||||
|
||||
if !fileMgr.fileExists(atPath: WhiteListDomainPACFilePath) && !fileMgr.fileExists(atPath: WhiteListIPPACFilePath) {
|
||||
if !fileMgr.fileExists(atPath: ACLWhiteListFilePath) && !fileMgr.fileExists(atPath: ACLBackCHNFilePath) {
|
||||
needGenerate = true
|
||||
}
|
||||
|
||||
@@ -71,17 +72,23 @@ func GeneratePACFile() -> Bool {
|
||||
try! fileMgr.copyItem(atPath: src!, toPath: PACUserRuleFilePath)
|
||||
}
|
||||
|
||||
// If whitelist.pac is not exsited, copy from bundle
|
||||
if !fileMgr.fileExists(atPath: WhiteListDomainPACFilePath) {
|
||||
let src = Bundle.main.path(forResource: "whitelist", ofType: "pac")
|
||||
try! fileMgr.copyItem(atPath: src!, toPath: WhiteListDomainPACFilePath)
|
||||
// If chn.acl is not exsited, copy from bundle
|
||||
if !fileMgr.fileExists(atPath: ACLWhiteListFilePath) {
|
||||
let src = Bundle.main.path(forResource: "chn", ofType: "acl")
|
||||
try! fileMgr.copyItem(atPath: src!, toPath: ACLWhiteListFilePath)
|
||||
}
|
||||
|
||||
// If whitelistip.pac is not exsited, copy from bundle
|
||||
if !fileMgr.fileExists(atPath: WhiteListIPPACFilePath) {
|
||||
let src = Bundle.main.path(forResource: "whiteiplist", ofType: "pac")
|
||||
try! fileMgr.copyItem(atPath: src!, toPath: WhiteListIPPACFilePath)
|
||||
// If backchn is not exsited, copy from bundle
|
||||
if !fileMgr.fileExists(atPath: ACLBackCHNFilePath) {
|
||||
let src = Bundle.main.path(forResource: "backchn", ofType: "acl")
|
||||
try! fileMgr.copyItem(atPath: src!, toPath: ACLBackCHNFilePath)
|
||||
|
||||
}
|
||||
// If chn.acl
|
||||
if !fileMgr.fileExists(atPath: ACLGFWListFilePath) {
|
||||
let src = Bundle.main.path(forResource: "gfwlist", ofType: "acl")
|
||||
try! fileMgr.copyItem(atPath: src!, toPath: ACLGFWListFilePath)
|
||||
|
||||
}
|
||||
|
||||
let socks5Port = UserDefaults.standard.integer(forKey: "LocalSocks5.ListenPort")
|
||||
@@ -157,9 +164,9 @@ func GeneratePACFile() -> Bool {
|
||||
}
|
||||
|
||||
try
|
||||
DomainPACStr.data(using: String.Encoding.utf8)?.write(to: URL(fileURLWithPath: WhiteListDomainPACFilePath), options: .atomic)
|
||||
DomainPACStr.data(using: String.Encoding.utf8)?.write(to: URL(fileURLWithPath: ACLWhiteListFilePath), options: .atomic)
|
||||
try
|
||||
IPPACStr.data(using: String.Encoding.utf8)?.write(to: URL(fileURLWithPath: WhiteListIPPACFilePath), options: .atomic)
|
||||
IPPACStr.data(using: String.Encoding.utf8)?.write(to: URL(fileURLWithPath: ACLBackCHNFilePath), options: .atomic)
|
||||
|
||||
return true
|
||||
} catch {
|
||||
@@ -228,7 +235,7 @@ func UpdatePACFromWhiteList(){
|
||||
if response.result.isSuccess {
|
||||
if let v = response.result.value {
|
||||
do {
|
||||
try v.write(toFile: WhiteListDomainPACFilePath, atomically: true, encoding: String.Encoding.utf8)
|
||||
try v.write(toFile: ACLWhiteListFilePath, atomically: true, encoding: String.Encoding.utf8)
|
||||
if GeneratePACFile() {
|
||||
// Popup a user notification
|
||||
let notification = NSUserNotification()
|
||||
@@ -256,7 +263,7 @@ func UpdatePACFromWhiteList(){
|
||||
if response.result.isSuccess {
|
||||
if let v = response.result.value {
|
||||
do {
|
||||
try v.write(toFile:WhiteListIPPACFilePath, atomically: true, encoding: String.Encoding.utf8)
|
||||
try v.write(toFile:ACLBackCHNFilePath, atomically: true, encoding: String.Encoding.utf8)
|
||||
if GeneratePACFile() {
|
||||
// Popup a user notification
|
||||
let notification = NSUserNotification()
|
||||
|
||||
@@ -68,6 +68,19 @@
|
||||
|
||||
"Turn Shadowsocks On" = "打开 Shadowsocks";
|
||||
|
||||
|
||||
"Check Updates" = "检查更新";
|
||||
|
||||
"Check Updates At Launch" = "打开时检查更新";
|
||||
|
||||
"Proxy Back China" = "代理大陆IP";
|
||||
|
||||
"ACL Mode" = "ACL模式";
|
||||
|
||||
"ACL Mode" = "ACL模式";
|
||||
|
||||
"ACL Auto" = "ACL自动";
|
||||
|
||||
/*
|
||||
* ./ShadowsocksX-NG/PreferencesWindowController.swift
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user