Skip to content

Commit

Permalink
fix: tell user if no zone found
Browse files Browse the repository at this point in the history
If the target record is not found, show the default record (SOA).
Otherwise, it's no zone.
  • Loading branch information
azzamsa committed Apr 16, 2021
1 parent 1d5a154 commit 4e5cd51
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Unreleased changes. Release notes have not yet been written.

- tell user if no zone found

# 0.1.5 (2021-04-08)

This release include fixes for creates.io workflow.
Expand Down
21 changes: 14 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,20 @@ fn run() -> Result<()> {
);
};

for res in res.answers() {
let rr_type = res.rr_type().to_string();
print_output(rr_type, res.name().to_string(), res.rdata().to_string());
}
for res in res.name_servers() {
let rr_type = res.rr_type().to_string();
print_output(rr_type, res.name().to_string(), res.rdata().to_string());
if !res.answers().is_empty() {
for res in res.answers() {
let rr_type = res.rr_type().to_string();
print_output(rr_type, res.name().to_string(), res.rdata().to_string());
}
} else if res.answers().is_empty() && !res.name_servers().is_empty() {
// if answers is empty, print default record (SOA)
for res in res.name_servers() {
let rr_type = res.rr_type().to_string();
print_output(rr_type, res.name().to_string(), res.rdata().to_string());
}
} else {
// if default doesn't exist
println!("{}", " No zone found".to_string().red());
}
}
}
Expand Down

0 comments on commit 4e5cd51

Please sign in to comment.