2018-10-24 01:37:28 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2018-10-30 02:57:35 +00:00
|
|
|
// 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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|