Parser: Peers in a configuation may not share the same public key
This commit is contained in:
parent
e6a6decd79
commit
e05a6c31b9
|
@ -16,6 +16,7 @@ class WgQuickConfigFileParser {
|
||||||
case noInterface
|
case noInterface
|
||||||
case invalidInterface
|
case invalidInterface
|
||||||
case multipleInterfaces
|
case multipleInterfaces
|
||||||
|
case multiplePeersWithSamePublicKey
|
||||||
case invalidPeer
|
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 {
|
if let interfaceConfiguration = interfaceConfiguration {
|
||||||
let tunnelConfiguration = TunnelConfiguration(interface: interfaceConfiguration)
|
let tunnelConfiguration = TunnelConfiguration(interface: interfaceConfiguration)
|
||||||
tunnelConfiguration.peers = peerConfigurations
|
tunnelConfiguration.peers = peerConfigurations
|
||||||
|
|
Loading…
Reference in New Issue