wireguard-apple/WireGuard/Shared/Model/DNSServer.swift

30 lines
599 B
Swift
Raw Normal View History

2018-10-24 01:37:28 +00:00
// SPDX-License-Identifier: MIT
// Copyright © 2018 WireGuard LLC. All Rights Reserved.
2018-10-23 10:53:27 +00:00
import Foundation
import Network
struct DNSServer {
let address: IPAddress
2018-12-21 22:34:56 +00:00
2018-12-21 04:52:45 +00:00
init(address: IPAddress) {
self.address = address
2018-10-23 10:53:27 +00:00
}
}
2018-12-21 04:52:45 +00:00
extension DNSServer {
var stringRepresentation: String {
return "\(address)"
}
2018-12-21 22:34:56 +00:00
2018-12-21 04:52:45 +00:00
init?(from addressString: String) {
if let addr = IPv4Address(addressString) {
address = addr
} else if let addr = IPv6Address(addressString) {
address = addr
} else {
return nil
}
}
}