aboutsummaryrefslogblamecommitdiffstats
path: root/WireGuard/Shared/Model/DNSServer.swift
blob: 0d03577fa1780b80bae5def30ff437a050d7d0e1 (plain) (tree)
1
2
3
4
5
6
7
8
9
                               
                                                             



                 

                          
 

                              


     





                                                             



                                      
 









                                                         
// SPDX-License-Identifier: MIT
// Copyright © 2018-2019 WireGuard LLC. All Rights Reserved.

import Foundation
import Network

struct DNSServer {
    let address: IPAddress

    init(address: IPAddress) {
        self.address = address
    }
}

extension DNSServer: Equatable {
    static func == (lhs: DNSServer, rhs: DNSServer) -> Bool {
        return lhs.address.rawValue == rhs.address.rawValue
    }
}

extension DNSServer {
    var stringRepresentation: String {
        return "\(address)"
    }

    init?(from addressString: String) {
        if let addr = IPv4Address(addressString) {
            address = addr
        } else if let addr = IPv6Address(addressString) {
            address = addr
        } else {
            return nil
        }
    }
}