From 5394468b44f2ebcf3d5e8cae5cd70f770bb079ec Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Sat, 11 Mar 2023 23:10:19 +0100 Subject: WIP: add bgp-java Add bgp-java. Update peer list based on TunnelEncapsAttribute in BGP. --- .../main/java/com/wireguard/android/backend/GoBackend.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java') 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 5a4dfc1e..860e2369 100644 --- a/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java +++ b/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java @@ -114,6 +114,7 @@ public final class GoBackend implements Backend { private ConnectivityManager.NetworkCallback vpnNetworkCallback; @Nullable private Network activeNetwork; private boolean obtainDhcpLease = false; + @Nullable private Bgp bgp; /** * Public constructor for GoBackend. @@ -435,6 +436,10 @@ public final class GoBackend implements Backend { service.protect(wgGetSocketV4(currentTunnelHandle)); service.protect(wgGetSocketV6(currentTunnelHandle)); Log.i(TAG, "Dhcp done"); + + bgp = new Bgp(channel, currentTunnel, currentTunnelHandle); + bgp.startServer(); + currentTunnel.onDhcpChange(dhcp); } @@ -714,6 +719,10 @@ public final class GoBackend implements Backend { currentTunnel = null; currentTunnelHandle = -1; currentConfig = null; + if (bgp != null) { + bgp.stopServer(); + bgp = null; + } stopHttpProxy(); if (vpnNetworkCallback != null) connectivityManager.unregisterNetworkCallback(vpnNetworkCallback); @@ -782,6 +791,10 @@ public final class GoBackend implements Backend { @Override public void onDestroy() { if (owner != null) { + if (owner.bgp != null) { + owner.bgp.stopServer(); + owner.bgp = null; + } owner.stopHttpProxy(); final Tunnel tunnel = owner.currentTunnel; if (tunnel != null) { -- cgit v1.2.3