diff options
| author | David Lönnhager <david.l@mullvad.net> | 2022-04-29 11:50:30 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2022-05-05 10:05:37 +0200 |
| commit | 5deb33e9beed61acfdd10c70aa7b00d7b3d8fde8 (patch) | |
| tree | 869f51d946bb1f02dc01ab235a600504e322233b | |
| parent | 4a70cd51f5b67ece14740c5cefcf969772f63088 (diff) | |
| download | mullvadvpn-5deb33e9beed61acfdd10c70aa7b00d7b3d8fde8.tar.xz mullvadvpn-5deb33e9beed61acfdd10c70aa7b00d7b3d8fde8.zip | |
Simplify panic
| -rw-r--r-- | mullvad-daemon/src/device/mod.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/mullvad-daemon/src/device/mod.rs b/mullvad-daemon/src/device/mod.rs index edce336c49..1b79b46853 100644 --- a/mullvad-daemon/src/device/mod.rs +++ b/mullvad-daemon/src/device/mod.rs @@ -415,7 +415,8 @@ impl AccountManager { match response { Ok(new_device_data) => { - if new_device_data.pubkey == current_data.device.pubkey { + let current_pubkey = current_data.wg_data.private_key.public_key(); + if new_device_data.pubkey == current_pubkey { let new_data = DeviceData { device: new_device_data, ..current_data.clone() @@ -463,12 +464,10 @@ impl AccountManager { } async fn consume_rotation_result(&mut self, api_result: Result<WireguardData, Error>) { - let mut device_data = match self.data.clone() { - Some(data) => data, - None => { - panic!("Received a key rotation result whilst having no data"); - } - }; + let mut device_data = self + .data + .clone() + .expect("Received a key rotation result whilst having no data"); match api_result { Ok(wg_data) => { |
