Commit 06837793 authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Use target "1" as shortcut for "127.0.0.1" (less bytes)

parent 9e0e0917
......@@ -945,9 +945,14 @@ class DnsVpnService : VpnService(), Runnable {
false
} else {
val uniformQuestion = question.name.toString().replace(wwwRegex, "")
var resolveResult = dao.findRuleTarget(uniformQuestion, question.type, useUserRules)
val resolveResult = dao.findRuleTarget(uniformQuestion, question.type, useUserRules)?.let {
when (it) {
"0" -> "0.0.0.0"
"1" -> "127.0.0.1"
else -> it
}
}
if (resolveResult != null) {
if(resolveResult == "0") resolveResult = "0.0.0.0"
resolveResults[question] = resolveResult
true
} else false
......
......@@ -277,16 +277,22 @@ class RuleImportService : Service() {
matcher == DNSMASQ_MATCHER -> {
val host = matcher.group(1).replace(wwwRegex, "")
val target = matcher.group(2).let {
if(it == "0.0.0.0") "0"
else it
when (it) {
"0.0.0.0" -> "0"
"127.0.0.1" -> "1"
else -> it
}
}
return DnsRule(if (target.contains(":")) Record.TYPE.AAAA else Record.TYPE.A, host, target, importedFrom = sourceId)
}
matcher == HOSTS_MATCHER -> {
val target = matcher.group(1)
val host = matcher.group(2).replace(wwwRegex, "").let {
if(it == "0.0.0.0") "0"
else it
when (it) {
"0.0.0.0" -> "0"
"127.0.0.1" -> "1"
else -> it
}
}
return DnsRule(if (target.contains(":")) Record.TYPE.AAAA else Record.TYPE.A, host, target, importedFrom = sourceId)
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment