From fef26b7139efc38b422844b25225f9ffd4e20087 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Mon, 29 Apr 2024 18:48:11 +0200 Subject: [PATCH] dns-test: add getters & make some fields public --- packages/dns-test/src/record.rs | 20 ++++++++++++++------ packages/dns-test/src/tshark.rs | 4 ++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/packages/dns-test/src/record.rs b/packages/dns-test/src/record.rs index aaaf446..dc9d442 100644 --- a/packages/dns-test/src/record.rs +++ b/packages/dns-test/src/record.rs @@ -142,6 +142,14 @@ impl Record { } .into() } + + pub fn try_into_ds(self) -> CoreResult { + if let Self::DS(v) = self { + Ok(v) + } else { + Err(self) + } + } } impl FromStr for Record { @@ -327,12 +335,12 @@ impl fmt::Display for DNSKEY { #[derive(Clone, Debug)] pub struct DS { - zone: FQDN, - ttl: u32, - key_tag: u16, - algorithm: u8, - digest_type: u8, - digest: String, + pub zone: FQDN, + pub ttl: u32, + pub key_tag: u16, + pub algorithm: u8, + pub digest_type: u8, + pub digest: String, } impl FromStr for DS { diff --git a/packages/dns-test/src/tshark.rs b/packages/dns-test/src/tshark.rs index 8b85001..c78e190 100644 --- a/packages/dns-test/src/tshark.rs +++ b/packages/dns-test/src/tshark.rs @@ -179,6 +179,10 @@ impl Message { .ok() } + pub fn as_value(&self) -> &serde_json::Value { + &self.inner + } + fn opt_record(&self) -> Option<&serde_json::Value> { for (key, value) in self.inner.get("Additional records")?.as_object()? { if key.ends_with(": type OPT") {