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
commit98c68e0cf8f199f97bf2fd683817b5ef73aa9462 (patch)
tree715cff5a080071f3bdc2c7b5e1f090fe7d5363ce
parent1ca67cdf2d36d1d882db1addcc8540bbf8b99533 (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.
-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();
}