diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2017-12-20 15:17:53 +0100 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2017-12-20 15:19:24 +0100 |
| commit | dcb407a6823f313b80f1b56ee0bc2c1a462dc0da (patch) | |
| tree | b290da02a6469e7fe5adceb63aebc757184d1bfa | |
| parent | 256ad3cf7a591891004383e1ea7f61fbdcd8547e (diff) | |
| download | mullvadvpn-dcb407a6823f313b80f1b56ee0bc2c1a462dc0da.tar.xz mullvadvpn-dcb407a6823f313b80f1b56ee0bc2c1a462dc0da.zip | |
Implement get_allow_lan in mgmt interface
| -rw-r--r-- | mullvad-daemon/src/main.rs | 5 | ||||
| -rw-r--r-- | mullvad-daemon/src/management_interface.rs | 15 |
2 files changed, 20 insertions, 0 deletions
diff --git a/mullvad-daemon/src/main.rs b/mullvad-daemon/src/main.rs index 0279c232be..59446eb5af 100644 --- a/mullvad-daemon/src/main.rs +++ b/mullvad-daemon/src/main.rs @@ -357,6 +357,7 @@ impl Daemon { GetAccount(tx) => Ok(self.on_get_account(tx)), UpdateRelaySettings(tx, update) => self.on_update_relay_settings(tx, update), SetAllowLan(tx, allow_lan) => self.on_set_allow_lan(tx, allow_lan), + GetAllowLan(tx) => Ok(self.on_get_allow_lan(tx)), GetRelaySettings(tx) => Ok(self.on_get_relay_settings(tx)), Shutdown => self.handle_trigger_shutdown_event(), } @@ -488,6 +489,10 @@ impl Daemon { Ok(()) } + fn on_get_allow_lan(&self, tx: OneshotSender<bool>) { + Self::oneshot_send(tx, self.settings.get_allow_lan(), "allow lan") + } + 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 a9905eb091..5bb79e8d14 100644 --- a/mullvad-daemon/src/management_interface.rs +++ b/mullvad-daemon/src/management_interface.rs @@ -77,6 +77,10 @@ build_rpc_trait! { #[rpc(meta, name = "set_allow_lan")] fn set_allow_lan(&self, Self::Metadata, bool) -> BoxFuture<(), Error>; + /// Get if the client should allow communication with the LAN while in secured state. + #[rpc(meta, name = "get_allow_lan")] + fn get_allow_lan(&self, Self::Metadata) -> BoxFuture<bool, Error>; + /// Set if the client should automatically establish a tunnel on start or not. #[rpc(meta, name = "set_autoconnect")] fn set_autoconnect(&self, Self::Metadata, bool) -> BoxFuture<(), Error>; @@ -166,6 +170,8 @@ pub enum TunnelCommand { GetRelaySettings(OneshotSender<RelaySettings>), /// Setting if communication with LAN networks should be possible. SetAllowLan(OneshotSender<()>, bool), + /// Request the current allow LAN setting. + GetAllowLan(OneshotSender<bool>), /// Makes the daemon exit the main loop and quit. Shutdown, } @@ -463,6 +469,15 @@ impl<T: From<TunnelCommand> + 'static + Send> ManagementInterfaceApi for Managem Box::new(future) } + fn get_allow_lan(&self, meta: Self::Metadata) -> BoxFuture<bool, Error> { + trace!("get_allow_lan"); + try_future!(self.check_auth(&meta)); + let (tx, rx) = sync::oneshot::channel(); + let future = self.send_command_to_daemon(TunnelCommand::GetAllowLan(tx)) + .and_then(|_| rx.map_err(|_| Error::internal_error())); + Box::new(future) + } + fn set_autoconnect(&self, meta: Self::Metadata, _autoconnect: bool) -> BoxFuture<(), Error> { trace!("set_autoconnect"); try_future!(self.check_auth(&meta)); |
