From 532edf774a21c3104cac53ffb554b9699db7a6ab Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 25 Apr 2018 18:26:42 +0200 Subject: GoBackend: bring down tunnels when revoked or disconnected This synchronizes the OS's connection state with ours, such as when the user disconnects using the system UI. Signed-off-by: Jason A. Donenfeld --- app/src/main/java/com/wireguard/android/backend/GoBackend.java | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app/src/main') diff --git a/app/src/main/java/com/wireguard/android/backend/GoBackend.java b/app/src/main/java/com/wireguard/android/backend/GoBackend.java index 5331ad88..1ebab857 100644 --- a/app/src/main/java/com/wireguard/android/backend/GoBackend.java +++ b/app/src/main/java/com/wireguard/android/backend/GoBackend.java @@ -7,9 +7,11 @@ import android.support.v4.util.ArraySet; import android.util.Log; import android.util.Pair; +import com.wireguard.android.Application; import com.wireguard.android.model.Tunnel; import com.wireguard.android.model.Tunnel.State; import com.wireguard.android.model.Tunnel.Statistics; +import com.wireguard.android.model.TunnelManager; import com.wireguard.config.Config; import com.wireguard.config.IPCidr; import com.wireguard.config.Interface; @@ -56,6 +58,10 @@ public final class GoBackend implements Backend { @Override public void onDestroy() { + for (final Tunnel tunnel : Application.getComponent().getTunnelManager().getTunnels()) { + if (tunnel != null && tunnel.getState() != State.DOWN) + tunnel.setState(State.DOWN); + } vpnService = vpnService.newIncompleteFuture(); super.onDestroy(); } -- cgit v1.2.3