diff options
Diffstat (limited to '')
-rw-r--r-- | WireGuard/Shared/Model/Legacy/LegacyPeerConfiguration.swift | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/WireGuard/Shared/Model/Legacy/LegacyPeerConfiguration.swift b/WireGuard/Shared/Model/Legacy/LegacyPeerConfiguration.swift new file mode 100644 index 0000000..5a61b4a --- /dev/null +++ b/WireGuard/Shared/Model/Legacy/LegacyPeerConfiguration.swift @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: MIT +// Copyright © 2018 WireGuard LLC. All Rights Reserved. + +import Foundation + +struct LegacyPeerConfiguration: Codable { + let publicKey: Data + let preSharedKey: Data? + let allowedIPs: [LegacyIPAddressRange] + let endpoint: LegacyEndpoint? + let persistentKeepAlive: UInt16? +} + +extension LegacyPeerConfiguration { + var migrated: PeerConfiguration { + var configuration = PeerConfiguration(publicKey: publicKey) + configuration.preSharedKey = preSharedKey + configuration.allowedIPs = allowedIPs.migrated + configuration.endpoint = endpoint?.migrated + configuration.persistentKeepAlive = persistentKeepAlive + return configuration + } +} + +extension Array where Element == LegacyPeerConfiguration { + var migrated: [PeerConfiguration] { + return map { $0.migrated } + } +} |