From aa0b6e0c60041c98e3085d689f0c0224bb55f7a8 Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Tue, 6 Nov 2018 23:36:48 +0530 Subject: [PATCH] Model: Endpoint.hasHostAsIPAddress() Signed-off-by: Roopesh Chander --- WireGuard/WireGuard/Model/Endpoint.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/WireGuard/WireGuard/Model/Endpoint.swift b/WireGuard/WireGuard/Model/Endpoint.swift index 483615b..a46d6b7 100644 --- a/WireGuard/WireGuard/Model/Endpoint.swift +++ b/WireGuard/WireGuard/Model/Endpoint.swift @@ -75,3 +75,16 @@ extension Endpoint: Codable { case invalidData } } + +extension Endpoint { + func hasHostAsIPAddress() -> Bool { + switch (host) { + case .name(_, _): + return false + case .ipv4(_): + return true + case .ipv6(_): + return true + } + } +}