major refactor

every instance of lan-mouse can now simultaneously send and receive
events
This commit is contained in:
Ferdinand Schober
2023-01-30 19:15:58 +01:00
parent 5c60e2eb58
commit 5222f54eee
15 changed files with 923 additions and 528 deletions

View File

@@ -10,14 +10,6 @@ struct DnsError {
host: String,
}
impl Error for InvalidConfigError {}
impl Display for InvalidConfigError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "No hostname specified!")
}
}
impl Error for DnsError {}
impl Display for DnsError {
@@ -26,11 +18,7 @@ impl Display for DnsError {
}
}
pub fn resolve(host: &Option<String>) -> Result<IpAddr, Box<dyn Error>> {
let host = match host {
Some(host) => host,
None => return Err(InvalidConfigError.into()),
};
pub fn resolve(host: &String) -> Result<IpAddr, Box<dyn Error>> {
let response = Resolver::from_system_conf()?.lookup_ip(host)?;
match response.iter().next() {
Some(ip) => Ok(ip),