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 uidListDNSDirect = mutableListOf<Int>()
|
||||||
val domainListDNSRemote = mutableListOf<String>()
|
val domainListDNSRemote = mutableListOf<String>()
|
||||||
val domainListDNSDirect = mutableListOf<String>()
|
val domainListDNSDirect = mutableListOf<String>()
|
||||||
|
val domainListDNSDirectForce = mutableListOf<String>()
|
||||||
val domainListDNSBlock = mutableListOf<String>()
|
val domainListDNSBlock = mutableListOf<String>()
|
||||||
val bypassDNSBeans = hashSetOf<AbstractBean>()
|
val bypassDNSBeans = hashSetOf<AbstractBean>()
|
||||||
val isVPN = DataStore.serviceMode == Key.MODE_VPN
|
val isVPN = DataStore.serviceMode == Key.MODE_VPN
|
||||||
@ -404,7 +405,7 @@ fun buildConfig(
|
|||||||
pastEntity?.requireBean()?.apply {
|
pastEntity?.requireBean()?.apply {
|
||||||
// don't loopback
|
// don't loopback
|
||||||
if (currentDomainStrategy != "" && !serverAddress.isIpAddress()) {
|
if (currentDomainStrategy != "" && !serverAddress.isIpAddress()) {
|
||||||
domainListDNSDirect.add("full:$serverAddress")
|
domainListDNSDirectForce.add("full:$serverAddress")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (forTest) {
|
if (forTest) {
|
||||||
@ -628,7 +629,7 @@ fun buildConfig(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!serverAddr.isIpAddress()) {
|
if (!serverAddr.isIpAddress()) {
|
||||||
domainListDNSDirect.add("full:${serverAddr}")
|
domainListDNSDirectForce.add("full:${serverAddr}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -639,7 +640,7 @@ fun buildConfig(
|
|||||||
}
|
}
|
||||||
"https://$address".toHttpUrlOrNull()?.apply {
|
"https://$address".toHttpUrlOrNull()?.apply {
|
||||||
if (!host.isIpAddress()) {
|
if (!host.isIpAddress()) {
|
||||||
domainListDNSDirect.add("full:$host")
|
domainListDNSDirectForce.add("full:$host")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -675,6 +676,14 @@ fun buildConfig(
|
|||||||
address = "rcode://success"
|
address = "rcode://success"
|
||||||
tag = "dns-block"
|
tag = "dns-block"
|
||||||
})
|
})
|
||||||
|
if (domainListDNSDirectForce.isNotEmpty()) {
|
||||||
|
dns.rules.add(
|
||||||
|
DNSRule_DefaultOptions().apply {
|
||||||
|
makeSingBoxRule(domainListDNSDirectForce.toHashSet().toList())
|
||||||
|
server = "dns-direct"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// dns object user rules
|
// dns object user rules
|
||||||
if (enableDnsRouting) {
|
if (enableDnsRouting) {
|
||||||
@ -696,7 +705,6 @@ fun buildConfig(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (domainListDNSBlock.isNotEmpty()) {
|
if (domainListDNSBlock.isNotEmpty()) {
|
||||||
dns.rules.add(
|
dns.rules.add(
|
||||||
DNSRule_DefaultOptions().apply {
|
DNSRule_DefaultOptions().apply {
|
||||||
@ -706,6 +714,7 @@ fun buildConfig(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Disable DNS for test
|
// Disable DNS for test
|
||||||
if (forTest) {
|
if (forTest) {
|
||||||
|
|||||||
@ -34,6 +34,11 @@ object DNS {
|
|||||||
domain.plusAssign(it)
|
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) {
|
fun SingBoxOptions.Rule_DefaultOptions.makeSingBoxRule(list: List<String>, isIP: Boolean) {
|
||||||
@ -70,5 +75,12 @@ object DNS {
|
|||||||
domain.plusAssign(it)
|
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