summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-12-18 14:52:58 -0200
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2019-01-09 07:44:06 -0200
commitdf7131022e3a61ff7fe2b50a9f513110fb81c18e (patch)
tree3d40e97031aa327e3db65348b8f88a383e4023a9
parente352ae38ade134d4d50cd87f1d9b5eaa25504901 (diff)
downloadmullvadvpn-df7131022e3a61ff7fe2b50a9f513110fb81c18e.tar.xz
mullvadvpn-df7131022e3a61ff7fe2b50a9f513110fb81c18e.zip
Perform post-mortem log analysis of OpenVPN
-rw-r--r--talpid-core/src/tunnel/openvpn.rs33
1 files changed, 32 insertions, 1 deletions
diff --git a/talpid-core/src/tunnel/openvpn.rs b/talpid-core/src/tunnel/openvpn.rs
index bf56ca7bbd..9d7e6eed93 100644
--- a/talpid-core/src/tunnel/openvpn.rs
+++ b/talpid-core/src/tunnel/openvpn.rs
@@ -29,6 +29,16 @@ mod errors {
EventDispatcherError {
description("Unable to start or manage the event dispatcher IPC server")
}
+ #[cfg(windows)]
+ /// No TAP adapter was detected
+ MissingTapAdapter {
+ description("No TAP adapter was detected")
+ }
+ #[cfg(windows)]
+ /// TAP adapter seems to be disabled
+ DisabledTapAdapter {
+ description("The TAP adapter appears to be disabled")
+ }
}
}
}
@@ -117,7 +127,7 @@ impl<C: OpenVpnBuilder> OpenVpnMonitor<C> {
Ok(())
} else {
log::error!("OpenVPN died unexpectedly with status: {}", exit_status);
- Err(ErrorKind::ChildProcessError("Died unexpectedly").into())
+ Err(self.postmortem())
}
}
WaitResult::Child(Err(e), _) => {
@@ -159,6 +169,27 @@ impl<C: OpenVpnBuilder> OpenVpnMonitor<C> {
let _ = rx.recv().unwrap();
result
}
+
+ /// Performs a postmortem analysis to attempt to provide a more detailed error result.
+ fn postmortem(self) -> Error {
+ #[cfg(windows)]
+ {
+ use std::fs;
+
+ if let Some(log_path) = self.log_path {
+ if let Ok(log) = fs::read_to_string(log_path) {
+ if log.contains("There are no TAP-Windows adapters on this system") {
+ return ErrorKind::MissingTapAdapter.into();
+ }
+ if log.contains("CreateFile failed on TAP device") {
+ return ErrorKind::DisabledTapAdapter.into();
+ }
+ }
+ }
+ }
+
+ ErrorKind::ChildProcessError("Died unexpectedly").into()
+ }
}
/// A handle to an `OpenVpnMonitor` for closing it.