add support for srv, sshfp, txt
This commit is contained in:
parent
c4c6e7185b
commit
a6bb2b8f55
2 changed files with 31 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue