diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2017-07-03 16:28:52 +0200 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2017-07-04 11:30:55 +0200 |
| commit | 1a49dd51114103b2ccf1e3c2ec9cd12dfb1ea206 (patch) | |
| tree | 63699e7ee9e0fae9b3cccb937ba166eb73c2a804 /mullvad_daemon/src/management_interface.rs | |
| parent | 76752aa899963977963e09e1b3dd748a1f64cd08 (diff) | |
| download | mullvadvpn-1a49dd51114103b2ccf1e3c2ec9cd12dfb1ea206.tar.xz mullvadvpn-1a49dd51114103b2ccf1e3c2ec9cd12dfb1ea206.zip | |
Add broadcasting of both state and target_state
Diffstat (limited to 'mullvad_daemon/src/management_interface.rs')
| -rw-r--r-- | mullvad_daemon/src/management_interface.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/mullvad_daemon/src/management_interface.rs b/mullvad_daemon/src/management_interface.rs index 4b5a104d5e..65e6e9b788 100644 --- a/mullvad_daemon/src/management_interface.rs +++ b/mullvad_daemon/src/management_interface.rs @@ -7,7 +7,7 @@ use jsonrpc_pubsub::{PubSubHandler, PubSubMetadata, Session, SubscriptionId}; use jsonrpc_ws_server; use serde; -use states::{SecurityState, TargetState}; +use states::{DaemonState, TargetState}; use std::collections::HashMap; use std::collections::hash_map::Entry; @@ -73,10 +73,10 @@ build_rpc_trait! { #[rpc(name = "disconnect")] fn disconnect(&self) -> Result<(), Error>; - /// Returns the current security state of the Mullvad client. Changes to this state will - /// be announced to subscribers of `event`. + /// Returns the current state of the Mullvad client. Changes to this state will + /// be announced to subscribers of `new_state`. #[rpc(async, name = "get_state")] - fn get_state(&self) -> BoxFuture<SecurityState, Error>; + fn get_state(&self) -> BoxFuture<DaemonState, Error>; /// Returns the current public IP of this computer. #[rpc(name = "get_ip")] @@ -90,7 +90,7 @@ build_rpc_trait! { #[pubsub(name = "new_state")] { /// Subscribes to the `new_state` event notifications. #[rpc(name = "new_state_subscribe")] - fn new_state_subscribe(&self, Self::Metadata, pubsub::Subscriber<SecurityState>); + fn new_state_subscribe(&self, Self::Metadata, pubsub::Subscriber<DaemonState>); /// Unsubscribes from the `new_state` event notifications. #[rpc(name = "new_state_unsubscribe")] @@ -116,7 +116,7 @@ pub enum TunnelCommand { /// Change target state. SetTargetState(TargetState), /// Request the current state. - GetState(sync::oneshot::Sender<SecurityState>), + GetState(sync::oneshot::Sender<DaemonState>), /// Set which account token to use for subsequent connection attempts. SetAccount(Option<AccountToken>), /// Request the current account token being used. @@ -125,7 +125,7 @@ pub enum TunnelCommand { #[derive(Default)] struct ActiveSubscriptions { - new_state_subscriptions: RwLock<HashMap<SubscriptionId, pubsub::Sink<SecurityState>>>, + new_state_subscriptions: RwLock<HashMap<SubscriptionId, pubsub::Sink<DaemonState>>>, error_subscriptions: RwLock<HashMap<SubscriptionId, pubsub::Sink<Vec<String>>>>, } @@ -175,7 +175,7 @@ pub struct EventBroadcaster { impl EventBroadcaster { /// Sends a new state update to all `new_state` subscribers of the management interface. - pub fn notify_new_state(&self, new_state: SecurityState) { + pub fn notify_new_state(&self, new_state: DaemonState) { self.notify(&self.subscriptions.new_state_subscriptions, new_state); } @@ -306,7 +306,7 @@ impl<T: From<TunnelCommand> + 'static + Send> ManagementInterfaceApi for Managem .map_err(|_| Error::internal_error()) } - fn get_state(&self) -> BoxFuture<SecurityState, Error> { + fn get_state(&self) -> BoxFuture<DaemonState, Error> { trace!("get_state"); let (state_tx, state_rx) = sync::oneshot::channel(); match self.tx.lock().unwrap().send(TunnelCommand::GetState(state_tx)) { @@ -333,7 +333,7 @@ impl<T: From<TunnelCommand> + 'static + Send> ManagementInterfaceApi for Managem fn new_state_subscribe(&self, _meta: Self::Metadata, - subscriber: pubsub::Subscriber<SecurityState>) { + subscriber: pubsub::Subscriber<DaemonState>) { trace!("new_state_subscribe"); Self::subscribe(subscriber, &self.subscriptions.new_state_subscriptions); } |
