INNER CODE UNIT · Rust

find_best_device

domcyrus/rustnet · crates/rustnet-capture/src/lib.rs:117

fn find_best_device() -> Result<Device> {
    let devices = Device::list().map_err(|e| {
        anyhow!(
            "Failed to list network devices: {}. This may indicate insufficient privileges.",
            e
        )
    })?;

    log::info!(
        "Scanning {} devices for best active interface...",
        devices.len()
    );

    for d in &devices {
        let has_valid_ip = d.addresses.iter().any(|addr| match &addr.addr {
            std::net::IpAddr::V4(v4) => {
                !v4.is_link_local() && !v4.is_loopback() && !v4.is_unspecified()
            }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…