diff --git a/mullvad-relay-selector/src/error.rs b/mullvad-relay-selector/src/error.rs index 0bd5fad5d455..9f7a50bda36c 100644 --- a/mullvad-relay-selector/src/error.rs +++ b/mullvad-relay-selector/src/error.rs @@ -3,8 +3,7 @@ use mullvad_types::{relay_constraints::MissingCustomBridgeSettings, relay_list::Relay}; -use crate::detailer; -use crate::relay_selector::relays::WireguardConfig; +use crate::{detailer, relay_selector::relays::WireguardConfig}; #[derive(thiserror::Error, Debug)] pub enum Error { diff --git a/mullvad-relay-selector/src/lib.rs b/mullvad-relay-selector/src/lib.rs index cbd7c94a3628..be12c2944353 100644 --- a/mullvad-relay-selector/src/lib.rs +++ b/mullvad-relay-selector/src/lib.rs @@ -8,10 +8,8 @@ mod relay_selector; // Re-exports pub use error::Error; -pub use relay_selector::detailer; -pub use relay_selector::query; -pub use relay_selector::relays::WireguardConfig; pub use relay_selector::{ - AdditionalRelayConstraints, AdditionalWireguardConstraints, GetRelay, RelaySelector, - RuntimeParameters, SelectedBridge, SelectedObfuscator, SelectorConfig, RETRY_ORDER, + detailer, query, relays::WireguardConfig, AdditionalRelayConstraints, + AdditionalWireguardConstraints, GetRelay, RelaySelector, RuntimeParameters, SelectedBridge, + SelectedObfuscator, SelectorConfig, RETRY_ORDER, }; diff --git a/mullvad-relay-selector/src/relay_selector/helpers.rs b/mullvad-relay-selector/src/relay_selector/helpers.rs index c8b529e0cd96..a8a2ba7fcb85 100644 --- a/mullvad-relay-selector/src/relay_selector/helpers.rs +++ b/mullvad-relay-selector/src/relay_selector/helpers.rs @@ -207,8 +207,8 @@ fn port_if_in_range>(port_ranges: &[R], port: u16) -> Result /// - `port_ranges`: A slice of port numbers. /// /// # Returns -/// - On success, a randomly selected port number within the given ranges. Otherwise, -/// an error is returned. +/// - On success, a randomly selected port number within the given ranges. Otherwise, an error is +/// returned. pub fn select_random_port + Iterator + Clone>( port_ranges: &[R], ) -> Result { diff --git a/mullvad-relay-selector/src/relay_selector/mod.rs b/mullvad-relay-selector/src/relay_selector/mod.rs index c71a85f37811..e7a69227272e 100644 --- a/mullvad-relay-selector/src/relay_selector/mod.rs +++ b/mullvad-relay-selector/src/relay_selector/mod.rs @@ -11,37 +11,45 @@ use matcher::{filter_matching_bridges, filter_matching_relay_list}; use parsed_relays::ParsedRelays; use relays::{Multihop, Singlehop, WireguardConfig}; -use crate::detailer::{openvpn_endpoint, wireguard_endpoint}; -use crate::error::{EndpointErrorDetails, Error}; -use crate::query::{ - BridgeQuery, ObfuscationQuery, OpenVpnRelayQuery, RelayQuery, RelayQueryExt, - WireguardRelayQuery, +use crate::{ + detailer::{openvpn_endpoint, wireguard_endpoint}, + error::{EndpointErrorDetails, Error}, + query::{ + BridgeQuery, ObfuscationQuery, OpenVpnRelayQuery, RelayQuery, RelayQueryExt, + WireguardRelayQuery, + }, }; -use std::path::Path; -use std::sync::{Arc, LazyLock, Mutex}; -use std::time::SystemTime; +use std::{ + path::Path, + sync::{Arc, LazyLock, Mutex}, + time::SystemTime, +}; use chrono::{DateTime, Local}; use itertools::Itertools; -use mullvad_types::constraints::Constraint; -use mullvad_types::custom_list::CustomListsSettings; -use mullvad_types::endpoint::MullvadWireguardEndpoint; -use mullvad_types::location::{Coordinates, Location}; -use mullvad_types::relay_constraints::{ - BridgeSettings, BridgeState, InternalBridgeConstraints, ObfuscationSettings, - OpenVpnConstraints, RelayConstraints, RelayOverride, RelaySettings, ResolvedBridgeSettings, - WireguardConstraints, +use mullvad_types::{ + constraints::Constraint, + custom_list::CustomListsSettings, + endpoint::MullvadWireguardEndpoint, + location::{Coordinates, Location}, + relay_constraints::{ + BridgeSettings, BridgeState, InternalBridgeConstraints, ObfuscationSettings, + OpenVpnConstraints, RelayConstraints, RelayOverride, RelaySettings, ResolvedBridgeSettings, + WireguardConstraints, + }, + relay_list::{Relay, RelayEndpointData, RelayList}, + settings::Settings, + wireguard::QuantumResistantState, + CustomTunnelEndpoint, Intersection, }; -use mullvad_types::relay_list::{Relay, RelayEndpointData, RelayList}; -use mullvad_types::settings::Settings; -use mullvad_types::wireguard::QuantumResistantState; -use mullvad_types::{CustomTunnelEndpoint, Intersection}; -use talpid_types::net::{ - obfuscation::ObfuscatorConfig, proxy::CustomProxy, Endpoint, TransportProtocol, TunnelType, +use talpid_types::{ + net::{ + obfuscation::ObfuscatorConfig, proxy::CustomProxy, Endpoint, TransportProtocol, TunnelType, + }, + ErrorExt, }; -use talpid_types::ErrorExt; /// [`RETRY_ORDER`] defines an ordered set of relay parameters which the relay selector should /// prioritize on successive connection attempts. Note that these will *never* override user @@ -684,8 +692,9 @@ impl RelaySelector { match Self::get_wireguard_singlehop_config(query, custom_lists, parsed_relays) { Some(exit) => WireguardConfig::from(exit), None => { - // If we found no matching relays because DAITA was enabled, and `use_multihop_if_necessary` - // is enabled, try enabling multihop and connecting using an automatically selected + // If we found no matching relays because DAITA was enabled, and + // `use_multihop_if_necessary` is enabled, try enabling + // multihop and connecting using an automatically selected // entry relay. if query.using_daita() && query.use_multihop_if_necessary() { let multihop = Self::get_wireguard_auto_multihop_config( diff --git a/mullvad-relay-selector/src/relay_selector/relays.rs b/mullvad-relay-selector/src/relay_selector/relays.rs index 9ebf31f41747..3cb8ff3c5d23 100644 --- a/mullvad-relay-selector/src/relay_selector/relays.rs +++ b/mullvad-relay-selector/src/relay_selector/relays.rs @@ -17,8 +17,8 @@ pub enum WireguardConfig { /// A type representing single Wireguard relay. /// -/// Before you can read any data out of a [`Singlehop`] value uou need to convert it to [`WireguardConfig`]. -/// This is easy since [`Singlehop`] implements [`Into`]. +/// Before you can read any data out of a [`Singlehop`] value uou need to convert it to +/// [`WireguardConfig`]. This is easy since [`Singlehop`] implements [`Into`]. /// /// # Why not simply use [`Relay`]? /// The only way to construct a [`Singlehop`] value is with [`Singlehop::new`] which performs @@ -27,8 +27,8 @@ pub enum WireguardConfig { pub struct Singlehop(Relay); /// A type representing two Wireguard relay - an entry and an exit. /// -/// Before you can read any data out of a [`Multihop`] value uou need to convert it to [`WireguardConfig`]. -/// This is easy since [`Multihop`] implements [`Into`]. +/// Before you can read any data out of a [`Multihop`] value uou need to convert it to +/// [`WireguardConfig`]. This is easy since [`Multihop`] implements [`Into`]. /// /// # Why not simply use [`Relay`]? /// The same rationale as for [`Singlehop`] applies - [`Multihop::new`] performs additional diff --git a/mullvad-relay-selector/tests/relay_selector.rs b/mullvad-relay-selector/tests/relay_selector.rs index d80fe359e979..6908d468de11 100644 --- a/mullvad-relay-selector/tests/relay_selector.rs +++ b/mullvad-relay-selector/tests/relay_selector.rs @@ -1422,8 +1422,8 @@ fn test_daita_any_tunnel_protocol() { ); } -/// Always use smart routing to select a DAITA-enabled entry relay if both smart routing and multihop is enabled. -/// This applies even if the entry is set explicitly. +/// Always use smart routing to select a DAITA-enabled entry relay if both smart routing and +/// multihop is enabled. This applies even if the entry is set explicitly. /// DAITA is a core privacy feature #[test] fn test_daita_smart_routing_overrides_multihop() {