diff options
| -rw-r--r-- | mullvad-daemon/src/lib.rs | 25 | ||||
| -rw-r--r-- | mullvad-daemon/src/management_interface.rs | 92 | ||||
| -rw-r--r-- | mullvad-jni/src/daemon_interface.rs | 47 |
3 files changed, 76 insertions, 88 deletions
diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs index ab93bae7f2..67c6b96231 100644 --- a/mullvad-daemon/src/lib.rs +++ b/mullvad-daemon/src/lib.rs @@ -132,7 +132,7 @@ pub enum Error { } /// Enum representing commands coming in on the management interface. -pub enum ManagementCommand { +pub enum DaemonCommand { /// Set target state. Does nothing if the daemon already has the state that is being set. SetTargetState(oneshot::Sender<std::result::Result<(), ()>>, TargetState), /// Reconnect the tunnel, if one is connecting/connected. @@ -220,7 +220,7 @@ pub(crate) enum InternalDaemonEvent { u32, ), /// An event coming from the JSONRPC-2.0 management interface. - ManagementInterfaceEvent(ManagementCommand), + ManagementInterfaceEvent(DaemonCommand), /// Triggered if the server hosting the JSONRPC-2.0 management interface dies unexpectedly. ManagementInterfaceExited, /// Daemon shutdown triggered by a signal, ctrl-c or similar. @@ -247,8 +247,8 @@ impl From<TunnelStateTransition> for InternalDaemonEvent { } } -impl From<ManagementCommand> for InternalDaemonEvent { - fn from(command: ManagementCommand) -> Self { +impl From<DaemonCommand> for InternalDaemonEvent { + fn from(command: DaemonCommand) -> Self { InternalDaemonEvent::ManagementInterfaceEvent(command) } } @@ -302,14 +302,14 @@ impl DaemonExecutionState { } } -pub struct DaemonCommandSender(IntoSender<ManagementCommand, InternalDaemonEvent>); +pub struct DaemonCommandSender(IntoSender<DaemonCommand, InternalDaemonEvent>); impl DaemonCommandSender { pub(crate) fn new(internal_event_sender: UnboundedSender<InternalDaemonEvent>) -> Self { DaemonCommandSender(IntoSender::from(internal_event_sender)) } - pub fn send(&self, command: ManagementCommand) -> Result<(), Error> { + pub fn send(&self, command: DaemonCommand) -> Result<(), Error> { self.0.send(command).map_err(|_| Error::DaemonUnavailable) } } @@ -395,7 +395,7 @@ impl Daemon<ManagementInterfaceEventBroadcaster> { } fn start_management_interface_server( - event_tx: IntoSender<ManagementCommand, InternalDaemonEvent>, + event_tx: IntoSender<DaemonCommand, InternalDaemonEvent>, ) -> Result<ManagementInterfaceServer, Error> { let server = ManagementInterfaceServer::start(event_tx).map_err(Error::StartManagementInterface)?; @@ -851,9 +851,10 @@ where if let Err(mpsc::RecvTimeoutError::Timeout) = rx.recv_timeout(delay) { debug!("Attempting to reconnect"); let _ = tunnel_command_tx.unbounded_send( - InternalDaemonEvent::ManagementInterfaceEvent( - ManagementCommand::SetTargetState(result_tx, TargetState::Secured), - ), + InternalDaemonEvent::ManagementInterfaceEvent(DaemonCommand::SetTargetState( + result_tx, + TargetState::Secured, + )), ); } }); @@ -865,8 +866,8 @@ where } } - fn handle_management_interface_event(&mut self, event: ManagementCommand) { - use self::ManagementCommand::*; + fn handle_management_interface_event(&mut self, event: DaemonCommand) { + use self::DaemonCommand::*; if !self.state.is_running() { log::trace!("Dropping management command because the daemon is shutting down",); return; diff --git a/mullvad-daemon/src/management_interface.rs b/mullvad-daemon/src/management_interface.rs index ff7048a8b2..db403b8960 100644 --- a/mullvad-daemon/src/management_interface.rs +++ b/mullvad-daemon/src/management_interface.rs @@ -1,4 +1,4 @@ -use crate::{BoxFuture, EventListener, ManagementCommand}; +use crate::{BoxFuture, DaemonCommand, EventListener}; use jsonrpc_core::{ futures::{future, sync, Future}, Error, ErrorCode, MetaIoHandler, Metadata, @@ -187,9 +187,9 @@ pub struct ManagementInterfaceServer { } impl ManagementInterfaceServer { - pub fn start<T>(tunnel_tx: IntoSender<ManagementCommand, T>) -> Result<Self, talpid_ipc::Error> + pub fn start<T>(tunnel_tx: IntoSender<DaemonCommand, T>) -> Result<Self, talpid_ipc::Error> where - T: From<ManagementCommand> + 'static + Send, + T: From<DaemonCommand> + 'static + Send, { let rpc = ManagementInterface::new(tunnel_tx); let subscriptions = rpc.subscriptions.clone(); @@ -280,13 +280,13 @@ impl Drop for ManagementInterfaceEventBroadcaster { } } -struct ManagementInterface<T: From<ManagementCommand> + 'static + Send> { +struct ManagementInterface<T: From<DaemonCommand> + 'static + Send> { subscriptions: Arc<RwLock<HashMap<SubscriptionId, pubsub::Sink<DaemonEvent>>>>, - tx: IntoSender<ManagementCommand, T>, + tx: IntoSender<DaemonCommand, T>, } -impl<T: From<ManagementCommand> + 'static + Send> ManagementInterface<T> { - pub fn new(tx: IntoSender<ManagementCommand, T>) -> Self { +impl<T: From<DaemonCommand> + 'static + Send> ManagementInterface<T> { + pub fn new(tx: IntoSender<DaemonCommand, T>) -> Self { ManagementInterface { subscriptions: Default::default(), tx, @@ -296,7 +296,7 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterface<T> { /// Sends a command to the daemon and maps the error to an RPC error. fn send_command_to_daemon( &self, - command: ManagementCommand, + command: DaemonCommand, ) -> impl Future<Item = (), Error = Error> { future::result(self.tx.send(command)).map_err(|_| Error::internal_error()) } @@ -320,15 +320,13 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterface<T> { } } -impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi - for ManagementInterface<T> -{ +impl<T: From<DaemonCommand> + 'static + Send> ManagementInterfaceApi for ManagementInterface<T> { type Metadata = Meta; fn create_new_account(&self, _: Self::Metadata) -> BoxFuture<String, Error> { let (tx, rx) = sync::oneshot::channel(); let future = self - .send_command_to_daemon(ManagementCommand::CreateNewAccount(tx)) + .send_command_to_daemon(DaemonCommand::CreateNewAccount(tx)) .and_then(|_| rx.map_err(|_| Error::internal_error())) .and_then(|result| match result { Ok(account_token) => Ok(account_token), @@ -346,7 +344,7 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi log::debug!("get_account_data"); let (tx, rx) = sync::oneshot::channel(); let future = self - .send_command_to_daemon(ManagementCommand::GetAccountData(tx, account_token)) + .send_command_to_daemon(DaemonCommand::GetAccountData(tx, account_token)) .and_then(|_| rx.map_err(|_| Error::internal_error())) .and_then(|rpc_future| { rpc_future.map_err(|error: mullvad_rpc::Error| { @@ -364,7 +362,7 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi log::debug!("get_account_data"); let (tx, rx) = sync::oneshot::channel(); let future = self - .send_command_to_daemon(ManagementCommand::GetWwwAuthToken(tx)) + .send_command_to_daemon(DaemonCommand::GetWwwAuthToken(tx)) .and_then(|_| rx.map_err(|_| Error::internal_error())) .and_then(|rpc_future| { rpc_future.map_err(|error: mullvad_rpc::Error| { @@ -386,7 +384,7 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi log::debug!("submit_voucher"); let (tx, rx) = sync::oneshot::channel(); let future = self - .send_command_to_daemon(ManagementCommand::SubmitVoucher(tx, voucher)) + .send_command_to_daemon(DaemonCommand::SubmitVoucher(tx, voucher)) .and_then(|_| rx.map_err(|_| Error::internal_error())) .and_then(|f| f.map_err(|e| Self::map_rpc_error(&e))); Box::new(future) @@ -396,14 +394,14 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi log::debug!("get_relay_locations"); let (tx, rx) = sync::oneshot::channel(); let future = self - .send_command_to_daemon(ManagementCommand::GetRelayLocations(tx)) + .send_command_to_daemon(DaemonCommand::GetRelayLocations(tx)) .and_then(|_| rx.map_err(|_| Error::internal_error())); Box::new(future) } fn update_relay_locations(&self, _: Self::Metadata) -> BoxFuture<(), Error> { log::debug!("update_relay_locations"); - Box::new(self.send_command_to_daemon(ManagementCommand::UpdateRelayLocations)) + Box::new(self.send_command_to_daemon(DaemonCommand::UpdateRelayLocations)) } fn set_account( @@ -414,7 +412,7 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi log::debug!("set_account"); let (tx, rx) = sync::oneshot::channel(); let future = self - .send_command_to_daemon(ManagementCommand::SetAccount(tx, account_token)) + .send_command_to_daemon(DaemonCommand::SetAccount(tx, account_token)) .and_then(|_| rx.map_err(|_| Error::internal_error())); Box::new(future) } @@ -427,7 +425,7 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi log::debug!("update_relay_settings"); let (tx, rx) = sync::oneshot::channel(); - let message = ManagementCommand::UpdateRelaySettings(tx, constraints_update); + let message = DaemonCommand::UpdateRelaySettings(tx, constraints_update); let future = self .send_command_to_daemon(message) .and_then(|_| rx.map_err(|_| Error::internal_error())); @@ -438,7 +436,7 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi log::debug!("set_allow_lan({})", allow_lan); let (tx, rx) = sync::oneshot::channel(); let future = self - .send_command_to_daemon(ManagementCommand::SetAllowLan(tx, allow_lan)) + .send_command_to_daemon(DaemonCommand::SetAllowLan(tx, allow_lan)) .and_then(|_| rx.map_err(|_| Error::internal_error())); Box::new(future) } @@ -451,7 +449,7 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi log::debug!("set_block_when_disconnected({})", block_when_disconnected); let (tx, rx) = sync::oneshot::channel(); let future = self - .send_command_to_daemon(ManagementCommand::SetBlockWhenDisconnected( + .send_command_to_daemon(DaemonCommand::SetBlockWhenDisconnected( tx, block_when_disconnected, )) @@ -463,7 +461,7 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi log::debug!("set_auto_connect({})", auto_connect); let (tx, rx) = sync::oneshot::channel(); let future = self - .send_command_to_daemon(ManagementCommand::SetAutoConnect(tx, auto_connect)) + .send_command_to_daemon(DaemonCommand::SetAutoConnect(tx, auto_connect)) .and_then(|_| rx.map_err(|_| Error::internal_error())); Box::new(future) } @@ -472,7 +470,7 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi log::debug!("connect"); let (tx, rx) = sync::oneshot::channel(); let future = self - .send_command_to_daemon(ManagementCommand::SetTargetState(tx, TargetState::Secured)) + .send_command_to_daemon(DaemonCommand::SetTargetState(tx, TargetState::Secured)) .and_then(|_| rx.map_err(|_| Error::internal_error())) .and_then(|result| match result { Ok(()) => future::ok(()), @@ -489,17 +487,14 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi log::debug!("disconnect"); let (tx, _) = sync::oneshot::channel(); let future = self - .send_command_to_daemon(ManagementCommand::SetTargetState( - tx, - TargetState::Unsecured, - )) + .send_command_to_daemon(DaemonCommand::SetTargetState(tx, TargetState::Unsecured)) .then(|_| future::ok(())); Box::new(future) } fn reconnect(&self, _: Self::Metadata) -> BoxFuture<(), Error> { log::debug!("reconnect"); - let future = self.send_command_to_daemon(ManagementCommand::Reconnect); + let future = self.send_command_to_daemon(DaemonCommand::Reconnect); Box::new(future) } @@ -507,7 +502,7 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi log::debug!("get_state"); let (state_tx, state_rx) = sync::oneshot::channel(); let future = self - .send_command_to_daemon(ManagementCommand::GetState(state_tx)) + .send_command_to_daemon(DaemonCommand::GetState(state_tx)) .and_then(|_| state_rx.map_err(|_| Error::internal_error())); Box::new(future) } @@ -516,21 +511,21 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi log::debug!("get_current_location"); let (tx, rx) = sync::oneshot::channel(); let future = self - .send_command_to_daemon(ManagementCommand::GetCurrentLocation(tx)) + .send_command_to_daemon(DaemonCommand::GetCurrentLocation(tx)) .and_then(|_| rx.map_err(|_| Error::internal_error())); Box::new(future) } fn shutdown(&self, _: Self::Metadata) -> BoxFuture<(), Error> { log::debug!("shutdown"); - Box::new(self.send_command_to_daemon(ManagementCommand::Shutdown)) + Box::new(self.send_command_to_daemon(DaemonCommand::Shutdown)) } fn get_account_history(&self, _: Self::Metadata) -> BoxFuture<Vec<AccountToken>, Error> { log::debug!("get_account_history"); let (tx, rx) = sync::oneshot::channel(); let future = self - .send_command_to_daemon(ManagementCommand::GetAccountHistory(tx)) + .send_command_to_daemon(DaemonCommand::GetAccountHistory(tx)) .and_then(|_| rx.map_err(|_| Error::internal_error())); Box::new(future) } @@ -543,10 +538,7 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi log::debug!("remove_account_from_history"); let (tx, rx) = sync::oneshot::channel(); let future = self - .send_command_to_daemon(ManagementCommand::RemoveAccountFromHistory( - tx, - account_token, - )) + .send_command_to_daemon(DaemonCommand::RemoveAccountFromHistory(tx, account_token)) .and_then(|_| rx.map_err(|_| Error::internal_error())); Box::new(future) } @@ -555,7 +547,7 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi log::debug!("set_openvpn_mssfix({:?})", mssfix); let (tx, rx) = sync::oneshot::channel(); let future = self - .send_command_to_daemon(ManagementCommand::SetOpenVpnMssfix(tx, mssfix)) + .send_command_to_daemon(DaemonCommand::SetOpenVpnMssfix(tx, mssfix)) .and_then(|_| rx.map_err(|_| Error::internal_error())); Box::new(future) @@ -569,7 +561,7 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi log::debug!("set_bridge_settings({:?})", bridge_settings); let (tx, rx) = sync::oneshot::channel(); let future = self - .send_command_to_daemon(ManagementCommand::SetBridgeSettings(tx, bridge_settings)) + .send_command_to_daemon(DaemonCommand::SetBridgeSettings(tx, bridge_settings)) .and_then(|_| rx.map_err(|_| Error::internal_error())) .and_then(|settings_result| { settings_result.map_err(|error| match error { @@ -589,7 +581,7 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi log::debug!("set_bridge_state({:?})", bridge_state); let (tx, rx) = sync::oneshot::channel(); let future = self - .send_command_to_daemon(ManagementCommand::SetBridgeState(tx, bridge_state)) + .send_command_to_daemon(DaemonCommand::SetBridgeState(tx, bridge_state)) .and_then(|_| rx.map_err(|_| Error::internal_error())) .and_then(|settings_result| settings_result.map_err(|_| Error::internal_error())); @@ -600,7 +592,7 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi log::debug!("set_enable_ipv6({})", enable_ipv6); let (tx, rx) = sync::oneshot::channel(); let future = self - .send_command_to_daemon(ManagementCommand::SetEnableIpv6(tx, enable_ipv6)) + .send_command_to_daemon(DaemonCommand::SetEnableIpv6(tx, enable_ipv6)) .and_then(|_| rx.map_err(|_| Error::internal_error())); Box::new(future) @@ -611,7 +603,7 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi log::debug!("set_wireguard_mtu({:?})", mtu); let (tx, rx) = sync::oneshot::channel(); let future = self - .send_command_to_daemon(ManagementCommand::SetWireguardMtu(tx, mtu)) + .send_command_to_daemon(DaemonCommand::SetWireguardMtu(tx, mtu)) .and_then(|_| rx.map_err(|_| Error::internal_error())); Box::new(future) } @@ -625,9 +617,7 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi log::debug!("set_wireguard_rotation_interval({:?})", interval); let (tx, rx) = sync::oneshot::channel(); let future = self - .send_command_to_daemon(ManagementCommand::SetWireguardRotationInterval( - tx, interval, - )) + .send_command_to_daemon(DaemonCommand::SetWireguardRotationInterval(tx, interval)) .and_then(|_| rx.map_err(|_| Error::internal_error())); Box::new(future) } @@ -636,7 +626,7 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi log::debug!("get_settings"); let (tx, rx) = sync::oneshot::channel(); let future = self - .send_command_to_daemon(ManagementCommand::GetSettings(tx)) + .send_command_to_daemon(DaemonCommand::GetSettings(tx)) .and_then(|_| rx.map_err(|_| Error::internal_error())); Box::new(future) } @@ -648,7 +638,7 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi log::debug!("generate_wireguard_key"); let (tx, rx) = sync::oneshot::channel(); let future = self - .send_command_to_daemon(ManagementCommand::GenerateWireguardKey(tx)) + .send_command_to_daemon(DaemonCommand::GenerateWireguardKey(tx)) .and_then(|_| rx.map_err(|_| Error::internal_error())); Box::new(future) } @@ -660,7 +650,7 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi log::debug!("get_wireguard_key"); let (tx, rx) = sync::oneshot::channel(); let future = self - .send_command_to_daemon(ManagementCommand::GetWireguardKey(tx)) + .send_command_to_daemon(DaemonCommand::GetWireguardKey(tx)) .and_then(|_| rx.map_err(|_| Error::internal_error())); Box::new(future) } @@ -669,7 +659,7 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi log::debug!("verify_wireguard_key"); let (tx, rx) = sync::oneshot::channel(); let future = self - .send_command_to_daemon(ManagementCommand::VerifyWireguardKey(tx)) + .send_command_to_daemon(DaemonCommand::VerifyWireguardKey(tx)) .and_then(|_| rx.map_err(|_| Error::internal_error())); Box::new(future) } @@ -678,7 +668,7 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi log::debug!("get_current_version"); let (tx, rx) = sync::oneshot::channel(); let future = self - .send_command_to_daemon(ManagementCommand::GetCurrentVersion(tx)) + .send_command_to_daemon(DaemonCommand::GetCurrentVersion(tx)) .and_then(|_| rx.map_err(|_| Error::internal_error())); Box::new(future) @@ -688,7 +678,7 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi log::debug!("get_version_info"); let (tx, rx) = sync::oneshot::channel(); let future = self - .send_command_to_daemon(ManagementCommand::GetVersionInfo(tx)) + .send_command_to_daemon(DaemonCommand::GetVersionInfo(tx)) .and_then(|_| rx.map_err(|_| Error::internal_error())); Box::new(future) @@ -700,7 +690,7 @@ impl<T: From<ManagementCommand> + 'static + Send> ManagementInterfaceApi log::debug!("factory_reset"); let (tx, rx) = sync::oneshot::channel(); let future = self - .send_command_to_daemon(ManagementCommand::FactoryReset(tx)) + .send_command_to_daemon(DaemonCommand::FactoryReset(tx)) .and_then(|_| rx.map_err(|_| Error::internal_error())); Box::new(future) diff --git a/mullvad-jni/src/daemon_interface.rs b/mullvad-jni/src/daemon_interface.rs index ceda7b5fd6..4be2a35c94 100644 --- a/mullvad-jni/src/daemon_interface.rs +++ b/mullvad-jni/src/daemon_interface.rs @@ -1,5 +1,5 @@ use futures::{sync::oneshot, Future}; -use mullvad_daemon::{DaemonCommandSender, ManagementCommand}; +use mullvad_daemon::{DaemonCommand, DaemonCommandSender}; use mullvad_types::{ account::AccountData, location::GeoIpLocation, @@ -40,7 +40,7 @@ impl DaemonInterface { pub fn connect(&self) -> Result<()> { let (tx, rx) = oneshot::channel(); - self.send_command(ManagementCommand::SetTargetState(tx, TargetState::Secured))?; + self.send_command(DaemonCommand::SetTargetState(tx, TargetState::Secured))?; rx.wait().map_err(|_| Error::NoResponse)?.unwrap(); @@ -50,10 +50,7 @@ impl DaemonInterface { pub fn disconnect(&self) -> Result<()> { let (tx, rx) = oneshot::channel(); - self.send_command(ManagementCommand::SetTargetState( - tx, - TargetState::Unsecured, - ))?; + self.send_command(DaemonCommand::SetTargetState(tx, TargetState::Unsecured))?; rx.wait().map_err(|_| Error::NoResponse)?.unwrap(); @@ -63,7 +60,7 @@ impl DaemonInterface { pub fn generate_wireguard_key(&self) -> Result<KeygenEvent> { let (tx, rx) = oneshot::channel(); - self.send_command(ManagementCommand::GenerateWireguardKey(tx))?; + self.send_command(DaemonCommand::GenerateWireguardKey(tx))?; rx.wait().map_err(|_| Error::NoResponse) } @@ -71,7 +68,7 @@ impl DaemonInterface { pub fn get_account_data(&self, account_token: String) -> Result<AccountData> { let (tx, rx) = oneshot::channel(); - self.send_command(ManagementCommand::GetAccountData(tx, account_token))?; + self.send_command(DaemonCommand::GetAccountData(tx, account_token))?; rx.wait() .map_err(|_| Error::NoResponse)? @@ -82,7 +79,7 @@ impl DaemonInterface { pub fn get_account_history(&self) -> Result<Vec<String>> { let (tx, rx) = oneshot::channel(); - self.send_command(ManagementCommand::GetAccountHistory(tx))?; + self.send_command(DaemonCommand::GetAccountHistory(tx))?; rx.wait().map_err(|_| Error::NoResponse) } @@ -90,7 +87,7 @@ impl DaemonInterface { pub fn get_www_auth_token(&self) -> Result<String> { let (tx, rx) = oneshot::channel(); - self.send_command(ManagementCommand::GetWwwAuthToken(tx))?; + self.send_command(DaemonCommand::GetWwwAuthToken(tx))?; rx.wait() .map_err(|_| Error::NoResponse)? @@ -101,7 +98,7 @@ impl DaemonInterface { pub fn get_current_location(&self) -> Result<Option<GeoIpLocation>> { let (tx, rx) = oneshot::channel(); - self.send_command(ManagementCommand::GetCurrentLocation(tx))?; + self.send_command(DaemonCommand::GetCurrentLocation(tx))?; Ok(rx.wait().map_err(|_| Error::NoResponse)?) } @@ -109,7 +106,7 @@ impl DaemonInterface { pub fn get_current_version(&self) -> Result<String> { let (tx, rx) = oneshot::channel(); - self.send_command(ManagementCommand::GetCurrentVersion(tx))?; + self.send_command(DaemonCommand::GetCurrentVersion(tx))?; Ok(rx.wait().map_err(|_| Error::NoResponse)?) } @@ -117,7 +114,7 @@ impl DaemonInterface { pub fn get_relay_locations(&self) -> Result<RelayList> { let (tx, rx) = oneshot::channel(); - self.send_command(ManagementCommand::GetRelayLocations(tx))?; + self.send_command(DaemonCommand::GetRelayLocations(tx))?; Ok(rx.wait().map_err(|_| Error::NoResponse)?) } @@ -125,7 +122,7 @@ impl DaemonInterface { pub fn get_settings(&self) -> Result<Settings> { let (tx, rx) = oneshot::channel(); - self.send_command(ManagementCommand::GetSettings(tx))?; + self.send_command(DaemonCommand::GetSettings(tx))?; Ok(rx.wait().map_err(|_| Error::NoResponse)?) } @@ -133,7 +130,7 @@ impl DaemonInterface { pub fn get_state(&self) -> Result<TunnelState> { let (tx, rx) = oneshot::channel(); - self.send_command(ManagementCommand::GetState(tx))?; + self.send_command(DaemonCommand::GetState(tx))?; Ok(rx.wait().map_err(|_| Error::NoResponse)?) } @@ -141,13 +138,13 @@ impl DaemonInterface { pub fn get_version_info(&self) -> Result<AppVersionInfo> { let (tx, rx) = oneshot::channel(); - self.send_command(ManagementCommand::GetVersionInfo(tx))?; + self.send_command(DaemonCommand::GetVersionInfo(tx))?; rx.wait().map_err(|_| Error::NoResponse) } pub fn reconnect(&self) -> Result<()> { - self.send_command(ManagementCommand::Reconnect)?; + self.send_command(DaemonCommand::Reconnect)?; Ok(()) } @@ -155,7 +152,7 @@ impl DaemonInterface { pub fn get_wireguard_key(&self) -> Result<Option<wireguard::PublicKey>> { let (tx, rx) = oneshot::channel(); - self.send_command(ManagementCommand::GetWireguardKey(tx))?; + self.send_command(DaemonCommand::GetWireguardKey(tx))?; rx.wait().map_err(|_| Error::NoResponse) } @@ -163,14 +160,14 @@ impl DaemonInterface { pub fn verify_wireguard_key(&self) -> Result<bool> { let (tx, rx) = oneshot::channel(); - self.send_command(ManagementCommand::VerifyWireguardKey(tx))?; + self.send_command(DaemonCommand::VerifyWireguardKey(tx))?; rx.wait().map_err(|_| Error::NoResponse) } pub fn set_account(&self, account_token: Option<String>) -> Result<()> { let (tx, rx) = oneshot::channel(); - self.send_command(ManagementCommand::SetAccount(tx, account_token))?; + self.send_command(DaemonCommand::SetAccount(tx, account_token))?; rx.wait().map_err(|_| Error::NoResponse) } @@ -178,7 +175,7 @@ impl DaemonInterface { pub fn set_allow_lan(&self, allow_lan: bool) -> Result<()> { let (tx, rx) = oneshot::channel(); - self.send_command(ManagementCommand::SetAllowLan(tx, allow_lan))?; + self.send_command(DaemonCommand::SetAllowLan(tx, allow_lan))?; rx.wait().map_err(|_| Error::NoResponse) } @@ -186,24 +183,24 @@ impl DaemonInterface { pub fn set_auto_connect(&self, auto_connect: bool) -> Result<()> { let (tx, rx) = oneshot::channel(); - self.send_command(ManagementCommand::SetAutoConnect(tx, auto_connect))?; + self.send_command(DaemonCommand::SetAutoConnect(tx, auto_connect))?; rx.wait().map_err(|_| Error::NoResponse) } pub fn shutdown(&self) -> Result<()> { - self.send_command(ManagementCommand::Shutdown) + self.send_command(DaemonCommand::Shutdown) } pub fn update_relay_settings(&self, update: RelaySettingsUpdate) -> Result<()> { let (tx, rx) = oneshot::channel(); - self.send_command(ManagementCommand::UpdateRelaySettings(tx, update))?; + self.send_command(DaemonCommand::UpdateRelaySettings(tx, update))?; rx.wait().map_err(|_| Error::NoResponse) } - fn send_command(&self, command: ManagementCommand) -> Result<()> { + fn send_command(&self, command: DaemonCommand) -> Result<()> { self.command_sender.send(command).map_err(Error::NoDaemon) } } |
