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(peerPublicKeysArray) + if (peerPublicKeysArray.count != peerPublicKeysSet.count) { + throw ParseError.multiplePeersWithSamePublicKey + } + if let interfaceConfiguration = interfaceConfiguration { let tunnelConfiguration = TunnelConfiguration(interface: interfaceConfiguration) tunnelConfiguration.peers = peerConfigurations