Commit a6bb2b8f authored by bksp's avatar bksp
Browse files

add support for srv, sshfp, txt

parent c4c6e718
......@@ -62,11 +62,25 @@ pub enum RData {
minimum: u32,
serial: u32
},
// SRV(SRV),
// SSHFP(SSHFP),
#[serde(rename_all = "PascalCase")]
SRV {
server: String,
port: u16,
priority: u16,
weight: u16,
},
#[serde(rename_all = "PascalCase")]
SSHFP {
algorithm: u8,
digest_type: u8,
fingerprint: String,
},
// SVCB(SVCB),
// TLSA(TLSA),
// TXT(TXT),
#[serde(rename_all = "PascalCase")]
TXT {
text: String
},
// TODO: Eventually allow deserialization of DNSSEC records
#[serde(skip)]
......@@ -120,11 +134,24 @@ impl From<trust_dns_types::RData> for RData {
minimum: soa.minimum(),
serial: soa.serial()
},
trust_dns_types::RData::SRV(srv) => RData::SRV {
server: srv.target().to_utf8(),
port: srv.port(),
priority: srv.priority(),
weight: srv.weight(),
},
trust_dns_types::RData::SSHFP(sshfp) => RData::SSHFP {
algorithm: sshfp.algorithm().into(),
digest_type: sshfp.fingerprint_type().into(),
fingerprint: trust_dns_types::sshfp::HEX.encode(sshfp.fingerprint()),
},
trust_dns_types::RData::TXT(txt) => RData::TXT { text: format!("{}", txt) },
trust_dns_types::RData::DNSSEC(data) => RData::DNSSEC(data),
rdata => {
let code = rdata.to_record_type().into();
let mut data = Vec::new();
let mut encoder = BinEncoder::new(&mut data);
// TODO: need better error handling (use TryFrom ?)
rdata.emit(&mut encoder).expect("could not encode data");
RData::Unknown {
......
......@@ -3,7 +3,7 @@ pub mod errors;
pub mod trust_dns_types {
pub use trust_dns_client::rr::rdata::{
NULL, caa, DNSSECRData
DNSSECRData, caa, sshfp,
};
pub use trust_dns_client::rr::{
RData, DNSClass, Record
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment