From bcfb21589713d7f7c077743f9d1b5f9a27ac1f35 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Tue, 7 Mar 2023 20:18:07 +0100 Subject: tunnel: add ConfigDetail and PeerDetail --- tunnel/src/main/java/com/wireguard/config/InetEndpoint.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tunnel/src/main/java/com/wireguard/config') diff --git a/tunnel/src/main/java/com/wireguard/config/InetEndpoint.java b/tunnel/src/main/java/com/wireguard/config/InetEndpoint.java index e1e9d653..f9db5779 100644 --- a/tunnel/src/main/java/com/wireguard/config/InetEndpoint.java +++ b/tunnel/src/main/java/com/wireguard/config/InetEndpoint.java @@ -65,6 +65,10 @@ public final class InetEndpoint { } } + public static InetEndpoint fromAddress(final InetAddress address, final int port) { + return new InetEndpoint(address.getHostAddress(), true, port); + } + @Override public boolean equals(final Object obj) { if (!(obj instanceof InetEndpoint)) @@ -81,6 +85,14 @@ public final class InetEndpoint { return port; } + public Optional getResolved() { + if (isResolved) { + return Optional.of(this); + } else { + 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. -- cgit v1.2.3