diff --git a/peach-network/src/error.rs b/peach-network/src/error.rs
index 3840b67..41d2b31 100644
--- a/peach-network/src/error.rs
+++ b/peach-network/src/error.rs
@@ -6,7 +6,7 @@ use std::num::ParseIntError;
use io::Error as IoError;
use probes::ProbeError;
use regex::Error as RegexError;
-use wpactrl::WpaError;
+use wpactrl::Error as WpaError;
/// Custom error type encapsulating all possible errors when querying
/// network interfaces and modifying their state.
diff --git a/peach-network/src/network.rs b/peach-network/src/network.rs
index 799180c..fe3dd1c 100644
--- a/peach-network/src/network.rs
+++ b/peach-network/src/network.rs
@@ -22,6 +22,7 @@ use std::{
};
use probes::network;
+use wpactrl::Client as WpaClient;
#[cfg(feature = "miniserde_support")]
use miniserde::{Deserialize, Serialize};
@@ -121,7 +122,7 @@ pub struct Traffic {
/// In the event of an error, a `NetworkError` is returned in the `Result`.
pub fn available_networks(iface: &str) -> Result>, NetworkError> {
let wpa_path: String = format!("/var/run/wpa_supplicant/{}", iface);
- let mut wpa = wpactrl::WpaCtrl::builder().ctrl_path(wpa_path).open()?;
+ let mut wpa = WpaClient::builder().ctrl_path(wpa_path).open()?;
wpa.request("SCAN")?;
let networks = wpa.request("SCAN_RESULTS")?;
let mut scan = Vec::new();
@@ -173,7 +174,7 @@ pub fn available_networks(iface: &str) -> Result >, NetworkError
/// event of an error, a `NetworkError` is returned in the `Result`.
pub fn id(iface: &str, ssid: &str) -> Result , NetworkError> {
let wpa_path: String = format!("/var/run/wpa_supplicant/{}", iface);
- let mut wpa = wpactrl::WpaCtrl::builder().ctrl_path(wpa_path).open()?;
+ let mut wpa = WpaClient::builder().ctrl_path(wpa_path).open()?;
let networks = wpa.request("LIST_NETWORKS")?;
let mut id = Vec::new();
for network in networks.lines() {
@@ -232,7 +233,7 @@ pub fn ip(iface: &str) -> Result , NetworkError> {
/// `Result`.
pub fn rssi(iface: &str) -> Result , NetworkError> {
let wpa_path: String = format!("/var/run/wpa_supplicant/{}", iface);
- let mut wpa = wpactrl::WpaCtrl::builder().ctrl_path(wpa_path).open()?;
+ let mut wpa = WpaClient::builder().ctrl_path(wpa_path).open()?;
let status = wpa.request("SIGNAL_POLL")?;
let rssi = utils::regex_finder(r"RSSI=(.*)\n", &status)?;
@@ -259,7 +260,7 @@ pub fn rssi(iface: &str) -> Result , NetworkError> {
/// the `Result`.
pub fn rssi_percent(iface: &str) -> Result , NetworkError> {
let wpa_path: String = format!("/var/run/wpa_supplicant/{}", iface);
- let mut wpa = wpactrl::WpaCtrl::builder().ctrl_path(wpa_path).open()?;
+ let mut wpa = WpaClient::builder().ctrl_path(wpa_path).open()?;
let status = wpa.request("SIGNAL_POLL")?;
let rssi = utils::regex_finder(r"RSSI=(.*)\n", &status)?;
@@ -291,7 +292,7 @@ pub fn rssi_percent(iface: &str) -> Result , NetworkError> {
/// is returned in the `Result`. In the event of an error, a `NetworkError` is
/// returned in the `Result`.
pub fn saved_networks() -> Result >, NetworkError> {
- let mut wpa = wpactrl::WpaCtrl::builder().open()?;
+ let mut wpa = WpaClient::builder().open()?;
let networks = wpa.request("LIST_NETWORKS")?;
let mut ssids = Vec::new();
for network in networks.lines() {
@@ -323,7 +324,7 @@ pub fn saved_networks() -> Result >, NetworkError> {
/// returned in the `Result`.
pub fn ssid(iface: &str) -> Result , NetworkError> {
let wpa_path: String = format!("/var/run/wpa_supplicant/{}", iface);
- let mut wpa = wpactrl::WpaCtrl::builder().ctrl_path(wpa_path).open()?;
+ let mut wpa = WpaClient::builder().ctrl_path(wpa_path).open()?;
let status = wpa.request("STATUS")?;
// pass the regex pattern and status output to the regex finder
@@ -379,7 +380,7 @@ pub fn state(iface: &str) -> Result , NetworkError> {
/// a `NetworkError` is returned in the `Result`.
pub fn status(iface: &str) -> Result , NetworkError> {
let wpa_path: String = format!("/var/run/wpa_supplicant/{}", iface);
- let mut wpa = wpactrl::WpaCtrl::builder().ctrl_path(wpa_path).open()?;
+ let mut wpa = WpaClient::builder().ctrl_path(wpa_path).open()?;
let wpa_status = wpa.request("STATUS")?;
// pass the regex pattern and status output to the regex finder
@@ -579,7 +580,7 @@ pub fn check_iface(wlan_iface: &str, ap_iface: &str) -> Result<(), NetworkError>
/// is returned in the `Result`.
pub fn connect(id: &str, iface: &str) -> Result<(), NetworkError> {
let wpa_path: String = format!("/var/run/wpa_supplicant/{}", iface);
- let mut wpa = wpactrl::WpaCtrl::builder().ctrl_path(wpa_path).open()?;
+ let mut wpa = WpaClient::builder().ctrl_path(wpa_path).open()?;
let select = format!("SELECT {}", id);
wpa.request(&select)?;
Ok(())
@@ -598,7 +599,7 @@ pub fn connect(id: &str, iface: &str) -> Result<(), NetworkError> {
/// returned in the `Result`.
pub fn delete(id: &str, iface: &str) -> Result<(), NetworkError> {
let wpa_path: String = format!("/var/run/wpa_supplicant/{}", iface);
- let mut wpa = wpactrl::WpaCtrl::builder().ctrl_path(wpa_path).open()?;
+ let mut wpa = WpaClient::builder().ctrl_path(wpa_path).open()?;
let remove = format!("REMOVE_NETWORK {}", id);
wpa.request(&remove)?;
Ok(())
@@ -617,7 +618,7 @@ pub fn delete(id: &str, iface: &str) -> Result<(), NetworkError> {
/// `Result`.
pub fn disable(id: &str, iface: &str) -> Result<(), NetworkError> {
let wpa_path: String = format!("/var/run/wpa_supplicant/{}", iface);
- let mut wpa = wpactrl::WpaCtrl::builder().ctrl_path(wpa_path).open()?;
+ let mut wpa = WpaClient::builder().ctrl_path(wpa_path).open()?;
let disable = format!("DISABLE_NETWORK {}", id);
wpa.request(&disable)?;
Ok(())
@@ -634,7 +635,7 @@ pub fn disable(id: &str, iface: &str) -> Result<(), NetworkError> {
/// error, a `NetworkError` is returned in the `Result`.
pub fn disconnect(iface: &str) -> Result<(), NetworkError> {
let wpa_path: String = format!("/var/run/wpa_supplicant/{}", iface);
- let mut wpa = wpactrl::WpaCtrl::builder().ctrl_path(wpa_path).open()?;
+ let mut wpa = WpaClient::builder().ctrl_path(wpa_path).open()?;
let disconnect = "DISCONNECT".to_string();
wpa.request(&disconnect)?;
Ok(())
@@ -685,7 +686,7 @@ pub fn forget(iface: &str, ssid: &str) -> Result<(), NetworkError> {
/// event of an error, a `NetworkError` is returned in the `Result`.
pub fn modify(id: &str, iface: &str, pass: &str) -> Result<(), NetworkError> {
let wpa_path: String = format!("/var/run/wpa_supplicant/{}", iface);
- let mut wpa = wpactrl::WpaCtrl::builder().ctrl_path(wpa_path).open()?;
+ let mut wpa = WpaClient::builder().ctrl_path(wpa_path).open()?;
let new_pass = format!("NEW_PASSWORD {} {}", id, pass);
wpa.request(&new_pass)?;
Ok(())
@@ -702,7 +703,7 @@ pub fn modify(id: &str, iface: &str, pass: &str) -> Result<(), NetworkError> {
/// error, a `NetworkError` is returned in the `Result`.
pub fn reassociate(iface: &str) -> Result<(), NetworkError> {
let wpa_path: String = format!("/var/run/wpa_supplicant/{}", iface);
- let mut wpa = wpactrl::WpaCtrl::builder().ctrl_path(wpa_path).open()?;
+ let mut wpa = WpaClient::builder().ctrl_path(wpa_path).open()?;
wpa.request("REASSOCIATE")?;
Ok(())
}
@@ -714,7 +715,7 @@ pub fn reassociate(iface: &str) -> Result<(), NetworkError> {
/// `Result` type is returned. In the event of an error, a `NetworkError` is
/// returned in the `Result`.
pub fn reconfigure() -> Result<(), NetworkError> {
- let mut wpa = wpactrl::WpaCtrl::builder().open()?;
+ let mut wpa = WpaClient::builder().open()?;
wpa.request("RECONFIGURE")?;
Ok(())
}
@@ -730,7 +731,7 @@ pub fn reconfigure() -> Result<(), NetworkError> {
/// event of an error, a `NetworkError` is returned in the `Result`.
pub fn reconnect(iface: &str) -> Result<(), NetworkError> {
let wpa_path: String = format!("/var/run/wpa_supplicant/{}", iface);
- let mut wpa = wpactrl::WpaCtrl::builder().ctrl_path(wpa_path).open()?;
+ let mut wpa = WpaClient::builder().ctrl_path(wpa_path).open()?;
wpa.request("DISCONNECT")?;
wpa.request("RECONNECT")?;
Ok(())
@@ -742,7 +743,7 @@ pub fn reconnect(iface: &str) -> Result<(), NetworkError> {
/// `wpa_supplicant.conf` file, an `Ok` `Result` type is returned. In the
/// event of an error, a `NetworkError` is returned in the `Result`.
pub fn save() -> Result<(), NetworkError> {
- let mut wpa = wpactrl::WpaCtrl::builder().open()?;
+ let mut wpa = WpaClient::builder().open()?;
wpa.request("SAVE_CONFIG")?;
Ok(())
}