summaryrefslogtreecommitdiffhomepage
path: root/tunnel/src/main/java/com/wireguard/config
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-10-26 00:11:06 +0200
commitfefb547341388d1359e948a7acdea259c3a0953b (patch)
tree7f8a56c7a1f761b7daeb44eda6c6c2ae7b73e3ba /tunnel/src/main/java/com/wireguard/config
parent86a461ecfd319e6521b68c88edb49c71a74c2ddd (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.java12
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.