diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2018-09-07 13:49:51 +0200 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2018-09-08 09:39:17 +0200 |
| commit | 7cbaf720cb4f44ac575d07d3c6e124824d003817 (patch) | |
| tree | c6dfeb37454a129acc8cef312c7b014006ef00d7 | |
| parent | 08feb489b790f76fbb10c9ab64eda9444d0bdfdd (diff) | |
| download | mullvadvpn-7cbaf720cb4f44ac575d07d3c6e124824d003817.tar.xz mullvadvpn-7cbaf720cb4f44ac575d07d3c6e124824d003817.zip | |
Add get_settings call to management interface
| -rw-r--r-- | mullvad-daemon/src/main.rs | 5 | ||||
| -rw-r--r-- | mullvad-daemon/src/management_interface.rs | 16 |
2 files changed, 20 insertions, 1 deletions
diff --git a/mullvad-daemon/src/main.rs b/mullvad-daemon/src/main.rs index 582e9bbc87..5610d63e98 100644 --- a/mullvad-daemon/src/main.rs +++ b/mullvad-daemon/src/main.rs @@ -364,6 +364,7 @@ impl Daemon { SetOpenVpnMssfix(tx, mssfix_arg) => self.on_set_openvpn_mssfix(tx, mssfix_arg), SetEnableIpv6(tx, enable_ipv6) => self.on_set_enable_ipv6(tx, enable_ipv6), GetTunnelOptions(tx) => self.on_get_tunnel_options(tx), + GetSettings(tx) => Ok(self.on_get_settings(tx)), GetRelaySettings(tx) => Ok(self.on_get_relay_settings(tx)), GetVersionInfo(tx) => Ok(self.on_get_version_info(tx)), GetCurrentVersion(tx) => Ok(self.on_get_current_version(tx)), @@ -597,6 +598,10 @@ impl Daemon { Ok(()) } + fn on_get_settings(&self, tx: OneshotSender<settings::Settings>) { + Self::oneshot_send(tx, self.settings.clone(), "get_settings response"); + } + fn oneshot_send<T>(tx: OneshotSender<T>, t: T, msg: &'static str) { if let Err(_) = tx.send(t) { warn!("Unable to send {} to management interface client", msg); diff --git a/mullvad-daemon/src/management_interface.rs b/mullvad-daemon/src/management_interface.rs index 05903f61b0..4039136299 100644 --- a/mullvad-daemon/src/management_interface.rs +++ b/mullvad-daemon/src/management_interface.rs @@ -40,7 +40,6 @@ build_rpc_trait! { pub trait ManagementInterfaceApi { type Metadata; - /// Fetches and returns metadata about an account. Returns an error on non-existing /// accounts. #[rpc(meta, name = "get_account_data")] @@ -131,6 +130,10 @@ build_rpc_trait! { #[rpc(meta, name = "get_tunnel_options")] fn get_tunnel_options(&self, Self::Metadata) -> BoxFuture<TunnelOptions, Error>; + /// Returns the current daemon settings + #[rpc(meta, name = "get_settings")] + fn get_settings(&self, Self::Metadata) -> BoxFuture<Settings, Error>; + /// Retreive version of the app #[rpc(meta, name = "get_current_version")] fn get_current_version(&self, Self::Metadata) -> BoxFuture<String, Error>; @@ -204,6 +207,8 @@ pub enum ManagementCommand { SetEnableIpv6(OneshotSender<()>, bool), /// Get the tunnel options GetTunnelOptions(OneshotSender<TunnelOptions>), + /// Get the daemon settings + GetSettings(OneshotSender<Settings>), /// Get information about the currently running and latest app versions GetVersionInfo(OneshotSender<BoxFuture<version::AppVersionInfo, mullvad_rpc::Error>>), /// Get current version of the app @@ -621,6 +626,15 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi Box::new(future) } + fn get_settings(&self, _: Self::Metadata) -> BoxFuture<Settings, Error> { + debug!("get_settings"); + let (tx, rx) = sync::oneshot::channel(); + let future = self + .send_command_to_daemon(ManagementCommand::GetSettings(tx)) + .and_then(|_| rx.map_err(|_| Error::internal_error())); + Box::new(future) + } + fn get_current_version(&self, _: Self::Metadata) -> BoxFuture<String, Error> { debug!("get_current_version"); let (tx, rx) = sync::oneshot::channel(); |
