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