From 6053defd54e52fa61f4e6a0e24415cb6131f103c Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Mon, 27 Mar 2023 00:07:53 +0200 Subject: tunnel: add backend to bgp constructor --- .../src/main/java/com/wireguard/android/backend/Bgp.java | 14 +++++++++----- .../main/java/com/wireguard/android/backend/GoBackend.java | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tunnel/src/main/java/com/wireguard/android/backend/Bgp.java b/tunnel/src/main/java/com/wireguard/android/backend/Bgp.java index 12668621..a6a8b420 100644 --- a/tunnel/src/main/java/com/wireguard/android/backend/Bgp.java +++ b/tunnel/src/main/java/com/wireguard/android/backend/Bgp.java @@ -23,6 +23,7 @@ import com.lumaserv.bgp.protocol.attribute.PathAttribute; import com.lumaserv.bgp.protocol.attribute.TunnelEncapsAttribute; import com.lumaserv.bgp.protocol.message.BGPUpdate; +import com.wireguard.android.backend.Backend; import com.wireguard.config.InetEndpoint; import com.wireguard.config.InetNetwork; import com.wireguard.crypto.Key; @@ -53,12 +54,14 @@ public class Bgp implements BGPListener { private static final int PORT = 0; private static final int STATS_TAG = 1; // FIXME - private ManagedChannel channel; - private Tunnel tunnel; - private int tunnelHandle; + private final Backend backend; + private final ManagedChannel channel; + private final Tunnel tunnel; + private final int tunnelHandle; private BGPServer server; - public Bgp(ManagedChannel channel, Tunnel tunnel, int tunnelHandle) { + public Bgp(Backend backend, ManagedChannel channel, Tunnel tunnel, int tunnelHandle) { + this.backend = backend; this.channel = channel; this.tunnel = tunnel; this.tunnelHandle = tunnelHandle; @@ -196,7 +199,8 @@ public class Bgp implements BGPListener { } tunnel.onAllowedIpsChange(publicKey, addNetworks, removeNetworks); - + // backend.addAllowedIps(tunnel, publicKey, addNetworks); + // backend.removeAllowedIps(tunnel, publicKey, addNetworks); // TODO } catch (KeyFormatException ex) { Log.w(TAG, "Key.fromBytes " + ex); } 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 894059c7..9c96e00f 100644 --- a/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java +++ b/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java @@ -460,7 +460,7 @@ public final class GoBackend implements Backend { service.protect(wgGetSocketV6(currentTunnelHandle)); Log.i(TAG, "Dhcp done"); - bgp = new Bgp(channel, currentTunnel, currentTunnelHandle); + bgp = new Bgp(this, channel, currentTunnel, currentTunnelHandle); bgp.startServer(); currentTunnel.onDhcpChange(dhcp); -- cgit v1.2.3