aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/Shared/Model
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2018-11-08 16:26:17 +0530
committerRoopesh Chander <roop@roopc.net>2018-11-08 17:52:11 +0530
commit4404bb2b7d61f01d6d01c45fa6bb2ec20673ed02 (patch)
treec14e760a055f60ebd4b66161036698cf080b9fa9 /WireGuard/Shared/Model
parentMove logic to extension: NETunnelProviderProtocol extension code should be shared (diff)
downloadwireguard-apple-4404bb2b7d61f01d6d01c45fa6bb2ec20673ed02.tar.xz
wireguard-apple-4404bb2b7d61f01d6d01c45fa6bb2ec20673ed02.zip
Model: Endpoint.hostname()
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard/Shared/Model')
-rw-r--r--WireGuard/Shared/Model/Endpoint.swift11
1 files changed, 11 insertions, 0 deletions
diff --git a/WireGuard/Shared/Model/Endpoint.swift b/WireGuard/Shared/Model/Endpoint.swift
index a46d6b76..ab357ba2 100644
--- a/WireGuard/Shared/Model/Endpoint.swift
+++ b/WireGuard/Shared/Model/Endpoint.swift
@@ -87,4 +87,15 @@ extension Endpoint {
return true
}
}
+
+ func hostname() -> String? {
+ switch (host) {
+ case .name(let hostname, _):
+ return hostname
+ case .ipv4(_):
+ return nil
+ case .ipv6(_):
+ return nil
+ }
+ }
}