diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2018-09-10 18:28:34 +0200 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2018-09-10 18:28:34 +0200 |
| commit | 01a1bfd53a3e3e0534ed78c841f4447be1afb763 (patch) | |
| tree | f0722c695578df38d2e8f9a591ba0e14f47ba960 | |
| parent | ddc590f7c71fe410527c3b7332598a0092a45028 (diff) | |
| parent | 07923a95aa5d061f7169a0f6d44cd70c0bba1829 (diff) | |
| download | mullvadvpn-01a1bfd53a3e3e0534ed78c841f4447be1afb763.tar.xz mullvadvpn-01a1bfd53a3e3e0534ed78c841f4447be1afb763.zip | |
Merge branch 'fail-less-when-restoring-windows-dns'
| -rw-r--r-- | CHANGELOG.md | 4 | ||||
| -rw-r--r-- | talpid-core/src/security/windows/dns.rs | 35 |
2 files changed, 24 insertions, 15 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 9df285663d..a8aac5a9fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,10 @@ Line wrap the file at 100 chars. Th - Make the pkg installer kill any running GUI process after installation is done. Prevents accidentally running an old GUI with a newer daemon. +#### Windows +- Failing to restore DNS settings on daemon start does not make the daemon exit with an error, just + log the error and continue. + ### Changed - The "Buy more credit" button is changed to open a dedicated account login page instead of one having a create account form first. diff --git a/talpid-core/src/security/windows/dns.rs b/talpid-core/src/security/windows/dns.rs index 73593e7ccb..d068cb4151 100644 --- a/talpid-core/src/security/windows/dns.rs +++ b/talpid-core/src/security/windows/dns.rs @@ -10,6 +10,8 @@ use std::path::Path; use std::ptr; use std::slice; +use error_chain::ChainedError; + const DNS_STATE_FILENAME: &'static str = "dns-state-backup"; error_chain!{ @@ -39,10 +41,6 @@ error_chain!{ description("Failed to recover to backed up system state") } } - - foreign_links { - Io(::std::io::Error) #[doc = "IO error, most probably occurs when reading system state backup"]; - } } pub struct WinDns { @@ -60,7 +58,12 @@ impl WinDns { .into_boxed_path(), ); let mut dns = WinDns { backup_writer }; - dns.restore_system_backup()?; + if let Err(error) = dns + .restore_system_backup() + .chain_err(|| "Failed to restore DNS backup") + { + error!("{}", error.display_chain()); + } Ok(dns) } @@ -109,19 +112,21 @@ impl WinDns { } fn restore_system_backup(&mut self) -> Result<()> { - if let Some(previous_state) = self.backup_writer.read_backup()? { + if let Some(previous_state) = self + .backup_writer + .read_backup() + .chain_err(|| "Failed to read backed up DNS state")? + { info!("Restoring DNS state from backup"); - self.restore_dns_settings(&previous_state)?; + self.restore_dns_settings(&previous_state) + .chain_err(|| "Failed to restore backed up DNS state")?; trace!("Successfully restored DNS state"); - if let Err(e) = self.backup_writer.remove_backup() { - error!( - "Failed to remove DNS config backup after restoring it: {}", - e - ); - } - return Ok(()); + self.backup_writer + .remove_backup() + .chain_err(|| "Failed to remove backed up DNS state after restoring it")?; + } else { + trace!("No dns state to restore"); } - trace!("No dns state to restore"); Ok(()) } } |
