add deserialization support for more types
This commit is contained in:
parent
b9ca63bed1
commit
936addb624
2 changed files with 47 additions and 10 deletions
|
@ -155,6 +155,7 @@ impl From<trust_dns_types::RData> for RData {
|
||||||
digest_type: sshfp.fingerprint_type().into(),
|
digest_type: sshfp.fingerprint_type().into(),
|
||||||
fingerprint: trust_dns_types::sshfp::HEX.encode(sshfp.fingerprint()),
|
fingerprint: trust_dns_types::sshfp::HEX.encode(sshfp.fingerprint()),
|
||||||
},
|
},
|
||||||
|
//TODO: This might alter data if not utf8 compatible, probably need to be replaced
|
||||||
trust_dns_types::RData::TXT(txt) => RData::TXT { text: format!("{}", txt) },
|
trust_dns_types::RData::TXT(txt) => RData::TXT { text: format!("{}", txt) },
|
||||||
trust_dns_types::RData::DNSSEC(data) => RData::DNSSEC(data),
|
trust_dns_types::RData::DNSSEC(data) => RData::DNSSEC(data),
|
||||||
rdata => {
|
rdata => {
|
||||||
|
@ -180,6 +181,7 @@ impl TryFrom<RData> for trust_dns_types::RData {
|
||||||
Ok(match rdata {
|
Ok(match rdata {
|
||||||
RData::A { address } => trust_dns_types::RData::A(address),
|
RData::A { address } => trust_dns_types::RData::A(address),
|
||||||
RData::AAAA { address } => trust_dns_types::RData::AAAA(address),
|
RData::AAAA { address } => trust_dns_types::RData::AAAA(address),
|
||||||
|
// TODO: Round trip test all types below (currently not tested...)
|
||||||
RData::CAA { issuer_critical, value, property_tag } => {
|
RData::CAA { issuer_critical, value, property_tag } => {
|
||||||
let property = trust_dns_types::caa::Property::from(property_tag);
|
let property = trust_dns_types::caa::Property::from(property_tag);
|
||||||
let caa_value = {
|
let caa_value = {
|
||||||
|
@ -203,16 +205,51 @@ impl TryFrom<RData> for trust_dns_types::RData {
|
||||||
value: caa_value,
|
value: caa_value,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
RData::CNAME { target } => todo!(),
|
RData::CNAME { target } => trust_dns_types::RData::CNAME(target.into_inner()),
|
||||||
RData::MX { preference, mail_exchanger } => todo!(),
|
RData::MX { preference, mail_exchanger } => trust_dns_types::RData::MX(
|
||||||
RData::NULL { data } => todo!(),
|
trust_dns_types::mx::MX::new(preference, mail_exchanger.into_inner())
|
||||||
RData::NS { target } => todo!(),
|
),
|
||||||
RData::PTR { target } => todo!(),
|
RData::NULL { data } => trust_dns_types::RData::NULL(
|
||||||
RData::SOA { master_server_name, maintainer_name, refresh, retry, expire, minimum, serial } => todo!(),
|
trust_dns_types::null::NULL::with(
|
||||||
RData::SRV { server, port, priority, weight } => todo!(),
|
base64::decode(data).map_err(|e| ProtoError::from(format!("{}", e)))?
|
||||||
RData::SSHFP { algorithm, digest_type, fingerprint } => todo!(),
|
)
|
||||||
RData::TXT { text } => todo!(),
|
),
|
||||||
|
RData::NS { target } => trust_dns_types::RData::NS(target.into_inner()),
|
||||||
|
RData::PTR { target } => trust_dns_types::RData::PTR(target.into_inner()),
|
||||||
|
RData::SOA {
|
||||||
|
master_server_name,
|
||||||
|
maintainer_name,
|
||||||
|
refresh,
|
||||||
|
retry,
|
||||||
|
expire,
|
||||||
|
minimum,
|
||||||
|
serial
|
||||||
|
} => trust_dns_types::RData::SOA(
|
||||||
|
trust_dns_types::soa::SOA::new(
|
||||||
|
master_server_name.into_inner(),
|
||||||
|
maintainer_name.into_inner(),
|
||||||
|
serial,
|
||||||
|
refresh,
|
||||||
|
retry,
|
||||||
|
expire,
|
||||||
|
minimum,
|
||||||
|
)
|
||||||
|
),
|
||||||
|
RData::SRV { server, port, priority, weight } => trust_dns_types::RData::SRV(
|
||||||
|
trust_dns_types::srv::SRV::new(priority, weight, port, server.into_inner())
|
||||||
|
),
|
||||||
|
RData::SSHFP { algorithm, digest_type, fingerprint } => trust_dns_types::RData::SSHFP(
|
||||||
|
trust_dns_types::sshfp::SSHFP::new(
|
||||||
|
// NOTE: This allows unassigned algorithms
|
||||||
|
trust_dns_types::sshfp::Algorithm::from(algorithm),
|
||||||
|
trust_dns_types::sshfp::FingerprintType::from(digest_type),
|
||||||
|
trust_dns_types::sshfp::HEX.decode(fingerprint.as_bytes()).map_err(|e| ProtoError::from(format!("{}", e)))?
|
||||||
|
)
|
||||||
|
),
|
||||||
|
RData::TXT { text } => trust_dns_types::RData::TXT(trust_dns_types::txt::TXT::new(vec![text])),
|
||||||
|
// TODO: Error out for DNSSEC? Prefer downstream checks?
|
||||||
RData::DNSSEC(_) => todo!(),
|
RData::DNSSEC(_) => todo!(),
|
||||||
|
// TODO: Disallow unknown? (could be used to bypass unsopported types?) Prefer downstream checks?
|
||||||
RData::Unknown { code, data } => todo!(),
|
RData::Unknown { code, data } => todo!(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ pub mod users;
|
||||||
|
|
||||||
pub mod trust_dns_types {
|
pub mod trust_dns_types {
|
||||||
pub use trust_dns_client::rr::rdata::{
|
pub use trust_dns_client::rr::rdata::{
|
||||||
DNSSECRData, caa, sshfp,
|
DNSSECRData, caa, sshfp, mx, null, soa, srv, txt
|
||||||
};
|
};
|
||||||
pub use trust_dns_client::rr::{
|
pub use trust_dns_client::rr::{
|
||||||
RData, DNSClass, Record
|
RData, DNSClass, Record
|
||||||
|
|
Loading…
Reference in a new issue