From cfada8d0c2d11df4c65308460a18552856ef84d9 Mon Sep 17 00:00:00 2001 From: Mygod Date: Sat, 29 Dec 2018 00:08:55 +0800 Subject: [PATCH] Fix DNS update not propagated --- .../java/be/mygod/vpnhotspot/net/Routing.kt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 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 e8c2d823..3625ac50 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt @@ -78,15 +78,18 @@ class Routing(val downstream: String, ownerAddress: InterfaceAddress? = null) { var dns: List = emptyList() override fun onAvailable(ifname: String, dns: List) = synchronized(this@Routing) { - if (!upstreams.add(ifname)) return val subrouting = subrouting - if (subrouting == null) this.subrouting = try { - Subrouting(this@Routing, priority, ifname) - } catch (e: Exception) { - SmartSnackbar.make(e).show() - Timber.w(e) - null - } else check(subrouting.upstream == ifname) + when { + subrouting != null -> check(subrouting.upstream == ifname) + !upstreams.add(ifname) -> return + else -> this.subrouting = try { + Subrouting(this@Routing, priority, ifname) + } catch (e: Exception) { + SmartSnackbar.make(e).show() + Timber.w(e) + null + } + } this.dns = dns updateDnsRoute() }