From d3cf93fb6c9b7e0faf9b7907328f0a042009e164 Mon Sep 17 00:00:00 2001 From: FxQnLr Date: Mon, 15 Apr 2024 20:33:32 +0200 Subject: Closes #35. Entry of Ip optional, error on ping request without saved ip --- src/services/ping.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/services/ping.rs') diff --git a/src/services/ping.rs b/src/services/ping.rs index 1bf022d..4e0ffcf 100644 --- a/src/services/ping.rs +++ b/src/services/ping.rs @@ -28,7 +28,9 @@ pub async fn spawn( let mut msg: Option = None; while msg.is_none() { - let ping = surge_ping::ping(device.ip.ip(), &payload).await; + // Safe: Only called when ip is set + let ip = device.ip.unwrap(); + let ping = surge_ping::ping(ip.ip(), &payload).await; if let Err(ping) = ping { let ping_timeout = matches!(ping, surge_ping::SurgeError::Timeout { .. }); -- cgit v1.2.3