Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): Bump trust-dns-proto from 0.22.0 to 0.23.0 #18349

Merged
merged 5 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ tokio-postgres = { version = "0.7.9", default-features = false, features = ["run
tokio-tungstenite = {version = "0.20.0", default-features = false, features = ["connect"], optional = true}
toml = { version = "0.7.6", default-features = false, features = ["parse", "display"] }
tonic = { version = "0.9", optional = true, default-features = false, features = ["transport", "codegen", "prost", "tls", "tls-roots", "gzip"] }
trust-dns-proto = { version = "0.22.0", default-features = false, features = ["dnssec"], optional = true }
trust-dns-proto = { version = "0.23.0", default-features = false, features = ["dnssec"], optional = true }
typetag = { version = "0.2.13", default-features = false }
url = { version = "2.4.0", default-features = false, features = ["serde"] }
uuid = { version = "1", default-features = false, features = ["serde", "v4"] }
Expand Down
1 change: 1 addition & 0 deletions LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ tracing-subscriber,https://github.com/tokio-rs/tracing,MIT,"Eliza Weisman <eliza
tracing-tower,https://github.com/tokio-rs/tracing,MIT,Eliza Weisman <[email protected]>
treediff,https://github.com/Byron/treediff-rs,MIT OR Apache-2.0,Sebastian Thiel <[email protected]>
trust-dns-proto,https://github.com/bluejekyll/trust-dns,MIT OR Apache-2.0,Benjamin Fry <[email protected]>
trust-dns-proto,https://github.com/bluejekyll/trust-dns,MIT OR Apache-2.0,The contributors to Trust-DNS
trust-dns-resolver,https://github.com/bluejekyll/trust-dns,MIT OR Apache-2.0,Benjamin Fry <[email protected]>
try-lock,https://github.com/seanmonstar/try-lock,MIT,Sean McArthur <[email protected]>
tungstenite,https://github.com/snapview/tungstenite-rs,MIT OR Apache-2.0,"Alexey Galakhov, Daniel Abramov"
Expand Down
2 changes: 1 addition & 1 deletion lib/dnsmsg-parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license = "MIT"
[dependencies]
data-encoding = "2.4"
thiserror = "1.0"
trust-dns-proto = { version = "0.22", features = ["dnssec"] }
trust-dns-proto = { version = "0.23", features = ["dnssec"] }

[dev-dependencies]
criterion = "0.5"
Expand Down
8 changes: 2 additions & 6 deletions lib/dnsmsg-parser/benches/benches.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use criterion::{criterion_group, criterion_main, BatchSize, Criterion, Throughput};
use data_encoding::BASE64;
use dnsmsg_parser::dns_message_parser::DnsMessageParser;
use trust_dns_proto::{
rr::rdata::null,
serialize::binary::{BinDecoder, Restrict},
};
use trust_dns_proto::rr::rdata::NULL;

fn benchmark_parse_as_query_message(c: &mut Criterion) {
let raw_dns_message = "szgAAAABAAAAAAAAAmg1B2V4YW1wbGUDY29tAAAGAAE=";
Expand Down Expand Up @@ -64,8 +61,7 @@ fn benchmark_parse_apl_rdata(c: &mut Criterion) {
fn benchmark_parse_rdata(c: &mut Criterion, data: &str, code: u16, id: &str) {
let raw_rdata = BASE64.decode(data.as_bytes()).unwrap();

let mut decoder = BinDecoder::new(&raw_rdata);
let record_rdata = null::read(&mut decoder, Restrict::new(raw_rdata.len() as u16)).unwrap();
let record_rdata = NULL::with(raw_rdata.clone());

let mut group = c.benchmark_group("dnstap");
group.throughput(Throughput::Bytes(raw_rdata.len() as u64));
Expand Down
75 changes: 36 additions & 39 deletions lib/dnsmsg-parser/src/dns_message_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ use trust_dns_proto::{
rr::{
dnssec::{rdata::DNSSECRData, Algorithm, SupportedAlgorithms},
rdata::{
a, aaaa,
caa::Value,
opt::{EdnsCode, EdnsOption},
NULL,
A, AAAA, NULL,
},
record_data::RData,
resource::Record,
Expand Down Expand Up @@ -69,7 +68,7 @@ impl DnsMessageParser {
let msg = TrustDnsMessage::from_vec(&self.raw_message)
.map_err(|source| DnsMessageParserError::TrustDnsError { source })?;
let header = parse_dns_query_message_header(&msg);
let edns_section = parse_edns(&msg);
let edns_section = parse_edns(&msg).transpose()?;
let rcode_high = edns_section.as_ref().map_or(0, |edns| edns.extended_rcode);
let response_code = (u16::from(rcode_high) << 4) | ((u16::from(header.rcode)) & 0x000F);

Expand Down Expand Up @@ -822,29 +821,32 @@ fn parse_dns_update_message_header(dns_message: &TrustDnsMessage) -> UpdateHeade
}
}

fn parse_edns(dns_message: &TrustDnsMessage) -> Option<OptPseudoSection> {
dns_message
.extensions()
.as_ref()
.map(|edns| OptPseudoSection {
fn parse_edns(dns_message: &TrustDnsMessage) -> Option<DnsParserResult<OptPseudoSection>> {
dns_message.extensions().as_ref().map(|edns| {
parse_edns_options(edns).map(|options| OptPseudoSection {
extended_rcode: edns.rcode_high(),
version: edns.version(),
dnssec_ok: edns.dnssec_ok(),
udp_max_payload_size: edns.max_payload(),
options: parse_edns_options(edns),
options,
})
})
}

fn parse_edns_options(edns: &Edns) -> Vec<EdnsOptionEntry> {
fn parse_edns_options(edns: &Edns) -> DnsParserResult<Vec<EdnsOptionEntry>> {
edns.options()
.as_ref()
.iter()
.map(|(code, option)| match option {
EdnsOption::DAU(algorithms)
| EdnsOption::DHU(algorithms)
| EdnsOption::N3U(algorithms) => parse_edns_opt_dnssec_algorithms(*code, *algorithms),
EdnsOption::Unknown(_, opt_data) => parse_edns_opt(*code, opt_data),
option => parse_edns_opt(*code, &Vec::<u8>::from(option)),
| EdnsOption::N3U(algorithms) => {
Ok(parse_edns_opt_dnssec_algorithms(*code, *algorithms))
}
EdnsOption::Unknown(_, opt_data) => Ok(parse_edns_opt(*code, opt_data)),
option => Vec::<u8>::try_from(option)
.map(|bytes| parse_edns_opt(*code, &bytes))
.map_err(|source| DnsMessageParserError::TrustDnsError { source }),
})
.collect()
}
Expand Down Expand Up @@ -983,13 +985,13 @@ fn parse_vec_with_u16_len(
}

fn parse_ipv6_address(decoder: &mut BinDecoder<'_>) -> DnsParserResult<String> {
Ok(aaaa::read(decoder)
Ok(<AAAA as BinDecodable>::read(decoder)
.map_err(|source| DnsMessageParserError::TrustDnsError { source })?
.to_string())
}

fn parse_ipv4_address(decoder: &mut BinDecoder<'_>) -> DnsParserResult<String> {
Ok(a::read(decoder)
Ok(<A as BinDecodable>::read(decoder)
.map_err(|source| DnsMessageParserError::TrustDnsError { source })?
.to_string())
}
Expand Down Expand Up @@ -1111,25 +1113,21 @@ mod tests {
str::FromStr,
};

use trust_dns_proto::{
rr::{
dnssec::{
rdata::{
dnskey::DNSKEY, ds::DS, nsec::NSEC, nsec3::NSEC3, nsec3param::NSEC3PARAM,
sig::SIG, DNSSECRData,
},
Algorithm as DNSSEC_Algorithm, DigestType, Nsec3HashAlgorithm,
},
domain::Name,
use trust_dns_proto::rr::{
dnssec::{
rdata::{
caa::KeyValue,
null,
sshfp::{Algorithm, FingerprintType},
tlsa::{CertUsage, Matching, Selector},
CAA, NAPTR, SSHFP, TLSA, TXT,
dnskey::DNSKEY, ds::DS, nsec::NSEC, nsec3::NSEC3, nsec3param::NSEC3PARAM, sig::SIG,
DNSSECRData,
},
Algorithm as DNSSEC_Algorithm, DigestType, Nsec3HashAlgorithm,
},
domain::Name,
rdata::{
caa::KeyValue,
sshfp::{Algorithm, FingerprintType},
tlsa::{CertUsage, Matching, Selector},
CAA, NAPTR, SSHFP, TLSA, TXT,
},
serialize::binary::Restrict,
};

use super::*;
Expand Down Expand Up @@ -1284,7 +1282,7 @@ mod tests {

#[test]
fn test_format_rdata_for_a_type() {
let rdata = RData::A(Ipv4Addr::from_str("1.2.3.4").unwrap());
let rdata = RData::A(Ipv4Addr::from_str("1.2.3.4").unwrap().into());
let rdata_text = format_rdata(&rdata);
assert!(rdata_text.is_ok());
if let Ok((parsed, raw_rdata)) = rdata_text {
Expand All @@ -1295,7 +1293,7 @@ mod tests {

#[test]
fn test_format_rdata_for_aaaa_type() {
let rdata = RData::AAAA(Ipv6Addr::from_str("2001::1234").unwrap());
let rdata = RData::AAAA(Ipv6Addr::from_str("2001::1234").unwrap().into());
let rdata_text = format_rdata(&rdata);
assert!(rdata_text.is_ok());
if let Ok((parsed, raw_rdata)) = rdata_text {
Expand All @@ -1306,7 +1304,9 @@ mod tests {

#[test]
fn test_format_rdata_for_cname_type() {
let rdata = RData::CNAME(Name::from_str("www.example.com.").unwrap());
let rdata = RData::CNAME(trust_dns_proto::rr::rdata::CNAME(
Name::from_str("www.example.com.").unwrap(),
));
let rdata_text = format_rdata(&rdata);
assert!(rdata_text.is_ok());
if let Ok((parsed, raw_rdata)) = rdata_text {
Expand Down Expand Up @@ -1778,8 +1778,7 @@ mod tests {
let raw_rdata = BASE64
.decode(raw_data.as_bytes())
.expect("Invalid base64 encoded rdata.");
let mut decoder = BinDecoder::new(&raw_rdata);
let record_rdata = null::read(&mut decoder, Restrict::new(raw_rdata.len() as u16)).unwrap();
let record_rdata = NULL::with(raw_rdata);
let rdata_text =
DnsMessageParser::new(Vec::<u8>::new()).format_unknown_rdata(code, &record_rdata);
assert!(rdata_text.is_ok());
Expand All @@ -1801,9 +1800,7 @@ mod tests {
.decode(raw_data_encoded.as_bytes())
.expect("Invalid base64 encoded raw rdata.");
for i in 1..=2 {
let mut decoder = BinDecoder::new(&raw_rdata);
let record_rdata =
null::read(&mut decoder, Restrict::new(raw_rdata.len() as u16)).unwrap();
let record_rdata = NULL::with(raw_rdata.clone());
let rdata_text = message_parser.format_unknown_rdata(code, &record_rdata);
assert!(rdata_text.is_ok());
assert_eq!(expected_output, rdata_text.unwrap().0.unwrap());
Expand Down