netls 1.1.0

Network connections viewer for daily use and automation - container visibility, JSON/CSV output, process tree, live watch mode
Documentation
use crate::{Connection, Result};

/// Linux connection collection via `/proc/net/{tcp,udp,unix}` plus
/// `/proc/<pid>/fd/` for inode -> PID resolution.
#[cfg(target_os = "linux")]
pub mod linux;
#[cfg(target_os = "macos")]
mod macos;
/// macOS-only enrichment helpers (full cmdline, fd usage, parent chain).
#[cfg(target_os = "macos")]
pub mod macos_enrich;

/// Collect all current network connections from the running OS.
/// Dispatches to the platform-specific implementation.
///
/// # Errors
///
/// On Linux/macOS: propagates the platform layer's I/O errors (procfs or
/// libproc). On unsupported platforms: returns [`crate::Error::UnsupportedPlatform`].
pub fn get_connections() -> Result<Vec<Connection>> {
    #[cfg(target_os = "linux")]
    return linux::get_connections();

    #[cfg(target_os = "macos")]
    return macos::get_connections();

    #[cfg(not(any(target_os = "linux", target_os = "macos")))]
    Err(crate::Error::UnsupportedPlatform)
}