diff --git a/ios/TunnelObfuscation/tunnel-obfuscator-proxy/src/ffi.rs b/ios/TunnelObfuscation/tunnel-obfuscator-proxy/src/ffi.rs index 1f7e5741d81c..c652b43e243e 100644 --- a/ios/TunnelObfuscation/tunnel-obfuscator-proxy/src/ffi.rs +++ b/ios/TunnelObfuscation/tunnel-obfuscator-proxy/src/ffi.rs @@ -1,8 +1,10 @@ #![cfg(target_os = "ios")] use super::{TunnelObfuscatorHandle, TunnelObfuscatorRuntime}; -use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}; -use std::sync::Once; +use std::{ + net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}, + sync::Once, +}; static INIT_LOGGING: Once = Once::new(); diff --git a/ios/TunnelObfuscation/tunnel-obfuscator-proxy/src/lib.rs b/ios/TunnelObfuscation/tunnel-obfuscator-proxy/src/lib.rs index 09ac816bfa59..198c7f4922dc 100644 --- a/ios/TunnelObfuscation/tunnel-obfuscator-proxy/src/lib.rs +++ b/ios/TunnelObfuscation/tunnel-obfuscator-proxy/src/lib.rs @@ -1,7 +1,6 @@ #![cfg(target_os = "ios")] -use std::io; -use std::net::SocketAddr; +use std::{io, net::SocketAddr}; use tokio::sync::oneshot; use tunnel_obfuscation::{create_obfuscator, Settings as ObfuscationSettings, Udp2TcpSettings}; diff --git a/mullvad-api/src/lib.rs b/mullvad-api/src/lib.rs index e66896a1b04d..ae7929deeca5 100644 --- a/mullvad-api/src/lib.rs +++ b/mullvad-api/src/lib.rs @@ -9,7 +9,6 @@ use mullvad_types::{ version::AppVersion, }; use proxy::ApiConnectionMode; -use std::sync::OnceLock; use std::{ cell::Cell, collections::BTreeMap, @@ -17,6 +16,7 @@ use std::{ net::{IpAddr, Ipv4Addr, SocketAddr}, ops::Deref, path::Path, + sync::OnceLock, }; use talpid_types::{net::AllowedEndpoint, ErrorExt}; diff --git a/mullvad-api/src/proxy.rs b/mullvad-api/src/proxy.rs index caf2068abb3a..3c7d071d9282 100644 --- a/mullvad-api/src/proxy.rs +++ b/mullvad-api/src/proxy.rs @@ -7,9 +7,8 @@ use std::{ pin::Pin, task::{self, Poll}, }; -use talpid_types::net::proxy; use talpid_types::{ - net::{AllowedClients, Endpoint, TransportProtocol}, + net::{proxy, AllowedClients, Endpoint, TransportProtocol}, ErrorExt, }; use tokio::{ diff --git a/mullvad-cli/src/cmds/api_access.rs b/mullvad-cli/src/cmds/api_access.rs index 887d378fa4ca..8883ea516b8d 100644 --- a/mullvad-cli/src/cmds/api_access.rs +++ b/mullvad-cli/src/cmds/api_access.rs @@ -26,9 +26,11 @@ pub enum ApiAccess { Enable(SelectItem), /// Disable an API access method Disable(SelectItem), - /// Try to use a specific API access method (If the API is unreachable, reverts back to the previous access method) + /// Try to use a specific API access method (If the API is unreachable, reverts back to the + /// previous access method) /// - /// Selecting "Direct" will connect to the Mullvad API without going through any proxy. This connection use https and is therefore encrypted. + /// Selecting "Direct" will connect to the Mullvad API without going through any proxy. This + /// connection use https and is therefore encrypted. /// /// Selecting "Mullvad Bridges" respects your current bridge settings Use(SelectItem), diff --git a/mullvad-cli/src/cmds/import_settings.rs b/mullvad-cli/src/cmds/import_settings.rs index a354eb4b95d0..a89c6814c336 100644 --- a/mullvad-cli/src/cmds/import_settings.rs +++ b/mullvad-cli/src/cmds/import_settings.rs @@ -9,8 +9,8 @@ use std::{ /// Maximum size of a settings patch. Bigger files/streams cause the read to fail. const MAX_PATCH_BYTES: usize = 10 * 1024; -/// If source is specified, read from the provided file and send it as a settings patch to the daemon. -/// Otherwise, read the patch from standard input. +/// If source is specified, read from the provided file and send it as a settings patch to the +/// daemon. Otherwise, read the patch from standard input. pub async fn handle(source: String) -> Result<()> { let json_blob = tokio::task::spawn_blocking(|| get_blob(source)) .await diff --git a/mullvad-daemon/src/api.rs b/mullvad-daemon/src/api.rs index c13bf77dedb7..efb8f3088d2d 100644 --- a/mullvad-daemon/src/api.rs +++ b/mullvad-daemon/src/api.rs @@ -49,9 +49,9 @@ impl std::fmt::Display for Message { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Message::Get(_) => f.write_str("Get"), - Message::Set(_, _) => f.write_str("Set"), + Message::Set(..) => f.write_str("Set"), Message::Next(_) => f.write_str("Next"), - Message::Update(_, _) => f.write_str("Update"), + Message::Update(..) => f.write_str("Update"), } } } diff --git a/mullvad-daemon/src/device/mod.rs b/mullvad-daemon/src/device/mod.rs index 70d491b4c6bb..ac65e2fbd5c7 100644 --- a/mullvad-daemon/src/device/mod.rs +++ b/mullvad-daemon/src/device/mod.rs @@ -1347,8 +1347,7 @@ impl TunnelStateChangeHandler { #[cfg(test)] mod test { - use super::TunnelStateChangeHandler; - use super::{Error, WG_DEVICE_CHECK_THRESHOLD}; + use super::{Error, TunnelStateChangeHandler, WG_DEVICE_CHECK_THRESHOLD}; use mullvad_relay_selector::RelaySelector; use std::sync::{ atomic::{AtomicBool, Ordering}, diff --git a/mullvad-daemon/src/exception_logging/unix.rs b/mullvad-daemon/src/exception_logging/unix.rs index 4cb3a35ac5a5..45948224b9e5 100644 --- a/mullvad-daemon/src/exception_logging/unix.rs +++ b/mullvad-daemon/src/exception_logging/unix.rs @@ -3,8 +3,11 @@ use libc::siginfo_t; use nix::sys::signal::{sigaction, SaFlags, SigAction, SigHandler, SigSet, Signal}; -use std::ffi::{c_int, c_void}; -use std::{convert::TryFrom, sync::Once}; +use std::{ + convert::TryFrom, + ffi::{c_int, c_void}, + sync::Once, +}; static INIT_ONCE: Once = Once::new(); diff --git a/mullvad-daemon/src/migrations/mod.rs b/mullvad-daemon/src/migrations/mod.rs index 5d13372a07d7..363c0bd2828e 100644 --- a/mullvad-daemon/src/migrations/mod.rs +++ b/mullvad-daemon/src/migrations/mod.rs @@ -25,8 +25,8 @@ //! # Creating a migration //! //! 1. Copy `vX.rs.template` to `vX.rs` where `X` is the latest settings version right now. -//! 1. Add the new version (`Y = X+1`) to `SettingsVersion` and bump `CURRENT_SETTINGS_VERSION` -//! to `Y`. +//! 1. Add the new version (`Y = X+1`) to `SettingsVersion` and bump `CURRENT_SETTINGS_VERSION` to +//! `Y`. //! 1. Write a comment in the new module about how the format changed, what it needs to migrate. //! 1. Implement the migration and add adequate tests. //! 1. Add to the changelog: "Settings format updated to `vY`" diff --git a/mullvad-daemon/src/migrations/v7.rs b/mullvad-daemon/src/migrations/v7.rs index 1453685e57d9..4baf49b5719a 100644 --- a/mullvad-daemon/src/migrations/v7.rs +++ b/mullvad-daemon/src/migrations/v7.rs @@ -80,7 +80,6 @@ pub struct ShadowsocksProxySettings { /// - shadowsocks.peer to shadowsocks.endpoint /// - socks5_remote.authentication to socks5_remote.auth /// - socks5_remote.peer to socks5_remote.endpoint -/// pub fn migrate(settings: &mut serde_json::Value) -> Result<()> { if !version_matches(settings) { return Ok(()); @@ -254,7 +253,6 @@ mod test { use crate::migrations::v7::{migrate_api_access_settings, migrate_bridge_settings}; use super::{migrate, version_matches}; - use serde_json; pub const V7_SETTINGS: &str = r#" { diff --git a/mullvad-daemon/src/settings/mod.rs b/mullvad-daemon/src/settings/mod.rs index 8a63b5c5a663..47a2edc98984 100644 --- a/mullvad-daemon/src/settings/mod.rs +++ b/mullvad-daemon/src/settings/mod.rs @@ -528,7 +528,7 @@ mod test { ); assert!( - settings.block_when_disconnected == false, + !settings.block_when_disconnected, "The daemon should not block the internet if settings are missing" ); } diff --git a/mullvad-daemon/src/tunnel.rs b/mullvad-daemon/src/tunnel.rs index 7af7adc4d0e8..a19c81740cd9 100644 --- a/mullvad-daemon/src/tunnel.rs +++ b/mullvad-daemon/src/tunnel.rs @@ -217,7 +217,8 @@ impl InnerParametersGenerator { private_key: data.device.wg_data.private_key, addresses: vec![IpAddr::from(tunnel_ipv4), IpAddr::from(tunnel_ipv6)], }; - // FIXME: Used for debugging purposes during the migration to same IP. Remove when the migration is over. + // FIXME: Used for debugging purposes during the migration to same IP. Remove when + // the migration is over. if tunnel_ipv4 == *SAME_IP_V4 || tunnel_ipv6 == *SAME_IP_V6 { log::debug!("Same IP is being used"); } else { diff --git a/mullvad-nsis/src/lib.rs b/mullvad-nsis/src/lib.rs index 24e1e86f77bc..7dd707b5e099 100644 --- a/mullvad-nsis/src/lib.rs +++ b/mullvad-nsis/src/lib.rs @@ -20,8 +20,8 @@ pub enum Status { /// Max path size allowed const MAX_PATH_SIZE: isize = 32_767; -/// SAFETY: path needs to be a windows path encoded as a string of u16 that terminates in 0 (two nul-bytes). -/// The string is also not allowed to be greater than `MAX_PATH_SIZE`. +/// SAFETY: path needs to be a windows path encoded as a string of u16 that terminates in 0 (two +/// nul-bytes). The string is also not allowed to be greater than `MAX_PATH_SIZE`. #[no_mangle] pub unsafe extern "C" fn create_privileged_directory(path: *const u16) -> Status { catch_and_log_unwind(|| { diff --git a/mullvad-paths/src/windows.rs b/mullvad-paths/src/windows.rs index e41f9faec9f7..912831a53c1f 100644 --- a/mullvad-paths/src/windows.rs +++ b/mullvad-paths/src/windows.rs @@ -67,7 +67,8 @@ fn get_wide_str>(string: S) -> Vec { /// Recursively creates directories, if set_security_permissions is true it will set /// file permissions corresponding to Authenticated Users - Read Only and Administrators - Full -/// Access. Only directories that do not already exist and the leaf directory will have their permissions set. +/// Access. Only directories that do not already exist and the leaf directory will have their +/// permissions set. pub fn create_dir_recursive(path: &Path, set_security_permissions: bool) -> Result<()> { if set_security_permissions { create_dir_with_permissions_recursive(path) @@ -114,7 +115,8 @@ fn create_dir_with_permissions_recursive(path: &Path) -> Result<()> { // Create parent directory Some(parent) => create_dir_with_permissions_recursive(parent)?, None => { - // Reached the top of the tree but when creating directories only got NotFound for some reason + // Reached the top of the tree but when creating directories only got NotFound for some + // reason return Err(Error::CreateDirFailed( path.display().to_string(), io::Error::new( @@ -129,13 +131,15 @@ fn create_dir_with_permissions_recursive(path: &Path) -> Result<()> { set_security_permissions(path) } -/// Recursively creates directories for the given path with permissions that give full access to admins and read only access to authenticated users. -/// If any of the directories already exist this will not return an error, instead it will apply the permissions and if successful return Ok(()). +/// Recursively creates directories for the given path with permissions that give full access to +/// admins and read only access to authenticated users. If any of the directories already exist this +/// will not return an error, instead it will apply the permissions and if successful return Ok(()). pub fn create_privileged_directory(path: &Path) -> Result<()> { create_dir_with_permissions_recursive(path) } -/// Sets security permissions for path such that admin has full ownership and access while authenticated users only have read access. +/// Sets security permissions for path such that admin has full ownership and access while +/// authenticated users only have read access. fn set_security_permissions(path: &Path) -> Result<()> { let wide_path = get_wide_str(path); let security_information = Security::DACL_SECURITY_INFORMATION diff --git a/mullvad-types/src/account.rs b/mullvad-types/src/account.rs index bb59f14fb173..d3c54d5bcdf6 100644 --- a/mullvad-types/src/account.rs +++ b/mullvad-types/src/account.rs @@ -49,7 +49,8 @@ pub struct VoucherSubmission { pub new_expiry: DateTime, } -/// `PlayPurchase` is provided to google in order to verify that a google play purchase was acknowledged. +/// `PlayPurchase` is provided to google in order to verify that a google play purchase was +/// acknowledged. #[derive(Deserialize, Serialize, Debug, Clone)] #[cfg_attr(target_os = "android", derive(FromJava))] #[cfg_attr(target_os = "android", jnix(package = "net.mullvad.mullvadvpn.model"))] diff --git a/talpid-core/src/dns/windows/iphlpapi.rs b/talpid-core/src/dns/windows/iphlpapi.rs index f9aba7006564..e48b3b65f593 100644 --- a/talpid-core/src/dns/windows/iphlpapi.rs +++ b/talpid-core/src/dns/windows/iphlpapi.rs @@ -80,9 +80,9 @@ impl IphlpApi { return Err(Error::LoadDll(io::Error::last_os_error())); } - // This function is loaded at runtime since it may be unavailable. See the module-level docs. - // TODO: `windows_sys` can be used directly when support for versions older than Windows 10, - // 2004, is dropped. + // This function is loaded at runtime since it may be unavailable. See the module-level + // docs. TODO: `windows_sys` can be used directly when support for versions older + // than Windows 10, 2004, is dropped. let set_interface_dns_settings = unsafe { GetProcAddress(module, s!("SetInterfaceDnsSettings")) }; let set_interface_dns_settings = set_interface_dns_settings.ok_or_else(|| { diff --git a/talpid-core/src/firewall/macos.rs b/talpid-core/src/firewall/macos.rs index c851be507f59..07e74f45ffe4 100644 --- a/talpid-core/src/firewall/macos.rs +++ b/talpid-core/src/firewall/macos.rs @@ -294,8 +294,8 @@ impl Firewall { builder.build() } - /// Produces a rule that allows traffic to flow to the API. Allows the app (or other apps if configured) - /// to reach the API in blocked states. + /// Produces a rule that allows traffic to flow to the API. Allows the app (or other apps if + /// configured) to reach the API in blocked states. fn get_allowed_endpoint_rule( &self, allowed_endpoint: &AllowedEndpoint, diff --git a/talpid-core/src/firewall/windows.rs b/talpid-core/src/firewall/windows.rs index f26102820a3c..c751a283a52f 100644 --- a/talpid-core/src/firewall/windows.rs +++ b/talpid-core/src/firewall/windows.rs @@ -153,8 +153,8 @@ impl Firewall { protocol: WinFwProt::from(endpoint.endpoint.protocol), }; - // SAFETY: `endpoint1_ip`, `endpoint2_ip`, `endpoint1`, `endpoint2`, `relay_client_wstrs` must not be dropped - // until `WinFw_ApplyPolicyConnecting` has returned. + // SAFETY: `endpoint1_ip`, `endpoint2_ip`, `endpoint1`, `endpoint2`, `relay_client_wstrs` + // must not be dropped until `WinFw_ApplyPolicyConnecting` has returned. let relay_client_wstrs: Vec<_> = endpoint .clients @@ -274,7 +274,8 @@ impl Firewall { None => ptr::null(), }; - // SAFETY: `relay_client_wstrs` must not be dropped until `WinFw_ApplyPolicyConnected` has returned. + // SAFETY: `relay_client_wstrs` must not be dropped until `WinFw_ApplyPolicyConnected` has + // returned. let relay_client_wstrs: Vec<_> = endpoint .clients .iter() diff --git a/talpid-openvpn/src/lib.rs b/talpid-openvpn/src/lib.rs index 47d1bc675a94..04f94a1a846e 100644 --- a/talpid-openvpn/src/lib.rs +++ b/talpid-openvpn/src/lib.rs @@ -755,8 +755,7 @@ mod event_server { task::{Context, Poll}, }; use talpid_tunnel::TunnelMetadata; - use talpid_types::net::proxy::CustomProxy; - use talpid_types::ErrorExt; + use talpid_types::{net::proxy::CustomProxy, ErrorExt}; use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; use tonic::{ self, diff --git a/talpid-openvpn/src/process/openvpn.rs b/talpid-openvpn/src/process/openvpn.rs index 84b9c8853464..c45c2c0a905a 100644 --- a/talpid-openvpn/src/process/openvpn.rs +++ b/talpid-openvpn/src/process/openvpn.rs @@ -440,8 +440,8 @@ impl OpenVpnProcHandle { }) } - /// Begins to kill the process, causing `wait()` to return. This function does not wait for the operation - /// to complete. + /// Begins to kill the process, causing `wait()` to return. This function does not wait for the + /// operation to complete. pub fn kill(&mut self, timeout: std::time::Duration) { if let Some(tx) = self.stop_tx.take() { let _ = tx.send(timeout); diff --git a/talpid-routing/src/unix/macos/mod.rs b/talpid-routing/src/unix/macos/mod.rs index 5b694029397b..ec5da51baec3 100644 --- a/talpid-routing/src/unix/macos/mod.rs +++ b/talpid-routing/src/unix/macos/mod.rs @@ -6,10 +6,10 @@ use futures::{ stream::{FusedStream, StreamExt}, }; use ipnetwork::IpNetwork; -use std::sync::Weak; use std::{ collections::{BTreeMap, HashSet}, pin::Pin, + sync::Weak, time::Duration, }; use talpid_types::ErrorExt; diff --git a/talpid-windows/src/net.rs b/talpid-windows/src/net.rs index 7147bb35b098..e9899743d6c1 100644 --- a/talpid-windows/src/net.rs +++ b/talpid-windows/src/net.rs @@ -11,7 +11,6 @@ use std::{ use talpid_types::win32_err; use windows_sys::{ core::GUID, - Win32::Networking::WinSock::SOCKADDR_STORAGE as sockaddr_storage, Win32::{ Foundation::{ERROR_NOT_FOUND, HANDLE}, NetworkManagement::{ @@ -30,6 +29,7 @@ use windows_sys::{ IpDadStateDeprecated, IpDadStateDuplicate, IpDadStateInvalid, IpDadStatePreferred, IpDadStateTentative, AF_INET, AF_INET6, AF_UNSPEC, IN6_ADDR, IN_ADDR, NL_DAD_STATE, SOCKADDR_IN as sockaddr_in, SOCKADDR_IN6 as sockaddr_in6, SOCKADDR_INET, + SOCKADDR_STORAGE as sockaddr_storage, }, }, };