diff options
author | Roopesh Chander <roop@roopc.net> | 2018-11-06 08:17:03 +0530 |
---|---|---|
committer | Roopesh Chander <roop@roopc.net> | 2018-11-06 08:17:56 +0530 |
commit | 636aa98b799562c46965a11d5991c1d0db4c6351 (patch) | |
tree | f06a0fb4f14a9f1f07bc01dce03ec9f5f9e9ef7d | |
parent | Version bump (diff) | |
download | wireguard-apple-636aa98b799562c46965a11d5991c1d0db4c6351.tar.xz wireguard-apple-636aa98b799562c46965a11d5991c1d0db4c6351.zip |
Parser: Peers in a configuation may not share the same public key
Signed-off-by: Roopesh Chander <roop@roopc.net>
-rw-r--r-- | WireGuard/WireGuard/ConfigFile/WgQuickConfigFileParser.swift | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/WireGuard/WireGuard/ConfigFile/WgQuickConfigFileParser.swift b/WireGuard/WireGuard/ConfigFile/WgQuickConfigFileParser.swift index 869d94e..863cd11 100644 --- a/WireGuard/WireGuard/ConfigFile/WgQuickConfigFileParser.swift +++ b/WireGuard/WireGuard/ConfigFile/WgQuickConfigFileParser.swift @@ -16,6 +16,7 @@ class WgQuickConfigFileParser { case noInterface case invalidInterface case multipleInterfaces + case multiplePeersWithSamePublicKey case invalidPeer } @@ -149,6 +150,12 @@ class WgQuickConfigFileParser { } } + let peerPublicKeysArray = peerConfigurations.map { $0.publicKey } + let peerPublicKeysSet = Set<Data>(peerPublicKeysArray) + if (peerPublicKeysArray.count != peerPublicKeysSet.count) { + throw ParseError.multiplePeersWithSamePublicKey + } + if let interfaceConfiguration = interfaceConfiguration { let tunnelConfiguration = TunnelConfiguration(interface: interfaceConfiguration) tunnelConfiguration.peers = peerConfigurations |