diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-02-21 17:24:20 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-02-24 12:45:05 +0000 |
| commit | d646d5a69d851540676ebca97334ed2a2d273991 (patch) | |
| tree | 0fd2a63457a6cdfdeaf2ed8acc5b0b35404b60e8 | |
| parent | 44adad73b1875cc15d14c02f48dc29dc57710ca5 (diff) | |
| download | mullvadvpn-d646d5a69d851540676ebca97334ed2a2d273991.tar.xz mullvadvpn-d646d5a69d851540676ebca97334ed2a2d273991.zip | |
Move `ManagementCommand` to root module
| -rw-r--r-- | mullvad-daemon/src/lib.rs | 80 | ||||
| -rw-r--r-- | mullvad-daemon/src/management_interface.rs | 82 |
2 files changed, 81 insertions, 81 deletions
diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs index fb2ba66360..ab93bae7f2 100644 --- a/mullvad-daemon/src/lib.rs +++ b/mullvad-daemon/src/lib.rs @@ -14,7 +14,6 @@ mod settings; pub mod version; mod version_check; -pub use crate::management_interface::ManagementCommand; use crate::management_interface::{ManagementInterfaceEventBroadcaster, ManagementInterfaceServer}; use futures::{ future::{self, Executor}, @@ -132,6 +131,85 @@ pub enum Error { ReadDirError(#[error(source)] io::Error), } +/// Enum representing commands coming in on the management interface. +pub enum ManagementCommand { + /// 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. + Reconnect, + /// Request the current state. + GetState(oneshot::Sender<TunnelState>), + /// Get the current geographical location. + GetCurrentLocation(oneshot::Sender<Option<GeoIpLocation>>), + CreateNewAccount(oneshot::Sender<std::result::Result<String, mullvad_rpc::Error>>), + /// Request the metadata for an account. + GetAccountData( + oneshot::Sender<BoxFuture<AccountData, mullvad_rpc::Error>>, + AccountToken, + ), + /// Request www auth token for an account + GetWwwAuthToken(oneshot::Sender<BoxFuture<String, mullvad_rpc::Error>>), + /// Submit voucher to add time to the current account. Returns time added in seconds + SubmitVoucher( + oneshot::Sender<BoxFuture<VoucherSubmission, mullvad_rpc::Error>>, + String, + ), + /// Request account history + GetAccountHistory(oneshot::Sender<Vec<AccountToken>>), + /// Request account history + RemoveAccountFromHistory(oneshot::Sender<()>, AccountToken), + /// Get the list of countries and cities where there are relays. + GetRelayLocations(oneshot::Sender<RelayList>), + /// Trigger an asynchronous relay list update. This returns before the relay list is actually + /// updated. + UpdateRelayLocations, + /// Set which account token to use for subsequent connection attempts. + SetAccount(oneshot::Sender<()>, Option<AccountToken>), + /// Place constraints on the type of tunnel and relay + UpdateRelaySettings(oneshot::Sender<()>, RelaySettingsUpdate), + /// Set the allow LAN setting. + SetAllowLan(oneshot::Sender<()>, bool), + /// Set the block_when_disconnected setting. + SetBlockWhenDisconnected(oneshot::Sender<()>, bool), + /// Set the auto-connect setting. + SetAutoConnect(oneshot::Sender<()>, bool), + /// Set the mssfix argument for OpenVPN + SetOpenVpnMssfix(oneshot::Sender<()>, Option<u16>), + /// Set proxy details for OpenVPN + SetBridgeSettings( + oneshot::Sender<std::result::Result<(), settings::Error>>, + BridgeSettings, + ), + /// Set proxy state + SetBridgeState( + oneshot::Sender<std::result::Result<(), settings::Error>>, + BridgeState, + ), + /// Set if IPv6 should be enabled in the tunnel + SetEnableIpv6(oneshot::Sender<()>, bool), + /// Set MTU for wireguard tunnels + SetWireguardMtu(oneshot::Sender<()>, Option<u16>), + /// Set automatic key rotation interval for wireguard tunnels + SetWireguardRotationInterval(oneshot::Sender<()>, Option<u32>), + /// Get the daemon settings + GetSettings(oneshot::Sender<Settings>), + /// Generate new wireguard key + GenerateWireguardKey(oneshot::Sender<wireguard::KeygenEvent>), + /// Return a public key of the currently set wireguard private key, if there is one + GetWireguardKey(oneshot::Sender<Option<wireguard::PublicKey>>), + /// Verify if the currently set wireguard key is valid. + VerifyWireguardKey(oneshot::Sender<bool>), + /// Get information about the currently running and latest app versions + GetVersionInfo(oneshot::Sender<AppVersionInfo>), + /// Get current version of the app + GetCurrentVersion(oneshot::Sender<AppVersion>), + /// Remove settings and clear the cache + #[cfg(not(target_os = "android"))] + FactoryReset(oneshot::Sender<()>), + /// Makes the daemon exit the main loop and quit. + Shutdown, +} + /// All events that can happen in the daemon. Sent from various threads and exposed interfaces. pub(crate) enum InternalDaemonEvent { /// Tunnel has changed state. diff --git a/mullvad-daemon/src/management_interface.rs b/mullvad-daemon/src/management_interface.rs index 8da075f539..ff7048a8b2 100644 --- a/mullvad-daemon/src/management_interface.rs +++ b/mullvad-daemon/src/management_interface.rs @@ -1,10 +1,6 @@ -use crate::{BoxFuture, EventListener}; +use crate::{BoxFuture, EventListener, ManagementCommand}; use jsonrpc_core::{ - futures::{ - future, - sync::{self, oneshot::Sender as OneshotSender}, - Future, - }, + futures::{future, sync, Future}, Error, ErrorCode, MetaIoHandler, Metadata, }; use jsonrpc_ipc_server; @@ -185,80 +181,6 @@ build_rpc_trait! { } } - -/// Enum representing commands coming in on the management interface. -pub enum ManagementCommand { - /// Set target state. Does nothing if the daemon already has the state that is being set. - SetTargetState(OneshotSender<Result<(), ()>>, TargetState), - /// Reconnect the tunnel, if one is connecting/connected. - Reconnect, - /// Request the current state. - GetState(OneshotSender<TunnelState>), - /// Get the current geographical location. - GetCurrentLocation(OneshotSender<Option<GeoIpLocation>>), - CreateNewAccount(OneshotSender<std::result::Result<String, mullvad_rpc::Error>>), - /// Request the metadata for an account. - GetAccountData( - OneshotSender<BoxFuture<AccountData, mullvad_rpc::Error>>, - AccountToken, - ), - /// Request www auth token for an account - GetWwwAuthToken(OneshotSender<BoxFuture<String, mullvad_rpc::Error>>), - /// Submit voucher to add time to the current account. Returns time added in seconds - SubmitVoucher( - OneshotSender<BoxFuture<VoucherSubmission, mullvad_rpc::Error>>, - String, - ), - /// Request account history - GetAccountHistory(OneshotSender<Vec<AccountToken>>), - /// Request account history - RemoveAccountFromHistory(OneshotSender<()>, AccountToken), - /// Get the list of countries and cities where there are relays. - GetRelayLocations(OneshotSender<RelayList>), - /// Trigger an asynchronous relay list update. This returns before the relay list is actually - /// updated. - UpdateRelayLocations, - /// Set which account token to use for subsequent connection attempts. - SetAccount(OneshotSender<()>, Option<AccountToken>), - /// Place constraints on the type of tunnel and relay - UpdateRelaySettings(OneshotSender<()>, RelaySettingsUpdate), - /// Set the allow LAN setting. - SetAllowLan(OneshotSender<()>, bool), - /// Set the block_when_disconnected setting. - SetBlockWhenDisconnected(OneshotSender<()>, bool), - /// Set the auto-connect setting. - SetAutoConnect(OneshotSender<()>, bool), - /// Set the mssfix argument for OpenVPN - SetOpenVpnMssfix(OneshotSender<()>, Option<u16>), - /// Set proxy details for OpenVPN - SetBridgeSettings(OneshotSender<Result<(), settings::Error>>, BridgeSettings), - /// Set proxy state - SetBridgeState(OneshotSender<Result<(), settings::Error>>, BridgeState), - /// Set if IPv6 should be enabled in the tunnel - SetEnableIpv6(OneshotSender<()>, bool), - /// Set MTU for wireguard tunnels - SetWireguardMtu(OneshotSender<()>, Option<u16>), - /// Set automatic key rotation interval for wireguard tunnels - SetWireguardRotationInterval(OneshotSender<()>, Option<u32>), - /// Get the daemon settings - GetSettings(OneshotSender<Settings>), - /// Generate new wireguard key - GenerateWireguardKey(OneshotSender<wireguard::KeygenEvent>), - /// Return a public key of the currently set wireguard private key, if there is one - GetWireguardKey(OneshotSender<Option<wireguard::PublicKey>>), - /// Verify if the currently set wireguard key is valid. - VerifyWireguardKey(OneshotSender<bool>), - /// Get information about the currently running and latest app versions - GetVersionInfo(OneshotSender<version::AppVersionInfo>), - /// Get current version of the app - GetCurrentVersion(OneshotSender<version::AppVersion>), - /// Remove settings and clear the cache - #[cfg(not(target_os = "android"))] - FactoryReset(OneshotSender<()>), - /// Makes the daemon exit the main loop and quit. - Shutdown, -} - pub struct ManagementInterfaceServer { server: talpid_ipc::IpcServer, subscriptions: Arc<RwLock<HashMap<SubscriptionId, pubsub::Sink<DaemonEvent>>>>, |
