Use new DNS mode

This commit is contained in:
世界
2026-05-03 09:07:48 +08:00
parent a5f9769134
commit 804ad7c91c

View File

@@ -7,6 +7,7 @@ import android.net.VpnService
import android.os.Build
import android.os.IBinder
import android.util.Log
import io.nekohasekai.libbox.Libbox
import io.nekohasekai.libbox.Notification
import io.nekohasekai.libbox.TunOptions
import io.nekohasekai.sfa.database.Settings
@@ -83,7 +84,12 @@ class VPNService :
}
if (options.autoRoute) {
builder.addDnsServer(options.dnsServerAddress.value)
if (options.dnsMode.value != Libbox.DNSModeDisabled) {
val dnsServerAddress = options.dnsServerAddress
while (dnsServerAddress.hasNext()) {
builder.addDnsServer(dnsServerAddress.next())
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
val inet4RouteAddress = options.inet4RouteAddress