2018-10-24 01:37:28 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2023-02-14 15:10:32 +00:00
|
|
|
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
|
2018-10-23 10:53:27 +00:00
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import Network
|
|
|
|
|
2020-11-05 11:23:06 +00:00
|
|
|
public struct DNSServer {
|
|
|
|
public let address: IPAddress
|
2018-12-21 22:34:56 +00:00
|
|
|
|
2020-11-05 11:23:06 +00:00
|
|
|
public init(address: IPAddress) {
|
2018-12-21 04:52:45 +00:00
|
|
|
self.address = address
|
2018-10-23 10:53:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-22 04:41:54 +00:00
|
|
|
extension DNSServer: Equatable {
|
2020-11-05 11:23:06 +00:00
|
|
|
public static func == (lhs: DNSServer, rhs: DNSServer) -> Bool {
|
2018-12-22 04:41:54 +00:00
|
|
|
return lhs.address.rawValue == rhs.address.rawValue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-21 04:52:45 +00:00
|
|
|
extension DNSServer {
|
2020-11-05 11:23:06 +00:00
|
|
|
public var stringRepresentation: String {
|
2018-12-21 04:52:45 +00:00
|
|
|
return "\(address)"
|
|
|
|
}
|
2018-12-21 22:34:56 +00:00
|
|
|
|
2020-11-05 11:23:06 +00:00
|
|
|
public init?(from addressString: String) {
|
2018-12-21 04:52:45 +00:00
|
|
|
if let addr = IPv4Address(addressString) {
|
|
|
|
address = addr
|
|
|
|
} else if let addr = IPv6Address(addressString) {
|
|
|
|
address = addr
|
|
|
|
} else {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|