summaryrefslogtreecommitdiffhomepage
path: root/talpid-core
diff options
context:
space:
mode:
authorTobias Järvelöv <tobias.jarvelov@mullvad.net>2025-09-18 17:19:55 +0200
committerTobias Järvelöv <tobias.jarvelov@mullvad.net>2025-09-30 10:27:20 +0200
commitc82bc5ef00a87bf96ee4ed3d3a55e35716f3375c (patch)
treefc25a5cbf10332889692860af0a999f61fcbd8c4 /talpid-core
parentdc2d5096fdd7f65bcc1b0ddfb196b4a548475bf1 (diff)
downloadmullvadvpn-c82bc5ef00a87bf96ee4ed3d3a55e35716f3375c.tar.xz
mullvadvpn-c82bc5ef00a87bf96ee4ed3d3a55e35716f3375c.zip
Rename block_when_disconnected to lockdown_mode in talpid crates
Diffstat (limited to 'talpid-core')
-rw-r--r--talpid-core/src/tunnel_state_machine/connected_state.rs4
-rw-r--r--talpid-core/src/tunnel_state_machine/connecting_state.rs4
-rw-r--r--talpid-core/src/tunnel_state_machine/disconnected_state.rs20
-rw-r--r--talpid-core/src/tunnel_state_machine/disconnecting_state.rs4
-rw-r--r--talpid-core/src/tunnel_state_machine/error_state.rs4
-rw-r--r--talpid-core/src/tunnel_state_machine/mod.rs42
6 files changed, 38 insertions, 40 deletions
diff --git a/talpid-core/src/tunnel_state_machine/connected_state.rs b/talpid-core/src/tunnel_state_machine/connected_state.rs
index 5076338653..b488c4dec0 100644
--- a/talpid-core/src/tunnel_state_machine/connected_state.rs
+++ b/talpid-core/src/tunnel_state_machine/connected_state.rs
@@ -337,8 +337,8 @@ impl ConnectedState {
consequence
}
#[cfg(not(target_os = "android"))]
- Some(TunnelCommand::BlockWhenDisconnected(block_when_disconnected, complete_tx)) => {
- shared_values.block_when_disconnected = block_when_disconnected;
+ Some(TunnelCommand::LockdownMode(lockdown_mode, complete_tx)) => {
+ shared_values.lockdown_mode = lockdown_mode;
let _ = complete_tx.send(());
SameState(self)
}
diff --git a/talpid-core/src/tunnel_state_machine/connecting_state.rs b/talpid-core/src/tunnel_state_machine/connecting_state.rs
index 479238af60..f338a9b7c3 100644
--- a/talpid-core/src/tunnel_state_machine/connecting_state.rs
+++ b/talpid-core/src/tunnel_state_machine/connecting_state.rs
@@ -474,8 +474,8 @@ impl ConnectingState {
consequence
}
#[cfg(not(target_os = "android"))]
- Some(TunnelCommand::BlockWhenDisconnected(block_when_disconnected, complete_tx)) => {
- shared_values.block_when_disconnected = block_when_disconnected;
+ Some(TunnelCommand::LockdownMode(lockdown_mode, complete_tx)) => {
+ shared_values.lockdown_mode = lockdown_mode;
let _ = complete_tx.send(());
SameState(self)
}
diff --git a/talpid-core/src/tunnel_state_machine/disconnected_state.rs b/talpid-core/src/tunnel_state_machine/disconnected_state.rs
index 024958bdc6..3d1e98830e 100644
--- a/talpid-core/src/tunnel_state_machine/disconnected_state.rs
+++ b/talpid-core/src/tunnel_state_machine/disconnected_state.rs
@@ -30,7 +30,7 @@ impl DisconnectedState {
);
}
#[cfg(target_os = "macos")]
- if shared_values.block_when_disconnected.bool() {
+ if shared_values.lockdown_mode.bool() {
if let Err(err) = Self::setup_local_dns_config(shared_values) {
log::error!(
"{}",
@@ -64,7 +64,7 @@ impl DisconnectedState {
// 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.bool(),
+ locked_down: shared_values.lockdown_mode.bool(),
},
)
}
@@ -74,13 +74,13 @@ impl DisconnectedState {
shared_values: &mut SharedTunnelStateValues,
should_reset_firewall: bool,
) {
- let result = if shared_values.block_when_disconnected.bool() {
+ let result = if shared_values.lockdown_mode.bool() {
#[cfg(target_os = "windows")]
{
- // Respect the persist flag of BlockWhenDisconnected.
+ // Respect the persist flag of LockdownMode.
shared_values
.firewall
- .persist(shared_values.block_when_disconnected.should_persist());
+ .persist(shared_values.lockdown_mode.should_persist());
}
let policy = FirewallPolicy::Blocked {
@@ -118,7 +118,7 @@ impl DisconnectedState {
shared_values: &mut SharedTunnelStateValues,
should_reset_firewall: bool,
) {
- if should_reset_firewall && !shared_values.block_when_disconnected.bool() {
+ if should_reset_firewall && !shared_values.lockdown_mode.bool() {
if let Err(error) = shared_values.split_tunnel.clear_tunnel_addresses() {
log::error!(
"{}",
@@ -193,9 +193,9 @@ impl TunnelState for DisconnectedState {
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;
+ Some(TunnelCommand::LockdownMode(lockdown_mode, complete_tx)) => {
+ if shared_values.lockdown_mode != lockdown_mode {
+ shared_values.lockdown_mode = lockdown_mode;
// TODO: Investigate if we can simply return
// `NewState(Self::enter(shared_values, true))`.
@@ -206,7 +206,7 @@ impl TunnelState for DisconnectedState {
#[cfg(windows)]
Self::register_split_tunnel_addresses(shared_values, true);
#[cfg(target_os = "macos")]
- if block_when_disconnected.bool() {
+ if lockdown_mode.bool() {
if let Err(err) = Self::setup_local_dns_config(shared_values) {
log::error!(
"{}",
diff --git a/talpid-core/src/tunnel_state_machine/disconnecting_state.rs b/talpid-core/src/tunnel_state_machine/disconnecting_state.rs
index a93be7b740..51807b76da 100644
--- a/talpid-core/src/tunnel_state_machine/disconnecting_state.rs
+++ b/talpid-core/src/tunnel_state_machine/disconnecting_state.rs
@@ -51,8 +51,8 @@ impl DisconnectingState {
let _ = complete_tx.send(());
}
#[cfg(not(target_os = "android"))]
- Some(TunnelCommand::BlockWhenDisconnected(block_when_disconnected, complete_tx)) => {
- shared_values.block_when_disconnected = block_when_disconnected;
+ Some(TunnelCommand::LockdownMode(lockdown_mode, complete_tx)) => {
+ shared_values.lockdown_mode = lockdown_mode;
let _ = complete_tx.send(());
}
Some(TunnelCommand::Connectivity(connectivity)) => {
diff --git a/talpid-core/src/tunnel_state_machine/error_state.rs b/talpid-core/src/tunnel_state_machine/error_state.rs
index 32e4747f47..e6f1008a73 100644
--- a/talpid-core/src/tunnel_state_machine/error_state.rs
+++ b/talpid-core/src/tunnel_state_machine/error_state.rs
@@ -177,8 +177,8 @@ impl TunnelState for ErrorState {
consequence
}
#[cfg(not(target_os = "android"))]
- Some(TunnelCommand::BlockWhenDisconnected(block_when_disconnected, complete_tx)) => {
- shared_values.block_when_disconnected = block_when_disconnected;
+ Some(TunnelCommand::LockdownMode(lockdown_mode, complete_tx)) => {
+ shared_values.lockdown_mode = lockdown_mode;
let _ = complete_tx.send(());
SameState(self)
}
diff --git a/talpid-core/src/tunnel_state_machine/mod.rs b/talpid-core/src/tunnel_state_machine/mod.rs
index 0dd029cf86..16e15d08a0 100644
--- a/talpid-core/src/tunnel_state_machine/mod.rs
+++ b/talpid-core/src/tunnel_state_machine/mod.rs
@@ -95,7 +95,7 @@ pub struct InitialTunnelState {
pub allow_lan: bool,
/// Block traffic unless connected to the VPN.
#[cfg(not(target_os = "android"))]
- pub block_when_disconnected: BlockWhenDisconnected,
+ pub lockdown_mode: LockdownMode,
/// DNS configuration to use
pub dns_config: DnsConfig,
/// A single endpoint that is allowed to communicate outside the tunnel, i.e.
@@ -199,9 +199,9 @@ pub enum TunnelCommand {
AllowEndpoint(AllowedEndpoint, oneshot::Sender<()>),
/// Set DNS configuration to use.
Dns(crate::dns::DnsConfig, oneshot::Sender<()>),
- /// Enable or disable the block_when_disconnected feature.
+ /// Enable or disable the lockdown_mode feature.
#[cfg(not(target_os = "android"))]
- BlockWhenDisconnected(BlockWhenDisconnected, oneshot::Sender<()>),
+ LockdownMode(LockdownMode, oneshot::Sender<()>),
/// Notify the state machine of the connectivity of the device.
Connectivity(Connectivity),
/// Open tunnel connection.
@@ -236,12 +236,12 @@ enum EventResult {
}
/// If firewall should apply blocking rules in the disconnected state.
-/// Argument of TunnelCommand::BlockWhenDisconnected message.
+/// Argument of TunnelCommand::LockdownMode message.
///
/// Semantically equivalent to a boolean value, but is grouped togetether with the persist
/// parameter on Windows for cohesiveness.
#[derive(Clone, Copy, Debug)]
-pub enum BlockWhenDisconnected {
+pub enum LockdownMode {
/// Firewall should *not* apply blocking rules.
Disabled,
/// Firewall should apply blocking rules.
@@ -251,28 +251,28 @@ pub enum BlockWhenDisconnected {
},
}
-impl BlockWhenDisconnected {
+impl LockdownMode {
/// `true`. Apply blocking firewall rules in the disconnected state.
pub const fn yes() -> Self {
- BlockWhenDisconnected::Enabled { persist: true }
+ LockdownMode::Enabled { persist: true }
}
/// `false`. Do *not* apply blocking firewall rules in the disconnected state.
pub const fn no() -> Self {
- BlockWhenDisconnected::Disabled
+ LockdownMode::Disabled
}
/// [self] as a boolean value.
pub const fn bool(&self) -> bool {
- matches!(self, BlockWhenDisconnected::Enabled { .. })
+ matches!(self, LockdownMode::Enabled { .. })
}
- /// If [BlockWhenDisconnected] should persist across reboots.
+ /// If [LockdownMode] should persist across reboots.
///
/// Semantically meaningless on non-Windows platforms, will always return true.
pub const fn should_persist(&self) -> bool {
if cfg!(target_os = "windows") {
- matches!(&self, BlockWhenDisconnected::Enabled { persist: true })
+ matches!(&self, LockdownMode::Enabled { persist: true })
} else {
true
}
@@ -288,24 +288,24 @@ impl BlockWhenDisconnected {
#[cfg(target_os = "windows")]
pub fn persist(self, persist: bool) -> Self {
match self {
- BlockWhenDisconnected::Disabled => BlockWhenDisconnected::Disabled,
+ LockdownMode::Disabled => LockdownMode::Disabled,
// Forget previous value of persist
- BlockWhenDisconnected::Enabled { .. } => BlockWhenDisconnected::Enabled { persist },
+ LockdownMode::Enabled { .. } => LockdownMode::Enabled { persist },
}
}
}
-impl From<bool> for BlockWhenDisconnected {
+impl From<bool> for LockdownMode {
fn from(block: bool) -> Self {
if block {
- BlockWhenDisconnected::yes()
+ LockdownMode::yes()
} else {
- BlockWhenDisconnected::no()
+ LockdownMode::no()
}
}
}
-impl PartialEq for BlockWhenDisconnected {
+impl PartialEq for LockdownMode {
fn eq(&self, other: &Self) -> bool {
self.bool() == other.bool()
}
@@ -385,9 +385,7 @@ impl TunnelStateMachine {
let fw_args = FirewallArguments {
#[cfg(not(target_os = "android"))]
- initial_state: if args.settings.block_when_disconnected.bool()
- || !args.settings.reset_firewall
- {
+ initial_state: if args.settings.lockdown_mode.bool() || !args.settings.reset_firewall {
InitialFirewallState::Blocked(args.settings.allowed_endpoint.clone())
} else {
InitialFirewallState::None
@@ -470,7 +468,7 @@ impl TunnelStateMachine {
_offline_monitor: offline_monitor,
allow_lan: args.settings.allow_lan,
#[cfg(not(target_os = "android"))]
- block_when_disconnected: args.settings.block_when_disconnected,
+ lockdown_mode: args.settings.lockdown_mode,
connectivity,
dns_config: args.settings.dns_config,
allowed_endpoint: args.settings.allowed_endpoint,
@@ -565,7 +563,7 @@ struct SharedTunnelStateValues {
allow_lan: bool,
/// Should network access be allowed when in the disconnected state.
#[cfg(not(target_os = "android"))]
- block_when_disconnected: BlockWhenDisconnected,
+ lockdown_mode: LockdownMode,
/// True when the computer is known to be offline.
connectivity: Connectivity,
/// DNS configuration to use.