From 04f111c1a4c77c968a5492a003cc63e4e7a9578b Mon Sep 17 00:00:00 2001 From: Mygod Date: Sun, 30 Dec 2018 16:10:39 +0800 Subject: [PATCH] Ensure DNS is never empty --- mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt index 3625ac50..d843a6a7 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt @@ -149,8 +149,9 @@ class Routing(val downstream: String, ownerAddress: InterfaceAddress? = null) { } private var currentDns: DnsRoute? = null private fun updateDnsRoute() { - val dns = (upstream.dns + fallbackUpstream.dns).firstOrNull { it is Inet4Address }?.hostAddress - ?: app.pref.getString("service.dns", "8.8.8.8") + var dns = (upstream.dns + fallbackUpstream.dns).firstOrNull { it is Inet4Address }?.hostAddress + ?: app.pref.getString("service.dns", null) + if (dns.isNullOrBlank()) dns = "8.8.8.8" if (dns != currentDns?.dns) { currentDns?.transaction?.revert() currentDns = try {