diff options
| author | Andrew Guschin <guschin@altlinux.org> | 2026-10-30 04:43:59 +0400 |
|---|---|---|
| committer | Andrew Guschin <guschin@altlinux.org> | 2026-10-30 04:43:59 +0400 |
| commit | 7999fab25c5172207ee41e38732f4923565ff6b6 (patch) | |
| tree | 0e239d6ba65d4babfc0f1007ac350f6f4f9e73d1 /src/controller.rs | |
| parent | fc3c1d51b1be9db6ba6ad286584fbc34bb305f38 (diff) | |
Validate controller diagnostics, reboot protection, and terminal authentication
Diffstat (limited to 'src/controller.rs')
| -rw-r--r-- | src/controller.rs | 70 |
1 files changed, 40 insertions, 30 deletions
diff --git a/src/controller.rs b/src/controller.rs index 4686118..ea98a65 100644 --- a/src/controller.rs +++ b/src/controller.rs @@ -336,27 +336,32 @@ impl Controller { "The diagnostic provider requested a pause; retry after its Retry-After delay" ); } - let probe = self - .runtime - .probe( - entry.connection.as_ref().unwrap(), - if speed { - settings.maximum_duration_seconds - } else { - 5 - }, + let result = async { + let probe = self + .runtime + .probe( + entry.connection.as_ref().unwrap(), + if speed { + settings.maximum_duration_seconds + } else { + 5 + }, + ) + .await?; + let connection = probe.connection(); + let measured = crate::diagnostics::measure( + &settings, + connection.proxy_url, + connection.certificate, + id.into(), + generation, + speed, ) - .await?; - let result = crate::diagnostics::measure( - &settings, - &probe.proxy, - &probe.certificate, - id.into(), - generation, - speed, - ) + .await; + probe.stop().await; + measured + } .await; - probe.stop().await; match result { Ok(observation) => { if let Some(wait) = observation.retry_after_seconds { @@ -383,19 +388,24 @@ impl Controller { Ok(observation) } Err(error) => { + let observation = crate::diagnostics::Observation { + configuration_id: id.into(), + generation, + kind: if speed { "speed" } else { "ping" }.into(), + success: false, + elapsed_ms: 0, + bytes: 0, + bytes_per_second: None, + stop_reason: error.to_string(), + retry_after_seconds: None, + }; if !speed && Some(id) == selected.as_deref() { - self.observation = Some(crate::diagnostics::Observation { - configuration_id: id.into(), - generation, - kind: "ping".into(), - success: false, - elapsed_ms: 0, - bytes: 0, - bytes_per_second: None, - stop_reason: error.to_string(), - retry_after_seconds: None, - }); + self.observation = Some(observation.clone()); } + self.measurements.retain(|previous| { + previous.configuration_id != id || previous.kind != observation.kind + }); + self.measurements.push(observation); self.record(error.to_string()); Err(error) } |