feat: Can now discover inventory agent and download its host definition, next up save it to db

This commit is contained in:
2025-08-30 20:01:52 -04:00
parent f9906cb419
commit e548bf619a
11 changed files with 135 additions and 41 deletions

View File

@@ -1,6 +1,6 @@
use serde::Serialize;
use serde::{Deserialize, Serialize};
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct MacAddress(pub [u8; 6]);
impl MacAddress {
@@ -25,6 +25,30 @@ impl std::fmt::Display for MacAddress {
}
}
impl TryFrom<String> for MacAddress {
type Error = std::io::Error;
fn try_from(value: String) -> Result<Self, Self::Error> {
let parts: Vec<&str> = value.split(':').collect();
if parts.len() != 6 {
return Err(std::io::Error::new(
std::io::ErrorKind::InvalidInput,
"Invalid MAC address format: expected 6 colon-separated hex pairs",
));
}
let mut bytes = [0u8; 6];
for (i, part) in parts.iter().enumerate() {
bytes[i] = u8::from_str_radix(part, 16).map_err(|_| {
std::io::Error::new(
std::io::ErrorKind::InvalidInput,
format!("Invalid hex value in part {}: '{}'", i, part),
)
})?;
}
Ok(MacAddress(bytes))
}
}
pub type IpAddress = std::net::IpAddr;
#[derive(Debug, Clone)]