diff options
| -rw-r--r-- | mullvad-daemon/src/main.rs | 5 | ||||
| -rw-r--r-- | mullvad-daemon/src/management_interface.rs | 16 |
2 files changed, 17 insertions, 4 deletions
diff --git a/mullvad-daemon/src/main.rs b/mullvad-daemon/src/main.rs index d548eb3e03..764427f1e1 100644 --- a/mullvad-daemon/src/main.rs +++ b/mullvad-daemon/src/main.rs @@ -369,10 +369,11 @@ impl Daemon { fn on_set_custom_relay(&mut self, tx: OneshotSender<()>, - relay_endpoint: RelayEndpoint) + relay_endpoint: Option<RelayEndpoint>) -> Result<()> { - let save_result = self.settings.set_custom_relay(Some(relay_endpoint)); + let save_result = self.settings.set_custom_relay(relay_endpoint); + match save_result.chain_err(|| "Unable to save settings") { Ok(servers_changed) => { Self::oneshot_send(tx, (), "set_custom_relay response"); diff --git a/mullvad-daemon/src/management_interface.rs b/mullvad-daemon/src/management_interface.rs index 15e5132a85..4826e8a97b 100644 --- a/mullvad-daemon/src/management_interface.rs +++ b/mullvad-daemon/src/management_interface.rs @@ -54,6 +54,10 @@ build_rpc_trait! { #[rpc(async, name = "set_custom_relay")] fn set_custom_relay(&self, RelayEndpoint) -> BoxFuture<(), Error>; + /// Unset the custom relay, reverting to the default relay listing + #[rpc(async, name = "remove_custom_relay")] + fn remove_custom_relay(&self) -> BoxFuture<(), Error>; + /// Set if the client should automatically establish a tunnel on start or not. #[rpc(name = "set_autoconnect")] fn set_autoconnect(&self, bool) -> Result<(), Error>; @@ -117,7 +121,7 @@ pub enum TunnelCommand { /// Request the current account token being used. GetAccount(OneshotSender<Option<AccountToken>>), /// Set a custom relay instead of the default list of relays - SetCustomRelay(OneshotSender<()>, RelayEndpoint), + SetCustomRelay(OneshotSender<()>, Option<RelayEndpoint>), } #[derive(Default)] @@ -318,7 +322,15 @@ impl<T: From<TunnelCommand> + 'static + Send> ManagementInterfaceApi for Managem fn set_custom_relay(&self, custom_relay: RelayEndpoint) -> BoxFuture<(), Error> { trace!("set_custom_relay"); let (tx, rx) = sync::oneshot::channel(); - let future = self.send_command_to_daemon(TunnelCommand::SetCustomRelay(tx, custom_relay)) + let future = self.send_command_to_daemon(TunnelCommand::SetCustomRelay(tx, Some(custom_relay)),) + .and_then(|_| rx.map_err(|_| Error::internal_error())); + Box::new(future) + } + + fn remove_custom_relay(&self) -> BoxFuture<(), Error> { + trace!("remove_custom_relay"); + let (tx, rx) = sync::oneshot::channel(); + let future = self.send_command_to_daemon(TunnelCommand::SetCustomRelay(tx, None)) .and_then(|_| rx.map_err(|_| Error::internal_error())); Box::new(future) } |
