Fix wrong spell in path.
This commit is contained in:
@ -9,9 +9,9 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
let SS_LOCAL_VERSION = "2.4.6"
|
let SS_LOCAL_VERSION = "2.4.6"
|
||||||
let APP_SUPPORT_DIR = "/Library/Application Support/ShadowsocksX-NE/"
|
let APP_SUPPORT_DIR = "/Library/Application Support/ShadowsocksX-NG/"
|
||||||
let LAUNCH_AGENT_DIR = "/Library/LaunchAgents/"
|
let LAUNCH_AGENT_DIR = "/Library/LaunchAgents/"
|
||||||
let LAUNCH_AGENT_CONF_NAME = "com.qiuyuzhou.shadowsocksX-NE.local.plist"
|
let LAUNCH_AGENT_CONF_NAME = "com.qiuyuzhou.shadowsocksX-NG.local.plist"
|
||||||
|
|
||||||
|
|
||||||
func getFileSHA1Sum(filepath: String) -> String {
|
func getFileSHA1Sum(filepath: String) -> String {
|
||||||
|
@ -9,7 +9,9 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import Alamofire
|
import Alamofire
|
||||||
|
|
||||||
let PACRulesDirPath = NSHomeDirectory() + "/.ShadowsocksX-NE/"
|
let OldErrorPACRulesDirPath = NSHomeDirectory() + "/.ShadowsocksX-NE/"
|
||||||
|
|
||||||
|
let PACRulesDirPath = NSHomeDirectory() + "/.ShadowsocksX-NG/"
|
||||||
let PACUserRuleFilePath = PACRulesDirPath + "user-rule.txt"
|
let PACUserRuleFilePath = PACRulesDirPath + "user-rule.txt"
|
||||||
let PACFilePath = PACRulesDirPath + "gfwlist.js"
|
let PACFilePath = PACRulesDirPath + "gfwlist.js"
|
||||||
let GFWListFilePath = PACRulesDirPath + "gfwlist.txt"
|
let GFWListFilePath = PACRulesDirPath + "gfwlist.txt"
|
||||||
@ -17,12 +19,23 @@ let GFWListFilePath = PACRulesDirPath + "gfwlist.txt"
|
|||||||
|
|
||||||
// Because of LocalSocks5.ListenPort may be changed
|
// Because of LocalSocks5.ListenPort may be changed
|
||||||
func SyncPac() {
|
func SyncPac() {
|
||||||
|
var needGenerate = false
|
||||||
|
|
||||||
let nowSocks5Port = NSUserDefaults.standardUserDefaults().integerForKey("LocalSocks5.ListenPort")
|
let nowSocks5Port = NSUserDefaults.standardUserDefaults().integerForKey("LocalSocks5.ListenPort")
|
||||||
let oldSocks5Port = NSUserDefaults.standardUserDefaults().integerForKey("LocalSocks5.ListenPort.Old")
|
let oldSocks5Port = NSUserDefaults.standardUserDefaults().integerForKey("LocalSocks5.ListenPort.Old")
|
||||||
if nowSocks5Port != oldSocks5Port {
|
if nowSocks5Port != oldSocks5Port {
|
||||||
GeneratePACFile()
|
needGenerate = true
|
||||||
NSUserDefaults.standardUserDefaults().setInteger(nowSocks5Port, forKey: "LocalSocks5.ListenPort.Old")
|
NSUserDefaults.standardUserDefaults().setInteger(nowSocks5Port, forKey: "LocalSocks5.ListenPort.Old")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let fileMgr = NSFileManager.defaultManager()
|
||||||
|
if !fileMgr.fileExistsAtPath(PACRulesDirPath) {
|
||||||
|
needGenerate = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if needGenerate {
|
||||||
|
GeneratePACFile()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -30,9 +43,13 @@ func GeneratePACFile() -> Bool {
|
|||||||
let fileMgr = NSFileManager.defaultManager()
|
let fileMgr = NSFileManager.defaultManager()
|
||||||
// Maker the dir if rulesDirPath is not exesited.
|
// Maker the dir if rulesDirPath is not exesited.
|
||||||
if !fileMgr.fileExistsAtPath(PACRulesDirPath) {
|
if !fileMgr.fileExistsAtPath(PACRulesDirPath) {
|
||||||
|
if fileMgr.fileExistsAtPath(OldErrorPACRulesDirPath) {
|
||||||
|
try! fileMgr.moveItemAtPath(OldErrorPACRulesDirPath, toPath: PACRulesDirPath)
|
||||||
|
} else {
|
||||||
try! fileMgr.createDirectoryAtPath(PACRulesDirPath
|
try! fileMgr.createDirectoryAtPath(PACRulesDirPath
|
||||||
, withIntermediateDirectories: true, attributes: nil)
|
, withIntermediateDirectories: true, attributes: nil)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If gfwlist.txt is not exsited, copy from bundle
|
// If gfwlist.txt is not exsited, copy from bundle
|
||||||
if !fileMgr.fileExistsAtPath(GFWListFilePath) {
|
if !fileMgr.fileExistsAtPath(GFWListFilePath) {
|
||||||
@ -40,7 +57,7 @@ func GeneratePACFile() -> Bool {
|
|||||||
try! fileMgr.copyItemAtPath(src!, toPath: GFWListFilePath)
|
try! fileMgr.copyItemAtPath(src!, toPath: GFWListFilePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If gfwlist.txt is not exsited, copy from bundle
|
// If user-rule.txt is not exsited, copy from bundle
|
||||||
if !fileMgr.fileExistsAtPath(PACUserRuleFilePath) {
|
if !fileMgr.fileExistsAtPath(PACUserRuleFilePath) {
|
||||||
let src = NSBundle.mainBundle().pathForResource("user-rule", ofType: "txt")
|
let src = NSBundle.mainBundle().pathForResource("user-rule", ofType: "txt")
|
||||||
try! fileMgr.copyItemAtPath(src!, toPath: PACUserRuleFilePath)
|
try! fileMgr.copyItemAtPath(src!, toPath: PACUserRuleFilePath)
|
||||||
|
Reference in New Issue
Block a user