ifaddrsx

Crates.ioifaddrsx
lib.rsifaddrsx
version
sourcesrc
created_at2025-02-02 07:42:19.671706
updated_at2025-02-02 07:42:19.671706
descriptionRetrieve the names and IP addresses of all active network interfaces.
homepage
repositoryhttps://github.com/spritetong/ifaddrsx
max_upload_size
id1539350
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Sprite Tong (spritetong)

documentation

https://docs.rs/ifaddrsx

README

ifaddrsx

Crates.io Documentation License: MIT

A Rust library for retrieving network interface information, including names and IP addresses of all active network interfaces. This crate provides a cross-platform solution that works on Windows, Linux, macOS, and other Unix-like systems.

Features

  • Get network interface names
  • Retrieve IPv4 and IPv6 addresses for each interface
  • Cross-platform support (Windows, Linux, macOS, and other Unix-like systems)
  • Easy-to-use API
  • No unsafe code (except for necessary FFI bindings)

Installation

Add this to your Cargo.toml:

[dependencies]
ifaddrsx = "0.3"

Usage

use ifaddrsx::get_ifaddrs;

fn main() {
    let ifaddrs = get_ifaddrs().unwrap();
    for ifaddr in ifaddrs {
        println!("Interface: {}", ifaddr.name);
        println!("  IP Addresses: {:?}", ifaddr.ips);
    }
}

Platform Support

  • Windows (via WinAPI)
  • Linux (via netlink)
  • macOS and other Unix-like systems (via getifaddrs)

Dependencies

  • bitflags: For flag handling
  • ipnetwork: IP address manipulation
  • libc: System library bindings
  • Platform-specific dependencies:
    • Windows: winapi with network-related features
    • Unix: nix for network operations

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Author

Sprite Tong spritetong@gmail.com

Commit count: 23

cargo fmt