Skip to content

Commit

Permalink
Use previous IP override indicator on settings change
Browse files Browse the repository at this point in the history
  • Loading branch information
Serock3 authored and dlon committed Aug 22, 2024
1 parent dfe166d commit 6d1a486
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions mullvad-daemon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ use mullvad_types::{
auth_failed::AuthFailed,
custom_list::CustomList,
device::{Device, DeviceEvent, DeviceEventCause, DeviceId, DeviceState, RemoveDeviceEvent},
features::{compute_feature_indicators, FeatureIndicators},
features::{compute_feature_indicators, FeatureIndicator, FeatureIndicators},
location::{GeoIpLocation, LocationEventData},
relay_constraints::{
BridgeSettings, BridgeState, BridgeType, ObfuscationSettings, RelayOverride, RelaySettings,
Expand Down Expand Up @@ -958,7 +958,7 @@ impl Daemon {
DeviceMigrationEvent(event) => self.handle_device_migration_event(event),
LocationEvent(location_data) => self.handle_location_event(location_data),
SettingsChanged => {
self.update_feature_indicators_on_settings_changed().await;
self.update_feature_indicators_on_settings_changed();
}
#[cfg(any(windows, target_os = "android", target_os = "macos"))]
ExcludedPathsEvent(update, tx) => self.handle_new_excluded_paths(update, tx).await,
Expand Down Expand Up @@ -1135,7 +1135,7 @@ impl Daemon {
}

/// Update the set of feature indicators based on the new settings.
async fn update_feature_indicators_on_settings_changed(&mut self) {
fn update_feature_indicators_on_settings_changed(&mut self) {
// Updated settings may affect the feature indicators, even if they don't change the tunnel
// state (e.g. activating lockdown mode). Note that only the connected and connecting states
// have feature indicators.
Expand All @@ -1150,7 +1150,13 @@ impl Daemon {
endpoint,
..
} => {
let ip_override = self.parameters_generator.last_relay_was_overridden().await;
// The server IP override feature indicator can only be changed when the tunnels
// state changes and it is updated in `handle_tunnel_state_transition`. We must rely
// on this value being up to date as we need the relay to know if
// the IP override is active.
let ip_override = feature_indicators
.active_features()
.any(|f| matches!(&f, FeatureIndicator::ServerIpOverride));
let new_feature_indicators =
compute_feature_indicators(&self.settings.to_settings(), endpoint, ip_override);
// Update and broadcast the new feature indicators if they have changed
Expand Down

0 comments on commit 6d1a486

Please sign in to comment.