returns error if dns resolved empty

This commit is contained in:
zonyitoo
2020-12-23 01:45:00 +08:00
parent 1288c2ed7c
commit 1af4206d65
2 changed files with 6 additions and 11 deletions
+1 -11
View File
@@ -1184,17 +1184,7 @@ impl Config {
}
#[cfg(feature = "local-dns")]
if self.local_protocol == ProtocolType::Dns {
if self.dns_bind_addr.is_none() || self.local_dns_addr.is_none() || self.remote_dns_addr.is_none() {
let err = Error::new(
ErrorKind::MissingField,
"missing `dns_bind_addr`, `local_dns_addr` or `remote_dns_addr` in configuration",
None,
);
return Err(err);
}
} else if self.dns_bind_addr.is_some() {
// Run a DNS server in the same process
if self.local_protocol == ProtocolType::Dns || self.dns_bind_addr.is_some() {
if self.local_dns_addr.is_none() || self.remote_dns_addr.is_none() {
let err = Error::new(
ErrorKind::MissingField,
@@ -210,6 +210,11 @@ impl DnsResolve for DnsResolver {
}
}
if vaddr.is_empty() {
let err = io::Error::new(ErrorKind::InvalidData, "resolve empty");
return Err(err);
}
Ok(vaddr)
}
}