major update:
- remove threading overhead by resorting to an event driven design with mio as a backend for epoll
- Clients can now have an arbitrary amount of ip adresses and lan-mouse will automatically choose the correct one
- -> seemless switching between ethernet and wifi
- cli frontend + frontend adapter for future frontends
This commit is contained in:
Ferdinand Schober
2023-09-19 19:12:47 +02:00
committed by GitHub
parent 22e6c531af
commit 1a4d0e05be
24 changed files with 2453 additions and 965 deletions

View File

@@ -1,27 +1,9 @@
use std::{error::Error, fmt::Display, net::IpAddr};
use std::{error::Error, net::IpAddr};
use trust_dns_resolver::Resolver;
#[derive(Debug, Clone)]
struct InvalidConfigError;
#[derive(Debug, Clone)]
struct DnsError {
host: String,
}
impl Error for DnsError {}
impl Display for DnsError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "couldn't resolve host \"{}\"", self.host)
}
}
pub fn resolve(host: &String) -> Result<IpAddr, Box<dyn Error>> {
pub fn resolve(host: &str) -> Result<Vec<IpAddr>, Box<dyn Error>> {
log::info!("resolving {host} ...");
let response = Resolver::from_system_conf()?.lookup_ip(host)?;
match response.iter().next() {
Some(ip) => Ok(ip),
None => Err(DnsError { host: host.clone() }.into()),
}
Ok(response.iter().collect())
}