This commit is contained in:
Max Lv
2017-12-10 22:51:18 +08:00
parent 7688cbe23e
commit aa53318408
3 changed files with 19 additions and 1 deletions
@@ -238,6 +238,22 @@ object BaseService {
Acl.getFile(if (route == Acl.CUSTOM_RULES) Acl.CUSTOM_RULES_FLATTENED else route)
}
fun getListFile(): File? {
val aclFile = getAclFile() ?: return null
val listFile = File(aclFile.absolutePath + ".lst")
val list = StringBuilder()
aclFile.bufferedReader().useLines {
for (line in it) {
if (line.startsWith("^(.*\\.)?")) {
list.append(line.substring(8).replace("\\","").replace("$",""))
list.append("\n")
}
}
}
listFile.bufferedWriter().use { it.write(list.toString()) }
return listFile
}
fun createNotification(): ServiceNotification
fun startRunner() {
@@ -89,7 +89,7 @@ object LocalDnsService {
.put("PrimaryDNS", localDns)
.put("AlternativeDNS", remoteDns)
.put("IPNetworkFile", "china_ip_list.txt")
.put("DomainFile", getAclFile()!!.absolutePath)
.put("DomainFile", getListFile()!!.absolutePath)
Acl.CHINALIST -> config
.put("PrimaryDNS", localDns)
.put("AlternativeDNS", remoteDns)