mirror of
https://github.com/MatsuriDayo/NekoBoxForAndroid.git
synced 2025-12-19 14:40:06 +08:00
fix dns routing
This commit is contained in:
parent
faf964e992
commit
03c99d7482
@ -139,6 +139,7 @@ fun buildConfig(
|
||||
val uidListDNSDirect = mutableListOf<Int>()
|
||||
val domainListDNSRemote = mutableListOf<String>()
|
||||
val domainListDNSDirect = mutableListOf<String>()
|
||||
val domainListDNSDirectForce = mutableListOf<String>()
|
||||
val domainListDNSBlock = mutableListOf<String>()
|
||||
val bypassDNSBeans = hashSetOf<AbstractBean>()
|
||||
val isVPN = DataStore.serviceMode == Key.MODE_VPN
|
||||
@ -404,7 +405,7 @@ fun buildConfig(
|
||||
pastEntity?.requireBean()?.apply {
|
||||
// don't loopback
|
||||
if (currentDomainStrategy != "" && !serverAddress.isIpAddress()) {
|
||||
domainListDNSDirect.add("full:$serverAddress")
|
||||
domainListDNSDirectForce.add("full:$serverAddress")
|
||||
}
|
||||
}
|
||||
if (forTest) {
|
||||
@ -628,7 +629,7 @@ fun buildConfig(
|
||||
}
|
||||
|
||||
if (!serverAddr.isIpAddress()) {
|
||||
domainListDNSDirect.add("full:${serverAddr}")
|
||||
domainListDNSDirectForce.add("full:${serverAddr}")
|
||||
}
|
||||
}
|
||||
|
||||
@ -639,7 +640,7 @@ fun buildConfig(
|
||||
}
|
||||
"https://$address".toHttpUrlOrNull()?.apply {
|
||||
if (!host.isIpAddress()) {
|
||||
domainListDNSDirect.add("full:$host")
|
||||
domainListDNSDirectForce.add("full:$host")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -675,6 +676,14 @@ fun buildConfig(
|
||||
address = "rcode://success"
|
||||
tag = "dns-block"
|
||||
})
|
||||
if (domainListDNSDirectForce.isNotEmpty()) {
|
||||
dns.rules.add(
|
||||
DNSRule_DefaultOptions().apply {
|
||||
makeSingBoxRule(domainListDNSDirectForce.toHashSet().toList())
|
||||
server = "dns-direct"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// dns object user rules
|
||||
if (enableDnsRouting) {
|
||||
@ -696,7 +705,6 @@ fun buildConfig(
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
if (domainListDNSBlock.isNotEmpty()) {
|
||||
dns.rules.add(
|
||||
DNSRule_DefaultOptions().apply {
|
||||
@ -706,6 +714,7 @@ fun buildConfig(
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Disable DNS for test
|
||||
if (forTest) {
|
||||
|
||||
@ -34,6 +34,11 @@ object DNS {
|
||||
domain.plusAssign(it)
|
||||
}
|
||||
}
|
||||
if (geosite?.isEmpty() == true) geosite = null
|
||||
if (domain?.isEmpty() == true) domain = null
|
||||
if (domain_suffix?.isEmpty() == true) domain_suffix = null
|
||||
if (domain_regex?.isEmpty() == true) domain_regex = null
|
||||
if (domain_keyword?.isEmpty() == true) domain_keyword = null
|
||||
}
|
||||
|
||||
fun SingBoxOptions.Rule_DefaultOptions.makeSingBoxRule(list: List<String>, isIP: Boolean) {
|
||||
@ -70,5 +75,12 @@ object DNS {
|
||||
domain.plusAssign(it)
|
||||
}
|
||||
}
|
||||
if (ip_cidr?.isEmpty() == true) geosite = null
|
||||
if (geoip?.isEmpty() == true) geosite = null
|
||||
if (geosite?.isEmpty() == true) geosite = null
|
||||
if (domain?.isEmpty() == true) domain = null
|
||||
if (domain_suffix?.isEmpty() == true) domain_suffix = null
|
||||
if (domain_regex?.isEmpty() == true) domain_regex = null
|
||||
if (domain_keyword?.isEmpty() == true) domain_keyword = null
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user