Files
wireguard-apple/Sources/WireGuardKitTypes/DNSServer.swift
T
Andrej Mihajlov a27dc674f1 Kit: move types from WireGuardKit to WireGuardKitTypes.
This prevents linking against wg-go when 3rd-party application needs to
use the WireGuardKit types from within the main bundle, therefore
prevents wg-go from spinning off Golang threads where not applicable.

Signed-off-by: Andrej Mihajlov <and@mullvad.net>
2022-03-11 14:21:40 +01:00

36 lines
810 B
Swift

// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Foundation
import Network
public struct DNSServer {
public let address: IPAddress
public init(address: IPAddress) {
self.address = address
}
}
extension DNSServer: Equatable {
public static func == (lhs: DNSServer, rhs: DNSServer) -> Bool {
return lhs.address.rawValue == rhs.address.rawValue
}
}
extension DNSServer {
public var stringRepresentation: String {
return "\(address)"
}
public init?(from addressString: String) {
if let addr = IPv4Address(addressString) {
address = addr
} else if let addr = IPv6Address(addressString) {
address = addr
} else {
return nil
}
}
}