toksdotdev / wifi-rs Goto Github PK
View Code? Open in Web Editor NEW📡 Easily interface and manage wireless networks.
Home Page: https://crates.io/crates/wifi-rs
📡 Easily interface and manage wireless networks.
Home Page: https://crates.io/crates/wifi-rs
Hi there!
I was looking for a multi-platform wifi crate and stumbled upon your work... sadly I am unable to build it due to the following Error:
Compiling wifi-rs v0.2.0
error[E0277]: the size for values of typestr
cannot be known at compilation time
--> X\Y\Z.cargo\registry\src\github.com-1ecc6299db9ec823\wifi-rs-0.2.0\src\connectivity\providers\windows.rs:48:18
|
48 | &format!("name={}", *self.connection.unwrap().ssid),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the traitstd::marker::Sized
is not implemented forstr
= note: to learn more, visit https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
sorry for the Inconvenience and thanks for your help! ;)
$ cargo run
Blocking waiting for file lock on package cache
Updating git repository `https://github.com/TNkemdilim/wifi-rs`
error: failed to load source for a dependency on `wifi-rs`
Caused by:
Unable to update https://github.com/TNkemdilim/wifi-rs
Caused by:
Could not find `Cargo.toml` in `C:\Users\robin\.cargo\git\checkouts\wifi-rs-f335658bb5041c43\wifi-rs`
robin@ROBIN-PC MINGW64 /f/phishing-wifi (master)
$ cargo run
--> C:\Users\robin\.cargo\registry\src\github.com-1ecc6299db9ec823\wifi-rs-0.1.0\src\lib.rs:3:5
| c\lib.rs:3:5
3 | mod handler;
| ^^^^^^^
|
= help: name the file either handler.rs or handler\mod.rs inside the directory "C:\Users\robin\.cargo\registry\src\github.com-1ecc6299db9ec823\wifi-rs-0.1.0\src" \Users\robin\.cargo\registry\src\github.com-1ecc6299db9ec823\wifi-rs-0.1.0\src"
error: aborting due to previous error
For more information about this error, try `rustc --explain E0583`.
error: could not compile `wifi-rs`.
To learn more, run the command again with --verbose.```
For example, find nearby WiFi, historical WiFi, etc
When cargo tries to build wifi-rs
, it fails with following error:
Compiling wifi-rs v0.2.1
error[E0599]: no variant or associated item named `CreationFailed` found for enum `WifiHotspotError` in the current scope
--> /home/jalon/.cargo/registry/src/github.com-1ecc6299db9ec823/wifi-rs-0.2.1/src/hotspot/providers/linux.rs:77:47
|
77 | .map_err(|_err| WifiHotspotError::CreationFailed)?;
| ^^^^^^^^^^^^^^ variant or associated item not found in `WifiHotspotError`
|
::: /home/jalon/.cargo/registry/src/github.com-1ecc6299db9ec823/wifi-rs-0.2.1/src/hotspot/mod.rs:9:1
|
9 | pub enum WifiHotspotError {
| ------------------------- variant or associated item `CreationFailed` not found here
error: aborting due to previous error
For more information about this error, try `rustc --explain E0599`.
error: could not compile `wifi-rs`
To learn more, run the command again with --verbose.
Host is Archlinux with up to date stable Rust compiler version 1.49 (instaled via rustc).
This error happens with versions 0.2.0
and 0.2.1
. Version 0.1.0
builds nicely (but unfortunately seems not to work, running the example program I get a "Invalid password" message even though SSID and password are correct).
windows : ssid is correct and password is incorrect. But output "connected"
Hello, I'm trying to create a hotspot on a Raspberry Pi 3b+ running Raspbian 11 (bullseye), the hotspot wouldn't create (returning Ok(false)
) and by outputting to console what the running command returns, we see:
https://github.com/tnkemdilim/wifi-rs/blob/3cbe13ef3b9a0f84b03b08abef1b3d6b857cbbcf/src/hotspot/providers/linux.rs#L83-L86 (referenced code)
Error: argument 'ifname' not understood. Try passing --help instead.
(output by printing)
... and I'm not sure whats going here, may this library reference an older version of nmcli
?
Hello there!
I was hoping to check the stability of this package, the application returns "Invalid password" irrespective of what I do, and this includes running the examples.
Rust version: rustc 1.77.1
OS type: macOS ( Ventura Version 13.6.4)
use wifi_rs::{prelude::*, WiFi};
fn main() -> Result<(), WifiConnectionError> {
let config = Some(Config {
interface: Some("wlo1"),
});
let mut wifi = WiFi::new(config);
match wifi.connect("snowflakes", "@opeolluwa") {
Ok(result) => println!(
"{}",
if result == true {
"Connection Successful."
} else {
"Invalid password."
}
),
Err(err) => println!("The following error occurred: {:?}", err),
}
Ok(())
}
I tried your example on creating WiFi hotspot and it wasn't able to find 'HotspotConfig', and enums 'HotspotBand' and 'Channel'.
I am using the version "0.2.2" release.
use std::io;
use wifi_rs::{prelude::*, WiFi};
fn main() -> Result<(), io::Error> {
let config = Some(Config {
interface: Some("wlo1"),
});
let mut wifi = WiFi::new(config);
let config = HotspotConfig::new(Some(HotspotBand::Bg), Some(Channel::One));
wifi.create_hotspot("test-hotspot", "password", Some(&config));
Ok(())
}
error[E0433]: failed to resolve: use of undeclared type HotspotConfig
--> src/main.rs:10:18
|
10 | let config = HotspotConfig::new(Some(HotspotBand::Bg), Some(Channel::One));
| ^^^^^^^^^^^^^ use of undeclared type HotspotConfig
error[E0433]: failed to resolve: use of undeclared type HotspotBand
--> src/main.rs:10:42
|
10 | let config = HotspotConfig::new(Some(HotspotBand::Bg), Some(Channel::One));
| ^^^^^^^^^^^ use of undeclared type HotspotBand
error[E0433]: failed to resolve: use of undeclared type Channel
--> src/main.rs:10:65
|
10 | let config = HotspotConfig::new(Some(HotspotBand::Bg), Some(Channel::One));
| ^^^^^^^ use of undeclared type Channel
error: aborting due to 3 previous errors
The network interface name was wlx9cefd5f8f9c0
but when renamed in Ubuntu to wlan0
the connection no longer failed.
Below is a code snippet:
let config = Some(Config {
interface: Some(self.net_iface.as_str()),
});
ctx.wifi_ctx = WiFi::new(config);
match ctx.wifi_ctx.connect(ssid.as_str(), psk.as_str()) {
Failed to check if the command is success when system is set to use other languages.
For example, in Linux we use this code to disconnect WiFi:
/// Attempts to disconnect from a wireless network currently connected to.
fn disconnect(&self) -> Result<bool, WifiConnectionError> {
let output = Command::new("nmcli")
.args(&["d", "disconnect", "ifname", &self.interface])
.output()
.map_err(|err| WifiConnectionError::FailedToDisconnect(format!("{}", err)))?;
Ok(String::from_utf8_lossy(&output.stdout)
.as_ref()
.contains("disconnect"))
}
But when locale is set to other language, this command's output is look like this:
成功断开设备 "wlan0"
(For LANG=zh_CN.UTF-8
)
As result, this command always returns Ok(false)
even if it did disconnect the WiFi.
I use Ubuntu's default NetworkManager, and every time I connect to WiFi using WiFi-rs, it creates and saves the same network as a new WiFi access point, leaving lots of duplicates:
$ ll /etc/NetworkManager/system-connections/
total 72
drwxr-xr-x 2 root root 4096 Oct 7 14:52 ./
drwxr-xr-x 7 root root 4096 May 15 2019 ../
-rw------- 1 root root 436 Oct 1 16:59 ATT12345H
-rw------- 1 root root 350 Oct 7 14:38 ATT12345H 12
-rw------- 1 root root 337 Oct 7 14:04 ATT12345H 2
-rw------- 1 root root 337 Oct 7 14:04 ATT12345H 3
⋮
Is it possible to have it use a preexisting saved connection? That would solve this problem along with allowing use of connections saved outside of WiFi-rs, which also have more settings than just SSID and password.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.