diff --git a/crates/network-scanner/src/broadcast.rs b/crates/network-scanner/src/broadcast.rs index 53041e3ba..7209413f4 100644 --- a/crates/network-scanner/src/broadcast.rs +++ b/crates/network-scanner/src/broadcast.rs @@ -53,6 +53,7 @@ pub struct BroadcastStream { receiver: tokio::sync::mpsc::Receiver>, SockAddr), std::io::Error>>, verifier: Vec, should_verify: bool, + handle: tokio::task::JoinHandle>, } impl BroadcastStream { @@ -115,7 +116,7 @@ pub async fn boardcast(ip: Ipv4Addr, read_time_out: Option) -> anyhow: .send_to(&packet.to_bytes(true), SockAddr::from(SocketAddr::new(ip.into(), 0))) .await?; let (sender, receiver) = tokio::sync::mpsc::channel(255); - tokio::task::spawn(async move { + let handle = tokio::task::spawn(async move { let mut buffer = [MaybeUninit::uninit(); icmp_v4::ICMPV4_MTU]; loop { let result = socket.recv_from(&mut buffer).await; @@ -130,14 +131,16 @@ pub async fn boardcast(ip: Ipv4Addr, read_time_out: Option) -> anyhow: }; let buffer_copy = buffer[..size].as_ref().to_vec(); - sender.send(Ok((buffer_copy, addr))).await.unwrap(); + sender.send(Ok((buffer_copy, addr))).await?; } + Ok::<(), anyhow::Error>(()) }); Ok(BroadcastStream { receiver, verifier, should_verify: true, + handle, }) } diff --git a/crates/network-scanner/src/ping.rs b/crates/network-scanner/src/ping.rs index 553921092..b94ffaec3 100644 --- a/crates/network-scanner/src/ping.rs +++ b/crates/network-scanner/src/ping.rs @@ -47,7 +47,7 @@ pub fn blocking_ping(ip: Ipv4Addr) -> anyhow::Result<()> { } } -/// Assume the `buf`fer to be initialised. +/// Assume the `buf`fer to be initialized. /// /// # Safety ///