diff options
| author | Sebastian Holmin <sebastian.holmin@mullvad.net> | 2025-03-07 14:17:53 +0100 |
|---|---|---|
| committer | Sebastian Holmin <sebastian.holmin@mullvad.net> | 2025-03-07 15:46:55 +0100 |
| commit | 9558232677cf157c1897602a2d8bc235e0d76b64 (patch) | |
| tree | 19fd9b1f4bb73e3be5f6ffd051be80e4b3dd5d37 | |
| parent | a37009c0f4a4187f0be847d335216003702a5f39 (diff) | |
| download | mullvadvpn-9558232677cf157c1897602a2d8bc235e0d76b64.tar.xz mullvadvpn-9558232677cf157c1897602a2d8bc235e0d76b64.zip | |
Remove tunnel protocol migration from v9
| -rw-r--r-- | mullvad-daemon/src/migrations/v9.rs | 59 |
1 files changed, 3 insertions, 56 deletions
diff --git a/mullvad-daemon/src/migrations/v9.rs b/mullvad-daemon/src/migrations/v9.rs index 36ac89ed6d..91aac7e53b 100644 --- a/mullvad-daemon/src/migrations/v9.rs +++ b/mullvad-daemon/src/migrations/v9.rs @@ -84,64 +84,11 @@ pub fn migrate( } } - migrate_tunnel_type(settings)?; + json_blob["settings_version"] = serde_json::json!(SettingsVersion::V10); - // TODO: Uncomment this when closing the migration: - // json_blob["settings_version"] = serde_json::json!(SettingsVersion::V10); - - Ok(()) -} - -fn migrate_tunnel_type(settings: &mut serde_json::Value) -> Result<()> { - let Some(ref mut normal) = relay_settings(settings) else { - return Ok(()); - }; - match normal.get_mut("tunnel_protocol") { - // Already migrated - Some(serde_json::Value::String(s)) if s == "any" => { - // If openvpn is selected, migrate to openvpn tunnel type - // Otherwise, select wireguard - let hostname = normal - .get_mut("location") - .and_then(|location| location.get_mut("only")) - .and_then(|only| only.get_mut("location")) - .and_then(|only| only.get_mut("hostname").cloned()); - - let protocol = if let Some(serde_json::Value::String(s)) = hostname { - if s.split('-').any(|token| token == "ovpn") { - TunnelType::OpenVpn - } else { - TunnelType::Wireguard - } - } else { - TunnelType::Wireguard - }; - - normal["tunnel_protocol"] = serde_json::json!(protocol); - } - // Migrate - Some(serde_json::Value::Object(ref mut constraint)) => { - if let Some(tunnel_type) = constraint.get("only") { - let tunnel_type: TunnelType = serde_json::from_value(tunnel_type.clone()) - .map_err(|_| Error::InvalidSettingsContent)?; - normal["tunnel_protocol"] = serde_json::json!(tunnel_type); - } else { - return Err(Error::InvalidSettingsContent); - } - } - Some(_) => { - return Err(Error::InvalidSettingsContent); - } - // Unexpected result. Do nothing. - None => (), - } Ok(()) } -fn relay_settings(settings: &mut serde_json::Value) -> Option<&mut serde_json::Value> { - settings.get_mut("relay_settings")?.get_mut("normal") -} - fn version_matches(settings: &serde_json::Value) -> bool { settings .get("settings_version") @@ -644,7 +591,7 @@ mod test { }, "providers": "any", "ownership": "any", - "tunnel_protocol": "openvpn", + "tunnel_protocol": "any", "wireguard_constraints": { "port": "any", "ip_version": "any", @@ -732,7 +679,7 @@ mod test { }, "relay_overrides": [], "show_beta_releases": true, - "settings_version": 9 + "settings_version": 10 } "#; } |
