mirror of
https://git.zx2c4.com/wireguard-apple
synced 2024-11-10 16:59:18 +00:00
7b279383d1
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
41 lines
1.2 KiB
Swift
41 lines
1.2 KiB
Swift
// SPDX-License-Identifier: MIT
|
|
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
|
|
|
|
import Foundation
|
|
|
|
public struct PeerConfiguration {
|
|
public var publicKey: PublicKey
|
|
public var preSharedKey: PreSharedKey?
|
|
public var allowedIPs = [IPAddressRange]()
|
|
public var endpoint: Endpoint?
|
|
public var persistentKeepAlive: UInt16?
|
|
public var rxBytes: UInt64?
|
|
public var txBytes: UInt64?
|
|
public var lastHandshakeTime: Date?
|
|
|
|
public init(publicKey: PublicKey) {
|
|
self.publicKey = publicKey
|
|
}
|
|
}
|
|
|
|
extension PeerConfiguration: Equatable {
|
|
public static func == (lhs: PeerConfiguration, rhs: PeerConfiguration) -> Bool {
|
|
return lhs.publicKey == rhs.publicKey &&
|
|
lhs.preSharedKey == rhs.preSharedKey &&
|
|
Set(lhs.allowedIPs) == Set(rhs.allowedIPs) &&
|
|
lhs.endpoint == rhs.endpoint &&
|
|
lhs.persistentKeepAlive == rhs.persistentKeepAlive
|
|
}
|
|
}
|
|
|
|
extension PeerConfiguration: Hashable {
|
|
public func hash(into hasher: inout Hasher) {
|
|
hasher.combine(publicKey)
|
|
hasher.combine(preSharedKey)
|
|
hasher.combine(Set(allowedIPs))
|
|
hasher.combine(endpoint)
|
|
hasher.combine(persistentKeepAlive)
|
|
|
|
}
|
|
}
|