mirror of
https://github.com/zaphar/durnitisp.git
synced 2025-07-22 18:19:48 -04:00
Allow ip addresses in the pingHosts list
This commit is contained in:
parent
b2b6d5f8ed
commit
278ef8da04
@ -32,10 +32,17 @@ pub fn resolve_hosts<'a>(servers: &'a Vec<&str>) -> io::Result<Vec<Option<IpAddr
|
|||||||
config.use_inet6 = ALLOWIPV6.flag;
|
config.use_inet6 = ALLOWIPV6.flag;
|
||||||
let resolver = DnsResolver::new(config)?;
|
let resolver = DnsResolver::new(config)?;
|
||||||
for name in servers.iter().cloned() {
|
for name in servers.iter().cloned() {
|
||||||
|
match name.parse::<IpAddr>() {
|
||||||
|
Ok(ip) => {
|
||||||
|
results.push(Some(ip));
|
||||||
|
}
|
||||||
|
Err(_) => {
|
||||||
// TODO for resolution errors return a more valid error with the domain name.
|
// TODO for resolution errors return a more valid error with the domain name.
|
||||||
let mut iter = resolver.resolve_host(name)?;
|
let mut iter = resolver.resolve_host(name)?;
|
||||||
results.push(iter.next());
|
results.push(iter.next());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return Ok(results);
|
return Ok(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user