2018-12-21 04:52:45 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2019-01-02 00:56:33 +00:00
|
|
|
// Copyright © 2018-2019 WireGuard LLC. All Rights Reserved.
|
2018-12-21 04:52:45 +00:00
|
|
|
|
|
|
|
import Foundation
|
2018-12-22 04:41:54 +00:00
|
|
|
import Network
|
2018-12-21 04:52:45 +00:00
|
|
|
|
2020-11-05 11:23:06 +00:00
|
|
|
public struct InterfaceConfiguration {
|
2020-11-26 16:23:50 +00:00
|
|
|
public var privateKey: PrivateKey
|
2020-11-05 11:23:06 +00:00
|
|
|
public var addresses = [IPAddressRange]()
|
|
|
|
public var listenPort: UInt16?
|
|
|
|
public var mtu: UInt16?
|
|
|
|
public var dns = [DNSServer]()
|
2018-12-21 22:34:56 +00:00
|
|
|
|
2020-11-26 16:23:50 +00:00
|
|
|
public init(privateKey: PrivateKey) {
|
2018-12-21 23:28:18 +00:00
|
|
|
self.privateKey = privateKey
|
2018-12-21 04:52:45 +00:00
|
|
|
}
|
|
|
|
}
|
2018-12-22 04:41:54 +00:00
|
|
|
|
|
|
|
extension InterfaceConfiguration: Equatable {
|
2020-11-05 11:23:06 +00:00
|
|
|
public static func == (lhs: InterfaceConfiguration, rhs: InterfaceConfiguration) -> Bool {
|
2018-12-22 04:41:54 +00:00
|
|
|
let lhsAddresses = lhs.addresses.filter { $0.address is IPv4Address } + lhs.addresses.filter { $0.address is IPv6Address }
|
|
|
|
let rhsAddresses = rhs.addresses.filter { $0.address is IPv4Address } + rhs.addresses.filter { $0.address is IPv6Address }
|
|
|
|
|
|
|
|
return lhs.privateKey == rhs.privateKey &&
|
|
|
|
lhsAddresses == rhsAddresses &&
|
|
|
|
lhs.listenPort == rhs.listenPort &&
|
|
|
|
lhs.mtu == rhs.mtu &&
|
|
|
|
lhs.dns == rhs.dns
|
|
|
|
}
|
|
|
|
}
|