Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
dns-test: add getters & make some fields public
Browse files Browse the repository at this point in the history
  • Loading branch information
japaric committed May 22, 2024
1 parent 3a54e69 commit fef26b7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
20 changes: 14 additions & 6 deletions packages/dns-test/src/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ impl Record {
}
.into()
}

pub fn try_into_ds(self) -> CoreResult<DS, Self> {
if let Self::DS(v) = self {
Ok(v)
} else {
Err(self)
}
}
}

impl FromStr for Record {
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions packages/dns-test/src/tshark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down

0 comments on commit fef26b7

Please sign in to comment.