lets GOOOOOOOO
This commit is contained in:
@@ -6,7 +6,8 @@ mod observations;
|
||||
|
||||
pub use leases::{
|
||||
enrich_leases_with_nud_state, parse_dhcp_lease_line, read_dhcp_leases,
|
||||
read_dhcp_leases_from_path, read_dhcp_leases_with_names, read_dhcp_leases_with_names_from_paths,
|
||||
read_dhcp_leases_from_path, read_dhcp_leases_with_names,
|
||||
read_dhcp_leases_with_names_from_paths,
|
||||
};
|
||||
pub use observations::{
|
||||
LocalDeviceObservation, LocalObservationStore, ObservedDhcpClient, ObservedNeighbor,
|
||||
@@ -22,7 +23,6 @@ const DHCP_LEASES_ENV: &str = "WAKEY_DHCP_LEASES";
|
||||
const MAC_NAME_CACHE_ENV: &str = "WAKEY_MAC_NAME_CACHE";
|
||||
const OBSERVATION_STORE_ENV: &str = "WAKEY_OBSERVATION_STORE";
|
||||
|
||||
|
||||
pub(crate) fn now_unix() -> u64 {
|
||||
SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
|
||||
@@ -99,19 +99,19 @@ async fn save_observation_store(store: &LocalObservationStore) -> io::Result<()>
|
||||
|
||||
pub async fn list_local_observations() -> io::Result<Vec<LocalDeviceObservation>> {
|
||||
let store = load_observation_store().await?;
|
||||
list_local_observations_from_store(store)
|
||||
Ok(list_local_observations_from_store(store))
|
||||
}
|
||||
|
||||
pub async fn list_local_observations_from_path(
|
||||
path: impl AsRef<std::path::Path>,
|
||||
) -> io::Result<Vec<LocalDeviceObservation>> {
|
||||
let store = load_observation_store_from_path(path).await?;
|
||||
list_local_observations_from_store(store)
|
||||
Ok(list_local_observations_from_store(store))
|
||||
}
|
||||
|
||||
fn list_local_observations_from_store(
|
||||
store: LocalObservationStore,
|
||||
) -> io::Result<Vec<LocalDeviceObservation>> {
|
||||
) -> Vec<LocalDeviceObservation> {
|
||||
let mut out = Vec::with_capacity(store.dhcp_clients.len() + store.neighbors.len());
|
||||
out.extend(
|
||||
store
|
||||
@@ -148,7 +148,7 @@ fn list_local_observations_from_store(
|
||||
.then(a.mac.cmp(&b.mac))
|
||||
.then(a.ip.cmp(&b.ip))
|
||||
});
|
||||
Ok(out)
|
||||
out
|
||||
}
|
||||
|
||||
/// Observe a DHCP hotplug event and update the local MAC-to-name cache.
|
||||
|
||||
Reference in New Issue
Block a user