From 6d9ca815b0284da132eeff4f6d8f2acaf375a6b7 Mon Sep 17 00:00:00 2001 From: Stan Bondi Date: Thu, 11 Aug 2022 13:12:10 +0400 Subject: [PATCH] fix(comms/tor): re-establish tor control port connection for any failure (#4446) Description --- Retries tor control port connection for any error. Motivation and Context --- If any error is encountered with the tor control port connection, the connection is re-established. Previously, this would only happen if the control port connection is cleanly closed How Has This Been Tested? --- Manually --- comms/core/src/tor/control_client/monitor.rs | 2 ++ comms/core/src/tor/hidden_service/controller.rs | 1 + 2 files changed, 3 insertions(+) diff --git a/comms/core/src/tor/control_client/monitor.rs b/comms/core/src/tor/control_client/monitor.rs index 952823e6bc..550cac0757 100644 --- a/comms/core/src/tor/control_client/monitor.rs +++ b/comms/core/src/tor/control_client/monitor.rs @@ -105,10 +105,12 @@ where // Error receiving a line from the control server Either::Right(Some(Err(err))) => { + cmd_rx.close(); error!( target: LOG_TARGET, "Line framing error when reading from tor control server: '{:?}'. Monitor is exiting.", err ); + let _result = event_tx.send(TorControlEvent::TorControlDisconnected); break; }, // The control server disconnected diff --git a/comms/core/src/tor/hidden_service/controller.rs b/comms/core/src/tor/hidden_service/controller.rs index 800a3ba5fb..a4482aecbc 100644 --- a/comms/core/src/tor/hidden_service/controller.rs +++ b/comms/core/src/tor/hidden_service/controller.rs @@ -211,6 +211,7 @@ impl HiddenServiceController { let either = future::select(connect_fut, signal.take().expect("signal was None")).await; match either { Either::Left((Ok(client), _)) => { + info!(target: LOG_TARGET, "Connection to tor control port re-established"); self.client = Some(client); self.authenticate().await?; self.set_events().await?;