Skip to content

Commit 8c4ab04

Browse files
committed
Remove tunnel protocol migration from v9
1 parent 2c635c5 commit 8c4ab04

File tree

1 file changed

+3
-56
lines changed
  • mullvad-daemon/src/migrations

1 file changed

+3
-56
lines changed

mullvad-daemon/src/migrations/v9.rs

+3-56
Original file line numberDiff line numberDiff line change
@@ -84,64 +84,11 @@ pub fn migrate(
8484
}
8585
}
8686

87-
migrate_tunnel_type(settings)?;
88-
89-
// TODO: Uncomment this when closing the migration:
90-
// json_blob["settings_version"] = serde_json::json!(SettingsVersion::V10);
87+
json_blob["settings_version"] = serde_json::json!(SettingsVersion::V10);
9188

9289
Ok(())
9390
}
9491

95-
fn migrate_tunnel_type(settings: &mut serde_json::Value) -> Result<()> {
96-
let Some(ref mut normal) = relay_settings(settings) else {
97-
return Ok(());
98-
};
99-
match normal.get_mut("tunnel_protocol") {
100-
// Already migrated
101-
Some(serde_json::Value::String(s)) if s == "any" => {
102-
// If openvpn is selected, migrate to openvpn tunnel type
103-
// Otherwise, select wireguard
104-
let hostname = normal
105-
.get_mut("location")
106-
.and_then(|location| location.get_mut("only"))
107-
.and_then(|only| only.get_mut("location"))
108-
.and_then(|only| only.get_mut("hostname").cloned());
109-
110-
let protocol = if let Some(serde_json::Value::String(s)) = hostname {
111-
if s.split('-').any(|token| token == "ovpn") {
112-
TunnelType::OpenVpn
113-
} else {
114-
TunnelType::Wireguard
115-
}
116-
} else {
117-
TunnelType::Wireguard
118-
};
119-
120-
normal["tunnel_protocol"] = serde_json::json!(protocol);
121-
}
122-
// Migrate
123-
Some(serde_json::Value::Object(ref mut constraint)) => {
124-
if let Some(tunnel_type) = constraint.get("only") {
125-
let tunnel_type: TunnelType = serde_json::from_value(tunnel_type.clone())
126-
.map_err(|_| Error::InvalidSettingsContent)?;
127-
normal["tunnel_protocol"] = serde_json::json!(tunnel_type);
128-
} else {
129-
return Err(Error::InvalidSettingsContent);
130-
}
131-
}
132-
Some(_) => {
133-
return Err(Error::InvalidSettingsContent);
134-
}
135-
// Unexpected result. Do nothing.
136-
None => (),
137-
}
138-
Ok(())
139-
}
140-
141-
fn relay_settings(settings: &mut serde_json::Value) -> Option<&mut serde_json::Value> {
142-
settings.get_mut("relay_settings")?.get_mut("normal")
143-
}
144-
14592
fn version_matches(settings: &serde_json::Value) -> bool {
14693
settings
14794
.get("settings_version")
@@ -644,7 +591,7 @@ mod test {
644591
},
645592
"providers": "any",
646593
"ownership": "any",
647-
"tunnel_protocol": "openvpn",
594+
"tunnel_protocol": "any",
648595
"wireguard_constraints": {
649596
"port": "any",
650597
"ip_version": "any",
@@ -732,7 +679,7 @@ mod test {
732679
},
733680
"relay_overrides": [],
734681
"show_beta_releases": true,
735-
"settings_version": 9
682+
"settings_version": 10
736683
}
737684
"#;
738685
}

0 commit comments

Comments
 (0)