diff options
| author | Markus Pettersson <markus.pettersson@mullvad.net> | 2024-10-17 17:23:36 +0200 |
|---|---|---|
| committer | Markus Pettersson <markus.pettersson@mullvad.net> | 2024-10-29 12:41:44 +0100 |
| commit | 643c7d61c9a25d95d81d07edeae8f26dbfc8d18b (patch) | |
| tree | aacd9886485028ae1e6ae9a452606e2519bade44 /talpid-core/src | |
| parent | afb0f3d6468708abd4abe800e42c2c6d4ebd7934 (diff) | |
| download | mullvadvpn-643c7d61c9a25d95d81d07edeae8f26dbfc8d18b.tar.xz mullvadvpn-643c7d61c9a25d95d81d07edeae8f26dbfc8d18b.zip | |
Remove `block_when_disconnected` setting on Android
Diffstat (limited to 'talpid-core/src')
6 files changed, 27 insertions, 0 deletions
diff --git a/talpid-core/src/tunnel_state_machine/connected_state.rs b/talpid-core/src/tunnel_state_machine/connected_state.rs index 25c13a0643..b2ebd7a3fe 100644 --- a/talpid-core/src/tunnel_state_machine/connected_state.rs +++ b/talpid-core/src/tunnel_state_machine/connected_state.rs @@ -332,6 +332,7 @@ impl ConnectedState { let _ = complete_tx.send(()); consequence } + #[cfg(not(target_os = "android"))] Some(TunnelCommand::BlockWhenDisconnected(block_when_disconnected, complete_tx)) => { shared_values.block_when_disconnected = block_when_disconnected; let _ = complete_tx.send(()); diff --git a/talpid-core/src/tunnel_state_machine/connecting_state.rs b/talpid-core/src/tunnel_state_machine/connecting_state.rs index 7a790a11b6..6739cb4402 100644 --- a/talpid-core/src/tunnel_state_machine/connecting_state.rs +++ b/talpid-core/src/tunnel_state_machine/connecting_state.rs @@ -476,6 +476,7 @@ impl ConnectingState { let _ = complete_tx.send(()); consequence } + #[cfg(not(target_os = "android"))] Some(TunnelCommand::BlockWhenDisconnected(block_when_disconnected, complete_tx)) => { shared_values.block_when_disconnected = block_when_disconnected; let _ = complete_tx.send(()); diff --git a/talpid-core/src/tunnel_state_machine/disconnected_state.rs b/talpid-core/src/tunnel_state_machine/disconnected_state.rs index c65a04c3f3..12e9c5aaa2 100644 --- a/talpid-core/src/tunnel_state_machine/disconnected_state.rs +++ b/talpid-core/src/tunnel_state_machine/disconnected_state.rs @@ -2,6 +2,7 @@ use super::{ ConnectingState, EventConsequence, SharedTunnelStateValues, TunnelCommand, TunnelCommandReceiver, TunnelState, TunnelStateTransition, }; +#[cfg(not(target_os = "android"))] use crate::firewall::FirewallPolicy; #[cfg(target_os = "macos")] use crate::{dns, tunnel_state_machine::ErrorState}; @@ -55,6 +56,7 @@ impl DisconnectedState { Self::construct_state_transition(shared_values) } + #[cfg_attr(target_os = "android", allow(unused_variables))] fn construct_state_transition( shared_values: &mut SharedTunnelStateValues, ) -> (Box<dyn TunnelState>, TunnelStateTransition) { @@ -63,11 +65,13 @@ impl DisconnectedState { TunnelStateTransition::Disconnected { // Being disconnected and having lockdown mode enabled implies that your internet // access is locked down + #[cfg(not(target_os = "android"))] locked_down: shared_values.block_when_disconnected, }, ) } + #[cfg(not(target_os = "android"))] fn set_firewall_policy( shared_values: &mut SharedTunnelStateValues, should_reset_firewall: bool, @@ -98,6 +102,13 @@ impl DisconnectedState { } } + // NOTE: There is no firewall on Android, so it is pointless to pretend to enforce firewall + // policies by calling a bunch of functions that will end up being a no-op. The proper + // long-term fix would be to remove the firewall module completely, + // but I leave this for a future developer to clean up. + #[cfg(target_os = "android")] + fn set_firewall_policy(_: &mut SharedTunnelStateValues, _: bool) {} + #[cfg(windows)] fn register_split_tunnel_addresses( shared_values: &mut SharedTunnelStateValues, @@ -176,6 +187,7 @@ impl TunnelState for DisconnectedState { let _ = complete_tx.send(()); SameState(self) } + #[cfg(not(target_os = "android"))] Some(TunnelCommand::BlockWhenDisconnected(block_when_disconnected, complete_tx)) => { if shared_values.block_when_disconnected != block_when_disconnected { shared_values.block_when_disconnected = block_when_disconnected; diff --git a/talpid-core/src/tunnel_state_machine/disconnecting_state.rs b/talpid-core/src/tunnel_state_machine/disconnecting_state.rs index 4a108788e1..b8d43ac7e9 100644 --- a/talpid-core/src/tunnel_state_machine/disconnecting_state.rs +++ b/talpid-core/src/tunnel_state_machine/disconnecting_state.rs @@ -55,6 +55,7 @@ impl DisconnectingState { let _ = complete_tx.send(()); AfterDisconnect::Nothing } + #[cfg(not(target_os = "android"))] Some(TunnelCommand::BlockWhenDisconnected( block_when_disconnected, complete_tx, @@ -109,6 +110,7 @@ impl DisconnectingState { let _ = complete_tx.send(()); AfterDisconnect::Block(reason) } + #[cfg(not(target_os = "android"))] Some(TunnelCommand::BlockWhenDisconnected( block_when_disconnected, complete_tx, @@ -167,6 +169,7 @@ impl DisconnectingState { let _ = complete_tx.send(()); AfterDisconnect::Reconnect(retry_attempt) } + #[cfg(not(target_os = "android"))] Some(TunnelCommand::BlockWhenDisconnected( block_when_disconnected, complete_tx, diff --git a/talpid-core/src/tunnel_state_machine/error_state.rs b/talpid-core/src/tunnel_state_machine/error_state.rs index 1b154840e2..a9ba470bfb 100644 --- a/talpid-core/src/tunnel_state_machine/error_state.rs +++ b/talpid-core/src/tunnel_state_machine/error_state.rs @@ -181,6 +181,7 @@ impl TunnelState for ErrorState { let _ = complete_tx.send(()); consequence } + #[cfg(not(target_os = "android"))] Some(TunnelCommand::BlockWhenDisconnected(block_when_disconnected, complete_tx)) => { shared_values.block_when_disconnected = block_when_disconnected; let _ = complete_tx.send(()); diff --git a/talpid-core/src/tunnel_state_machine/mod.rs b/talpid-core/src/tunnel_state_machine/mod.rs index e0ef07850d..6a1d779be8 100644 --- a/talpid-core/src/tunnel_state_machine/mod.rs +++ b/talpid-core/src/tunnel_state_machine/mod.rs @@ -90,6 +90,7 @@ pub struct InitialTunnelState { /// Whether to allow LAN traffic when not in the (non-blocking) disconnected state. pub allow_lan: bool, /// Block traffic unless connected to the VPN. + #[cfg(not(target_os = "android"))] pub block_when_disconnected: bool, /// DNS configuration to use pub dns_config: DnsConfig, @@ -190,6 +191,7 @@ pub enum TunnelCommand { /// Set DNS configuration to use. Dns(crate::dns::DnsConfig, oneshot::Sender<()>), /// Enable or disable the block_when_disconnected feature. + #[cfg(not(target_os = "android"))] BlockWhenDisconnected(bool, oneshot::Sender<()>), /// Notify the state machine of the connectivity of the device. Connectivity(Connectivity), @@ -292,12 +294,17 @@ impl TunnelStateMachine { split_tunnel::SplitTunnel::spawn(args.command_tx.clone(), route_manager.clone()); let fw_args = FirewallArguments { + #[cfg(not(target_os = "android"))] initial_state: if args.settings.block_when_disconnected || !args.settings.reset_firewall { InitialFirewallState::Blocked(args.settings.allowed_endpoint.clone()) } else { InitialFirewallState::None }, + // NOTE: This really has no effect. In all honesty, we should probably remove the + // firewall stub completely. + #[cfg(target_os = "android")] + initial_state: InitialFirewallState::None, allow_lan: args.settings.allow_lan, #[cfg(target_os = "linux")] fwmark: args.linux_ids.fwmark, @@ -371,6 +378,7 @@ impl TunnelStateMachine { route_manager, _offline_monitor: offline_monitor, allow_lan: args.settings.allow_lan, + #[cfg(not(target_os = "android"))] block_when_disconnected: args.settings.block_when_disconnected, connectivity, dns_config: args.settings.dns_config, @@ -463,6 +471,7 @@ struct SharedTunnelStateValues { /// Should LAN access be allowed outside the tunnel. allow_lan: bool, /// Should network access be allowed when in the disconnected state. + #[cfg(not(target_os = "android"))] block_when_disconnected: bool, /// True when the computer is known to be offline. connectivity: Connectivity, |
