From 7999fab25c5172207ee41e38732f4923565ff6b6 Mon Sep 17 00:00:00 2001 From: Andrew Guschin Date: Fri, 30 Oct 2026 04:43:59 +0400 Subject: Validate controller diagnostics, reboot protection, and terminal authentication --- src/bus.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/bus.rs') diff --git a/src/bus.rs b/src/bus.rs index fd26f1d..68bd316 100644 --- a/src/bus.rs +++ b/src/bus.rs @@ -308,13 +308,22 @@ impl Client { ) -> Result { let proxy = self.proxy().await?; let arguments = (id.unwrap_or(""), speed, interactive); - tokio::select! { - result = proxy.call("Diagnostic", &arguments) => Ok(result?), + let value: String = tokio::select! { + result = proxy.call("Diagnostic", &arguments) => result?, _ = tokio::signal::ctrl_c() => { let _: () = proxy.call("CancelDiagnostic", &(interactive,)).await?; anyhow::bail!("Diagnostic cancelled; proxy intent is unchanged") } + }; + let observation: crate::diagnostics::Observation = serde_json::from_str(&value)?; + if !observation.success { + let delay = observation + .retry_after_seconds + .map(|seconds| format!("; retry after at least {seconds} seconds")) + .unwrap_or_default(); + anyhow::bail!("Diagnostic failed: {}{}", observation.stop_reason, delay); } + Ok(value) } pub async fn change(&self, operation: Operation, interactive: bool) -> Result<()> { let proxy = self.proxy().await?; -- cgit v1.2.3