diff options
| author | David Lönnhager <david.l@mullvad.net> | 2023-11-17 11:10:16 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2023-11-17 11:10:16 +0100 |
| commit | d798fd5872e311fffeccd9930a45fdb2ed7eb2ea (patch) | |
| tree | e01cb6d76e8b3ee10c530bb85767b533fa1bebc3 /mullvad-daemon/src/lib.rs | |
| parent | 0a82036e2b49dbd42819d36860b00289b3219a6b (diff) | |
| parent | b83735c6a569baecd2272d0a78721fe7998a47ce (diff) | |
| download | mullvadvpn-d798fd5872e311fffeccd9930a45fdb2ed7eb2ea.tar.xz mullvadvpn-d798fd5872e311fffeccd9930a45fdb2ed7eb2ea.zip | |
Merge branch 'add-settings-patching' into main
Diffstat (limited to 'mullvad-daemon/src/lib.rs')
| -rw-r--r-- | mullvad-daemon/src/lib.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs index d4964a8b80..890cdfb13e 100644 --- a/mullvad-daemon/src/lib.rs +++ b/mullvad-daemon/src/lib.rs @@ -349,6 +349,8 @@ pub enum DaemonCommand { /// Verify that a google play payment was successful through the API. #[cfg(target_os = "android")] VerifyPlayPurchase(ResponseTx<(), Error>, PlayPurchase), + /// Patch the settings using a blob of JSON settings + ApplyJsonSettings(ResponseTx<(), settings::patch::Error>, String), } /// All events that can happen in the daemon. Sent from various threads and exposed interfaces. @@ -1171,6 +1173,7 @@ where VerifyPlayPurchase(tx, play_purchase) => { self.on_verify_play_purchase(tx, play_purchase) } + ApplyJsonSettings(tx, blob) => self.on_apply_json_settings(tx, blob).await, } } @@ -2439,6 +2442,18 @@ where }); } + async fn on_apply_json_settings( + &mut self, + tx: ResponseTx<(), settings::patch::Error>, + blob: String, + ) { + let result = settings::patch::merge_validate_patch(&mut self.settings, &blob).await; + if result.is_ok() { + self.reconnect_tunnel(); + } + Self::oneshot_send(tx, result, "apply_json_settings response"); + } + /// Set the target state of the client. If it changed trigger the operations needed to /// progress towards that state. /// Returns a bool representing whether or not a state change was initiated. |
