Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for CAA record type #434

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/base/charstr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,22 @@ impl<Octs: AsRef<[u8]> + ?Sized> CharStr<Octs> {
.compose(target)?;
target.append_slice(self.0.as_ref())
}

/// Appends the canonical wire format representation to an octets builder.
pub fn compose_canonical<Target: OctetsBuilder + ?Sized>(
&self,
target: &mut Target,
) -> Result<(), Target::AppendError> {
u8::try_from(self.0.as_ref().len())
.expect("long charstr")
.compose(target)?;

for ch in self.0.as_ref() {
ch.compose(target)?;
}

Ok(())
}
}

impl<Octs> CharStr<Octs> {
Expand Down
14 changes: 14 additions & 0 deletions src/base/zonefile_fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,4 +371,18 @@ mod test {
record.display_zonefile(false).to_string()
);
}

#[test]
fn caa_record() {
use crate::rdata::Caa;
let record = create_record(Caa::new(
0,
"issue".parse().unwrap(),
"ca.example.net".as_bytes().to_vec(),
));
assert_eq!(
"example.com. 3600 IN CAA 0 issue \"ca.example.net\"",
record.display_zonefile(false).to_string()
);
}
}
Loading
Loading