diff --git a/clients/android/native/src/discovery.rs b/clients/android/native/src/discovery.rs index d68da71..1eec536 100644 --- a/clients/android/native/src/discovery.rs +++ b/clients/android/native/src/discovery.rs @@ -299,7 +299,11 @@ mod tests { mac: "aa:bb\u{1f}cc".into(), }; let encoded = h.encode(); - assert_eq!(encoded.matches(FIELD_SEP).count(), 6, "exactly seven fields"); + assert_eq!( + encoded.matches(FIELD_SEP).count(), + 6, + "exactly seven fields" + ); assert!(!encoded.contains('\n') && !encoded.contains('\r')); let fields: Vec<&str> = encoded.split(FIELD_SEP).collect(); assert_eq!(fields[0], "kinjected"); diff --git a/clients/linux/src/trust.rs b/clients/linux/src/trust.rs index d8b1e00..86739ac 100644 --- a/clients/linux/src/trust.rs +++ b/clients/linux/src/trust.rs @@ -154,9 +154,11 @@ pub fn learn_mac(fp_hex: &str, addr: &str, port: u16, mac: &[String]) { return; } let mut known = KnownHosts::load(); - let Some(h) = known.hosts.iter_mut().find(|h| { - (!fp_hex.is_empty() && h.fp_hex == fp_hex) || (h.addr == addr && h.port == port) - }) else { + let Some(h) = known + .hosts + .iter_mut() + .find(|h| (!fp_hex.is_empty() && h.fp_hex == fp_hex) || (h.addr == addr && h.port == port)) + else { return; }; if h.mac == mac { diff --git a/clients/linux/src/ui_hosts.rs b/clients/linux/src/ui_hosts.rs index 54f98aa..7e62dff 100644 --- a/clients/linux/src/ui_hosts.rs +++ b/clients/linux/src/ui_hosts.rs @@ -319,7 +319,10 @@ fn rebuild(state: &Rc) { let online = adverts.values().any(|a| matches(k, a)); // Learn this host's wake MAC(s) from its live advert while it's online, so we can wake it // once it sleeps and stops advertising (no-op / no disk write when unchanged). - if let Some(a) = adverts.values().find(|a| matches(k, a) && !a.mac.is_empty()) { + if let Some(a) = adverts + .values() + .find(|a| matches(k, a) && !a.mac.is_empty()) + { crate::trust::learn_mac(&k.fp_hex, &k.addr, k.port, &a.mac); } let recent = most_recent.as_deref() == Some(k.fp_hex.as_str()); @@ -505,7 +508,10 @@ fn saved_card( // Explicit "just wake it" (the tap-to-connect already auto-wakes an offline host). let mac = k.mac.clone(); let addr = k.addr.clone(); - add("wake", Box::new(move || crate::wol::wake(&mac, addr.parse().ok()))); + add( + "wake", + Box::new(move || crate::wol::wake(&mac, addr.parse().ok())), + ); } overlay.insert_action_group("card", Some(&actions)); diff --git a/clients/windows/src/app/hosts.rs b/clients/windows/src/app/hosts.rs index df93e99..a7104c6 100644 --- a/clients/windows/src/app/hosts.rs +++ b/clients/windows/src/app/hosts.rs @@ -327,7 +327,8 @@ pub(crate) fn hosts_page(props: &HostsProps, cx: &mut RenderCx) -> Element { // Learn this host's wake MAC(s) from its live advert while it's online, so we can wake // it once it sleeps (no-op / no disk write when unchanged). if let Some(a) = hosts.iter().find(|h| { - (h.fp_hex == k.fp_hex || (h.addr == k.addr && h.port == k.port)) && !h.mac.is_empty() + (h.fp_hex == k.fp_hex || (h.addr == k.addr && h.port == k.port)) + && !h.mac.is_empty() }) { crate::trust::learn_mac(&k.fp_hex, &k.addr, k.port, &a.mac); } diff --git a/clients/windows/src/trust.rs b/clients/windows/src/trust.rs index d16a3a4..a1ed461 100644 --- a/clients/windows/src/trust.rs +++ b/clients/windows/src/trust.rs @@ -129,9 +129,11 @@ pub fn learn_mac(fp_hex: &str, addr: &str, port: u16, mac: &[String]) { return; } let mut known = KnownHosts::load(); - let Some(h) = known.hosts.iter_mut().find(|h| { - (!fp_hex.is_empty() && h.fp_hex == fp_hex) || (h.addr == addr && h.port == port) - }) else { + let Some(h) = known + .hosts + .iter_mut() + .find(|h| (!fp_hex.is_empty() && h.fp_hex == fp_hex) || (h.addr == addr && h.port == port)) + else { return; }; if h.mac == mac { diff --git a/crates/punktfunk-core/src/wol.rs b/crates/punktfunk-core/src/wol.rs index 247fd56..b2d6a3d 100644 --- a/crates/punktfunk-core/src/wol.rs +++ b/crates/punktfunk-core/src/wol.rs @@ -64,7 +64,10 @@ pub fn build_magic_packet(mac: Mac) -> [u8; 102] { /// could be opened or nothing could be sent at all. pub fn send_magic_packet(macs: &[Mac], last_known_ip: Option) -> io::Result<()> { if macs.is_empty() { - return Err(io::Error::new(io::ErrorKind::InvalidInput, "no MAC addresses")); + return Err(io::Error::new( + io::ErrorKind::InvalidInput, + "no MAC addresses", + )); } // Build the target IP set: each interface's directed broadcast, the limited broadcast, and @@ -100,7 +103,10 @@ pub fn send_magic_packet(macs: &[Mac], last_known_ip: Option) -> io::R if sent_any { Ok(()) } else { - Err(io::Error::new(io::ErrorKind::Other, "no magic packet could be sent")) + Err(io::Error::new( + io::ErrorKind::Other, + "no magic packet could be sent", + )) } } @@ -118,9 +124,9 @@ fn broadcast_addrs() -> Vec { continue; } if let if_addrs::IfAddr::V4(v4) = iface.addr { - let bcast = v4.broadcast.unwrap_or_else(|| { - Ipv4Addr::from(u32::from(v4.ip) | !u32::from(v4.netmask)) - }); + let bcast = v4 + .broadcast + .unwrap_or_else(|| Ipv4Addr::from(u32::from(v4.ip) | !u32::from(v4.netmask))); // Skip a degenerate 0.0.0.0 (unconfigured) and the all-ones limited broadcast we // already add unconditionally. if !bcast.is_unspecified() && bcast != Ipv4Addr::BROADCAST { @@ -156,8 +162,14 @@ mod tests { #[test] fn parse_mac_forms() { - assert_eq!(parse_mac("aa:bb:cc:dd:ee:ff"), Some([0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff])); - assert_eq!(parse_mac("AA-BB-CC-DD-EE-FF"), Some([0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff])); + assert_eq!( + parse_mac("aa:bb:cc:dd:ee:ff"), + Some([0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff]) + ); + assert_eq!( + parse_mac("AA-BB-CC-DD-EE-FF"), + Some([0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff]) + ); assert_eq!(parse_mac("01:02:03:04:05:06"), Some([1, 2, 3, 4, 5, 6])); assert_eq!(parse_mac("aa:bb:cc:dd:ee"), None); // too few assert_eq!(parse_mac("aa:bb:cc:dd:ee:ff:00"), None); // too many diff --git a/crates/punktfunk-host/src/wol.rs b/crates/punktfunk-host/src/wol.rs index 02ff3c2..5a10c3b 100644 --- a/crates/punktfunk-host/src/wol.rs +++ b/crates/punktfunk-host/src/wol.rs @@ -66,11 +66,17 @@ pub fn wake_macs(primary_ip: IpAddr) -> Vec { #[cfg(target_os = "linux")] pub fn warn_if_not_armed(primary_ip: IpAddr) { let ifaces = if_addrs::get_if_addrs().unwrap_or_default(); - let Some(iface) = ifaces.iter().find(|i| i.ip() == primary_ip).map(|i| i.name.clone()) else { + let Some(iface) = ifaces + .iter() + .find(|i| i.ip() == primary_ip) + .map(|i| i.name.clone()) + else { return; }; match ethtool_wol_has_magic(&iface) { - Some(true) => tracing::info!(iface = %iface, "Wake-on-LAN armed (magic packet) on host NIC"), + Some(true) => { + tracing::info!(iface = %iface, "Wake-on-LAN armed (magic packet) on host NIC") + } Some(false) => tracing::warn!( iface = %iface, "Wake-on-LAN is NOT armed on this host's NIC — clients cannot wake it from sleep. \ @@ -88,7 +94,10 @@ pub fn warn_if_not_armed(_primary_ip: IpAddr) {} /// (wake on MagicPacket). Returns `None` if ethtool is missing/failed or the field is absent. #[cfg(target_os = "linux")] fn ethtool_wol_has_magic(iface: &str) -> Option { - let out = std::process::Command::new("ethtool").arg(iface).output().ok()?; + let out = std::process::Command::new("ethtool") + .arg(iface) + .output() + .ok()?; if !out.status.success() { return None; }