From 3662325e23ffae92b094f716250503f2193f9934 Mon Sep 17 00:00:00 2001 From: wisp3rwind <17089248+wisp3rwind@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:27:03 +0100 Subject: [PATCH] discovery: don't panic on libmdns errors On panic, the discovery task crashes, but the main program is not notified of this. Returning an error will result in the Discovery stream yielding None, serving as notification to the application (which might shutdown with error, for example, if no other means of authentication is available). --- discovery/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/discovery/src/lib.rs b/discovery/src/lib.rs index d829e0f57..c6d88a2e7 100644 --- a/discovery/src/lib.rs +++ b/discovery/src/lib.rs @@ -396,7 +396,7 @@ fn launch_libmdns( let task_handle = tokio::task::spawn_blocking(move || { let inner = move || -> Result<(), DiscoveryError> { - let svc = if !zeroconf_ip.is_empty() { + let responder = if !zeroconf_ip.is_empty() { libmdns::Responder::spawn_with_ip_list( &tokio::runtime::Handle::current(), zeroconf_ip, @@ -404,9 +404,9 @@ fn launch_libmdns( } else { libmdns::Responder::spawn(&tokio::runtime::Handle::current()) } - .map_err(|e| DiscoveryError::DnsSdError(Box::new(e))) - .unwrap() - .register( + .map_err(|e| DiscoveryError::DnsSdError(Box::new(e)))?; + + let svc = responder.register( DNS_SD_SERVICE_NAME.to_owned(), name.into_owned(), port,