test on plasma + now working

This commit is contained in:
Ferdinand Schober
2022-09-20 20:27:20 +02:00
parent 944685f6c2
commit f813261f50
6 changed files with 217 additions and 117 deletions

View File

@@ -1,4 +1,4 @@
use std::{net::IpAddr, error::Error, fmt::Display};
use std::{error::Error, fmt::Display, net::IpAddr};
use trust_dns_resolver::Resolver;
@@ -6,11 +6,10 @@ use trust_dns_resolver::Resolver;
struct InvalidConfigError;
#[derive(Debug, Clone)]
struct DnsError{
struct DnsError {
host: String,
}
impl Error for InvalidConfigError {}
impl Display for InvalidConfigError {
@@ -35,6 +34,6 @@ pub fn resolve(host: &Option<String>) -> Result<IpAddr, Box<dyn Error>> {
let response = Resolver::from_system_conf()?.lookup_ip(host)?;
match response.iter().next() {
Some(ip) => Ok(ip),
None => Err(DnsError{host: host.clone()}.into()),
None => Err(DnsError { host: host.clone() }.into()),
}
}