Small updates to interface printing

This commit is contained in:
Random936 2024-12-22 18:47:53 -08:00
parent adda5dd958
commit 4c4b3bc202

View File

@ -1,7 +1,7 @@
use std::{fs, io};
use std::net::IpAddr;
use std::path::Path;
use if_addrs::{Interface, get_if_addrs};
use if_addrs::{get_if_addrs, IfAddr, Interface};
fn print_single_interface<P: AsRef<Path>>(iface: Interface, port: &u16, path: P) -> io::Result<()> {
for entry in fs::read_dir(path)? {
@ -11,8 +11,10 @@ fn print_single_interface<P: AsRef<Path>>(iface: Interface, port: &u16, path: P)
let filename = entry_path.file_name().unwrap();
if let IfAddr::V4(_) = iface.addr {
println!("http://{}:{}/{}", iface.ip(), port, filename.to_str().unwrap());
}
}
Ok(())
}