From 98fba67c52c0a33c17c0b1beeb5c1fecd86c1f57 Mon Sep 17 00:00:00 2001 From: Ximon Eighteen <3304436+ximon18@users.noreply.github.com> Date: Mon, 16 Dec 2024 09:35:09 +0100 Subject: [PATCH] Minor improvements in compatibility of generated zonefile comment format with the original ldns-signzone. --- src/commands/signzone.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/commands/signzone.rs b/src/commands/signzone.rs index 97268e1..53da723 100644 --- a/src/commands/signzone.rs +++ b/src/commands/signzone.rs @@ -1659,12 +1659,15 @@ impl<'b, O: AsRef<[u8]>> Commented> for Nsec3 { record: &'a Record, ZoneRecordData>>, state: Nsec3CommentState<'b>, ) -> Result<(), fmt::Error> { - if let Some(hashes) = state.hashes { // TODO: For ldns-signzone backward compatibilty we output // " ;{... .}" but I find the spacing ugly and // would prefer for dnst to output " ; {... . }" // instead. - writer.write_str(" ;{ flags: ")?; + + // For an existing NSEC3 chain that we didn't generate ourselves but + // left intact, still output flags info, but not the from/to owner as + // we didn't generate the hash mappings. + writer.write_str(" ;{ flags: ")?; if self.opt_out() { writer.write_str("optout")?; @@ -1672,6 +1675,7 @@ impl<'b, O: AsRef<[u8]>> Commented> for Nsec3 { writer.write_str("-")?; } + if let Some(hashes) = state.hashes { let next_owner_hash_hex = format!("{}", self.next_owner()); let next_owner_name = next_owner_hash_to_name(&next_owner_hash_hex, state.apex); @@ -1689,9 +1693,10 @@ impl<'b, O: AsRef<[u8]>> Commented> for Nsec3 { format!("") }; - writer.write_fmt(format_args!(", from: {from} to: {to}}}"))?; + writer.write_fmt(format_args!(", from: {from} to: {to}"))?; } - Ok(()) + + writer.write_char('}') } }