log mdns discoveries

This commit is contained in:
Alex Janka 2024-03-07 09:24:07 +11:00
parent 2ebf87272c
commit 42b742feb1

View file

@ -111,11 +111,18 @@ pub fn spawn_discover_thread() -> Result<MdnsDiscoveredList, DiscoveryError> {
None None
}) { }) {
let mut connections = discovered.write().await; let mut connections = discovered.write().await;
if !connections.get(&id).is_some_and(|(old_ip, old_port)| {
*old_ip == ip.to_string() && *old_port == port
}) {
log::info!(
"mdns: discovered {name} - id: {id}, ip: {ip}, port: {port}"
);
connections.insert(id, (ip.to_string(), port)); connections.insert(id, (ip.to_string(), port));
} }
} }
} }
} }
}
tokio::time::sleep(Duration::from_secs(5 * 60)).await; tokio::time::sleep(Duration::from_secs(5 * 60)).await;
} }
}); });