summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-04-25 18:26:42 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-04-25 18:27:18 +0200
commit532edf774a21c3104cac53ffb554b9699db7a6ab (patch)
tree715cff5a080071f3bdc2c7b5e1f090fe7d5363ce
parent86ffb2474883642c3f95698d47acea32458247e0 (diff)
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 <Jason@zx2c4.com>
-rw-r--r--app/src/main/java/com/wireguard/android/backend/GoBackend.java6
1 files changed, 6 insertions, 0 deletions
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();
}