Skip to content

Commit

Permalink
Merge pull request shadowsocks#1243 from RonnieRen/bug/813
Browse files Browse the repository at this point in the history
override the gwf rules with user rules
  • Loading branch information
qiuyuzhou authored Feb 25, 2020
2 parents fc538fe + c199373 commit dd6149e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion ShadowsocksX-NG/PACUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,21 @@ func GeneratePACFile() -> Bool {
let userRuleStr = try String(contentsOfFile: PACUserRuleFilePath, encoding: String.Encoding.utf8)
let userRuleLines = userRuleStr.components(separatedBy: CharacterSet.newlines)

lines = userRuleLines + lines
lines = userRuleLines + lines.filter { (line) in
// ignore the rule from gwf if user provide same rule for the same url
var i = line.startIndex
while i < line.endIndex {
if line[i] == "@" || line[i] == "|" {
i = line.index(after: i)
continue
}
break
}
if i == line.startIndex {
return !userRuleLines.contains(line)
}
return !userRuleLines.contains(String(line[i...]))
}
} catch {
NSLog("Not found user-rule.txt")
}
Expand Down

0 comments on commit dd6149e

Please sign in to comment.