From 3f01463c442be8c9e4e5ff939398c755af510fe6 Mon Sep 17 00:00:00 2001 From: joalopez1206 Date: Thu, 24 Oct 2024 12:15:28 -0300 Subject: [PATCH] chore: added fmt utf8 for NSID --- src/message/rdata/opt_rdata.rs | 2 +- tests/edns_test.rs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/message/rdata/opt_rdata.rs b/src/message/rdata/opt_rdata.rs index 1c2b0fae..0db762fc 100644 --- a/src/message/rdata/opt_rdata.rs +++ b/src/message/rdata/opt_rdata.rs @@ -104,7 +104,7 @@ impl fmt::Display for OptRdata { for (option_code, option_length, option_data) in &self.option { result.push_str(&format!("OPTION-CODE: {}\n", option_code)); result.push_str(&format!("OPTION-LENGTH: {}\n", option_length)); - result.push_str(&format!("OPTION-DATA: {:?}\n", option_data)); + result.push_str(&format!("OPTION-DATA: {:?} (\"{}\")\n", option_data, std::str::from_utf8(option_data).unwrap())); } } else { diff --git a/tests/edns_test.rs b/tests/edns_test.rs index 6d09b6cb..4000108b 100644 --- a/tests/edns_test.rs +++ b/tests/edns_test.rs @@ -72,7 +72,9 @@ async fn query_a_type_edns() { #[tokio::test] async fn query_a_type_with_rrsig_edns() { - let response = query_response_edns("example.com", "UDP", "A", Some(1024), 0, true, Some(vec![3])).await; + let response = query_response_edns("example.com", + "UDP", "A", Some(1024), 0, + true, Some(vec![3])).await; if let Ok(rrs) = response { println!("{}", rrs); @@ -91,11 +93,12 @@ async fn query_a_type_with_rrsig_edns() { panic!("No RRSIG"); } + assert_eq!(answer.get_ttl(), rrsig.get_ttl()); let opt = &rrs.get_additional()[0]; assert_eq!(opt.get_name(), DomainName::new_from_str("")); assert_eq!(opt.get_rtype(), Rrtype::OPT); assert_eq!(opt.get_rclass(), Rclass::UNKNOWN(512)); - println!("{:?}", opt); + //println!("{}", opt); } }