diff options
author | Roopesh Chander <roop@roopc.net> | 2018-12-08 18:52:11 +0530 |
---|---|---|
committer | Roopesh Chander <roop@roopc.net> | 2018-12-09 14:07:03 +0530 |
commit | 60e13ddbf6e0d9fc03b57806043dbf0266a8cf70 (patch) | |
tree | 6a77e77358b5d9b25231d70058732aafaf7b486f /WireGuard/WireGuard/ConfigFile/WgQuickConfigFileParser.swift | |
parent | TunnelsManager: Observe status for all tunnels in one block (diff) | |
download | wireguard-apple-60e13ddbf6e0d9fc03b57806043dbf0266a8cf70.tar.xz wireguard-apple-60e13ddbf6e0d9fc03b57806043dbf0266a8cf70.zip |
Model: Declare keyLength constant and use that wherever applicable
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard/WireGuard/ConfigFile/WgQuickConfigFileParser.swift')
-rw-r--r-- | WireGuard/WireGuard/ConfigFile/WgQuickConfigFileParser.swift | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/WireGuard/WireGuard/ConfigFile/WgQuickConfigFileParser.swift b/WireGuard/WireGuard/ConfigFile/WgQuickConfigFileParser.swift index af3baf0..4cba816 100644 --- a/WireGuard/WireGuard/ConfigFile/WgQuickConfigFileParser.swift +++ b/WireGuard/WireGuard/ConfigFile/WgQuickConfigFileParser.swift @@ -27,7 +27,7 @@ class WgQuickConfigFileParser { func collate(interfaceAttributes attributes: [String: String]) -> InterfaceConfiguration? { // required wg fields guard let privateKeyString = attributes["privatekey"] else { return nil } - guard let privateKey = Data(base64Encoded: privateKeyString), privateKey.count == 32 else { return nil } + guard let privateKey = Data(base64Encoded: privateKeyString), privateKey.count == TunnelConfiguration.keyLength else { return nil } var interface = InterfaceConfiguration(name: name, privateKey: privateKey) // other wg fields if let listenPortString = attributes["listenport"] { @@ -63,11 +63,11 @@ class WgQuickConfigFileParser { func collate(peerAttributes attributes: [String: String]) -> PeerConfiguration? { // required wg fields guard let publicKeyString = attributes["publickey"] else { return nil } - guard let publicKey = Data(base64Encoded: publicKeyString), publicKey.count == 32 else { return nil } + guard let publicKey = Data(base64Encoded: publicKeyString), publicKey.count == TunnelConfiguration.keyLength else { return nil } var peer = PeerConfiguration(publicKey: publicKey) // wg fields if let preSharedKeyString = attributes["presharedkey"] { - guard let preSharedKey = Data(base64Encoded: preSharedKeyString), preSharedKey.count == 32 else { return nil } + guard let preSharedKey = Data(base64Encoded: preSharedKeyString), preSharedKey.count == TunnelConfiguration.keyLength else { return nil } peer.preSharedKey = preSharedKey } if let allowedIPsString = attributes["allowedips"] { |