diff options
author | Andrej Mihajlov <and@mullvad.net> | 2020-12-02 15:21:36 +0100 |
---|---|---|
committer | Andrej Mihajlov <and@mullvad.net> | 2020-12-03 13:32:25 +0100 |
commit | 9f9d1ffed86ffc39d06c218594fb4a66d7f6c371 (patch) | |
tree | eeb48373dd0ebe79875c78d47ec8f60624b919f7 /Sources/WireGuardKit/PeerConfiguration.swift | |
parent | Linter: Fix all linter issues across the codebase (diff) | |
download | wireguard-apple-9f9d1ffed86ffc39d06c218594fb4a66d7f6c371.tar.xz wireguard-apple-9f9d1ffed86ffc39d06c218594fb4a66d7f6c371.zip |
WireGuardKit: Rename WireGuardKitSwift -> WireGuardKit
Signed-off-by: Andrej Mihajlov <and@mullvad.net>
Diffstat (limited to 'Sources/WireGuardKit/PeerConfiguration.swift')
-rw-r--r-- | Sources/WireGuardKit/PeerConfiguration.swift | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Sources/WireGuardKit/PeerConfiguration.swift b/Sources/WireGuardKit/PeerConfiguration.swift new file mode 100644 index 0000000..f11b473 --- /dev/null +++ b/Sources/WireGuardKit/PeerConfiguration.swift @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: MIT +// Copyright © 2018-2019 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) + + } +} |