Fix bug with new dig format

This commit is contained in:
D. Scott Boggs 2025-03-29 09:39:01 -04:00
parent 6e8c5d927b
commit 965a9d0724
2 changed files with 5 additions and 2 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
/target
result-bin

View file

@ -56,7 +56,7 @@ impl DigResponse {
pub fn query(domain: impl AsRef<str>) -> anyhow::Result<Self> {
let domain = domain.as_ref();
let start = Instant::now();
let cmd = Command::new("dig")
let mut cmd = Command::new("dig")
.arg("+yaml")
.arg(domain)
.output()
@ -76,7 +76,9 @@ impl DigResponse {
String::from_utf8(if cmd.stdout.starts_with(b"-\n") {
cmd.stdout.into_iter().skip(2).collect()
} else {
cmd.stdout
let stdout = cmd.stdout.as_mut_slice();
stdout[0] = b' ';
stdout.to_vec()
})
// we skip two here --------------------------^
// because the dig output starts with "-\n" which fails to parse.