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

Update to match changes in Zonefilefmt in latest domain. #48

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions src/commands/key2ds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use lexopt::Arg;

use crate::env::Env;
use crate::error::Error;
use crate::Args;
use crate::{Args, DISPLAY_KIND};

use super::{Command, LdnsCommand};

Expand Down Expand Up @@ -184,7 +184,7 @@ impl Key2ds {
let rr = Record::new(owner, class, ttl, ds);

if self.write_to_stdout {
writeln!(env.stdout(), "{}", rr.display_zonefile(false));
writeln!(env.stdout(), "{}", rr.display_zonefile(DISPLAY_KIND));
} else {
let owner = owner.fmt_with_dot();
let sec_alg = sec_alg.to_int();
Expand Down Expand Up @@ -214,7 +214,7 @@ impl Key2ds {
let mut out_file =
res.map_err(|e| format!("Could not create file \"{filename}\": {e}"))?;

writeln!(out_file, "{}", rr.display_zonefile(false))
writeln!(out_file, "{}", rr.display_zonefile(DISPLAY_KIND))
.map_err(|e| format!("Could not write to file \"{filename}\": {e}"))?;

writeln!(env.stdout(), "{keyname}");
Expand Down Expand Up @@ -440,7 +440,7 @@ mod test {
assert_eq!(res.stderr, "");

let out = std::fs::read_to_string(dir.path().join("Kexample.test.+015+60136.ds")).unwrap();
assert_eq!(out, "example.test. 3600 IN DS 60136 15 2 52BD3BF40C8220BF1A3E2A3751C423BC4B69BCD7F328D38C4CD021A85DE65AD4\n");
assert_eq!(out, "example.test.\t3600\tIN\tDS 60136 15 2 52BD3BF40C8220BF1A3E2A3751C423BC4B69BCD7F328D38C4CD021A85DE65AD4\n");
}

#[test]
Expand All @@ -454,10 +454,10 @@ mod test {
assert_eq!(res.stderr, "");

let out = std::fs::read_to_string(dir.path().join("Kone.test.+015+38429.ds")).unwrap();
assert_eq!(out, "one.test. 3600 IN DS 38429 15 2 B85F7D27C48A7B84D633C7A41C3022EA0F7FC80896227B61AE7BFC59BF5F0256\n");
assert_eq!(out, "one.test.\t3600\tIN\tDS 38429 15 2 B85F7D27C48A7B84D633C7A41C3022EA0F7FC80896227B61AE7BFC59BF5F0256\n");

let out = std::fs::read_to_string(dir.path().join("Ktwo.test.+015+00425.ds")).unwrap();
assert_eq!(out, "two.test. 3600 IN DS 425 15 2 AA2030287A7C5C56CB3C0E9C64BE55616729C0C78DE2B83613D03B10C0F1EA93\n");
assert_eq!(out, "two.test.\t3600\tIN\tDS 425 15 2 AA2030287A7C5C56CB3C0E9C64BE55616729C0C78DE2B83613D03B10C0F1EA93\n");
}

#[test]
Expand All @@ -471,7 +471,7 @@ mod test {
assert_eq!(res.exit_code, 0);
assert_eq!(
res.stdout,
"example.test. 3600 IN DS 60136 15 2 52BD3BF40C8220BF1A3E2A3751C423BC4B69BCD7F328D38C4CD021A85DE65AD4\n"
"example.test.\t3600\tIN\tDS 60136 15 2 52BD3BF40C8220BF1A3E2A3751C423BC4B69BCD7F328D38C4CD021A85DE65AD4\n"
);
assert_eq!(res.stderr, "");
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/keygen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use lexopt::Arg;
use crate::env::Env;
use crate::error::{Context, Error};
use crate::parse::parse_name;
use crate::{util, Args};
use crate::{util, Args, DISPLAY_KIND};

use super::{parse_os, parse_os_with, Command, LdnsCommand};

Expand Down Expand Up @@ -342,7 +342,7 @@ impl Keygen {
format!(
"{} IN DS {}\n",
self.name.fmt_with_dot(),
digest.display_zonefile(false)
digest.display_zonefile(DISPLAY_KIND)
)
});

Expand Down
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use commands::LdnsCommand;
use env::Env;
use error::Error;

use domain::base::zonefile_fmt::DisplayKind;

pub use self::args::Args;

pub mod args;
Expand All @@ -20,6 +22,10 @@ pub mod error;
pub mod parse;
pub mod util;

/// Define the way that we output zonefile records once for consistent use
/// everywhere.
pub const DISPLAY_KIND: DisplayKind = DisplayKind::Tabbed;

pub fn try_ldns_compatibility<I: IntoIterator<Item = OsString>>(
args: I,
) -> Result<Option<Args>, Error> {
Expand Down
Loading