diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2023-03-07 20:18:07 +0100 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2023-07-05 21:40:32 +0200 |
commit | bcfb21589713d7f7c077743f9d1b5f9a27ac1f35 (patch) | |
tree | 524465bee13ff42b188af324f4c76726b14582a4 /tunnel/src/main/java/com/wireguard/config | |
parent | 7a12989f6241fe4ab2f56707c20e7aa7810f1212 (diff) |
tunnel: add ConfigDetail and PeerDetail
Diffstat (limited to 'tunnel/src/main/java/com/wireguard/config')
-rw-r--r-- | tunnel/src/main/java/com/wireguard/config/InetEndpoint.java | 12 |
1 files changed, 12 insertions, 0 deletions
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<InetEndpoint> 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. |