diff options
| author | Markus Pettersson <markus.pettersson@mullvad.net> | 2023-09-19 13:43:53 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2023-10-09 14:40:06 +0200 |
| commit | fc477f4e4df6db2973ff88fc4b6819d38d64d8cc (patch) | |
| tree | 069b709abb09599b37f32716de679298095bc1c1 /mullvad-daemon/src/access_methods.rs | |
| parent | be5e93c32f3b3e9ec59da18215fad80457dd4d49 (diff) | |
| download | mullvadvpn-fc477f4e4df6db2973ff88fc4b6819d38d64d8cc.tar.xz mullvadvpn-fc477f4e4df6db2973ff88fc4b6819d38d64d8cc.zip | |
Add `mullvad proxy use`
Allow for settings a specific Access Method to use
Diffstat (limited to 'mullvad-daemon/src/access_methods.rs')
| -rw-r--r-- | mullvad-daemon/src/access_methods.rs | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/mullvad-daemon/src/access_methods.rs b/mullvad-daemon/src/access_methods.rs index 79afdae054..a0c168c026 100644 --- a/mullvad-daemon/src/access_methods.rs +++ b/mullvad-daemon/src/access_methods.rs @@ -86,22 +86,29 @@ where .map_err(Error::Settings) } + pub async fn set_api_access_method( + &mut self, + access_method: AccessMethod, + ) -> Result<(), Error> { + { + let mut connection_modes = self.connection_modes.lock().unwrap(); + connection_modes.set_access_method(access_method); + } + // Force a rotation of Acces Methods. + let _ = self.api_handle.service().next_api_endpoint(); + Ok(()) + } + /// If settings were changed due to an update, notify all listeners. fn notify_on_change(&mut self, settings_changed: MadeChanges) { if settings_changed { self.event_listener .notify_settings(self.settings.to_settings()); - }; - // TODO: Could this be replaced by message passing? Yes plz. - let mut connection_modes = self.connection_modes.lock().unwrap(); - *connection_modes = self - .settings - .api_access_methods - .api_access_methods - .clone() - .into_iter() - .map(|x| (x, 1)) - .collect(); + // TODO: Could this be replaced by message passing? Yes plz. + let mut connection_modes = self.connection_modes.lock().unwrap(); + connection_modes + .update_access_methods(self.settings.api_access_methods.api_access_methods.clone()) + }; } } |
