wireguard-apple/WireGuard/Shared/Model/TunnelConfiguration.swift

23 lines
673 B
Swift
Raw Normal View History

2018-12-21 04:52:45 +00:00
// SPDX-License-Identifier: MIT
// Copyright © 2018 WireGuard LLC. All Rights Reserved.
import Foundation
final class TunnelConfiguration {
var interface: InterfaceConfiguration
let peers: [PeerConfiguration]
static let keyLength = 32
init(interface: InterfaceConfiguration, peers: [PeerConfiguration]) {
self.interface = interface
self.peers = peers
let peerPublicKeysArray = peers.map { $0.publicKey }
let peerPublicKeysSet = Set<Data>(peerPublicKeysArray)
if peerPublicKeysArray.count != peerPublicKeysSet.count {
fatalError("Two or more peers cannot have the same public key")
}
}
}