Skip to content

Commit

Permalink
Run nightly formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusPettersson98 committed Oct 18, 2024
1 parent 77a192e commit a416d9d
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 40 deletions.
3 changes: 1 addition & 2 deletions mullvad-relay-selector/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 3 additions & 5 deletions mullvad-relay-selector/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
4 changes: 2 additions & 2 deletions mullvad-relay-selector/src/relay_selector/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ fn port_if_in_range<R: RangeBounds<u16>>(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<R: RangeBounds<u16> + Iterator<Item = u16> + Clone>(
port_ranges: &[R],
) -> Result<u16, Error> {
Expand Down
59 changes: 34 additions & 25 deletions mullvad-relay-selector/src/relay_selector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions mullvad-relay-selector/src/relay_selector/relays.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<WireguardConfig>`].
/// 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<WireguardConfig>`].
///
/// # Why not simply use [`Relay`]?
/// The only way to construct a [`Singlehop`] value is with [`Singlehop::new`] which performs
Expand All @@ -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<WireguardConfig>`].
/// 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<WireguardConfig>`].
///
/// # Why not simply use [`Relay`]?
/// The same rationale as for [`Singlehop`] applies - [`Multihop::new`] performs additional
Expand Down
4 changes: 2 additions & 2 deletions mullvad-relay-selector/tests/relay_selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit a416d9d

Please sign in to comment.