Propagate wireguard setup error message

This commit is contained in:
Bogdan-Ștefan Neacşu
2024-05-20 10:06:55 +00:00
parent 72c40d8576
commit d16a288b6d
2 changed files with 13 additions and 4 deletions
+7
View File
@@ -182,6 +182,13 @@ pub enum GatewayError {
#[cfg(all(feature = "wireguard", target_os = "linux"))]
#[error("wireguard not set")]
WireguardNotSet,
#[cfg(all(feature = "wireguard", target_os = "linux"))]
#[error("failed to catch an interrupt: {source}")]
StdError {
#[source]
source: Box<dyn std::error::Error + Send + Sync>,
},
}
impl From<ClientCoreError> for GatewayError {
+6 -4
View File
@@ -571,7 +571,10 @@ impl<St> Gateway<St> {
// Once this is a bit more mature, make this a commandline flag instead of a compile time
// flag
#[cfg(all(feature = "wireguard", target_os = "linux"))]
let wg_api = self.start_wireguard(shutdown.fork("wireguard")).await.ok();
let wg_api = self
.start_wireguard(shutdown.fork("wireguard"))
.await
.map_err(|source| GatewayError::StdError { source })?;
#[cfg(all(feature = "wireguard", not(target_os = "linux")))]
self.start_wireguard(shutdown.fork("wireguard")).await;
@@ -583,9 +586,8 @@ impl<St> Gateway<St> {
return Err(GatewayError::ShutdownFailure { source });
}
#[cfg(all(feature = "wireguard", target_os = "linux"))]
if let Some(wg_api) = wg_api {
defguard_wireguard_rs::WireguardInterfaceApi::remove_interface(&wg_api)?;
}
defguard_wireguard_rs::WireguardInterfaceApi::remove_interface(&wg_api)?;
Ok(())
}
}