From 07509a4597e4613aa0f86f5be1ad3f885c784798 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Sat, 13 Mar 2021 21:58:21 +0000 Subject: implement wgOnEvent --- .../main/java/com/wireguard/android/backend/GoBackend.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'tunnel/src/main/java/com/wireguard/android') diff --git a/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java b/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java index 3d0886cf..b7e55465 100644 --- a/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java +++ b/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java @@ -40,7 +40,7 @@ import androidx.collection.ArraySet; * WireGuard tunnels. */ @NonNullForAll -public final class GoBackend implements Backend { +public final class GoBackend implements Backend, EventHandler { private static final int DNS_RESOLUTION_RETRIES = 10; private static final String TAG = "WireGuard/GoBackend"; @Nullable private static AlwaysOnCallback alwaysOnCallback; @@ -78,7 +78,7 @@ public final class GoBackend implements Backend { private static native void wgTurnOff(int handle); - private static native int wgTurnOn(String ifName, int tunFd, String settings); + private static native int wgTurnOn(String ifName, int tunFd, String settings, EventHandler handler); private static native String wgVersion(); @@ -304,7 +304,7 @@ public final class GoBackend implements Backend { if (tun == null) throw new BackendException(Reason.TUN_CREATION_ERROR); Log.d(TAG, "Go backend " + wgVersion()); - currentTunnelHandle = wgTurnOn(tunnel.getName(), tun.detachFd(), goConfig); + currentTunnelHandle = wgTurnOn(tunnel.getName(), tun.detachFd(), goConfig, this); } if (currentTunnelHandle < 0) throw new BackendException(Reason.GO_ACTIVATION_ERROR_CODE, currentTunnelHandle); @@ -329,6 +329,9 @@ public final class GoBackend implements Backend { tunnel.onStateChange(state); } + public void onEvent(String event) { + } + /** * Callback for {@link GoBackend} that is invoked when {@link VpnService} is started by the * system's Always-On VPN mode. @@ -415,3 +418,7 @@ public final class GoBackend implements Backend { } } } + +interface EventHandler { + public void onEvent(String event); +} -- cgit v1.2.3