-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
932 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[package] | ||
name = "orb-wpa-supplicant" | ||
version = "0.0.0" | ||
authors = ["Galileo Daras <[email protected]>", "Ryan Butler <[email protected]>"] | ||
publish = false | ||
|
||
edition.workspace = true | ||
license.workspace = true | ||
repository.workspace = true | ||
rust-version.workspace = true | ||
|
||
[dependencies] | ||
zbus.workspace = true | ||
tokio.workspace = true | ||
data-encoding.workspace = true | ||
eyre.workspace = true | ||
futures.workspace = true | ||
tracing.workspace = true | ||
ring.workspace = true | ||
serde.workspace = true | ||
|
||
[dev-dependencies] | ||
tokio-test.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# orb-wpa-supplicant | ||
|
||
Provides a replacement for wpa_cli, by using wpa supplicant's DBUS interface. | ||
|
||
This crate is currently unused, because talking to wpa_supplicant requires root. | ||
This is too risky, so once we configure polkit, we will begin using this crate. | ||
|
||
## Platform support notes | ||
|
||
This binary builds on all targets but assumes the presence of the | ||
wpa-supplicant daemon and the wlan0 network interface, so it is unlikely to run outside of the orb. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const IFACE: &str = "wlan0"; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let status = orb_wpa_supplicant::iface_status(IFACE) | ||
.await | ||
.expect("failed to get status"); | ||
println!("status: {status:?}"); | ||
let ssid = orb_wpa_supplicant::current_network_ssid(IFACE) | ||
.await | ||
.expect("failed to get ssid"); | ||
println!("ssid: {ssid:?}"); | ||
let rssi = orb_wpa_supplicant::current_network_rssi(IFACE) | ||
.await | ||
.expect("failed to get rssi"); | ||
println!("rssi: {rssi:?}"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use std::{fmt, ops::Deref}; | ||
|
||
/// WiFi network credentials. | ||
#[derive(Debug)] | ||
pub struct Credentials { | ||
/// Network SSID. | ||
pub ssid: String, | ||
/// Password. | ||
pub password: Option<Password>, | ||
/// Whether the network SSID is hidden. | ||
pub hidden: bool, | ||
pub auth_type: AuthType, | ||
} | ||
|
||
/// Authentication type. | ||
#[derive(Clone, Copy, Eq, PartialEq, Debug)] | ||
pub enum AuthType { | ||
/// WEP encryption. | ||
Wep, | ||
/// WPA encryption. | ||
Wpa, | ||
/// Pure WPA3-SAE. | ||
Sae, | ||
/// Unencrypted. | ||
Nopass, | ||
} | ||
|
||
impl Default for AuthType { | ||
fn default() -> Self { | ||
Self::Nopass | ||
} | ||
} | ||
|
||
/// Newtype on `String` to prevent printing in plaintext. | ||
#[derive(Clone, Hash, Eq, PartialEq)] | ||
pub struct Password(pub String); | ||
|
||
impl fmt::Debug for Password { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
f.write_str("***") | ||
} | ||
} | ||
|
||
impl Deref for Password { | ||
type Target = str; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.0 | ||
} | ||
} | ||
|
||
impl PartialEq<&str> for Password { | ||
fn eq(&self, other: &&str) -> bool { | ||
self.0 == *other | ||
} | ||
} |
Oops, something went wrong.