diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2019-08-05 11:41:06 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2019-08-06 12:30:41 +0000 |
| commit | 6e0acc3a0f0786affb38e445ed3eec1c47d020a0 (patch) | |
| tree | 6101b7106742696c570d3e8feb2e70e4e28fc031 | |
| parent | e71cf419a84d02598c6c71d0fe7d6621fbe00c17 (diff) | |
| download | mullvadvpn-6e0acc3a0f0786affb38e445ed3eec1c47d020a0.tar.xz mullvadvpn-6e0acc3a0f0786affb38e445ed3eec1c47d020a0.zip | |
Separate `StartWireguardError` into error variants
| -rw-r--r-- | talpid-core/src/tunnel/wireguard/mod.rs | 17 | ||||
| -rw-r--r-- | talpid-core/src/tunnel/wireguard/wireguard_go.rs | 7 | ||||
| -rw-r--r-- | talpid-core/src/tunnel_state_machine/connecting_state.rs | 2 |
3 files changed, 21 insertions, 5 deletions
diff --git a/talpid-core/src/tunnel/wireguard/mod.rs b/talpid-core/src/tunnel/wireguard/mod.rs index 4af0ca2344..316d0304a5 100644 --- a/talpid-core/src/tunnel/wireguard/mod.rs +++ b/talpid-core/src/tunnel/wireguard/mod.rs @@ -24,9 +24,20 @@ pub enum Error { #[error(display = "Failed to create tunnel device")] SetupTunnelDeviceError(#[error(cause)] BoxedError), - /// Failed to setup wireguard tunnel. - #[error(display = "Failed to start wireguard tunnel - {}", status)] - StartWireguardError { status: i32 }, + /// A recoverable error occurred while starting the wireguard tunnel + /// + /// This is an error returned by wireguard-go that indicates that trying to establish the + /// tunnel again should work normally. The error encountered is known to be sporadic. + #[error(display = "Recoverable error while starting wireguard tunnel")] + RecoverableStartWireguardError, + + /// An unrecoverable error occurred while starting the wireguard tunnel + /// + /// This is an error returned by wireguard-go that indicates that trying to establish the + /// tunnel again will likely fail with the same error. An error was encountered during tunnel + /// configuration which can't be dealt with gracefully. + #[error(display = "Failed to start wireguard tunnel")] + FatalStartWireguardError, /// Failed to tear down wireguard tunnel. #[error(display = "Failed to stop wireguard tunnel - {}", status)] diff --git a/talpid-core/src/tunnel/wireguard/wireguard_go.rs b/talpid-core/src/tunnel/wireguard/wireguard_go.rs index f2349ef0cb..38a0c83218 100644 --- a/talpid-core/src/tunnel/wireguard/wireguard_go.rs +++ b/talpid-core/src/tunnel/wireguard/wireguard_go.rs @@ -45,7 +45,12 @@ impl WgGoTunnel { }; if handle < 0 { - return Err(Error::StartWireguardError { status: handle }); + // Error values returned from the wireguard-go library + return match handle { + -1 => Err(Error::FatalStartWireguardError), + -2 => Err(Error::RecoverableStartWireguardError), + _ => unreachable!("Unknown status code returned from wireguard-go"), + }; } #[cfg(target_os = "android")] diff --git a/talpid-core/src/tunnel_state_machine/connecting_state.rs b/talpid-core/src/tunnel_state_machine/connecting_state.rs index 4449226664..266a23b79f 100644 --- a/talpid-core/src/tunnel_state_machine/connecting_state.rs +++ b/talpid-core/src/tunnel_state_machine/connecting_state.rs @@ -347,7 +347,7 @@ impl TunnelState for ConnectingState { #[cfg(not(windows))] Err( error @ tunnel::Error::WireguardTunnelMonitoringError( - tunnel::wireguard::Error::StartWireguardError { status: -2 }, + tunnel::wireguard::Error::RecoverableStartWireguardError, ), ) => { log::warn!( |
