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

36 lines
768 B
Swift
Raw Normal View History

2018-10-24 01:37:28 +00:00
// SPDX-License-Identifier: MIT
2019-01-02 00:56:33 +00:00
// Copyright © 2018-2019 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-22 04:41:54 +00:00
extension DNSServer: Equatable {
static func == (lhs: DNSServer, rhs: DNSServer) -> Bool {
return lhs.address.rawValue == rhs.address.rawValue
}
}
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
}
}
}