summaryrefslogtreecommitdiffhomepage
path: root/tunnel/src/main
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2023-03-07 20:18:07 +0100
committerMikael Magnusson <mikma@users.sourceforge.net>2023-03-23 22:32:11 +0100
commitde9cb9f5dd3e1086166ea21341b81d72e0578d24 (patch)
treed3fe9c307f1c4ecc7f532b9fb534c7add05f4953 /tunnel/src/main
parent01e47c71ec96a026877160c469f27b23be7d8023 (diff)
WIP add ConfigDetail and PeerDetail
Diffstat (limited to 'tunnel/src/main')
-rw-r--r--tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java3
-rw-r--r--tunnel/src/main/java/com/wireguard/android/backend/Tunnel.java6
-rw-r--r--tunnel/src/main/java/com/wireguard/config/InetEndpoint.java4
3 files changed, 13 insertions, 0 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 1d76b02d..5a4dfc1e 100644
--- a/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java
+++ b/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java
@@ -661,6 +661,9 @@ public final class GoBackend implements Backend {
final InetEndpoint ep = peer.getEndpoint().orElse(null);
if (ep == null)
continue;
+ // FIXME
+ tunnel.onEndpointChange(peer.getPublicKey(), ep);
+ Log.i(TAG, "onEndpointChange " + peer.getPublicKey() + ", " + ep);
if (ep.getResolved(resolver, true).orElse(null) == null) {
if (i < DNS_RESOLUTION_RETRIES - 1) {
Log.w(TAG, "DNS host \"" + ep.getHost() + "\" failed to resolve; trying again");
diff --git a/tunnel/src/main/java/com/wireguard/android/backend/Tunnel.java b/tunnel/src/main/java/com/wireguard/android/backend/Tunnel.java
index 40c460d2..a2342807 100644
--- a/tunnel/src/main/java/com/wireguard/android/backend/Tunnel.java
+++ b/tunnel/src/main/java/com/wireguard/android/backend/Tunnel.java
@@ -5,6 +5,10 @@
package com.wireguard.android.backend;
+import androidx.annotation.Nullable;
+
+import com.wireguard.config.InetEndpoint;
+import com.wireguard.crypto.Key;
import com.wireguard.util.NonNullForAll;
import java.util.regex.Pattern;
@@ -61,4 +65,6 @@ public interface Tunnel {
* @param newDhcp The new DHCP info of the tunnel.
*/
void onDhcpChange(Dhcp newDhcp);
+
+ void onEndpointChange(@Nullable Key publicKey, @Nullable InetEndpoint newEndpoint);
}
diff --git a/tunnel/src/main/java/com/wireguard/config/InetEndpoint.java b/tunnel/src/main/java/com/wireguard/config/InetEndpoint.java
index abd888c8..290195e4 100644
--- a/tunnel/src/main/java/com/wireguard/config/InetEndpoint.java
+++ b/tunnel/src/main/java/com/wireguard/config/InetEndpoint.java
@@ -81,6 +81,10 @@ public final class InetEndpoint {
return port;
}
+ public Optional<InetEndpoint> getResolved() {
+ return Optional.ofNullable(resolved);
+ }
+
/**
* Generate an {@code InetEndpoint} instance with the same port and the host resolved using DNS
* to a numeric address. If the host is already numeric, the existing instance may be returned.