Fix VPN connections change handlers

This commit is contained in:
Mygod
2018-01-13 12:13:22 +08:00
parent 57b9463a6f
commit c25b7a3f0c
4 changed files with 7 additions and 6 deletions

View File

@@ -59,7 +59,7 @@ class TetheringService : Service(), VpnListener.Callback {
}
override fun onAvailable(ifname: String) {
assert(upstream == null || upstream == ifname)
check(upstream == null || upstream == ifname)
upstream = ifname
for ((downstream, value) in routings) if (value == null) {
val routing = Routing(ifname, downstream).rule().forward().dnsRedirect(app.dns)
@@ -68,7 +68,7 @@ class TetheringService : Service(), VpnListener.Callback {
}
override fun onLost(ifname: String) {
assert(upstream == null || upstream == ifname)
check(upstream == null || upstream == ifname)
upstream = null
for ((iface, routing) in routings) {
routing?.stop()