diff options
| -rw-r--r-- | mullvad-daemon/src/main.rs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/mullvad-daemon/src/main.rs b/mullvad-daemon/src/main.rs index 8f03a78170..661da885dc 100644 --- a/mullvad-daemon/src/main.rs +++ b/mullvad-daemon/src/main.rs @@ -58,7 +58,7 @@ mod version; use error_chain::ChainedError; use futures::sync::mpsc::UnboundedSender; use futures::{Future, Sink}; -use jsonrpc_core::futures::sync::oneshot::Sender as OneshotSender; +use jsonrpc_core::futures::sync::oneshot::{self, Sender as OneshotSender}; use management_interface::{BoxFuture, ManagementCommand, ManagementInterfaceServer}; use mullvad_rpc::{AccountsProxy, AppVersionProxy, HttpHandle}; @@ -332,7 +332,14 @@ impl Daemon { self.state.disconnected(); self.current_relay = None; } - Blocked(ref reason) => info!("Blocking all network connections, reason: {}", reason), + Blocked(ref reason) => { + info!("Blocking all network connections, reason: {}", reason); + + match reason { + BlockReason::AuthFailed(_) => self.schedule_reconnect(Duration::from_secs(60)), + _ => {} + } + } _ => {} } @@ -341,6 +348,20 @@ impl Daemon { .notify_new_state(tunnel_state); } + fn schedule_reconnect(&mut self, delay: Duration) { + let command_tx = self.tx.clone(); + + thread::spawn(move || { + let (result_tx, _result_rx) = oneshot::channel(); + + thread::sleep(delay); + debug!("Attempting to reconnect"); + let _ = command_tx.send(DaemonEvent::ManagementInterfaceEvent( + ManagementCommand::SetTargetState(result_tx, TargetState::Secured), + )); + }); + } + fn handle_management_interface_event(&mut self, event: ManagementCommand) { use ManagementCommand::*; match event { |
