summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2019-02-15 07:42:23 -0200
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2019-02-15 07:42:23 -0200
commitff2126b41d04f7e0810e993b0c7dcdd92f307dc4 (patch)
treea96008f20dce85a7b7987cef0f6a08990e236c11
parente068322f25f486b57e9acfd28428be01199c6a2c (diff)
parent85c2c1dd4c856b064ff5a2d214fc2d750db04e88 (diff)
downloadmullvadvpn-ff2126b41d04f7e0810e993b0c7dcdd92f307dc4.tar.xz
mullvadvpn-ff2126b41d04f7e0810e993b0c7dcdd92f307dc4.zip
Merge branch 'refactor-tunnel-errors'
-rw-r--r--talpid-core/src/tunnel/mod.rs34
-rw-r--r--talpid-core/src/tunnel/wireguard/mod.rs8
2 files changed, 15 insertions, 27 deletions
diff --git a/talpid-core/src/tunnel/mod.rs b/talpid-core/src/tunnel/mod.rs
index 6491071697..d7506b3b7c 100644
--- a/talpid-core/src/tunnel/mod.rs
+++ b/talpid-core/src/tunnel/mod.rs
@@ -22,14 +22,6 @@ const WIREGUARD_LOG_FILENAME: &str = "wireguard.log";
error_chain! {
errors {
- /// Failed to monitor the tunnel
- TunnelMonitoringError {
- description("Failed to monitor tunnel")
- }
- /// There was an error whilst preparing to listen for events from the VPN tunnel.
- TunnelMonitorSetUpError {
- description("Error while setting up to listen for events from the VPN tunnel")
- }
/// Tunnel can't have IPv6 enabled because the system has disabled IPv6 support.
EnableIpv6Error {
description("Can't enable IPv6 on tunnel interface because IPv6 is disabled")
@@ -42,12 +34,20 @@ error_chain! {
RotateLogError {
description("Failed to rotate tunnel log file")
}
+ /// Failure to build Wireguard configuration.
+ WireguardConfigError {
+ description("Failed to configure Wireguard with the given parameters")
+ }
}
links {
OpenVpnTunnelMonitoringError(openvpn::Error, openvpn::ErrorKind)
/// There was an error listening for events from the OpenVPN tunnel
;
+ WirguardTunnelMonitoringError(wireguard::Error, wireguard::ErrorKind)
+ /// There was an error listening for events from the OpenVPN tunnel
+ #[cfg(unix)]
+ ;
}
}
@@ -157,13 +157,12 @@ impl TunnelMonitor {
L: Fn(TunnelEvent) + Send + Sync + 'static,
{
let config = wireguard::config::Config::from_parameters(&params)
- .chain_err(|| ErrorKind::TunnelMonitoringError)?;
+ .chain_err(|| ErrorKind::WireguardConfigError)?;
let monitor = wireguard::WireguardMonitor::start(
&config,
log.as_ref().map(|p| p.as_path()),
on_event,
- )
- .chain_err(|| ErrorKind::TunnelMonitorSetUpError)?;
+ )?;
Ok(TunnelMonitor {
monitor: InternalTunnelMonitor::Wireguard(monitor),
})
@@ -180,8 +179,7 @@ impl TunnelMonitor {
L: Fn(TunnelEvent) + Send + Sync + 'static,
{
let monitor =
- openvpn::OpenVpnMonitor::start(on_event, config, tunnel_alias, log, resource_dir)
- .chain_err(|| ErrorKind::TunnelMonitorSetUpError)?;
+ openvpn::OpenVpnMonitor::start(on_event, config, tunnel_alias, log, resource_dir)?;
Ok(TunnelMonitor {
monitor: InternalTunnelMonitor::OpenVpn(monitor),
})
@@ -267,14 +265,12 @@ impl InternalTunnelMonitor {
fn wait(self) -> Result<()> {
match self {
- InternalTunnelMonitor::OpenVpn(tun) => {
- tun.wait().chain_err(|| ErrorKind::TunnelMonitoringError)
- }
+ InternalTunnelMonitor::OpenVpn(tun) => tun.wait()?,
#[cfg(unix)]
- InternalTunnelMonitor::Wireguard(tun) => {
- tun.wait().chain_err(|| ErrorKind::TunnelMonitoringError)
- }
+ InternalTunnelMonitor::Wireguard(tun) => tun.wait()?,
}
+
+ Ok(())
}
}
diff --git a/talpid-core/src/tunnel/wireguard/mod.rs b/talpid-core/src/tunnel/wireguard/mod.rs
index cc60f71c38..1707f8170e 100644
--- a/talpid-core/src/tunnel/wireguard/mod.rs
+++ b/talpid-core/src/tunnel/wireguard/mod.rs
@@ -14,10 +14,6 @@ const PING_TIMEOUT: u16 = 5;
error_chain! {
errors {
- /// Config error
- ConfigError{
- description("Invalid configuration")
- }
/// Failed to setup a tunnel device
SetupTunnelDeviceError {
description("Failed to create tunnel device")
@@ -42,10 +38,6 @@ error_chain! {
InterfaceNameError {
display("Tunnel interface name contains null bytes")
}
- /// No private key supplied
- NoKeyError {
- display("Config has no keys")
- }
/// Pinging timed out
PingTimeoutError {
display("Ping timed out")