Get default network information

default-net examples or doc

default-net

default-net provides a cross-platform API for network interface and gateway.

Supported platform

  • Linux
  • macOS(OS X)
  • Windows

Usage

Add default-net to your dependencies

[dependencies]
default-net = "0.2.0"

Example

use default_net;

fn main(){
    if let Some(default_interface) = default_net::get_default_interface(){
        println!("Index {}", default_interface.index);
        println!("Name {}", default_interface.name);
        println!("MAC {:?}", default_interface.mac);
        println!("IPv4 {:?}", default_interface.ipv4);
        println!("IPv6 {:?}", default_interface.ipv6);
        println!("Gateway IP {:?}", default_interface.gateway.ip);
        println!("Gateway MAC {:?}", default_interface.gateway.mac);
    }else{
        println!("Failed to get default interface info");
    }
}

For more details, see examples or doc.

Issues

Collection of the latest Issues

RickSKy

RickSKy

enhancement
0

Maybe it is nice to check the interface configured dhcp client or not for all platform

Versions

Find the latest versions by id

v0.11.0 - May 05, 2022

Change

Interface TX/RX speed

  • Add transmit_speed and receive_speed to Interface struct

v0.10.0 - May 03, 2022

Change

  • Update Rust edition to 2021
  • Add friendly_name field to Interface struct
  • [Windows] Change iphlpapi function from GetAdaptersInfo to GetAdaptersAddresses
    • Get friendly_name of interfaces
    • IPv6 support

v0.9.0 - Mar 28, 2022

  • Add InterfaceType enum
  • Add if_type and flags fields to Interface struct

v0.8.2 - Mar 22, 2022

Bug fix for Windows network interface enumeration.

  • Add interface types that were skipped during enumeration (e.g. IF_TYPE_IEEE80211)

v0.8.1 - Feb 12, 2022

  • Bug fix for Windows
    • Add adapter type filter

v0.8.0 - Jan 29, 2022

v0.7.0 - Jan 16, 2022

  • Refactoring for Unix-Like OS
  • Remove libpnet from dependencies(to minimize dependencies)

The dependencies of v0.7.0 are as follows

  • Unix-Like OS
    • libc ^0.2
  • Windows
    • windows ^0.29.0

v0.6.0 - Jan 09, 2022

  • Remove libpnet from Windows build dependencies and changed to windows-rs only.

v0.5.0 - Nov 13, 2021

  • Reduce the time to get the IP address and MAC address of the default gateway
  • Reduce memory usage
  • Improve error handling
  • Add MacAddr struct for convenience

Information - Updated May 25, 2022

Stars: 13
Forks: 0
Issues: 3

This is an example of a Rust server that functions as a remote schema for...

Rust + Hasura Rust server that functions as a Hasura

This is an example of a Rust server that functions as a remote schema for...

Newport Engine is a modular 2D and 3D game engine built in Rust for Rust

It is designed to be easily extendable and easy to use

Newport Engine is a modular 2D and 3D game engine built in Rust for Rust

Newport Engine is a modular 2D and 3D game engine built in Rust for Rust

It is designed to be easily extendable and easy to use

Newport Engine is a modular 2D and 3D game engine built in Rust for Rust

liboqs-rust: Rust bindings for liboqs

Qyantum Safe liboqs rust bindings

liboqs-rust: Rust bindings for liboqs

msgflo-rust: Rust participant support for MsgFlo

Flowhub visual programming IDE

msgflo-rust: Rust participant support for MsgFlo

Trojan-rust is a rust implementation for Trojan protocol that is targeted to circumvent GFW

Trojan protocol that is targeted to circumvent tokio-rs to achieve high performance async io

Trojan-rust is a rust implementation for Trojan protocol that is targeted to circumvent GFW
Actix

1.0K

How to be a full stack Rust Developer

Read Rust the Rust blog posts at Steadylearner

How to be a full stack Rust Developer

Rust library translation (rust-src/rust-std/stdlib/rustlib translation)

This is the place to translate Having a documentation in your native language is essential if you don't speak English, and still enjoyable even if...

Rust library translation (rust-src/rust-std/stdlib/rustlib translation)

False Positive for rust-lang/rust#83583

The deprecation lint proc_macro_derive_resolution_fallback is intended to catch proc macro generated code that refers to items from parent modules that should not be in scope:

False Positive for rust-lang/rust#83583

A CHIP-8 & SuperChip interpreter written in Rust using rust-sdl2

If you're getting compile errors it may be because

A CHIP-8 & SuperChip interpreter written in Rust using rust-sdl2

Rust-Svelte-on-Rust

Starter template for Rocket backend server

Rust-Svelte-on-Rust
Facebook Instagram Twitter GitHub Dribbble
Privacy