From 2120fffa5771b6da0e70ac0d29911efef3d44006 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Fri, 6 Jan 2023 17:11:08 -0500 Subject: [PATCH] feat: add wifi security --- networkmanager/Cargo.toml | 7 ++-- networkmanager/src/settings/connection.rs | 39 +++++++++++++++++++++++ 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/networkmanager/Cargo.toml b/networkmanager/Cargo.toml index c3f480d..f513368 100644 --- a/networkmanager/Cargo.toml +++ b/networkmanager/Cargo.toml @@ -9,8 +9,5 @@ bitflags = "1.3" derive_builder = "0.12" procfs = { version = "0.14", default-features = false } time = "0.3" -zvariant = "3.1.2" - -[dependencies.zbus] -git = "https://gitlab.freedesktop.org/dbus/zbus" -branch = "main" +zvariant = "3.10" +zbus = "3.7" \ No newline at end of file diff --git a/networkmanager/src/settings/connection.rs b/networkmanager/src/settings/connection.rs index e43005e..10291a1 100644 --- a/networkmanager/src/settings/connection.rs +++ b/networkmanager/src/settings/connection.rs @@ -263,3 +263,42 @@ derive_value_build!( (pac_script("pac-script"): String), (pac_url("pac-url"): String) ); + +#[derive(Debug, Default, Builder, Clone)] +pub struct Secrets { + #[builder(setter(strip_option))] + pub wifi: Option, +} + +impl Secrets { + pub async fn new(connection: &Connection<'_>) -> Self { + Self { + wifi: connection + .get_secrets("802-11-wireless-security") + .await + .ok() + .and_then(|mut s| s.remove("802-11-wireless-security").map(WifiSecurity::new)), + } + } +} + +derive_value_build!( + WifiSecurity, + (psk("psk"): String), + (key_mgmt("key-mgmt"): String), + (auth_alg("auth-alg"): String), + (leap_password("leap-password"): String), + (leap_password_flags("leap-password-flags"): u32), + (leap_username("leap-username"): String), + (pairwise("pairwise"): Vec), + (pmf("pmf"): u32), + (psk_flags("psk-flags"): u32), + (wep_key_flags("wep-key-flags"): u32), + (wep_key_type("wep-key-type"): u32), + (wep_key0("wep-key0"): String), + (wep_key1("wep-key1"): String), + (wep_key2("wep-key2"): String), + (wep_key3("wep-key3"): String), + (wep_tx_keyidx("wep-tx-keyidx"): u32), + (wps_method("wps-method"): u32) +);