#wifi #network #wireless

bin+lib wifi-rs

Interface with and manage Wireless Network (WiFi)

4 releases

Uses old Rust 2015

0.2.2 Jan 19, 2021
0.2.1 Nov 29, 2020
0.2.0 Dec 12, 2019
0.1.0 Nov 11, 2018

#2601 in Network programming

Download history 27/week @ 2023-02-11 30/week @ 2023-02-18 14/week @ 2023-02-25 24/week @ 2023-03-04 14/week @ 2023-03-11 20/week @ 2023-03-18 18/week @ 2023-03-25 18/week @ 2023-04-01 17/week @ 2023-04-08 15/week @ 2023-04-15 6/week @ 2023-04-22 27/week @ 2023-04-29 30/week @ 2023-05-06 17/week @ 2023-05-13 33/week @ 2023-05-20 23/week @ 2023-05-27

109 downloads per month
Used in ifwifi

MIT license

30KB
669 lines

WiFi-rs

A rust crate to interface and manage Wi-Fi networks.

This is a command-line counterpart of managing networks instead of via a GUI.

Features

  • Connect to a WiFi (Windows, Linux, MacOS).
  • Disconnect from a WiFi network (Windows, Linux, MacOS).
  • Create hotspot (Windows, Linux).

Currently supported network types

Note that only open, WEP and WPA-PSK networks are supported at the moment.

It is also supposed that IP configuration is obtained via DHCP.

Supported Operating Systems

  • Windows
  • Linux
  • MacOS

Example

extern crate wifi_rs;
use wifi_rs::prelude::*;
use wifi_rs::{WiFi, Config};

fn main() -> Result<(), WifiConnectionError> {
    let config = Some(Config {
        interface: Some("wlo1"),
    });

    let mut wifi = WiFi::new(config);

    match wifi.connect("AndroidAPSD22", "belm4235") {
        Ok(result) => println!(
            "{}",
            if result == true {
                "Connection Successfull."
            } else {
                "Invalid password."
            }
        ),
        Err(err) => println!("The following error occurred: {:?}", err),
    }

    Ok(())
}

Todos

Windows

  • Support for Windows.
  • Bundle windows profile sample as literals.
  • Add hotspot functionality.
  • Use tempfile crate on windows to generate windows profile temporary file.
  • Fix the implementation for is_wifi_enabled for windows.
  • Add implementation for WifiInterface trait.
  • Add get network type feature.

Linux

  • Support for linux.
  • Add disconnect feature.
  • Add hotspot functionality.
  • Add get network type feature.

MacOS

  • Add support for MacOS.
  • Add hotspot functionality.
  • Add get network type feature.

General

  • Return detailed error messages.
  • Write documentation.
  • Update wifi-CLI with recent updates.

Contribution

Any feature you feel is missing, why not send in a Pull Request, and let's help make this project better. Or are there any bugs, kindly create an issue, so we could work together towards fixing it.

Support

Love this project, please show some love by staring the project 😃.

Dependencies

~0–5MB
~87K SLoC