Fix bug in acl auto mode and whit list mode

This commit is contained in:
秦宇航
2017-05-07 22:06:47 +08:00
parent e19d516320
commit 53c4b846df
+6 -4
View File
@@ -19,6 +19,8 @@ let GFWListFilePath = PACRulesDirPath + "gfwlist.txt"
let ACLWhiteListFilePath = PACRulesDirPath + "chn.acl"
let ACLBackCHNFilePath = PACRulesDirPath + "backchn.acl"
let ACLGFWListFilePath = PACRulesDirPath + "gfwlist.acl"
let WhiteListDomainPACFilePath = PACRulesDirPath + "whitelist.pac"
let WhiteListIPPACFilePath = PACRulesDirPath + "whiteiplist.pac"
// Because of LocalSocks5.ListenPort may be changed
func SyncPac() {
@@ -164,9 +166,9 @@ func GeneratePACFile() -> Bool {
}
try
DomainPACStr.data(using: String.Encoding.utf8)?.write(to: URL(fileURLWithPath: ACLWhiteListFilePath), options: .atomic)
DomainPACStr.data(using: String.Encoding.utf8)?.write(to: URL(fileURLWithPath: WhiteListDomainPACFilePath), options: .atomic)
try
IPPACStr.data(using: String.Encoding.utf8)?.write(to: URL(fileURLWithPath: ACLBackCHNFilePath), options: .atomic)
IPPACStr.data(using: String.Encoding.utf8)?.write(to: URL(fileURLWithPath: WhiteListIPPACFilePath), options: .atomic)
return true
} catch {
@@ -235,7 +237,7 @@ func UpdatePACFromWhiteList(){
if response.result.isSuccess {
if let v = response.result.value {
do {
try v.write(toFile: ACLWhiteListFilePath, atomically: true, encoding: String.Encoding.utf8)
try v.write(toFile: WhiteListDomainPACFilePath, atomically: true, encoding: String.Encoding.utf8)
if GeneratePACFile() {
// Popup a user notification
let notification = NSUserNotification()
@@ -263,7 +265,7 @@ func UpdatePACFromWhiteList(){
if response.result.isSuccess {
if let v = response.result.value {
do {
try v.write(toFile:ACLBackCHNFilePath, atomically: true, encoding: String.Encoding.utf8)
try v.write(toFile: WhiteListIPPACFilePath, atomically: true, encoding: String.Encoding.utf8)
if GeneratePACFile() {
// Popup a user notification
let notification = NSUserNotification()