diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2021-03-13 21:58:21 +0000 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2023-02-07 22:41:25 +0100 |
commit | 07509a4597e4613aa0f86f5be1ad3f885c784798 (patch) | |
tree | 128cd6b2be44b7255b7961ab7389ce67a009f369 /tunnel/src/main/java/com/wireguard/android | |
parent | 4ff564521fd42dcd54c8e0886317cae64d19d6f3 (diff) |
implement wgOnEvent
Diffstat (limited to 'tunnel/src/main/java/com/wireguard/android')
-rw-r--r-- | tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java | 13 |
1 files changed, 10 insertions, 3 deletions
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); +} |