//! NetDesk LAN scan — discover NetDesk hosts on the local network by UDP //! broadcast (the viewer end of the host's discovery responder). Prints each //! host's id + name so you can connect by id. Developed by Akronlogic. //! //! Usage: netdesk-lan-scan [timeout_ms] (default 800ms) use netdesk_core::lan; use std::time::Duration; fn main() { let ms: u64 = std::env::args() .nth(1) .and_then(|s| s.parse().ok()) .unwrap_or(800); eprintln!("[lan] scanning for NetDesk hosts on udp/{} for {ms}ms…", lan::LAN_PORT); match lan::scan(&lan::broadcast_targets(), Duration::from_millis(ms)) { Ok(hosts) if hosts.is_empty() => { println!("no NetDesk hosts found on this LAN"); } Ok(hosts) => { println!("found {} host(s):", hosts.len()); for h in hosts { // addr.port() is 0 until direct-IP connect ships; the id is what // a viewer uses to connect through the relay today. println!(" id={} name=\"{}\" ip={}", h.id, h.name, h.addr.ip()); } } Err(e) => { eprintln!("[lan] scan failed: {e}"); std::process::exit(1); } } }