Emil Fresk 3 سال پیش
والد
کامیت
1efe5d50da
2فایلهای تغییر یافته به همراه14 افزوده شده و 3 حذف شده
  1. 9 3
      src/socket/dns.rs
  2. 5 0
      src/wire/dns.rs

+ 9 - 3
src/socket/dns.rs

@@ -78,12 +78,18 @@ impl<'a> DnsSocket<'a> {
         }
     }
 
-    /// Update the managed slice with servers
+    /// Update the list of DNS servers, will replace all existing servers
     pub fn update_servers(&mut self, servers: &[IpAddress]) {
-        self.servers
-            .iter_mut()
+        let mut local_servers = self.servers.iter_mut();
+        local_servers
+            .by_ref()
             .zip(servers.iter())
             .for_each(|(a, b)| *a = *b);
+
+        // Fill the rest with no address
+        for s in local_servers {
+            *s = IpAddress::Unspecified;
+        }
     }
 
     /// Return the time-to-live (IPv4) or hop limit (IPv6) value used in outgoing packets.

+ 5 - 0
src/wire/dns.rs

@@ -47,6 +47,7 @@ enum_with_unknown! {
 }
 
 bitflags! {
+    #[cfg_attr(feature = "defmt", derive(defmt::Format))]
     pub struct Flags: u16 {
         const RESPONSE            = 0b1000_0000_0000_0000;
         const AUTHORITATIVE       = 0b0000_0100_0000_0000;
@@ -284,6 +285,7 @@ fn parse_name_part<'a>(
 }
 
 #[derive(Debug, PartialEq)]
+#[cfg_attr(feature = "defmt", derive(defmt::Format))]
 pub struct Question<'a> {
     pub name: &'a [u8],
     pub type_: Type,
@@ -323,6 +325,7 @@ impl<'a> Question<'a> {
 }
 
 #[derive(Debug, PartialEq)]
+#[cfg_attr(feature = "defmt", derive(defmt::Format))]
 pub struct Record<'a> {
     pub name: &'a [u8],
     pub ttl: u32,
@@ -351,6 +354,7 @@ impl<'a> RecordData<'a> {
 }
 
 #[derive(Debug, PartialEq)]
+#[cfg_attr(feature = "defmt", derive(defmt::Format))]
 pub enum RecordData<'a> {
     #[cfg(feature = "proto-ipv4")]
     A(Ipv4Address),
@@ -396,6 +400,7 @@ impl<'a> Record<'a> {
 ///
 /// Currently only supports query packets.
 #[derive(Debug, PartialEq)]
+#[cfg_attr(feature = "defmt", derive(defmt::Format))]
 pub struct Repr<'a> {
     pub transaction_id: u16,
     pub opcode: Opcode,