diff options
| author | Sebastian Holmin <sebastian.holmin@mullvad.net> | 2024-04-17 13:06:02 +0200 |
|---|---|---|
| committer | Markus Pettersson <markus.pettersson@mullvad.net> | 2024-06-25 17:31:36 +0200 |
| commit | 7475c53d540768a49ccda0517a1437bf50a06e2d (patch) | |
| tree | 88013da1ededbc2c7dd20eced025d011c43fd616 | |
| parent | 540f68fe14164f604be897b0324717aac402b116 (diff) | |
| download | mullvadvpn-7475c53d540768a49ccda0517a1437bf50a06e2d.tar.xz mullvadvpn-7475c53d540768a49ccda0517a1437bf50a06e2d.zip | |
Enable DAITA for linux in CLI and types
| -rw-r--r-- | mullvad-cli/src/cmds/relay.rs | 2 | ||||
| -rw-r--r-- | mullvad-cli/src/cmds/tunnel.rs | 14 | ||||
| -rw-r--r-- | mullvad-cli/src/format.rs | 4 | ||||
| -rw-r--r-- | mullvad-daemon/src/lib.rs | 8 | ||||
| -rw-r--r-- | mullvad-daemon/src/management_interface.rs | 4 | ||||
| -rw-r--r-- | mullvad-management-interface/src/client.rs | 4 | ||||
| -rw-r--r-- | mullvad-management-interface/src/types/conversions/custom_tunnel.rs | 2 | ||||
| -rw-r--r-- | mullvad-management-interface/src/types/conversions/net.rs | 6 | ||||
| -rw-r--r-- | mullvad-management-interface/src/types/conversions/settings.rs | 6 | ||||
| -rw-r--r-- | mullvad-management-interface/src/types/conversions/wireguard.rs | 4 | ||||
| -rw-r--r-- | mullvad-relay-selector/src/relay_selector/detailer.rs | 6 | ||||
| -rw-r--r-- | mullvad-types/src/wireguard.rs | 8 | ||||
| -rw-r--r-- | talpid-types/src/net/mod.rs | 6 | ||||
| -rw-r--r-- | talpid-types/src/net/wireguard.rs | 4 | ||||
| -rw-r--r-- | test/test-manager/src/tests/dns.rs | 2 | ||||
| -rw-r--r-- | test/test-manager/src/tests/helpers.rs | 2 | ||||
| -rw-r--r-- | test/test-manager/src/tests/tunnel_state.rs | 2 |
17 files changed, 45 insertions, 39 deletions
diff --git a/mullvad-cli/src/cmds/relay.rs b/mullvad-cli/src/cmds/relay.rs index f022402a83..585b2736a4 100644 --- a/mullvad-cli/src/cmds/relay.rs +++ b/mullvad-cli/src/cmds/relay.rs @@ -542,7 +542,7 @@ impl Relay { allowed_ips: all_of_the_internet(), endpoint: SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), port), psk: None, - #[cfg(target_os = "windows")] + #[cfg(any(target_os = "windows", target_os = "linux"))] constant_packet_size: false, }, exit_peer: None, diff --git a/mullvad-cli/src/cmds/tunnel.rs b/mullvad-cli/src/cmds/tunnel.rs index 77338ee336..316bada856 100644 --- a/mullvad-cli/src/cmds/tunnel.rs +++ b/mullvad-cli/src/cmds/tunnel.rs @@ -1,7 +1,7 @@ use anyhow::Result; use clap::Subcommand; use mullvad_management_interface::MullvadProxyClient; -#[cfg(target_os = "windows")] +#[cfg(any(target_os = "windows", target_os = "linux"))] use mullvad_types::wireguard::DaitaSettings; use mullvad_types::{ constraints::Constraint, @@ -41,7 +41,7 @@ pub enum TunnelOptions { #[arg(long)] quantum_resistant: Option<QuantumResistantState>, /// Configure whether to enable DAITA - #[cfg(target_os = "windows")] + #[cfg(any(target_os = "windows", target_os = "linux"))] #[arg(long)] daita: Option<BooleanOption>, /// The key rotation interval. Number of hours, or 'any' @@ -101,7 +101,7 @@ impl Tunnel { tunnel_options.wireguard.quantum_resistant, ); - #[cfg(target_os = "windows")] + #[cfg(any(target_os = "windows", target_os = "linux"))] print_option!("DAITA", tunnel_options.wireguard.daita.enabled); let key = rpc.get_wireguard_key().await?; @@ -138,7 +138,7 @@ impl Tunnel { TunnelOptions::Wireguard { mtu, quantum_resistant, - #[cfg(target_os = "windows")] + #[cfg(any(target_os = "windows", target_os = "linux"))] daita, rotation_interval, rotate_key, @@ -146,7 +146,7 @@ impl Tunnel { Self::handle_wireguard( mtu, quantum_resistant, - #[cfg(target_os = "windows")] + #[cfg(any(target_os = "windows", target_os = "linux"))] daita, rotation_interval, rotate_key, @@ -178,7 +178,7 @@ impl Tunnel { async fn handle_wireguard( mtu: Option<Constraint<u16>>, quantum_resistant: Option<QuantumResistantState>, - #[cfg(target_os = "windows")] daita: Option<BooleanOption>, + #[cfg(any(target_os = "windows", target_os = "linux"))] daita: Option<BooleanOption>, rotation_interval: Option<Constraint<RotationInterval>>, rotate_key: Option<RotateKey>, ) -> Result<()> { @@ -194,7 +194,7 @@ impl Tunnel { println!("Quantum resistant setting has been updated"); } - #[cfg(target_os = "windows")] + #[cfg(any(target_os = "windows", target_os = "linux"))] if let Some(daita) = daita { rpc.set_daita_settings(DaitaSettings { enabled: *daita }) .await?; diff --git a/mullvad-cli/src/format.rs b/mullvad-cli/src/format.rs index 6b092e8939..abd85b178a 100644 --- a/mullvad-cli/src/format.rs +++ b/mullvad-cli/src/format.rs @@ -174,7 +174,7 @@ fn format_relay_connection( "\nQuantum resistant tunnel: no" }; - #[cfg(target_os = "windows")] + #[cfg(any(target_os = "windows", target_os = "linux"))] let daita = if !verbose { "" } else if endpoint.daita { @@ -182,7 +182,7 @@ fn format_relay_connection( } else { "\nDAITA: no" }; - #[cfg(not(target_os = "windows"))] + #[cfg(not(any(target_os = "windows", target_os = "linux")))] let daita = ""; let mut bridge_type = String::new(); diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs index 269bd1dbb1..6e5ae40042 100644 --- a/mullvad-daemon/src/lib.rs +++ b/mullvad-daemon/src/lib.rs @@ -44,7 +44,7 @@ use mullvad_relay_selector::{ use mullvad_types::account::{PlayPurchase, PlayPurchasePaymentToken}; #[cfg(any(windows, target_os = "android", target_os = "macos"))] use mullvad_types::settings::SplitApp; -#[cfg(target_os = "windows")] +#[cfg(any(target_os = "windows", target_os = "linux"))] use mullvad_types::wireguard::DaitaSettings; use mullvad_types::{ access_method::{AccessMethod, AccessMethodSetting}, @@ -255,7 +255,7 @@ pub enum DaemonCommand { /// Set whether to enable PQ PSK exchange in the tunnel SetQuantumResistantTunnel(ResponseTx<(), settings::Error>, QuantumResistantState), /// Set DAITA settings for the tunnel - #[cfg(target_os = "windows")] + #[cfg(any(target_os = "windows", target_os = "linux"))] SetDaitaSettings(ResponseTx<(), settings::Error>, DaitaSettings), /// Set DNS options or servers to use SetDnsOptions(ResponseTx<(), settings::Error>, DnsOptions), @@ -1172,7 +1172,7 @@ where self.on_set_quantum_resistant_tunnel(tx, quantum_resistant_state) .await } - #[cfg(target_os = "windows")] + #[cfg(any(target_os = "windows", target_os = "linux"))] SetDaitaSettings(tx, daita_settings) => { self.on_set_daita_settings(tx, daita_settings).await } @@ -2240,7 +2240,7 @@ where } } - #[cfg(target_os = "windows")] + #[cfg(any(target_os = "windows", target_os = "linux"))] async fn on_set_daita_settings( &mut self, tx: ResponseTx<(), settings::Error>, diff --git a/mullvad-daemon/src/management_interface.rs b/mullvad-daemon/src/management_interface.rs index b5f29a386e..a151feae8d 100644 --- a/mullvad-daemon/src/management_interface.rs +++ b/mullvad-daemon/src/management_interface.rs @@ -330,7 +330,7 @@ impl ManagementService for ManagementServiceImpl { Ok(Response::new(())) } - #[cfg(target_os = "windows")] + #[cfg(any(target_os = "windows", target_os = "linux"))] async fn set_daita_settings( &self, request: Request<types::DaitaSettings>, @@ -344,7 +344,7 @@ impl ManagementService for ManagementServiceImpl { Ok(Response::new(())) } - #[cfg(not(target_os = "windows"))] + #[cfg(not(any(target_os = "windows", target_os = "linux")))] async fn set_daita_settings(&self, _: Request<types::DaitaSettings>) -> ServiceResult<()> { Ok(Response::new(())) } diff --git a/mullvad-management-interface/src/client.rs b/mullvad-management-interface/src/client.rs index 3d217ace32..41609a1d4f 100644 --- a/mullvad-management-interface/src/client.rs +++ b/mullvad-management-interface/src/client.rs @@ -3,7 +3,7 @@ use crate::types; #[cfg(not(target_os = "android"))] use futures::{Stream, StreamExt}; -#[cfg(target_os = "windows")] +#[cfg(any(target_os = "windows", target_os = "linux"))] use mullvad_types::wireguard::DaitaSettings; use mullvad_types::{ access_method::AccessMethodSetting, @@ -372,7 +372,7 @@ impl MullvadProxyClient { Ok(()) } - #[cfg(target_os = "windows")] + #[cfg(any(target_os = "windows", target_os = "linux"))] pub async fn set_daita_settings(&mut self, settings: DaitaSettings) -> Result<()> { let settings = types::DaitaSettings::from(settings); self.0 diff --git a/mullvad-management-interface/src/types/conversions/custom_tunnel.rs b/mullvad-management-interface/src/types/conversions/custom_tunnel.rs index 2445ec3292..0e5f362eb6 100644 --- a/mullvad-management-interface/src/types/conversions/custom_tunnel.rs +++ b/mullvad-management-interface/src/types/conversions/custom_tunnel.rs @@ -91,7 +91,7 @@ impl TryFrom<proto::ConnectionConfig> for mullvad_types::ConnectionConfig { allowed_ips, endpoint, psk: None, - #[cfg(target_os = "windows")] + #[cfg(any(target_os = "windows", target_os = "linux"))] constant_packet_size: false, }, exit_peer: None, diff --git a/mullvad-management-interface/src/types/conversions/net.rs b/mullvad-management-interface/src/types/conversions/net.rs index 3557a6a636..77c0d1a449 100644 --- a/mullvad-management-interface/src/types/conversions/net.rs +++ b/mullvad-management-interface/src/types/conversions/net.rs @@ -40,9 +40,9 @@ impl From<talpid_types::net::TunnelEndpoint> for proto::TunnelEndpoint { tunnel_metadata: endpoint .tunnel_interface .map(|tunnel_interface| proto::TunnelMetadata { tunnel_interface }), - #[cfg(target_os = "windows")] + #[cfg(any(target_os = "windows", target_os = "linux"))] daita: endpoint.daita, - #[cfg(not(target_os = "windows"))] + #[cfg(not(any(target_os = "windows", target_os = "linux")))] daita: false, } } @@ -127,7 +127,7 @@ impl TryFrom<proto::TunnelEndpoint> for talpid_types::net::TunnelEndpoint { tunnel_interface: endpoint .tunnel_metadata .map(|tunnel_metadata| tunnel_metadata.tunnel_interface), - #[cfg(target_os = "windows")] + #[cfg(any(target_os = "windows", target_os = "linux"))] daita: endpoint.daita, }) } diff --git a/mullvad-management-interface/src/types/conversions/settings.rs b/mullvad-management-interface/src/types/conversions/settings.rs index e1d1905575..393fae6b9d 100644 --- a/mullvad-management-interface/src/types/conversions/settings.rs +++ b/mullvad-management-interface/src/types/conversions/settings.rs @@ -100,9 +100,9 @@ impl From<&mullvad_types::settings::TunnelOptions> for proto::TunnelOptions { .expect("Failed to convert std::time::Duration to prost_types::Duration for tunnel_options.wireguard.rotation_interval") }), quantum_resistant: Some(proto::QuantumResistantState::from(options.wireguard.quantum_resistant)), - #[cfg(target_os = "windows")] + #[cfg(any(target_os = "windows", target_os = "linux"))] daita: Some(proto::DaitaSettings::from(options.wireguard.daita.clone())), - #[cfg(not(target_os = "windows"))] + #[cfg(not(any(target_os = "windows", target_os = "linux")))] daita: None, }), generic: Some(proto::tunnel_options::GenericOptions { @@ -283,7 +283,7 @@ impl TryFrom<proto::TunnelOptions> for mullvad_types::settings::TunnelOptions { .ok_or(FromProtobufTypeError::InvalidArgument( "missing quantum resistant state", ))??, - #[cfg(target_os = "windows")] + #[cfg(any(target_os = "windows", target_os = "linux"))] daita: wireguard_options .daita .map(mullvad_types::wireguard::DaitaSettings::from) diff --git a/mullvad-management-interface/src/types/conversions/wireguard.rs b/mullvad-management-interface/src/types/conversions/wireguard.rs index 1ef378ef5e..875b963897 100644 --- a/mullvad-management-interface/src/types/conversions/wireguard.rs +++ b/mullvad-management-interface/src/types/conversions/wireguard.rs @@ -73,7 +73,7 @@ impl TryFrom<proto::QuantumResistantState> for mullvad_types::wireguard::Quantum } } -#[cfg(target_os = "windows")] +#[cfg(any(target_os = "windows", target_os = "linux"))] impl From<mullvad_types::wireguard::DaitaSettings> for proto::DaitaSettings { fn from(settings: mullvad_types::wireguard::DaitaSettings) -> Self { proto::DaitaSettings { @@ -82,7 +82,7 @@ impl From<mullvad_types::wireguard::DaitaSettings> for proto::DaitaSettings { } } -#[cfg(target_os = "windows")] +#[cfg(any(target_os = "windows", target_os = "linux"))] impl From<proto::DaitaSettings> for mullvad_types::wireguard::DaitaSettings { fn from(settings: proto::DaitaSettings) -> Self { mullvad_types::wireguard::DaitaSettings { diff --git a/mullvad-relay-selector/src/relay_selector/detailer.rs b/mullvad-relay-selector/src/relay_selector/detailer.rs index 3dc1cc903e..a9921c3556 100644 --- a/mullvad-relay-selector/src/relay_selector/detailer.rs +++ b/mullvad-relay-selector/src/relay_selector/detailer.rs @@ -85,7 +85,7 @@ fn wireguard_singlehop_endpoint( // This will be filled in later, not the relay selector's problem psk: None, // This will be filled in later - #[cfg(target_os = "windows")] + #[cfg(any(target_os = "windows", target_os = "linux"))] constant_packet_size: false, }; Ok(MullvadWireguardEndpoint { @@ -126,7 +126,7 @@ fn wireguard_multihop_endpoint( // This will be filled in later, not the relay selector's problem psk: None, // This will be filled in later - #[cfg(target_os = "windows")] + #[cfg(any(target_os = "windows", target_os = "linux"))] constant_packet_size: false, }; @@ -144,7 +144,7 @@ fn wireguard_multihop_endpoint( // This will be filled in later psk: None, // This will be filled in later - #[cfg(target_os = "windows")] + #[cfg(any(target_os = "windows", target_os = "linux"))] constant_packet_size: false, }; diff --git a/mullvad-types/src/wireguard.rs b/mullvad-types/src/wireguard.rs index 5bb3981a7c..2ee30df902 100644 --- a/mullvad-types/src/wireguard.rs +++ b/mullvad-types/src/wireguard.rs @@ -51,7 +51,7 @@ impl FromStr for QuantumResistantState { #[error("Not a valid state")] pub struct QuantumResistantStateParseError; -#[cfg(target_os = "windows")] +#[cfg(any(target_os = "windows", target_os = "linux"))] #[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)] pub struct DaitaSettings { pub enabled: bool, @@ -195,7 +195,7 @@ pub struct TunnelOptions { /// Obtain a PSK using the relay config client. pub quantum_resistant: QuantumResistantState, /// Configure DAITA - #[cfg(target_os = "windows")] + #[cfg(any(target_os = "windows", target_os = "linux"))] pub daita: DaitaSettings, /// Interval used for automatic key rotation pub rotation_interval: Option<RotationInterval>, @@ -207,7 +207,7 @@ impl Default for TunnelOptions { TunnelOptions { mtu: None, quantum_resistant: QuantumResistantState::Auto, - #[cfg(target_os = "windows")] + #[cfg(any(target_os = "windows", target_os = "linux"))] daita: DaitaSettings::default(), rotation_interval: None, } @@ -223,7 +223,7 @@ impl TunnelOptions { QuantumResistantState::On => true, QuantumResistantState::Off => false, }, - #[cfg(target_os = "windows")] + #[cfg(any(target_os = "windows", target_os = "linux"))] daita: self.daita.enabled, } } diff --git a/talpid-types/src/net/mod.rs b/talpid-types/src/net/mod.rs index 576899c911..09e5a39928 100644 --- a/talpid-types/src/net/mod.rs +++ b/talpid-types/src/net/mod.rs @@ -38,7 +38,7 @@ impl TunnelParameters { obfuscation: None, entry_endpoint: None, tunnel_interface: None, - #[cfg(target_os = "windows")] + #[cfg(any(target_os = "windows", target_os = "linux"))] daita: false, }, TunnelParameters::Wireguard(params) => TunnelEndpoint { @@ -55,7 +55,7 @@ impl TunnelParameters { .get_exit_endpoint() .map(|_| params.connection.get_endpoint()), tunnel_interface: None, - #[cfg(target_os = "windows")] + #[cfg(any(target_os = "windows", target_os = "linux"))] daita: params.options.daita, }, } @@ -179,7 +179,7 @@ pub struct TunnelEndpoint { pub obfuscation: Option<ObfuscationEndpoint>, pub entry_endpoint: Option<Endpoint>, pub tunnel_interface: Option<String>, - #[cfg(target_os = "windows")] + #[cfg(any(target_os = "windows", target_os = "linux"))] pub daita: bool, } diff --git a/talpid-types/src/net/wireguard.rs b/talpid-types/src/net/wireguard.rs index 4f1298323f..8fc189e64f 100644 --- a/talpid-types/src/net/wireguard.rs +++ b/talpid-types/src/net/wireguard.rs @@ -62,7 +62,7 @@ pub struct PeerConfig { #[serde(skip)] pub psk: Option<PresharedKey>, /// Enable constant packet sizes for `entry_peer`` - #[cfg(target_os = "windows")] + #[cfg(any(target_os = "windows", target_os = "linux"))] #[serde(skip)] pub constant_packet_size: bool, } @@ -82,7 +82,7 @@ pub struct TunnelOptions { /// Perform PQ-safe PSK exchange when connecting pub quantum_resistant: bool, /// Enable DAITA during tunnel config - #[cfg(target_os = "windows")] + #[cfg(any(target_os = "windows", target_os = "linux"))] pub daita: bool, } diff --git a/test/test-manager/src/tests/dns.rs b/test/test-manager/src/tests/dns.rs index a6f564139f..35a2fcc917 100644 --- a/test/test-manager/src/tests/dns.rs +++ b/test/test-manager/src/tests/dns.rs @@ -650,6 +650,8 @@ async fn connect_local_wg_relay(mullvad_client: &mut MullvadProxyClient) -> Resu allowed_ips: vec!["0.0.0.0/0".parse().unwrap()], endpoint: peer_addr, psk: None, + #[cfg(target_os = "linux")] + constant_packet_size: false, }, ipv4_gateway: CUSTOM_TUN_GATEWAY, exit_peer: None, diff --git a/test/test-manager/src/tests/helpers.rs b/test/test-manager/src/tests/helpers.rs index 96c6dc65bb..a6a2cae242 100644 --- a/test/test-manager/src/tests/helpers.rs +++ b/test/test-manager/src/tests/helpers.rs @@ -517,6 +517,8 @@ pub fn unreachable_wireguard_tunnel() -> talpid_types::net::wireguard::Connectio ], endpoint: "1.3.3.7:1234".parse().unwrap(), psk: None, + #[cfg(target_os = "linux")] + constant_packet_size: false, }, exit_peer: None, ipv4_gateway: Ipv4Addr::new(10, 64, 10, 1), diff --git a/test/test-manager/src/tests/tunnel_state.rs b/test/test-manager/src/tests/tunnel_state.rs index f75bc79498..b04a71ba5a 100644 --- a/test/test-manager/src/tests/tunnel_state.rs +++ b/test/test-manager/src/tests/tunnel_state.rs @@ -369,6 +369,8 @@ pub async fn test_connected_state( obfuscation: None, entry_endpoint: None, tunnel_interface: _, + #[cfg(target_os = "linux")] + daita: _, }, .. } => { |
