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

Small improvements for dig-compatible output. #38

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
18 changes: 12 additions & 6 deletions src/output/dig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use domain::base::opt::AllOptData;
use domain::base::ParsedRecord;
use domain::rdata::AllRecordData;
use std::io;
use std::time::Duration;

use super::error::OutputError;

Expand Down Expand Up @@ -46,7 +47,7 @@ pub fn write(
target,
"; EDNS: version {}; flags: {}; udp: {}",
opt.version(),
opt.dnssec_ok(),
if opt.dnssec_ok() { "do" } else { "" },
opt.udp_payload_size()
)?;
for option in opt.opt().iter::<AllOptData<_, _>>() {
Expand All @@ -61,9 +62,14 @@ pub fn write(
Expire(expire) => {
writeln!(target, "; EXPIRE: {}", expire)?
}
TcpKeepalive(opt) => {
writeln!(target, "; TCPKEEPALIVE: {}", opt)?
}
TcpKeepalive(opt) => writeln!(
target,
"; TCPKEEPALIVE: {} secs",
opt.timeout().map_or("".to_string(), |t| format!(
"{:.1}",
Duration::from(t).as_secs_f64()
))
)?,
Padding(padding) => {
writeln!(target, "; PADDING: {}", padding)?
}
Expand Down Expand Up @@ -95,10 +101,10 @@ pub fn write(
// Question
let questions = msg.question();
if counts.qdcount() > 0 {
write!(target, ";; QUESTION SECTION:")?;
writeln!(target, ";; QUESTION SECTION:")?;
for item in questions {
let item = item?;
writeln!(target, "; {}", item)?;
writeln!(target, ";{}", item)?;
}
}

Expand Down
Loading