summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLinus Färnstrand <linus@mullvad.net>2017-06-27 17:01:06 +0200
committerLinus Färnstrand <linus@mullvad.net>2017-06-30 15:58:39 +0200
commitba1ed122e8f1e2ad19c3dfb6f40696bfa2d57fd1 (patch)
tree2d7f65b08088df5bfe16d4a51f1a01dc1125a7cf
parentfd2935c046925b169dd268918e8b594d5cd8e278 (diff)
downloadmullvadvpn-ba1ed122e8f1e2ad19c3dfb6f40696bfa2d57fd1.tar.xz
mullvadvpn-ba1ed122e8f1e2ad19c3dfb6f40696bfa2d57fd1.zip
Handle set_account in mgmt interface
-rw-r--r--mullvad_daemon/src/main.rs6
-rw-r--r--mullvad_daemon/src/management_interface.rs10
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> {