aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-net/src/lib.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/embassy-net/src/lib.rs b/embassy-net/src/lib.rs
index bda5f9e14..4ec1b5a77 100644
--- a/embassy-net/src/lib.rs
+++ b/embassy-net/src/lib.rs
@@ -236,6 +236,22 @@ impl<D: Driver + 'static> Stack<D> {
236 /// Make a query for a given name and return the corresponding IP addresses. 236 /// Make a query for a given name and return the corresponding IP addresses.
237 #[cfg(feature = "dns")] 237 #[cfg(feature = "dns")]
238 pub async fn dns_query(&self, name: &str, qtype: dns::DnsQueryType) -> Result<Vec<IpAddress, 1>, dns::Error> { 238 pub async fn dns_query(&self, name: &str, qtype: dns::DnsQueryType) -> Result<Vec<IpAddress, 1>, dns::Error> {
239 // For A and AAAA queries we try detect whether `name` is just an IP address
240 match qtype {
241 dns::DnsQueryType::A => {
242 if let Ok(ip) = name.parse().map(IpAddress::Ipv4) {
243 return Ok([ip].into_iter().collect());
244 }
245 }
246 #[cfg(feature = "proto-ipv6")]
247 dns::DnsQueryType::Aaaa => {
248 if let Ok(ip) = name.parse().map(IpAddress::Ipv6) {
249 return Ok([ip].into_iter().collect());
250 }
251 }
252 _ => {}
253 }
254
239 let query = poll_fn(|cx| { 255 let query = poll_fn(|cx| {
240 self.with_mut(|s, i| { 256 self.with_mut(|s, i| {
241 let socket = s.sockets.get_mut::<dns::Socket>(i.dns_socket); 257 let socket = s.sockets.get_mut::<dns::Socket>(i.dns_socket);