diff options
| -rw-r--r-- | mullvad_daemon/src/main.rs | 6 | ||||
| -rw-r--r-- | mullvad_daemon/src/management_interface.rs | 10 |
2 files changed, 13 insertions, 3 deletions
diff --git a/mullvad_daemon/src/main.rs b/mullvad_daemon/src/main.rs index 62c09608a5..53faed7f6f 100644 --- a/mullvad_daemon/src/main.rs +++ b/mullvad_daemon/src/main.rs @@ -118,6 +118,8 @@ struct Daemon { // Just for testing. A cyclic iterator iterating over the hardcoded remotes, // picking a new one for each retry. remote_iter: std::iter::Cycle<std::iter::Cloned<std::slice::Iter<'static, Endpoint>>>, + // The current account token for now. Should be moved into the settings later. + account_token: String, } impl Daemon { @@ -135,6 +137,7 @@ impl Daemon { tunnel_close_handle: None, management_interface_broadcaster, remote_iter: REMOTES.iter().cloned().cycle(), + account_token: "0".to_owned(), }, ) } @@ -225,7 +228,8 @@ impl Daemon { if let Err(_) = tx.send(self.last_broadcasted_state) { warn!("Unable to send current state to management interface client",); } - } + }, + TunnelCommand::SetAccount(account_token) => self.account_token = account_token, } Ok(()) } diff --git a/mullvad_daemon/src/management_interface.rs b/mullvad_daemon/src/management_interface.rs index fccdae2414..010ce807ec 100644 --- a/mullvad_daemon/src/management_interface.rs +++ b/mullvad_daemon/src/management_interface.rs @@ -113,6 +113,8 @@ pub enum TunnelCommand { SetTargetState(TargetState), /// Request the current state. GetState(sync::oneshot::Sender<SecurityState>), + /// Set which account token to use for subsequent connection attempts. + SetAccount(AccountToken), } #[derive(Default)] @@ -252,9 +254,13 @@ impl<T: From<TunnelCommand> + 'static + Send> ManagementInterfaceApi for Managem Ok(HashMap::new()) } - fn set_account(&self, _account_token: AccountToken) -> Result<(), Error> { + fn set_account(&self, account_token: AccountToken) -> Result<(), Error> { trace!("set_account"); - Ok(()) + self.tx + .lock() + .unwrap() + .send(TunnelCommand::SetAccount(account_token)) + .map_err(|_| Error::internal_error()) } fn set_country(&self, _country_code: CountryCode) -> Result<(), Error> { |
