MCPcopy Index your code
hub / github.com/LeoBorai/network-interface

github.com/LeoBorai/network-interface @v2.0.5

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.0.5 ↗ · + Follow
28 symbols 31 edges 10 files 4 documented · 14% 1 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

network-interface

Retrieve system's Network Interfaces/Adapters on Android, FreeBSD, Linux, macOS, iOS and Windows on a standarized manner

Crates.io Documentation Build Clippy Formatter

This crate is under development, feel free to contribute on GitHub. API and implementation is subject to change.

The main goal of network-interface crate is to retrieve system's Network Interfaces in a standardized manner.

standardized manner means that every supported platform must expose the same API and no further changes to the implementation are required to support such platform.

Usage

use network_interface::NetworkInterface;
use network_interface::NetworkInterfaceConfig;

fn main() {
    let network_interfaces = NetworkInterface::show().unwrap();

    for itf in network_interfaces.iter() {
        println!("{:?}", itf);
    }
}

Output

NetworkInterface { name: "lo", addr: Some(V4(V4IfAddr { ip: 127.0.0.1, broadcast: Some(127.0.0.1), netmask: Some(255.0.0.0) })) }
NetworkInterface { name: "wlp1s0", addr: Some(V4(V4IfAddr { ip: 192.168.0.16, broadcast: Some(192.168.0.255), netmask: Some(255.255.255.0) })) }
NetworkInterface { name: "wg0", addr: Some(V4(V4IfAddr { ip: 10.8.0.4, broadcast: Some(10.8.0.4), netmask: Some(255.255.255.0) })) }
NetworkInterface { name: "docker0", addr: Some(V4(V4IfAddr { ip: 172.17.0.1, broadcast: Some(172.17.255.255), netmask: Some(255.255.0.0) })) }
NetworkInterface { name: "lo", addr: Some(V6(V6IfAddr { ip: ::1, broadcast: None, netmask: Some(ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff) })) }
NetworkInterface { name: "wlp1s0", addr: Some(V6(V6IfAddr { ip: <redacted>, broadcast: None, netmask: Some(ffff:ffff:ffff:ffff::) })) }
NetworkInterface { name: "docker0", addr: Some(V6(V6IfAddr { ip: <redacted>, broadcast: None, netmask: Some(ffff:ffff:ffff:ffff::) })) }
NetworkInterface { name: "veth9d2904f", addr: Some(V6(V6IfAddr { ip: <redacted>, broadcast: None, netmask: Some(ffff:ffff:ffff:ffff::) })) }
NetworkInterface { name: "vethcdd79af", addr: Some(V6(V6IfAddr { ip: <redacted>, broadcast: None, netmask: Some(ffff:ffff:ffff:ffff::) })) }

Release

In order to create a release you must push a Git tag as follows

git tag -a <version> -m <message>

Example

git tag -a v0.1.0 -m "First release"

Tags must follow semver conventions Tags must be prefixed with a lowercase v letter.

Then push tags as follows:

git push origin main --follow-tags

Contributing

Every contribution to this project is welcome. Feel free to open a pull request, an issue or just by starting this project.

License

Distributed under the terms of both the MIT license and the Apache License (Version 2.0)

Extension points exported contracts — how you extend this code

NetworkInterfaceConfig (Interface)
(no doc)
src/lib.rs

Core symbols most depended-on inside this repo

ipv4_from_in_addr
called by 1
src/utils/unix.rs
ipv6_from_in6_addr
called by 1
src/utils/unix.rs
main
called by 0
build.rs
new_afinet
called by 0
src/interface.rs
new_afinet6
called by 0
src/interface.rs
with_mac_addr
called by 0
src/interface.rs
ip
called by 0
src/interface.rs
broadcast
called by 0
src/interface.rs

Shape

Method 13
Function 7
Class 5
Enum 2
Interface 1

Languages

Rust100%

Modules by API surface

src/interface.rs10 symbols
src/utils/ffialloc.rs5 symbols
src/utils/unix.rs4 symbols
src/utils/hex.rs3 symbols
src/error.rs2 symbols
src/test.rs1 symbols
src/lib.rs1 symbols
examples/demo.rs1 symbols
build.rs1 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add network-interface \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact