diff options
| author | Linus Färnstrand <faern@faern.net> | 2023-03-22 13:56:33 +0100 |
|---|---|---|
| committer | Linus Färnstrand <faern@faern.net> | 2023-03-23 09:53:11 +0100 |
| commit | 4ad0cc856dcb77aa7a8126ece1dd6abc992df25b (patch) | |
| tree | 5f6b4d9b94bfa76fc731c8066e1cb50016897855 | |
| parent | bc9b34fc93eae89ac68ddd530e00e5319fa423df (diff) | |
| download | mullvadvpn-4ad0cc856dcb77aa7a8126ece1dd6abc992df25b.tar.xz mullvadvpn-4ad0cc856dcb77aa7a8126ece1dd6abc992df25b.zip | |
Add settings migration for udp2tcp port constraint
| -rw-r--r-- | mullvad-daemon/src/migrations/v6.rs | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/mullvad-daemon/src/migrations/v6.rs b/mullvad-daemon/src/migrations/v6.rs index 3fa6da7d43..b5ba7fdf5b 100644 --- a/mullvad-daemon/src/migrations/v6.rs +++ b/mullvad-daemon/src/migrations/v6.rs @@ -1,4 +1,5 @@ use super::{Error, Result}; +use mullvad_types::relay_constraints::Constraint; use mullvad_types::settings::SettingsVersion; // ====================================================== @@ -24,6 +25,9 @@ pub enum QuantumResistantState { /// /// The `use_pq_safe_psk` tunnel option is replaced by `quantum_resistant`, which /// is optional. `false` is mapped to `None`. `true` is mapped to `Some(true)`. +/// +/// Migrate WireGuard over TCP port setting away from Only(443) (to auto), +/// since it's no longer a valid port. pub fn migrate(settings: &mut serde_json::Value) -> Result<()> { if !version_matches(settings) { return Ok(()); @@ -31,6 +35,8 @@ pub fn migrate(settings: &mut serde_json::Value) -> Result<()> { migrate_pq_setting(settings)?; + migrate_udp2tcp_port_443(settings); + // TODO // log::info!("Migrating settings format to V7"); @@ -62,6 +68,19 @@ fn migrate_pq_setting(settings: &mut serde_json::Value) -> Result<()> { Ok(()) } +/// If udp2tcp port constraint is set to `Only(443)`, change that to `Any` +fn migrate_udp2tcp_port_443(settings: &mut serde_json::Value) -> Option<()> { + let port_constraint = settings + .get_mut("obfuscation_settings")? + .get_mut("udp2tcp")? + .get_mut("port")?; + if port_constraint == &serde_json::json!(Constraint::Only(443)) { + log::info!("Migrating udp2tcp port setting from 443 -> any"); + *port_constraint = serde_json::json!(Constraint::<u16>::Any); + } + None +} + fn version_matches(settings: &mut serde_json::Value) -> bool { settings .get("settings_version") @@ -110,7 +129,9 @@ mod test { "obfuscation_settings": { "selected_obfuscation": "udp2_tcp", "udp2tcp": { - "port": "any" + "port": { + "only": 443 + } } }, "bridge_state": "auto", |
