diff options
38 files changed, 142 insertions, 138 deletions
diff --git a/mullvad-api/src/ffi/mod.rs b/mullvad-api/src/ffi/mod.rs index 7fc385d145..5eae180f01 100644 --- a/mullvad-api/src/ffi/mod.rs +++ b/mullvad-api/src/ffi/mod.rs @@ -7,9 +7,9 @@ use std::{ }; use crate::{ - AccountsProxy, ApiEndpoint, DevicesProxy, proxy::ApiConnectionMode, rest::{self, MullvadRestHandle}, + AccountsProxy, ApiEndpoint, DevicesProxy, }; mod device; diff --git a/mullvad-cli/src/cmds/relay.rs b/mullvad-cli/src/cmds/relay.rs index b56c2c2991..1f2d1f9192 100644 --- a/mullvad-cli/src/cmds/relay.rs +++ b/mullvad-cli/src/cmds/relay.rs @@ -944,33 +944,36 @@ pub async fn resolve_location_constraint( match relay_iter .clone() .find(|relay| relay.hostname.to_lowercase() == location_constraint_args.country) - { Some(matching_relay) => { - if relay_filter(&matching_relay) { - Ok(Constraint::Only(relay_to_geographical_constraint( - matching_relay, - ))) - } else { - bail!( - "The relay `{}` is not valid for this operation", - location_constraint_args.country - ) + { + Some(matching_relay) => { + if relay_filter(&matching_relay) { + Ok(Constraint::Only(relay_to_geographical_constraint( + matching_relay, + ))) + } else { + bail!( + "The relay `{}` is not valid for this operation", + location_constraint_args.country + ) + } } - } _ => { - // The Constraint was not a relay, assuming it to be a location - let location_constraint: Constraint<GeographicLocationConstraint> = - Constraint::from(location_constraint_args); + _ => { + // The Constraint was not a relay, assuming it to be a location + let location_constraint: Constraint<GeographicLocationConstraint> = + Constraint::from(location_constraint_args); - // If the location constraint was not "any", then validate the country/city - if let Constraint::Only(constraint) = &location_constraint { - let found = relay_iter.clone().any(|relay| constraint.matches(&relay)); + // If the location constraint was not "any", then validate the country/city + if let Constraint::Only(constraint) = &location_constraint { + let found = relay_iter.clone().any(|relay| constraint.matches(&relay)); - if !found { - bail!("Invalid location argument"); + if !found { + bail!("Invalid location argument"); + } } - } - Ok(location_constraint) - }} + Ok(location_constraint) + } + } } /// Return a list of all relays that are active and not bridges diff --git a/mullvad-daemon/src/access_method.rs b/mullvad-daemon/src/access_method.rs index a5980ec596..94f126a115 100644 --- a/mullvad-daemon/src/access_method.rs +++ b/mullvad-daemon/src/access_method.rs @@ -1,5 +1,5 @@ -use crate::{Daemon, api, settings}; -use mullvad_api::{ApiProxy, proxy::ApiConnectionMode, rest}; +use crate::{api, settings, Daemon}; +use mullvad_api::{proxy::ApiConnectionMode, rest, ApiProxy}; use mullvad_types::{ access_method::{self, AccessMethod, AccessMethodSetting}, settings::Settings, diff --git a/mullvad-daemon/src/android_dns.rs b/mullvad-daemon/src/android_dns.rs index 8409edd6e3..5cbc9c271a 100644 --- a/mullvad-daemon/src/android_dns.rs +++ b/mullvad-daemon/src/android_dns.rs @@ -3,8 +3,8 @@ use async_trait::async_trait; use hickory_resolver::{ - TokioAsyncResolver, config::{NameServerConfigGroup, ResolverConfig, ResolverOpts}, + TokioAsyncResolver, }; use mullvad_api::DnsResolver; use std::{io, net::SocketAddr}; diff --git a/mullvad-daemon/src/api.rs b/mullvad-daemon/src/api.rs index b37c628281..e07a5a7077 100644 --- a/mullvad-daemon/src/api.rs +++ b/mullvad-daemon/src/api.rs @@ -7,15 +7,15 @@ use crate::DaemonCommand; use crate::DaemonEventSender; use futures::{ - StreamExt, channel::{mpsc, oneshot}, + StreamExt, }; #[cfg(feature = "api-override")] use mullvad_api::ApiEndpoint; use mullvad_api::{ - AddressCache, availability::ApiAvailability, proxy::{ApiConnectionMode, ConnectionModeProvider, ProxyConfig}, + AddressCache, }; use mullvad_encrypted_dns_proxy::state::EncryptedDnsProxyState; use mullvad_relay_selector::RelaySelector; @@ -25,7 +25,7 @@ use mullvad_types::access_method::{ use std::{net::SocketAddr, path::PathBuf}; use talpid_core::mpsc::Sender; use talpid_types::net::{ - AllowedClients, AllowedEndpoint, Connectivity, Endpoint, TransportProtocol, proxy::CustomProxy, + proxy::CustomProxy, AllowedClients, AllowedEndpoint, Connectivity, Endpoint, TransportProtocol, }; pub enum Message { diff --git a/mullvad-daemon/src/api_address_updater.rs b/mullvad-daemon/src/api_address_updater.rs index d020038fca..de347daccb 100644 --- a/mullvad-daemon/src/api_address_updater.rs +++ b/mullvad-daemon/src/api_address_updater.rs @@ -2,7 +2,7 @@ //! Mullvad API. #[cfg(feature = "api-override")] use mullvad_api::ApiEndpoint; -use mullvad_api::{AddressCache, ApiProxy, rest::MullvadRestHandle}; +use mullvad_api::{rest::MullvadRestHandle, AddressCache, ApiProxy}; use std::time::Duration; const API_IP_CHECK_INITIAL: Duration = Duration::from_secs(15 * 60); diff --git a/mullvad-daemon/src/device/api.rs b/mullvad-daemon/src/device/api.rs index 93cfba8851..714df2dfb3 100644 --- a/mullvad-daemon/src/device/api.rs +++ b/mullvad-daemon/src/device/api.rs @@ -1,7 +1,7 @@ use std::pin::Pin; use chrono::{DateTime, Utc}; -use futures::{Future, future::FusedFuture}; +use futures::{future::FusedFuture, Future}; #[cfg(target_os = "android")] use mullvad_types::account::PlayPurchasePaymentToken; use mullvad_types::{account::VoucherSubmission, device::Device, wireguard::WireguardData}; diff --git a/mullvad-daemon/src/device/mod.rs b/mullvad-daemon/src/device/mod.rs index 7b0649a4d9..e6e89d8b24 100644 --- a/mullvad-daemon/src/device/mod.rs +++ b/mullvad-daemon/src/device/mod.rs @@ -19,16 +19,16 @@ use std::{ future::Future, path::Path, sync::{ - Arc, atomic::{AtomicBool, Ordering}, + Arc, }, time::{Duration, SystemTime}, }; use talpid_core::mpsc::Sender; use talpid_types::{ - ErrorExt, net::{TunnelEndpoint, TunnelType}, tunnel::TunnelStateTransition, + ErrorExt, }; use tokio::{ fs, @@ -1385,8 +1385,8 @@ impl TunnelStateChangeHandler { #[cfg(test)] mod test { use std::sync::{ - Arc, atomic::{AtomicBool, Ordering}, + Arc, }; use talpid_types::tunnel::TunnelStateTransition; diff --git a/mullvad-daemon/src/device/service.rs b/mullvad-daemon/src/device/service.rs index 32dc1bb4e1..3ebecf0483 100644 --- a/mullvad-daemon/src/device/service.rs +++ b/mullvad-daemon/src/device/service.rs @@ -1,7 +1,7 @@ use std::{future::Future, time::Duration}; use chrono::Utc; -use futures::future::{AbortHandle, abortable}; +use futures::future::{abortable, AbortHandle}; #[cfg(target_os = "android")] use mullvad_types::account::{PlayPurchase, PlayPurchasePaymentToken}; use mullvad_types::{ @@ -13,11 +13,11 @@ use talpid_types::net::wireguard::PrivateKey; use super::{Error, PrivateAccountAndDevice, PrivateDevice}; use mullvad_api::{ - AccountsProxy, DevicesProxy, availability::ApiAvailability, rest::{self, MullvadRestHandle}, + AccountsProxy, DevicesProxy, }; -use talpid_future::retry::{ConstantInterval, ExponentialBackoff, Jittered, retry_future}; +use talpid_future::retry::{retry_future, ConstantInterval, ExponentialBackoff, Jittered}; /// Retry strategy used for user-initiated actions that require immediate feedback const RETRY_ACTION_STRATEGY: ConstantInterval = ConstantInterval::new(Duration::ZERO, Some(3)); /// Retry strategy used for background tasks diff --git a/mullvad-daemon/src/exception_logging/unix.rs b/mullvad-daemon/src/exception_logging/unix.rs index 7b8940b984..b956db8319 100644 --- a/mullvad-daemon/src/exception_logging/unix.rs +++ b/mullvad-daemon/src/exception_logging/unix.rs @@ -2,17 +2,17 @@ #![warn(clippy::undocumented_unsafe_blocks)] use libc::siginfo_t; -use nix::sys::signal::{SaFlags, SigAction, SigHandler, SigSet, Signal, sigaction}; +use nix::sys::signal::{sigaction, SaFlags, SigAction, SigHandler, SigSet, Signal}; use core::fmt; use std::{ backtrace::Backtrace, env, - ffi::{CString, c_int, c_void}, + ffi::{c_int, c_void, CString}, os::fd::{FromRawFd, RawFd}, sync::{ - Once, OnceLock, atomic::{AtomicBool, Ordering}, + Once, OnceLock, }, }; diff --git a/mullvad-daemon/src/exception_logging/win.rs b/mullvad-daemon/src/exception_logging/win.rs index 9687de8db9..3fa50aa506 100644 --- a/mullvad-daemon/src/exception_logging/win.rs +++ b/mullvad-daemon/src/exception_logging/win.rs @@ -17,8 +17,8 @@ use windows_sys::Win32::{ System::{ Diagnostics::{ Debug::{ - CONTEXT, EXCEPTION_POINTERS, EXCEPTION_RECORD, MINIDUMP_EXCEPTION_INFORMATION, - MiniDumpNormal, MiniDumpWriteDump, SetUnhandledExceptionFilter, + MiniDumpNormal, MiniDumpWriteDump, SetUnhandledExceptionFilter, CONTEXT, + EXCEPTION_POINTERS, EXCEPTION_RECORD, MINIDUMP_EXCEPTION_INFORMATION, }, ToolHelp::TH32CS_SNAPMODULE, }, diff --git a/mullvad-daemon/src/geoip.rs b/mullvad-daemon/src/geoip.rs index 09d52ba824..815b83b13f 100644 --- a/mullvad-daemon/src/geoip.rs +++ b/mullvad-daemon/src/geoip.rs @@ -5,7 +5,7 @@ use mullvad_api::rest::{Error, RequestServiceHandle}; use mullvad_types::location::{AmIMullvad, GeoIpLocation, LocationEventData}; use std::sync::LazyLock; use talpid_core::mpsc::Sender; -use talpid_future::retry::{ExponentialBackoff, Jittered, retry_future}; +use talpid_future::retry::{retry_future, ExponentialBackoff, Jittered}; use talpid_types::ErrorExt; use crate::{DaemonEventSender, InternalDaemonEvent}; diff --git a/mullvad-daemon/src/leak_checker/mod.rs b/mullvad-daemon/src/leak_checker/mod.rs index 625c094290..e24c2358fe 100644 --- a/mullvad-daemon/src/leak_checker/mod.rs +++ b/mullvad-daemon/src/leak_checker/mod.rs @@ -1,4 +1,4 @@ -use futures::{FutureExt, select}; +use futures::{select, FutureExt}; pub use mullvad_leak_checker::LeakInfo; use std::time::Duration; use talpid_routing::RouteManagerHandle; @@ -167,8 +167,8 @@ async fn check_for_leaks( route_manager: &RouteManagerHandle, destination: Endpoint, ) -> anyhow::Result<Option<LeakInfo>> { - use anyhow::{Context, anyhow}; - use mullvad_leak_checker::{LeakStatus, traceroute::TracerouteOpt}; + use anyhow::{anyhow, Context}; + use mullvad_leak_checker::{traceroute::TracerouteOpt, LeakStatus}; #[cfg(target_os = "linux")] let interface = { diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs index 7fd3411fa8..1da90693fc 100644 --- a/mullvad-daemon/src/lib.rs +++ b/mullvad-daemon/src/lib.rs @@ -34,9 +34,9 @@ use crate::target_state::PersistentTargetState; use api::AccessMethodEvent; use device::{AccountEvent, PrivateAccountAndDevice, PrivateDeviceEvent}; use futures::{ - StreamExt, channel::{mpsc, oneshot}, - future::{AbortHandle, Future, abortable}, + future::{abortable, AbortHandle, Future}, + StreamExt, }; use geoip::GeoIpHandler; use leak_checker::{LeakChecker, LeakInfo}; @@ -55,7 +55,7 @@ use mullvad_types::{ auth_failed::AuthFailed, custom_list::CustomList, device::{Device, DeviceEvent, DeviceEventCause, DeviceId, DeviceState, RemoveDeviceEvent}, - features::{FeatureIndicator, FeatureIndicators, compute_feature_indicators}, + features::{compute_feature_indicators, FeatureIndicator, FeatureIndicators}, location::{GeoIpLocation, LocationEventData}, relay_constraints::{ BridgeSettings, BridgeState, BridgeType, ObfuscationSettings, RelayOverride, RelaySettings, @@ -66,7 +66,7 @@ use mullvad_types::{ version::{AppVersion, AppVersionInfo}, wireguard::{PublicKey, QuantumResistantState, RotationInterval}, }; -use relay_list::{RELAYS_FILENAME, RelayListUpdater, RelayListUpdaterHandle}; +use relay_list::{RelayListUpdater, RelayListUpdaterHandle, RELAYS_FILENAME}; use settings::SettingsPersister; #[cfg(any(windows, target_os = "android", target_os = "macos"))] use std::collections::HashSet; @@ -90,9 +90,9 @@ use talpid_types::android::AndroidContext; #[cfg(target_os = "windows")] use talpid_types::split_tunnel::ExcludedProcess; use talpid_types::{ - ErrorExt, net::{IpVersion, TunnelType}, tunnel::{ErrorStateCause, TunnelStateTransition}, + ErrorExt, }; use tokio::io; @@ -2465,7 +2465,7 @@ impl Daemon { #[cfg(daita)] async fn on_set_daita_enabled(&mut self, tx: ResponseTx<(), settings::Error>, value: bool) { - use mullvad_types::{Intersection, constraints::Constraint}; + use mullvad_types::{constraints::Constraint, Intersection}; let result = self .settings @@ -2504,7 +2504,7 @@ impl Daemon { tx: ResponseTx<(), settings::Error>, value: bool, ) { - use mullvad_types::{Intersection, constraints::Constraint}; + use mullvad_types::{constraints::Constraint, Intersection}; match self .settings diff --git a/mullvad-daemon/src/logging.rs b/mullvad-daemon/src/logging.rs index 9f98dda394..6e91e86ea6 100644 --- a/mullvad-daemon/src/logging.rs +++ b/mullvad-daemon/src/logging.rs @@ -1,6 +1,6 @@ use fern::{ - Output, colors::{Color, ColoredLevelConfig}, + Output, }; use std::{ fmt, io, diff --git a/mullvad-daemon/src/macos_launch_daemon.rs b/mullvad-daemon/src/macos_launch_daemon.rs index 4b46c5bb0a..0c9c89080c 100644 --- a/mullvad-daemon/src/macos_launch_daemon.rs +++ b/mullvad-daemon/src/macos_launch_daemon.rs @@ -6,7 +6,7 @@ //! daemon in the system settings. use libc::c_longlong; -use objc2::{Encode, Encoding, RefEncode, class, msg_send, runtime::AnyObject}; +use objc2::{class, msg_send, runtime::AnyObject, Encode, Encoding, RefEncode}; use std::ffi::CStr; type Id = *mut AnyObject; diff --git a/mullvad-daemon/src/main.rs b/mullvad-daemon/src/main.rs index f20ee3c816..c2146752c7 100644 --- a/mullvad-daemon/src/main.rs +++ b/mullvad-daemon/src/main.rs @@ -3,8 +3,8 @@ use std::{path::PathBuf, thread, time::Duration}; #[cfg(not(windows))] use mullvad_daemon::cleanup_old_rpc_socket; use mullvad_daemon::{ - Daemon, DaemonCommandChannel, DaemonConfig, exception_logging, logging, rpc_uniqueness_check, - runtime, version, + exception_logging, logging, rpc_uniqueness_check, runtime, version, Daemon, + DaemonCommandChannel, DaemonConfig, }; use talpid_types::ErrorExt; diff --git a/mullvad-daemon/src/management_interface.rs b/mullvad-daemon/src/management_interface.rs index 86af3eb676..8249aea968 100644 --- a/mullvad-daemon/src/management_interface.rs +++ b/mullvad-daemon/src/management_interface.rs @@ -1,12 +1,12 @@ -use crate::{DaemonCommand, DaemonCommandSender, account_history, device, version_check}; +use crate::{account_history, device, version_check, DaemonCommand, DaemonCommandSender}; use futures::{ - StreamExt, channel::{mpsc, oneshot}, + StreamExt, }; -use mullvad_api::{StatusCode, rest::Error as RestError}; +use mullvad_api::{rest::Error as RestError, StatusCode}; use mullvad_management_interface::{ - Code, Request, Response, ServerJoinHandle, Status, types::{self, daemon_event, management_service_server::ManagementService}, + Code, Request, Response, ServerJoinHandle, Status, }; use mullvad_types::{ account::AccountNumber, diff --git a/mullvad-daemon/src/migrations/device.rs b/mullvad-daemon/src/migrations/device.rs index efbf926e83..d5c05c9353 100644 --- a/mullvad-daemon/src/migrations/device.rs +++ b/mullvad-daemon/src/migrations/device.rs @@ -6,10 +6,10 @@ //! This module is allowed to import a number of types, unlike other migration modules, as it //! does not modify any files directly and may safely fail. -use super::{MigrationComplete, v5::MigrationData}; +use super::{v5::MigrationData, MigrationComplete}; use crate::{ - DaemonEventSender, InternalDaemonEvent, device::{self, DeviceService, PrivateAccountAndDevice, PrivateDevice}, + DaemonEventSender, InternalDaemonEvent, }; use mullvad_types::{account::AccountNumber, wireguard::WireguardData}; use std::time::Duration; diff --git a/mullvad-daemon/src/migrations/mod.rs b/mullvad-daemon/src/migrations/mod.rs index 20dca54820..635c2f6ebe 100644 --- a/mullvad-daemon/src/migrations/mod.rs +++ b/mullvad-daemon/src/migrations/mod.rs @@ -34,8 +34,8 @@ use std::{ path::Path, sync::{ - Arc, atomic::{AtomicBool, Ordering}, + Arc, }, }; use tokio::{ @@ -231,11 +231,11 @@ mod windows { use talpid_types::ErrorExt; use tokio::fs; use windows_sys::Win32::{ - Foundation::{ERROR_SUCCESS, HLOCAL, LocalFree, PSID}, + Foundation::{LocalFree, ERROR_SUCCESS, HLOCAL, PSID}, Security::{ Authorization::{GetNamedSecurityInfoW, SE_FILE_OBJECT, SE_OBJECT_TYPE}, - IsWellKnownSid, OWNER_SECURITY_INFORMATION, SECURITY_DESCRIPTOR, SID, - WELL_KNOWN_SID_TYPE, WinBuiltinAdministratorsSid, WinLocalSystemSid, + IsWellKnownSid, WinBuiltinAdministratorsSid, WinLocalSystemSid, + OWNER_SECURITY_INFORMATION, SECURITY_DESCRIPTOR, SID, WELL_KNOWN_SID_TYPE, }, }; diff --git a/mullvad-daemon/src/migrations/v7.rs b/mullvad-daemon/src/migrations/v7.rs index 0cc29df04e..47c6bf6275 100644 --- a/mullvad-daemon/src/migrations/v7.rs +++ b/mullvad-daemon/src/migrations/v7.rs @@ -7,8 +7,8 @@ use mullvad_types::{ }; use serde::{Deserialize, Serialize}; use talpid_types::net::{ - Endpoint, TransportProtocol, proxy::{CustomProxy, Shadowsocks, Socks5Local, Socks5Remote, SocksAuth}, + Endpoint, TransportProtocol, }; // ====================================================== diff --git a/mullvad-daemon/src/migrations/v9.rs b/mullvad-daemon/src/migrations/v9.rs index f8ee03831b..1275c488e1 100644 --- a/mullvad-daemon/src/migrations/v9.rs +++ b/mullvad-daemon/src/migrations/v9.rs @@ -205,7 +205,7 @@ mod test { fn test_v9_to_v10_migration() { use crate::migrations::v9::{ add_split_tunneling_settings, - test::constants::{V9_ANDROID_SETTINGS, V10_ANDROID_SETTINGS}, + test::constants::{V10_ANDROID_SETTINGS, V9_ANDROID_SETTINGS}, }; let enabled = true; diff --git a/mullvad-daemon/src/relay_list/mod.rs b/mullvad-daemon/src/relay_list/mod.rs index 6126f113a0..ee5781aff0 100644 --- a/mullvad-daemon/src/relay_list/mod.rs +++ b/mullvad-daemon/src/relay_list/mod.rs @@ -1,9 +1,9 @@ //! Relay list updater use futures::{ - Future, FutureExt, SinkExt, StreamExt, channel::mpsc, future::{Fuse, FusedFuture}, + Future, FutureExt, SinkExt, StreamExt, }; use std::{ path::{Path, PathBuf}, @@ -11,10 +11,10 @@ use std::{ }; use tokio::fs::File; -use mullvad_api::{RelayListProxy, availability::ApiAvailability, rest::MullvadRestHandle}; +use mullvad_api::{availability::ApiAvailability, rest::MullvadRestHandle, RelayListProxy}; use mullvad_relay_selector::RelaySelector; use mullvad_types::relay_list::RelayList; -use talpid_future::retry::{ExponentialBackoff, Jittered, retry_future}; +use talpid_future::retry::{retry_future, ExponentialBackoff, Jittered}; use talpid_types::ErrorExt; /// How often the updater should wake up to check the cache of the in-memory cache of relays. diff --git a/mullvad-daemon/src/settings/mod.rs b/mullvad-daemon/src/settings/mod.rs index 31c7d8874b..0b0d914569 100644 --- a/mullvad-daemon/src/settings/mod.rs +++ b/mullvad-daemon/src/settings/mod.rs @@ -398,7 +398,11 @@ pub struct SettingsSummary<'a> { impl Display for SettingsSummary<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let bool_to_label = |state| { - if state { "on" } else { "off" } + if state { + "on" + } else { + "off" + } }; let relay_settings = self.settings.get_relay_settings(); diff --git a/mullvad-daemon/src/system_service.rs b/mullvad-daemon/src/system_service.rs index ec2ad3ff3a..ccec49486b 100644 --- a/mullvad-daemon/src/system_service.rs +++ b/mullvad-daemon/src/system_service.rs @@ -1,13 +1,12 @@ use crate::cli; -use mullvad_daemon::{DaemonShutdownHandle, runtime::new_multi_thread}; +use mullvad_daemon::{runtime::new_multi_thread, DaemonShutdownHandle}; use std::{ env, - ffi::{OsString, c_void}, + ffi::{c_void, OsString}, ptr, slice, sync::{ - Arc, LazyLock, atomic::{AtomicBool, AtomicUsize, Ordering}, - mpsc, + mpsc, Arc, LazyLock, }, thread, time::{Duration, Instant}, diff --git a/mullvad-daemon/src/tunnel.rs b/mullvad-daemon/src/tunnel.rs index 4f97207389..3fd94d591d 100644 --- a/mullvad-daemon/src/tunnel.rs +++ b/mullvad-daemon/src/tunnel.rs @@ -17,13 +17,13 @@ use std::sync::LazyLock; use talpid_core::tunnel_state_machine::TunnelParametersGenerator; #[cfg(not(target_os = "android"))] use talpid_types::net::{ - Endpoint, TunnelParameters, obfuscation::ObfuscatorConfig, openvpn, proxy::CustomProxy, - wireguard, + obfuscation::ObfuscatorConfig, openvpn, proxy::CustomProxy, wireguard, Endpoint, + TunnelParameters, }; #[cfg(target_os = "android")] -use talpid_types::net::{TunnelParameters, obfuscation::ObfuscatorConfig, wireguard}; +use talpid_types::net::{obfuscation::ObfuscatorConfig, wireguard, TunnelParameters}; -use talpid_types::{ErrorExt, tunnel::ParameterGenerationError}; +use talpid_types::{tunnel::ParameterGenerationError, ErrorExt}; use crate::device::{AccountManagerHandle, Error as DeviceError, PrivateAccountAndDevice}; diff --git a/mullvad-daemon/src/version_check.rs b/mullvad-daemon/src/version_check.rs index 8e4578a9ea..1ee879ca1f 100644 --- a/mullvad-daemon/src/version_check.rs +++ b/mullvad-daemon/src/version_check.rs @@ -1,10 +1,10 @@ -use crate::{DaemonEventSender, version::is_beta_version}; +use crate::{version::is_beta_version, DaemonEventSender}; use futures::{ - FutureExt, SinkExt, StreamExt, TryFutureExt, channel::{mpsc, oneshot}, future::{BoxFuture, FusedFuture}, + FutureExt, SinkExt, StreamExt, TryFutureExt, }; -use mullvad_api::{AppVersionProxy, availability::ApiAvailability, rest::MullvadRestHandle}; +use mullvad_api::{availability::ApiAvailability, rest::MullvadRestHandle, AppVersionProxy}; use mullvad_types::version::{AppVersionInfo, ParsedAppVersion}; use serde::{Deserialize, Serialize}; use std::{ @@ -18,7 +18,7 @@ use std::{ time::{Duration, SystemTime}, }; use talpid_core::mpsc::Sender; -use talpid_future::retry::{ConstantInterval, retry_future}; +use talpid_future::retry::{retry_future, ConstantInterval}; use talpid_types::ErrorExt; use tokio::{fs::File, io::AsyncReadExt}; @@ -564,8 +564,8 @@ fn suggested_upgrade( #[cfg(test)] mod test { use std::sync::{ - Arc, atomic::{AtomicBool, Ordering}, + Arc, }; use super::*; diff --git a/talpid-core/src/dns/windows/dnsapi.rs b/talpid-core/src/dns/windows/dnsapi.rs index dcf04d22b2..03d9d44abf 100644 --- a/talpid-core/src/dns/windows/dnsapi.rs +++ b/talpid-core/src/dns/windows/dnsapi.rs @@ -1,8 +1,7 @@ use std::{ sync::{ - Arc, OnceLock, atomic::{AtomicUsize, Ordering}, - mpsc, + mpsc, Arc, OnceLock, }, time::{Duration, Instant}, }; diff --git a/talpid-core/src/firewall/windows/mod.rs b/talpid-core/src/firewall/windows/mod.rs index 51f5adc498..8dadd7db5c 100644 --- a/talpid-core/src/firewall/windows/mod.rs +++ b/talpid-core/src/firewall/windows/mod.rs @@ -5,12 +5,12 @@ use std::{ffi::CStr, io, net::IpAddr, ptr, sync::LazyLock}; use self::winfw::*; use super::{FirewallArguments, FirewallPolicy, InitialFirewallState}; use talpid_types::{ - ErrorExt, net::{AllowedEndpoint, AllowedTunnelTraffic}, tunnel::FirewallPolicyError, + ErrorExt, }; use widestring::WideCString; -use windows_sys::Win32::Globalization::{CP_ACP, MultiByteToWideChar}; +use windows_sys::Win32::Globalization::{MultiByteToWideChar, CP_ACP}; mod hyperv; @@ -554,7 +554,7 @@ fn with_wmi_if_enabled(f: impl FnOnce(&wmi::WMIConnection)) { #[allow(non_snake_case)] mod winfw { - use super::{AllowedEndpoint, AllowedTunnelTraffic, Error, WideCString, widestring_ip}; + use super::{widestring_ip, AllowedEndpoint, AllowedTunnelTraffic, Error, WideCString}; use std::ffi::{c_char, c_void}; use talpid_types::net::TransportProtocol; diff --git a/talpid-core/src/split_tunnel/windows/driver.rs b/talpid-core/src/split_tunnel/windows/driver.rs index 481514c61b..e3026b0d95 100644 --- a/talpid-core/src/split_tunnel/windows/driver.rs +++ b/talpid-core/src/split_tunnel/windows/driver.rs @@ -1,6 +1,6 @@ use super::windows::{ - ProcessAccess, get_device_path, get_process_creation_time, get_process_device_path, - open_process, + get_device_path, get_process_creation_time, get_process_device_path, open_process, + ProcessAccess, }; use bitflags::bitflags; use memoffset::offset_of; @@ -10,7 +10,7 @@ use std::{ ffi::{OsStr, OsString}, fs::{self, OpenOptions}, io, - mem::{self, MaybeUninit, size_of}, + mem::{self, size_of, MaybeUninit}, net::{Ipv4Addr, Ipv6Addr}, os::windows::{ ffi::{OsStrExt, OsStringExt}, @@ -28,13 +28,13 @@ use windows_sys::Win32::{ ERROR_ACCESS_DENIED, ERROR_FILE_NOT_FOUND, ERROR_INVALID_PARAMETER, ERROR_IO_PENDING, HANDLE, NTSTATUS, WAIT_ABANDONED, WAIT_ABANDONED_0, WAIT_FAILED, WAIT_OBJECT_0, }, - Networking::WinSock::{IN_ADDR, IN6_ADDR}, + Networking::WinSock::{IN6_ADDR, IN_ADDR}, Storage::FileSystem::FILE_FLAG_OVERLAPPED, System::{ Diagnostics::ToolHelp::TH32CS_SNAPPROCESS, - IO::{DeviceIoControl, GetOverlappedResult, OVERLAPPED}, Ioctl::{FILE_ANY_ACCESS, METHOD_BUFFERED, METHOD_NEITHER}, - Threading::{INFINITE, WaitForMultipleObjects, WaitForSingleObject}, + Threading::{WaitForMultipleObjects, WaitForSingleObject, INFINITE}, + IO::{DeviceIoControl, GetOverlappedResult, OVERLAPPED}, }, }; diff --git a/talpid-core/src/split_tunnel/windows/volume_monitor.rs b/talpid-core/src/split_tunnel/windows/volume_monitor.rs index 6ebcaf48a0..1c20254c37 100644 --- a/talpid-core/src/split_tunnel/windows/volume_monitor.rs +++ b/talpid-core/src/split_tunnel/windows/volume_monitor.rs @@ -1,20 +1,20 @@ //! Used to monitor volume mounts and dismounts, and reapply the split //! tunnel config if any of the excluded paths are affected by them. use super::path_monitor::PathMonitorHandle; -use crate::window::{WindowCloseHandle, create_hidden_window}; -use futures::{StreamExt, channel::mpsc}; +use crate::window::{create_hidden_window, WindowCloseHandle}; +use futures::{channel::mpsc, StreamExt}; use std::{ ffi::OsString, io, path::{self, Path}, - sync::{Arc, Mutex, MutexGuard, mpsc as sync_mpsc}, + sync::{mpsc as sync_mpsc, Arc, Mutex, MutexGuard}, }; use talpid_types::ErrorExt; use windows_sys::Win32::{ Storage::FileSystem::GetLogicalDrives, UI::WindowsAndMessaging::{ - DBT_DEVICEARRIVAL, DBT_DEVICEREMOVECOMPLETE, DBT_DEVTYP_VOLUME, DBTF_NET, - DEV_BROADCAST_HDR, DEV_BROADCAST_VOLUME, DefWindowProcW, WM_DEVICECHANGE, + DefWindowProcW, DBTF_NET, DBT_DEVICEARRIVAL, DBT_DEVICEREMOVECOMPLETE, DBT_DEVTYP_VOLUME, + DEV_BROADCAST_HDR, DEV_BROADCAST_VOLUME, WM_DEVICECHANGE, }, }; diff --git a/talpid-core/src/window.rs b/talpid-core/src/window.rs index 6154e2719b..30df21f2da 100644 --- a/talpid-core/src/window.rs +++ b/talpid-core/src/window.rs @@ -3,17 +3,17 @@ use std::{os::windows::io::AsRawHandle, ptr, sync::Arc, thread}; use tokio::sync::broadcast; use windows_sys::{ + w, Win32::{ Foundation::{HANDLE, HWND, LPARAM, LRESULT, WPARAM}, System::{LibraryLoader::GetModuleHandleW, Threading::GetThreadId}, UI::WindowsAndMessaging::{ - CreateWindowExW, DefWindowProcW, DestroyWindow, DispatchMessageW, GWLP_USERDATA, - GWLP_WNDPROC, GetMessageW, GetWindowLongPtrW, PBT_APMRESUMEAUTOMATIC, - PBT_APMRESUMESUSPEND, PBT_APMSUSPEND, PostQuitMessage, PostThreadMessageW, - SetWindowLongPtrW, TranslateMessage, WM_DESTROY, WM_POWERBROADCAST, WM_USER, + CreateWindowExW, DefWindowProcW, DestroyWindow, DispatchMessageW, GetMessageW, + GetWindowLongPtrW, PostQuitMessage, PostThreadMessageW, SetWindowLongPtrW, + TranslateMessage, GWLP_USERDATA, GWLP_WNDPROC, PBT_APMRESUMEAUTOMATIC, + PBT_APMRESUMESUSPEND, PBT_APMSUSPEND, WM_DESTROY, WM_POWERBROADCAST, WM_USER, }, }, - w, }; const CLASS_NAME: *const u16 = w!("STATIC"); diff --git a/talpid-openvpn/src/wintun.rs b/talpid-openvpn/src/wintun.rs index 2c95f08b2f..e3e7938828 100644 --- a/talpid-openvpn/src/wintun.rs +++ b/talpid-openvpn/src/wintun.rs @@ -1,22 +1,22 @@ use once_cell::sync::OnceCell; use std::{ffi::CStr, fmt, io, mem, os::windows::io::RawHandle, path::Path, ptr}; -use talpid_types::{ErrorExt, win32_err}; +use talpid_types::{win32_err, ErrorExt}; use widestring::{U16CStr, U16CString}; use windows_sys::{ + core::GUID, Win32::{ Foundation::{FreeLibrary, HMODULE}, NetworkManagement::{IpHelper::ConvertInterfaceLuidToGuid, Ndis::NET_LUID_LH}, System::{ Com::StringFromGUID2, - LibraryLoader::{GetProcAddress, LOAD_WITH_ALTERED_SEARCH_PATH, LoadLibraryExW}, + LibraryLoader::{GetProcAddress, LoadLibraryExW, LOAD_WITH_ALTERED_SEARCH_PATH}, Registry::REG_SAM_FLAGS, }, }, - core::GUID, }; use winreg::{ - RegKey, enums::{HKEY_LOCAL_MACHINE, KEY_READ, KEY_WRITE}, + RegKey, }; /// Shared `WintunDll` instance diff --git a/talpid-routing/src/windows/default_route_monitor.rs b/talpid-routing/src/windows/default_route_monitor.rs index 17d270df34..fd73684821 100644 --- a/talpid-routing/src/windows/default_route_monitor.rs +++ b/talpid-routing/src/windows/default_route_monitor.rs @@ -1,6 +1,6 @@ use super::{ - Error, InterfaceAndGateway, Result, get_best_default_route, - get_best_default_route::route_has_gateway, + get_best_default_route, get_best_default_route::route_has_gateway, Error, InterfaceAndGateway, + Result, }; use crate::debounce::BurstGuard; @@ -14,9 +14,9 @@ use windows_sys::Win32::{ Foundation::{BOOLEAN, HANDLE}, NetworkManagement::{ IpHelper::{ - CancelMibChangeNotify2, ConvertInterfaceLuidToIndex, MIB_IPFORWARD_ROW2, + CancelMibChangeNotify2, ConvertInterfaceLuidToIndex, NotifyIpInterfaceChange, + NotifyRouteChange2, NotifyUnicastIpAddressChange, MIB_IPFORWARD_ROW2, MIB_IPINTERFACE_ROW, MIB_NOTIFICATION_TYPE, MIB_UNICASTIPADDRESS_ROW, - NotifyIpInterfaceChange, NotifyRouteChange2, NotifyUnicastIpAddressChange, }, Ndis::NET_LUID_LH, }, diff --git a/talpid-routing/src/windows/route_manager.rs b/talpid-routing/src/windows/route_manager.rs index 43df3a02a9..86ccff21fa 100644 --- a/talpid-routing/src/windows/route_manager.rs +++ b/talpid-routing/src/windows/route_manager.rs @@ -1,7 +1,6 @@ use super::{ - Error, InterfaceAndGateway, Result, default_route_monitor::{DefaultRouteMonitor, EventType as RouteMonitorEventType}, - get_best_default_route, + get_best_default_route, Error, InterfaceAndGateway, Result, }; use crate::NetNode; use ipnetwork::IpNetwork; @@ -13,27 +12,27 @@ use std::{ }; use talpid_types::win32_err; use talpid_windows::net::{ - AddressFamily, inet_sockaddr_from_socketaddr, try_socketaddr_from_inet_sockaddr, + inet_sockaddr_from_socketaddr, try_socketaddr_from_inet_sockaddr, AddressFamily, }; use widestring::{WideCStr, WideCString}; use windows_sys::Win32::{ Foundation::{ - ERROR_BUFFER_OVERFLOW, ERROR_NO_DATA, ERROR_NOT_FOUND, ERROR_OBJECT_ALREADY_EXISTS, + ERROR_BUFFER_OVERFLOW, ERROR_NOT_FOUND, ERROR_NO_DATA, ERROR_OBJECT_ALREADY_EXISTS, ERROR_SUCCESS, }, NetworkManagement::{ IpHelper::{ ConvertInterfaceAliasToLuid, CreateIpForwardEntry2, DeleteIpForwardEntry2, + GetAdaptersAddresses, InitializeIpForwardEntry, SetIpForwardEntry2, GAA_FLAG_INCLUDE_GATEWAYS, GAA_FLAG_SKIP_ANYCAST, GAA_FLAG_SKIP_DNS_SERVER, GAA_FLAG_SKIP_FRIENDLY_NAME, GAA_FLAG_SKIP_MULTICAST, GET_ADAPTERS_ADDRESSES_FLAGS, - GetAdaptersAddresses, IP_ADAPTER_ADDRESSES_LH, IP_ADAPTER_GATEWAY_ADDRESS_LH, - IP_ADAPTER_IPV4_ENABLED, IP_ADAPTER_IPV6_ENABLED, IP_ADDRESS_PREFIX, - InitializeIpForwardEntry, MIB_IPFORWARD_ROW2, SetIpForwardEntry2, + IP_ADAPTER_ADDRESSES_LH, IP_ADAPTER_GATEWAY_ADDRESS_LH, IP_ADAPTER_IPV4_ENABLED, + IP_ADAPTER_IPV6_ENABLED, IP_ADDRESS_PREFIX, MIB_IPFORWARD_ROW2, }, Ndis::NET_LUID_LH, }, Networking::WinSock::{ - ADDRESS_FAMILY, AF_INET, AF_INET6, MIB_IPPROTO_NETMGMT, NlroManual, SOCKADDR_IN, + NlroManual, ADDRESS_FAMILY, AF_INET, AF_INET6, MIB_IPPROTO_NETMGMT, SOCKADDR_IN, SOCKADDR_IN6, SOCKADDR_INET, SOCKET_ADDRESS, }, }; diff --git a/talpid-windows/src/net.rs b/talpid-windows/src/net.rs index c9bb04ebee..c744114a3a 100644 --- a/talpid-windows/src/net.rs +++ b/talpid-windows/src/net.rs @@ -10,6 +10,7 @@ use std::{ }; use talpid_types::win32_err; use windows_sys::{ + core::GUID, Win32::{ Foundation::{ERROR_NOT_FOUND, HANDLE}, NetworkManagement::{ @@ -18,20 +19,19 @@ use windows_sys::{ ConvertInterfaceLuidToGuid, ConvertInterfaceLuidToIndex, CreateUnicastIpAddressEntry, FreeMibTable, GetIpInterfaceEntry, GetUnicastIpAddressEntry, GetUnicastIpAddressTable, - InitializeUnicastIpAddressEntry, MIB_IPINTERFACE_ROW, MIB_UNICASTIPADDRESS_ROW, - MIB_UNICASTIPADDRESS_TABLE, MibAddInstance, NotifyIpInterfaceChange, - SetIpInterfaceEntry, + InitializeUnicastIpAddressEntry, MibAddInstance, NotifyIpInterfaceChange, + SetIpInterfaceEntry, MIB_IPINTERFACE_ROW, MIB_UNICASTIPADDRESS_ROW, + MIB_UNICASTIPADDRESS_TABLE, }, Ndis::{IF_MAX_STRING_SIZE, NET_LUID_LH}, }, Networking::WinSock::{ - AF_INET, AF_INET6, AF_UNSPEC, IN_ADDR, IN6_ADDR, IpDadStateDeprecated, - IpDadStateDuplicate, IpDadStateInvalid, IpDadStatePreferred, IpDadStateTentative, - NL_DAD_STATE, SOCKADDR_IN as sockaddr_in, SOCKADDR_IN6 as sockaddr_in6, SOCKADDR_INET, + 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, }, }, - core::GUID, }; /// Result type for this module. diff --git a/talpid-wireguard/src/wireguard_nt/mod.rs b/talpid-wireguard/src/wireguard_nt/mod.rs index f03d11ffff..4451f36281 100644 --- a/talpid-wireguard/src/wireguard_nt/mod.rs +++ b/talpid-wireguard/src/wireguard_nt/mod.rs @@ -1,13 +1,15 @@ use super::{ - Tunnel, config::Config, logging, stats::{Stats, StatsMap}, + Tunnel, }; use bitflags::bitflags; use futures::SinkExt; use ipnetwork::IpNetwork; use once_cell::sync::OnceCell; +#[cfg(daita)] +use std::{ffi::c_uchar, path::PathBuf}; use std::{ ffi::CStr, fmt, @@ -21,21 +23,19 @@ use std::{ ptr, sync::{Arc, LazyLock, Mutex}, }; -#[cfg(daita)] -use std::{ffi::c_uchar, path::PathBuf}; use talpid_types::{BoxedError, ErrorExt}; use talpid_windows::net; use widestring::{U16CStr, U16CString}; use windows_sys::{ + core::GUID, Win32::{ - Foundation::{BOOL, ERROR_MORE_DATA, FreeLibrary, HMODULE}, + Foundation::{FreeLibrary, BOOL, ERROR_MORE_DATA, HMODULE}, NetworkManagement::Ndis::NET_LUID_LH, Networking::WinSock::{ - ADDRESS_FAMILY, AF_INET, AF_INET6, IN_ADDR, IN6_ADDR, SOCKADDR_INET, + ADDRESS_FAMILY, AF_INET, AF_INET6, IN6_ADDR, IN_ADDR, SOCKADDR_INET, }, - System::LibraryLoader::{GetProcAddress, LOAD_WITH_ALTERED_SEARCH_PATH, LoadLibraryExW}, + System::LibraryLoader::{GetProcAddress, LoadLibraryExW, LOAD_WITH_ALTERED_SEARCH_PATH}, }, - core::GUID, }; #[cfg(daita)] diff --git a/wireguard-go-rs/src/lib.rs b/wireguard-go-rs/src/lib.rs index 75d4de02c5..37756a7afb 100644 --- a/wireguard-go-rs/src/lib.rs +++ b/wireguard-go-rs/src/lib.rs @@ -6,7 +6,7 @@ //! //! The [`Tunnel`] type provides a safe Rust wrapper around the C FFI. -use core::ffi::{CStr, c_char}; +use core::ffi::{c_char, CStr}; use core::mem::ManuallyDrop; #[cfg(target_os = "windows")] use core::mem::MaybeUninit; |
