#[cfg(target_os = "linux")]
mod linux;
#[cfg(target_os = "macos")]
mod macos;
use crate::model::PortEntry;
use anyhow::Result;
pub fn scan_ports() -> Result<Vec<PortEntry>> {
#[cfg(target_os = "linux")]
{
linux::scan()
}
#[cfg(target_os = "macos")]
{
macos::scan()
}
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
{
anyhow::bail!("unsupported platform")
}
}
pub fn scan_ports_elevated() -> Result<Vec<PortEntry>> {
#[cfg(target_os = "macos")]
{
macos::scan_elevated()
}
#[cfg(target_os = "linux")]
{
linux::scan()
}
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
{
anyhow::bail!("unsupported platform")
}
}
pub fn scan_ports_with_sudo(password: &str) -> Result<Vec<PortEntry>> {
#[cfg(target_os = "macos")]
{
macos::scan_with_sudo(password)
}
#[cfg(target_os = "linux")]
{
let _ = password;
linux::scan()
}
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
{
let _ = password;
anyhow::bail!("unsupported platform")
}
}