summaryrefslogtreecommitdiffhomepage
path: root/mullvad-daemon/src
diff options
context:
space:
mode:
Diffstat (limited to 'mullvad-daemon/src')
-rw-r--r--mullvad-daemon/src/cleanup.rs31
-rw-r--r--mullvad-daemon/src/device/api.rs13
-rw-r--r--mullvad-daemon/src/exception_logging/unix.rs2
-rw-r--r--mullvad-daemon/src/lib.rs47
-rw-r--r--mullvad-daemon/src/management_interface.rs2
-rw-r--r--mullvad-daemon/src/migrations/account_history.rs12
-rw-r--r--mullvad-daemon/src/migrations/mod.rs28
-rw-r--r--mullvad-daemon/src/migrations/v2.rs1
-rw-r--r--mullvad-daemon/src/migrations/v3.rs2
-rw-r--r--mullvad-daemon/src/migrations/v4.rs7
-rw-r--r--mullvad-daemon/src/migrations/v5.rs5
-rw-r--r--mullvad-daemon/src/tunnel.rs24
-rw-r--r--mullvad-daemon/src/version_check.rs9
13 files changed, 95 insertions, 88 deletions
diff --git a/mullvad-daemon/src/cleanup.rs b/mullvad-daemon/src/cleanup.rs
index b4765761e0..1f0cbdf309 100644
--- a/mullvad-daemon/src/cleanup.rs
+++ b/mullvad-daemon/src/cleanup.rs
@@ -7,26 +7,26 @@ use tokio::{fs, io};
#[error(no_from)]
pub enum Error {
#[error(display = "Failed to get path")]
- PathError(#[error(source)] mullvad_paths::Error),
+ Path(#[error(source)] mullvad_paths::Error),
#[error(display = "Failed to remove directory {}", _0)]
- RemoveDirError(String, #[error(source)] io::Error),
+ RemoveDir(String, #[error(source)] io::Error),
#[cfg(not(target_os = "windows"))]
#[error(display = "Failed to create directory {}", _0)]
- CreateDirError(String, #[error(source)] io::Error),
+ CreateDir(String, #[error(source)] io::Error),
#[cfg(target_os = "windows")]
#[error(display = "Failed to get file type info")]
- FileTypeError(#[error(source)] io::Error),
+ FileType(#[error(source)] io::Error),
#[cfg(target_os = "windows")]
#[error(display = "Failed to get dir entry")]
- FileEntryError(#[error(source)] io::Error),
+ FileEntry(#[error(source)] io::Error),
#[cfg(target_os = "windows")]
#[error(display = "Failed to read dir entries")]
- ReadDirError(#[error(source)] io::Error),
+ ReadDir(#[error(source)] io::Error),
}
pub async fn clear_directories() -> Result<(), Error> {
@@ -35,12 +35,12 @@ pub async fn clear_directories() -> Result<(), Error> {
}
async fn clear_log_directory() -> Result<(), Error> {
- let log_dir = mullvad_paths::get_log_dir().map_err(Error::PathError)?;
+ let log_dir = mullvad_paths::get_log_dir().map_err(Error::Path)?;
clear_directory(&log_dir).await
}
async fn clear_cache_directory() -> Result<(), Error> {
- let cache_dir = mullvad_paths::cache_dir().map_err(Error::PathError)?;
+ let cache_dir = mullvad_paths::cache_dir().map_err(Error::Path)?;
clear_directory(&cache_dir).await
}
@@ -49,22 +49,22 @@ async fn clear_directory(path: &Path) -> Result<(), Error> {
{
fs::remove_dir_all(path)
.await
- .map_err(|e| Error::RemoveDirError(path.display().to_string(), e))?;
+ .map_err(|e| Error::RemoveDir(path.display().to_string(), e))?;
fs::create_dir_all(path)
.await
- .map_err(|e| Error::CreateDirError(path.display().to_string(), e))
+ .map_err(|e| Error::CreateDir(path.display().to_string(), e))
}
#[cfg(target_os = "windows")]
{
- let mut dir = fs::read_dir(&path).await.map_err(Error::ReadDirError)?;
+ let mut dir = fs::read_dir(&path).await.map_err(Error::ReadDir)?;
let mut result = Ok(());
- while let Some(entry) = dir.next_entry().await.map_err(Error::FileEntryError)? {
+ while let Some(entry) = dir.next_entry().await.map_err(Error::FileEntry)? {
let entry_type = match entry.file_type().await {
Ok(entry_type) => entry_type,
Err(error) => {
- result = result.and(Err(Error::FileTypeError(error)));
+ result = result.and(Err(Error::FileType(error)));
continue;
}
};
@@ -74,9 +74,8 @@ async fn clear_directory(path: &Path) -> Result<(), Error> {
} else {
fs::remove_dir_all(entry.path()).await
};
- result = result.and(
- removal.map_err(|e| Error::RemoveDirError(entry.path().display().to_string(), e)),
- );
+ result = result
+ .and(removal.map_err(|e| Error::RemoveDir(entry.path().display().to_string(), e)));
}
result
}
diff --git a/mullvad-daemon/src/device/api.rs b/mullvad-daemon/src/device/api.rs
index cee0186987..6e00b669ca 100644
--- a/mullvad-daemon/src/device/api.rs
+++ b/mullvad-daemon/src/device/api.rs
@@ -35,10 +35,10 @@ impl CurrentApiCall {
}
pub fn is_validating(&self) -> bool {
- match &self.current_call {
- Some(Call::Validation(_)) | Some(Call::OneshotKeyRotation(_)) => true,
- _ => false,
- }
+ matches!(
+ &self.current_call,
+ Some(Call::Validation(_)) | Some(Call::OneshotKeyRotation(_))
+ )
}
pub fn is_running_timed_totation(&self) -> bool {
@@ -51,10 +51,7 @@ impl CurrentApiCall {
pub fn is_logging_in(&self) -> bool {
use Call::*;
- match &self.current_call {
- Some(Login(..)) => true,
- _ => false,
- }
+ matches!(&self.current_call, Some(Login(..)))
}
}
diff --git a/mullvad-daemon/src/exception_logging/unix.rs b/mullvad-daemon/src/exception_logging/unix.rs
index 8d87be2da6..430fedb74f 100644
--- a/mullvad-daemon/src/exception_logging/unix.rs
+++ b/mullvad-daemon/src/exception_logging/unix.rs
@@ -5,7 +5,7 @@ use nix::sys::signal::{sigaction, SaFlags, SigAction, SigHandler, SigSet, Signal
use std::{convert::TryFrom, sync::Once};
-const INIT_ONCE: Once = Once::new();
+static INIT_ONCE: Once = Once::new();
const FAULT_SIGNALS: [Signal; 5] = [
// Access to invalid memory address
diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs
index 95039cd662..c6f024eb49 100644
--- a/mullvad-daemon/src/lib.rs
+++ b/mullvad-daemon/src/lib.rs
@@ -31,7 +31,7 @@ use crate::target_state::PersistentTargetState;
use device::{PrivateAccountAndDevice, PrivateDeviceEvent};
use futures::{
channel::{mpsc, oneshot},
- future::{abortable, AbortHandle, Future},
+ future::{abortable, AbortHandle, Future, LocalBoxFuture},
StreamExt,
};
use mullvad_relay_selector::{
@@ -385,6 +385,12 @@ pub struct DaemonCommandChannel {
receiver: mpsc::UnboundedReceiver<InternalDaemonEvent>,
}
+impl Default for DaemonCommandChannel {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
impl DaemonCommandChannel {
pub fn new() -> Self {
let (untracked_sender, receiver) = mpsc::unbounded();
@@ -472,13 +478,13 @@ impl<E> Sender<E> for DaemonEventSender<E>
where
InternalDaemonEvent: From<E>,
{
- fn send(&self, event: E) -> Result<(), ()> {
+ fn send(&self, event: E) -> Result<(), talpid_core::mpsc::Error> {
if let Some(sender) = self.sender.upgrade() {
sender
.unbounded_send(InternalDaemonEvent::from(event))
- .map_err(|_| ())
+ .map_err(|_| talpid_core::mpsc::Error::ChannelClosed)
} else {
- Err(())
+ Err(talpid_core::mpsc::Error::ChannelClosed)
}
}
}
@@ -684,7 +690,7 @@ where
relay_list_listener.notify_relay_list(relay_list.clone());
};
- let mut relay_list_updater = RelayListUpdater::new(
+ let mut relay_list_updater = RelayListUpdater::spawn(
relay_selector.clone(),
api_handle.clone(),
&cache_dir,
@@ -785,11 +791,11 @@ where
/// Shuts down the daemon without shutting down the underlying event listener and the shutdown
/// callbacks
- fn shutdown(
+ fn shutdown<'a>(
self,
) -> (
L,
- Vec<Pin<Box<dyn Future<Output = ()>>>>,
+ Vec<LocalBoxFuture<'a, ()>>,
mullvad_api::Runtime,
TunnelStateMachineHandle,
) {
@@ -845,11 +851,11 @@ where
TunnelStateTransition::Disconnected => TunnelState::Disconnected,
TunnelStateTransition::Connecting(endpoint) => TunnelState::Connecting {
endpoint,
- location: self.parameters_generator.get_last_location(),
+ location: self.parameters_generator.get_last_location().await,
},
TunnelStateTransition::Connected(endpoint) => TunnelState::Connected {
endpoint,
- location: self.parameters_generator.get_last_location(),
+ location: self.parameters_generator.get_last_location().await,
},
TunnelStateTransition::Disconnecting(after_disconnect) => {
TunnelState::Disconnecting(after_disconnect)
@@ -1184,7 +1190,7 @@ where
}
Disconnecting(..) => Self::oneshot_send(
tx,
- self.parameters_generator.get_last_location(),
+ self.parameters_generator.get_last_location().await,
"current location",
),
Connected { location, .. } => {
@@ -1703,7 +1709,8 @@ where
Self::oneshot_send(tx, Ok(()), "use_wireguard_nt response");
if settings_changed {
self.parameters_generator
- .set_tunnel_options(&self.settings.tunnel_options);
+ .set_tunnel_options(&self.settings.tunnel_options)
+ .await;
self.event_listener
.notify_settings(self.settings.to_settings());
if let Some(TunnelType::Wireguard) = self.get_target_tunnel_type() {
@@ -1854,7 +1861,8 @@ where
Self::oneshot_send(tx, Ok(()), "set_openvpn_mssfix response");
if settings_changed {
self.parameters_generator
- .set_tunnel_options(&self.settings.tunnel_options);
+ .set_tunnel_options(&self.settings.tunnel_options)
+ .await;
self.event_listener
.notify_settings(self.settings.to_settings());
if self.get_target_tunnel_type() == Some(TunnelType::OpenVpn) {
@@ -1963,7 +1971,8 @@ where
Self::oneshot_send(tx, Ok(()), "set_enable_ipv6 response");
if settings_changed {
self.parameters_generator
- .set_tunnel_options(&self.settings.tunnel_options);
+ .set_tunnel_options(&self.settings.tunnel_options)
+ .await;
self.event_listener
.notify_settings(self.settings.to_settings());
log::info!("Initiating tunnel restart because the enable IPv6 setting changed");
@@ -1991,7 +2000,8 @@ where
Self::oneshot_send(tx, Ok(()), "set_quantum_resistant_tunnel response");
if settings_changed {
self.parameters_generator
- .set_tunnel_options(&self.settings.tunnel_options);
+ .set_tunnel_options(&self.settings.tunnel_options)
+ .await;
self.event_listener
.notify_settings(self.settings.to_settings());
if self.get_target_tunnel_type() == Some(TunnelType::Wireguard) {
@@ -2021,7 +2031,8 @@ where
let resolvers =
dns::addresses_from_options(&settings.tunnel_options.dns_options);
self.parameters_generator
- .set_tunnel_options(&settings.tunnel_options);
+ .set_tunnel_options(&settings.tunnel_options)
+ .await;
self.event_listener.notify_settings(settings);
self.send_tunnel_command(TunnelCommand::Dns(resolvers));
}
@@ -2044,7 +2055,8 @@ where
Self::oneshot_send(tx, Ok(()), "set_wireguard_mtu response");
if settings_changed {
self.parameters_generator
- .set_tunnel_options(&self.settings.tunnel_options);
+ .set_tunnel_options(&self.settings.tunnel_options)
+ .await;
self.event_listener
.notify_settings(self.settings.to_settings());
if let Some(TunnelType::Wireguard) = self.get_connected_tunnel_type() {
@@ -2086,7 +2098,8 @@ where
);
}
self.parameters_generator
- .set_tunnel_options(&self.settings.tunnel_options);
+ .set_tunnel_options(&self.settings.tunnel_options)
+ .await;
self.event_listener
.notify_settings(self.settings.to_settings());
}
diff --git a/mullvad-daemon/src/management_interface.rs b/mullvad-daemon/src/management_interface.rs
index 7999fd9c55..26ad5e39c0 100644
--- a/mullvad-daemon/src/management_interface.rs
+++ b/mullvad-daemon/src/management_interface.rs
@@ -151,7 +151,7 @@ impl ManagementService for ManagementServiceImpl {
self.send_command_to_daemon(DaemonCommand::GetVersionInfo(tx))?;
self.wait_for_result(rx)
.await?
- .ok_or(Status::not_found("no version cache"))
+ .ok_or_else(|| Status::not_found("no version cache"))
.map(types::AppVersionInfo::from)
.map(Response::new)
}
diff --git a/mullvad-daemon/src/migrations/account_history.rs b/mullvad-daemon/src/migrations/account_history.rs
index 22534c7f88..520717e405 100644
--- a/mullvad-daemon/src/migrations/account_history.rs
+++ b/mullvad-daemon/src/migrations/account_history.rs
@@ -53,12 +53,12 @@ pub async fn migrate_formats(settings_dir: &Path, settings: &mut serde_json::Val
.read(true)
.open(path)
.await
- .map_err(Error::ReadHistoryError)?;
+ .map_err(Error::ReadHistory)?;
let mut bytes = vec![];
file.read_to_end(&mut bytes)
.await
- .map_err(Error::ReadHistoryError)?;
+ .map_err(Error::ReadHistory)?;
if is_format_v3(&bytes) {
return Ok(());
@@ -92,16 +92,16 @@ fn is_format_v3(bytes: &[u8]) -> bool {
}
async fn write_format_v3(mut file: File, token: Option<AccountToken>) -> Result<()> {
- file.set_len(0).await.map_err(Error::WriteHistoryError)?;
+ file.set_len(0).await.map_err(Error::WriteHistory)?;
file.seek(io::SeekFrom::Start(0))
.await
- .map_err(Error::WriteHistoryError)?;
+ .map_err(Error::WriteHistory)?;
if let Some(token) = token {
file.write_all(token.as_bytes())
.await
- .map_err(Error::WriteHistoryError)?;
+ .map_err(Error::WriteHistory)?;
}
- file.sync_all().await.map_err(Error::WriteHistoryError)
+ file.sync_all().await.map_err(Error::WriteHistory)
}
fn try_format_v2(bytes: &[u8]) -> Result<Option<(AccountToken, serde_json::Value)>> {
diff --git a/mullvad-daemon/src/migrations/mod.rs b/mullvad-daemon/src/migrations/mod.rs
index bb1e9d1ba0..b4a1d18979 100644
--- a/mullvad-daemon/src/migrations/mod.rs
+++ b/mullvad-daemon/src/migrations/mod.rs
@@ -57,31 +57,31 @@ const SETTINGS_FILE: &str = "settings.json";
#[error(no_from)]
pub enum Error {
#[error(display = "Failed to read the settings")]
- ReadError(#[error(source)] io::Error),
+ Read(#[error(source)] io::Error),
#[error(display = "Malformed settings")]
- ParseError(#[error(source)] serde_json::Error),
+ Parse(#[error(source)] serde_json::Error),
#[error(display = "Unable to read any version of the settings")]
NoMatchingVersion,
#[error(display = "Unable to serialize settings to JSON")]
- SerializeError(#[error(source)] serde_json::Error),
+ Serialize(#[error(source)] serde_json::Error),
#[error(display = "Unable to open settings for writing")]
- OpenError(#[error(source)] io::Error),
+ Open(#[error(source)] io::Error),
#[error(display = "Unable to write new settings")]
- WriteError(#[error(source)] io::Error),
+ Write(#[error(source)] io::Error),
#[error(display = "Unable to sync settings to disk")]
- SyncError(#[error(source)] io::Error),
+ SyncSettings(#[error(source)] io::Error),
#[error(display = "Failed to read the account history")]
- ReadHistoryError(#[error(source)] io::Error),
+ ReadHistory(#[error(source)] io::Error),
#[error(display = "Failed to write new account history")]
- WriteHistoryError(#[error(source)] io::Error),
+ WriteHistory(#[error(source)] io::Error),
#[error(display = "Failed to parse account history")]
ParseHistoryError,
@@ -129,10 +129,10 @@ pub(crate) async fn migrate_all(
return Ok(None);
}
- let settings_bytes = fs::read(&path).await.map_err(Error::ReadError)?;
+ let settings_bytes = fs::read(&path).await.map_err(Error::Read)?;
let mut settings: serde_json::Value =
- serde_json::from_reader(&settings_bytes[..]).map_err(Error::ParseError)?;
+ serde_json::from_reader(&settings_bytes[..]).map_err(Error::Parse)?;
if !settings.is_object() {
return Err(Error::NoMatchingVersion);
@@ -155,7 +155,7 @@ pub(crate) async fn migrate_all(
return Ok(migration_data);
}
- let buffer = serde_json::to_string_pretty(&settings).map_err(Error::SerializeError)?;
+ let buffer = serde_json::to_string_pretty(&settings).map_err(Error::Serialize)?;
let mut options = fs::OpenOptions::new();
#[cfg(unix)]
@@ -168,11 +168,11 @@ pub(crate) async fn migrate_all(
.truncate(true)
.open(&path)
.await
- .map_err(Error::OpenError)?;
+ .map_err(Error::Open)?;
file.write_all(&buffer.into_bytes())
.await
- .map_err(Error::WriteError)?;
- file.sync_data().await.map_err(Error::SyncError)?;
+ .map_err(Error::Write)?;
+ file.sync_data().await.map_err(Error::SyncSettings)?;
log::debug!("Migrated settings. Wrote settings to {}", path.display());
diff --git a/mullvad-daemon/src/migrations/v2.rs b/mullvad-daemon/src/migrations/v2.rs
index e91a0d08e8..d4acbf77a7 100644
--- a/mullvad-daemon/src/migrations/v2.rs
+++ b/mullvad-daemon/src/migrations/v2.rs
@@ -1,3 +1,4 @@
+#![allow(clippy::identity_op)]
use super::{Error, Result};
use mullvad_types::settings::SettingsVersion;
use std::time::Duration;
diff --git a/mullvad-daemon/src/migrations/v3.rs b/mullvad-daemon/src/migrations/v3.rs
index cf8631e121..7d2800e32a 100644
--- a/mullvad-daemon/src/migrations/v3.rs
+++ b/mullvad-daemon/src/migrations/v3.rs
@@ -66,7 +66,7 @@ pub fn migrate(settings: &mut serde_json::Value) -> Result<()> {
DnsState::Default
};
let addresses = if let Some(addrs) = options.get("addresses") {
- serde_json::from_value(addrs.clone()).map_err(Error::ParseError)?
+ serde_json::from_value(addrs.clone()).map_err(Error::Parse)?
} else {
vec![]
};
diff --git a/mullvad-daemon/src/migrations/v4.rs b/mullvad-daemon/src/migrations/v4.rs
index 6908b13010..77b72bcb3e 100644
--- a/mullvad-daemon/src/migrations/v4.rs
+++ b/mullvad-daemon/src/migrations/v4.rs
@@ -43,8 +43,7 @@ pub fn migrate(settings: &mut serde_json::Value) -> Result<()> {
if let Some(constraints) = wireguard_constraints {
let (port, protocol): (Constraint<u16>, TransportProtocol) =
if let Some(port) = constraints.get("port") {
- let port_constraint =
- serde_json::from_value(port.clone()).map_err(Error::ParseError)?;
+ let port_constraint = serde_json::from_value(port.clone()).map_err(Error::Parse)?;
match port_constraint {
Constraint::Any => (Constraint::Any, TransportProtocol::Udp),
Constraint::Only(port) => (Constraint::Only(port), wg_protocol_from_port(port)),
@@ -77,13 +76,13 @@ pub fn migrate(settings: &mut serde_json::Value) -> Result<()> {
if let Some(constraints) = openvpn_constraints {
let port: Constraint<u16> = if let Some(port) = constraints.get("port") {
- serde_json::from_value(port.clone()).map_err(Error::ParseError)?
+ serde_json::from_value(port.clone()).map_err(Error::Parse)?
} else {
Constraint::Any
};
let transport_constraint: Constraint<TransportProtocol> =
if let Some(protocol) = constraints.get("protocol") {
- serde_json::from_value(protocol.clone()).map_err(Error::ParseError)?
+ serde_json::from_value(protocol.clone()).map_err(Error::Parse)?
} else {
Constraint::Any
};
diff --git a/mullvad-daemon/src/migrations/v5.rs b/mullvad-daemon/src/migrations/v5.rs
index 9f0fdc4b94..cfc74d8438 100644
--- a/mullvad-daemon/src/migrations/v5.rs
+++ b/mullvad-daemon/src/migrations/v5.rs
@@ -95,7 +95,7 @@ pub(crate) async fn migrate(settings: &mut serde_json::Value) -> Result<Option<M
//
if let Some(port) = wireguard_constraints.get("port") {
let port_constraint: Constraint<TransportPort> =
- serde_json::from_value(port.clone()).map_err(Error::ParseError)?;
+ serde_json::from_value(port.clone()).map_err(Error::Parse)?;
if let Some(transport_port) = port_constraint.option() {
let (port, obfuscation_settings) = match transport_port.protocol {
TransportProtocol::Udp => (serde_json::json!(transport_port.port), None),
@@ -116,8 +116,7 @@ pub(crate) async fn migrate(settings: &mut serde_json::Value) -> Result<Option<M
let migration_data = if let Some(token) = settings.get("account_token").filter(|t| !t.is_null())
{
- let token: AccountToken =
- serde_json::from_value(token.clone()).map_err(Error::ParseError)?;
+ let token: AccountToken = serde_json::from_value(token.clone()).map_err(Error::Parse)?;
let migration_data =
if let Some(wg_data) = settings.get("wireguard").filter(|wg| !wg.is_null()) {
Some(MigrationData {
diff --git a/mullvad-daemon/src/tunnel.rs b/mullvad-daemon/src/tunnel.rs
index e95850c4f4..18b8bf2c20 100644
--- a/mullvad-daemon/src/tunnel.rs
+++ b/mullvad-daemon/src/tunnel.rs
@@ -1,8 +1,6 @@
-use std::{
- future::Future,
- pin::Pin,
- sync::{Arc, Mutex},
-};
+use std::{future::Future, pin::Pin, sync::Arc};
+
+use tokio::sync::Mutex;
use mullvad_relay_selector::{RelaySelector, SelectedBridge, SelectedObfuscator, SelectedRelay};
use mullvad_types::{
@@ -32,7 +30,7 @@ pub enum Error {
NoBridgeAvailable,
#[error(display = "Failed to resolve hostname for custom relay")]
- ResolveCustomHostnameError,
+ ResolveCustomHostname,
}
#[derive(Clone)]
@@ -65,13 +63,13 @@ impl ParametersGenerator {
}
/// Sets the tunnel options to use when generating new tunnel parameters.
- pub fn set_tunnel_options(&self, tunnel_options: &TunnelOptions) {
- self.0.lock().unwrap().tunnel_options = tunnel_options.clone();
+ pub async fn set_tunnel_options(&self, tunnel_options: &TunnelOptions) {
+ self.0.lock().await.tunnel_options = tunnel_options.clone();
}
/// Gets the location associated with the last generated tunnel parameters.
- pub fn get_last_location(&self) -> Option<GeoIpLocation> {
- let inner = self.0.lock().unwrap();
+ pub async fn get_last_location(&self) -> Option<GeoIpLocation> {
+ let inner = self.0.lock().await;
let relays = inner.last_generated_relays.as_ref()?;
@@ -131,7 +129,7 @@ impl InnerParametersGenerator {
.to_tunnel_parameters(self.tunnel_options.clone(), None)
.map_err(|e| {
log::error!("Failed to resolve hostname for custom tunnel config: {}", e);
- Error::ResolveCustomHostnameError
+ Error::ResolveCustomHostname
})
}
Ok((SelectedRelay::Normal(constraints), bridge, obfuscator)) => {
@@ -246,13 +244,13 @@ impl TunnelParametersGenerator for ParametersGenerator {
) -> Pin<Box<dyn Future<Output = Result<TunnelParameters, ParameterGenerationError>>>> {
let generator = self.0.clone();
Box::pin(async move {
- let mut inner = generator.lock().unwrap();
+ let mut inner = generator.lock().await;
inner
.generate(retry_attempt)
.await
.map_err(|error| match error {
Error::NoBridgeAvailable => ParameterGenerationError::NoMatchingBridgeRelay,
- Error::ResolveCustomHostnameError => {
+ Error::ResolveCustomHostname => {
ParameterGenerationError::CustomTunnelHostResultionError
}
error => {
diff --git a/mullvad-daemon/src/version_check.rs b/mullvad-daemon/src/version_check.rs
index ffa5abc979..10dbf7bfb4 100644
--- a/mullvad-daemon/src/version_check.rs
+++ b/mullvad-daemon/src/version_check.rs
@@ -14,6 +14,7 @@ use std::{
future::Future,
io,
path::{Path, PathBuf},
+ str::FromStr,
time::Duration,
};
use talpid_core::mpsc::Sender;
@@ -297,10 +298,10 @@ impl VersionUpdater {
if !*IS_DEV_BUILD {
let stable_version = latest_stable
.as_ref()
- .and_then(|stable| ParsedAppVersion::from_str(stable));
+ .and_then(|stable| ParsedAppVersion::from_str(stable).ok());
let beta_version = if show_beta {
- ParsedAppVersion::from_str(latest_beta)
+ ParsedAppVersion::from_str(latest_beta).ok()
} else {
None
};
@@ -339,10 +340,10 @@ impl VersionUpdater {
let mut check_delay = next_delay();
let mut version_check = futures::future::Fuse::terminated();
- // If this is a dev build ,there's no need to pester the API for version checks.
+ // If this is a dev build, there's no need to pester the API for version checks.
if *IS_DEV_BUILD {
log::warn!("Not checking for updates because this is a development build");
- while let Some(_) = rx.next().await {}
+ while rx.next().await.is_some() {}
return;
}