4
0
Эх сурвалжийг харах

URI: Use name and comment from RFC

Benjamin Sago 4 жил өмнө
parent
commit
933201d562

+ 6 - 5
dns/src/record/uri.rs

@@ -25,7 +25,7 @@ pub struct URI {
 
     /// The URI contained in the record. Since all we are doing is displaying
     /// it to the user, we do not need to parse it for accuracy.
-    pub contents: String,
+    pub target: String,
 }
 
 impl Wire for URI {
@@ -40,6 +40,7 @@ impl Wire for URI {
         let weight = c.read_u16::<BigEndian>()?;
         trace!("Parsed weight -> {:?}", weight);
 
+        // The target must not be empty.
         if stated_length <= 4 {
             let mandated_length = MandatedLength::AtLeast(5);
             return Err(WireError::WrongRecordLength { stated_length, mandated_length });
@@ -52,10 +53,10 @@ impl Wire for URI {
             buf.push(c.read_u8()?);
         }
 
-        let contents = String::from_utf8_lossy(&buf).to_string();
-        trace!("Parsed contents -> {:?}", contents);
+        let target = String::from_utf8_lossy(&buf).to_string();
+        trace!("Parsed target -> {:?}", target);
 
-        Ok(Self { priority, weight, contents })
+        Ok(Self { priority, weight, target })
     }
 }
 
@@ -78,7 +79,7 @@ mod test {
                    URI {
                        priority: 10,
                        weight: 16,
-                       contents: String::from("https://rfcs.io/"),
+                       target: String::from("https://rfcs.io/"),
                    });
     }
 

+ 2 - 2
src/output.rs

@@ -260,7 +260,7 @@ impl TextFormat {
                 messages.join(", ")
             }
             Record::URI(ref uri) => {
-                format!("{} {} {:?}", uri.priority, uri.weight, uri.contents)
+                format!("{} {} {:?}", uri.priority, uri.weight, uri.target)
             }
             Record::Other { ref bytes, .. } => {
                 format!("{:?}", bytes)
@@ -481,7 +481,7 @@ fn json_record(record: &Record) -> JsonValue {
                 "type": "URI",
                 "priority": rec.priority,
                 "weight": rec.weight,
-                "contents": rec.contents,
+                "target": rec.target,
             })
         }
         Record::Other { type_number, bytes } => {