summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-09-03 11:48:59 -0300
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-09-03 11:48:59 -0300
commit4bcb0e91cb76242e8bbc104378814cd59cb8306d (patch)
treed37a85adbb93c3a4b7e98e2c755d0816bf05ffb5
parentafb85e6f18e16e06783739f74229933ca277c1c1 (diff)
parentdfcc0a2e9b65eea6ed159261bfb88dfa4bdc1176 (diff)
downloadmullvadvpn-4bcb0e91cb76242e8bbc104378814cd59cb8306d.tar.xz
mullvadvpn-4bcb0e91cb76242e8bbc104378814cd59cb8306d.zip
Merge branch 'tunnel-trigger-fixes'
-rw-r--r--mullvad-daemon/src/main.rs21
1 files changed, 17 insertions, 4 deletions
diff --git a/mullvad-daemon/src/main.rs b/mullvad-daemon/src/main.rs
index b82430098e..4385b3a291 100644
--- a/mullvad-daemon/src/main.rs
+++ b/mullvad-daemon/src/main.rs
@@ -438,14 +438,20 @@ impl Daemon {
tx: OneshotSender<()>,
account_token: Option<String>,
) -> Result<()> {
+ let account_token_cleared = account_token.is_none();
let save_result = self.settings.set_account_token(account_token);
match save_result.chain_err(|| "Unable to save settings") {
Ok(account_changed) => {
Self::oneshot_send(tx, (), "set_account response");
if account_changed {
- info!("Initiating tunnel restart because the account token changed");
- self.connect_tunnel()?;
+ if account_token_cleared {
+ info!("Disconnecting because account token was cleared");
+ self.set_target_state(TargetState::Unsecured)?;
+ } else {
+ info!("Initiating tunnel restart because the account token changed");
+ self.reconnect_tunnel()?;
+ }
}
}
Err(e) => error!("{}", e.display_chain()),
@@ -493,7 +499,7 @@ impl Daemon {
if changed {
info!("Initiating tunnel restart because the relay settings changed");
- self.connect_tunnel()?;
+ self.reconnect_tunnel()?;
}
}
Err(e) => error!("{}", e.display_chain()),
@@ -569,7 +575,7 @@ impl Daemon {
if settings_changed {
info!("Initiating tunnel restart because the enable IPv6 setting changed");
- self.connect_tunnel()?;
+ self.reconnect_tunnel()?;
}
}
Err(e) => error!("{}", e.display_chain()),
@@ -646,6 +652,13 @@ impl Daemon {
.expect("Tunnel state machine has stopped");
}
+ fn reconnect_tunnel(&mut self) -> Result<()> {
+ match self.target_state {
+ TargetState::Secured => self.connect_tunnel(),
+ TargetState::Unsecured => Ok(()),
+ }
+ }
+
fn build_tunnel_parameters(&mut self) -> Result<TunnelParameters> {
let endpoint = match self.settings.get_relay_settings() {
RelaySettings::CustomTunnelEndpoint(custom_relay) => custom_relay