diff --git a/Cargo.toml b/Cargo.toml index 9fbd55d23..0650707dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,29 +3,32 @@ resolver = "3" members = [".", "./macros"] [workspace.package] -version = "0.12.0" -edition = "2021" authors = ["NLnet Labs "] + +version = "0.12.0" +# The MSRV is at least 4 versions behind stable (about half a year). +rust-version = "1.87.0" +edition = "2024" + homepage = "https://nlnetlabs.nl/projects/domain/" repository = "https://github.com/nlnetlabs/domain/" keywords = ["DNS", "domain"] license = "BSD-3-Clause" -# The MSRV is at least 4 versions behind stable (about half a year). -rust-version = "1.87.0" - [package] name = "domain" +description = "A DNS library for Rust." +authors.workspace = true + version.workspace = true +rust-version.workspace = true edition.workspace = true -authors.workspace = true + homepage.workspace = true repository.workspace = true -rust-version.workspace = true keywords.workspace = true license.workspace = true -description = "A DNS library for Rust." documentation = "https://docs.rs/domain" readme = "README.md" diff --git a/examples/ixfr-client.rs b/examples/ixfr-client.rs index 1e0613b49..dc41c995a 100644 --- a/examples/ixfr-client.rs +++ b/examples/ixfr-client.rs @@ -33,7 +33,9 @@ async fn main() { let qname = Name::>::from_str(&args[2]).unwrap(); let soa_serial: u32 = args[3].parse().unwrap(); - eprintln!("Requesting IXFR from {server_addr} for zone {qname} from serial {soa_serial}"); + eprintln!( + "Requesting IXFR from {server_addr} for zone {qname} from serial {soa_serial}" + ); let tcp_conn = TcpStream::connect(server_addr).await.unwrap(); let (tcp, transport) = stream::Connection::< diff --git a/examples/keyset.rs b/examples/keyset.rs index 3e5e775ce..036e96af1 100644 --- a/examples/keyset.rs +++ b/examples/keyset.rs @@ -1,6 +1,6 @@ //! Demonstrate the use of key sets. -use domain::base::iana::SecurityAlgorithm; use domain::base::Name; +use domain::base::iana::SecurityAlgorithm; use domain::dnssec::sign::keys::keyset::{ Action, Available, Error, KeySet, KeyType, RollType, UnixTime, }; @@ -97,7 +97,9 @@ keyset example-keyset.json status return; } - eprintln!("Unknown command '{command}'. Valid commands are: init, addkey, deletekey, start, propagation1-complete, cache-expired1, propagation2-complete, cache-expired2, done, actions, and status"); + eprintln!( + "Unknown command '{command}'. Valid commands are: init, addkey, deletekey, start, propagation1-complete, cache-expired1, propagation2-complete, cache-expired2, done, actions, and status" + ); exit(1); } @@ -508,7 +510,9 @@ fn report_actions(actions: Result, Error>, ks: &KeySet) { } } Action::UpdateDsRrset => { - println!("\tUpdate the DS records at the parent to contain just the following keys:"); + println!( + "\tUpdate the DS records at the parent to contain just the following keys:" + ); let keys = ks.keys(); for (pubref, key) in keys { let status = match key.keytype() { @@ -523,7 +527,9 @@ fn report_actions(actions: Result, Error>, ks: &KeySet) { } } Action::CreateCdsRrset => { - println!("\tCreate CDS and CDNSKEY RRsets with the following keys:"); + println!( + "\tCreate CDS and CDNSKEY RRsets with the following keys:" + ); let keys = ks.keys(); for (pubref, key) in keys { let status = match key.keytype() { diff --git a/examples/query-zone.rs b/examples/query-zone.rs index 913477a81..f949af7d4 100644 --- a/examples/query-zone.rs +++ b/examples/query-zone.rs @@ -109,7 +109,11 @@ fn main() { let zone_answer = if let Some(zone) = zones.find_zone(&qname, qclass) { // Query the built zone for the requested records. if verbosity != Verbosity::Quiet { - println!("Querying zone {} class {} for qname {qname} with qtype {qtype}...", zone.apex_name(), zone.class()); + println!( + "Querying zone {} class {} for qname {qname} with qtype {qtype}...", + zone.apex_name(), + zone.class() + ); } zone.read().query(qname.clone(), qtype).unwrap() } else { diff --git a/examples/read-zone.rs b/examples/read-zone.rs index 110aaa804..390299150 100644 --- a/examples/read-zone.rs +++ b/examples/read-zone.rs @@ -14,7 +14,9 @@ fn main() { let zone_files: Vec<_> = args.collect(); if zone_files.is_empty() { - eprintln!("Usage: {prog_name} [, , , , , ...]"); + eprintln!( + "Usage: {prog_name} [, , , , , ...]" + ); exit(2); } @@ -47,9 +49,13 @@ fn main() { "\nThe last record read was:\n{record}." ); } else { - eprintln!("\nThe last record read was:\n{last_entry:#?}."); + eprintln!( + "\nThe last record read was:\n{last_entry:#?}." + ); } - eprintln!("\nTry commenting out the line after that record with a leading ; (semi-colon) character.") + eprintln!( + "\nTry commenting out the line after that record with a leading ; (semi-colon) character." + ) } exit(1); } diff --git a/examples/resolv-sync.rs b/examples/resolv-sync.rs index 854aae491..d07eeee14 100644 --- a/examples/resolv-sync.rs +++ b/examples/resolv-sync.rs @@ -1,5 +1,5 @@ -use domain::base::name::Name; use domain::base::Rtype; +use domain::base::name::Name; use domain::rdata::AllRecordData; use domain::resolv::StubResolver; use std::env; diff --git a/examples/serve-zone.rs b/examples/serve-zone.rs index c9cc223d1..9d5487532 100644 --- a/examples/serve-zone.rs +++ b/examples/serve-zone.rs @@ -15,7 +15,7 @@ //! //! dig @127.0.0.1 -p 8053 AXFR example.com -use core::future::{ready, Future}; +use core::future::{Future, ready}; use core::pin::Pin; use core::str::FromStr; @@ -28,8 +28,8 @@ use std::time::Duration; use domain::rdata::{Soa, ZoneRecordData}; use octseq::Octets; -use rand::distr::Alphanumeric; use rand::RngExt; +use rand::distr::Alphanumeric; use tokio::net::{TcpListener, UdpSocket}; use tracing_subscriber::EnvFilter; @@ -186,11 +186,17 @@ async fn main() { eprintln!("Try:"); eprintln!(" dig @127.0.0.1 -p 8053 example.com"); eprintln!(" dig @127.0.0.1 -p 8053 example.com AXFR"); - eprintln!(" dig @127.0.0.1 -p 8053 -y hmac-sha256:demo-key:zlCZbVJPIhobIs1gJNQfrsS3xCxxsR9pMUrGwG8OgG8= example.com AXFR"); + eprintln!( + " dig @127.0.0.1 -p 8053 -y hmac-sha256:demo-key:zlCZbVJPIhobIs1gJNQfrsS3xCxxsR9pMUrGwG8OgG8= example.com AXFR" + ); eprintln!(" dig @127.0.0.1 -p 8053 +opcode=notify example.com SOA"); - eprintln!(" cargo run --example ixfr-client --all-features -- 127.0.0.1:8053 example.com 2020080302"); + eprintln!( + " cargo run --example ixfr-client --all-features -- 127.0.0.1:8053 example.com 2020080302" + ); eprintln!(); - eprintln!("Tip: set env var RUST_LOG=info (or debug or trace) for more log output."); + eprintln!( + "Tip: set env var RUST_LOG=info (or debug or trace) for more log output." + ); // Print some status information every 5 seconds tokio::spawn(async move { @@ -309,7 +315,9 @@ impl Notifiable for DemoNotifyTarget { ) -> Pin< Box> + Sync + Send + '_>, > { - eprintln!("Notify received from {source} of change to zone {apex_name} in class {class} with serial {serial:?}"); + eprintln!( + "Notify received from {source} of change to zone {apex_name} in class {class} with serial {serial:?}" + ); let res = match apex_name.to_string().to_lowercase().as_str() { "example.com" => Ok(()), diff --git a/examples/server-transports.rs b/examples/server-transports.rs index 94f57ba8b..c0ace8f63 100644 --- a/examples/server-transports.rs +++ b/examples/server-transports.rs @@ -1,5 +1,5 @@ use core::fmt; -use core::future::{ready, Future, Ready}; +use core::future::{Future, Ready, ready}; use core::sync::atomic::{AtomicBool, AtomicU8, Ordering}; use core::task::{Context, Poll}; use core::time::Duration; @@ -13,13 +13,13 @@ use std::sync::Arc; use std::sync::RwLock; use std::vec::Vec; -use futures_util::stream::{once, Empty, Once, Stream}; +use futures_util::stream::{Empty, Once, Stream, once}; use octseq::{FreezeBuilder, Octets}; use tokio::net::{TcpListener, TcpSocket, TcpStream, UdpSocket}; use tokio::sync::mpsc::unbounded_channel; use tokio::time::Instant; -use tokio_rustls::rustls; use tokio_rustls::TlsAcceptor; +use tokio_rustls::rustls; use tokio_stream::wrappers::UnboundedReceiverStream; use tokio_tfo::{TfoListener, TfoStream}; use tracing_subscriber::EnvFilter; @@ -44,7 +44,7 @@ use domain::net::server::service::{ use domain::net::server::sock::AsyncAccept; use domain::net::server::stream::StreamServer; use domain::net::server::util::{mk_builder_for_target, service_fn}; -use domain::rdata::{Soa, A}; +use domain::rdata::{A, Soa}; //----------- mk_answer() ---------------------------------------------------- @@ -241,7 +241,9 @@ fn name_to_ip( if out_answer.is_none() { let builder = mk_builder_for_target(); - eprintln!("Refusing request, only requests for A records in IPv4 dotted quad format are accepted by this service."); + eprintln!( + "Refusing request, only requests for A records in IPv4 dotted quad format are accepted by this service." + ); out_answer = Some( builder .start_answer(request.message(), Rcode::REFUSED) @@ -447,16 +449,22 @@ pub struct Stats { impl std::fmt::Display for Stats { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "# Reqs={} [UDP={}, IPv4={}, IPv6={}] Bytes [rx={}, tx={}] Speed [fastest={}, slowest={}]", + write!( + f, + "# Reqs={} [UDP={}, IPv4={}, IPv6={}] Bytes [rx={}, tx={}] Speed [fastest={}, slowest={}]", self.num_reqs, self.num_udp, self.num_ipv4, self.num_ipv6, self.num_req_bytes, self.num_resp_bytes, - self.fastest_req.map(|v| format!("{}μs", v.as_micros())).unwrap_or_else(|| "-".to_string()), - self.slowest_req.map(|v| format!("{}ms", v.as_millis())).unwrap_or_else(|| "-".to_string()), - ) + self.fastest_req + .map(|v| format!("{}μs", v.as_micros())) + .unwrap_or_else(|| "-".to_string()), + self.slowest_req + .map(|v| format!("{}ms", v.as_millis())) + .unwrap_or_else(|| "-".to_string()), + ) } } diff --git a/macros/Cargo.toml b/macros/Cargo.toml index b081f032c..508b86482 100644 --- a/macros/Cargo.toml +++ b/macros/Cargo.toml @@ -1,15 +1,17 @@ [package] name = "domain-macros" +description = "Procedural macros for the `domain` crate." +authors.workspace = true + version.workspace = true +rust-version.workspace = true edition.workspace = true -authors.workspace = true + homepage.workspace = true repository.workspace = true -rust-version.workspace = true keywords.workspace = true license.workspace = true -description = "Procedural macros for the `domain` crate." documentation = "https://docs.rs/domain-macros" [lib] diff --git a/macros/src/data.rs b/macros/src/data.rs index ee0c52baf..e40649ec7 100644 --- a/macros/src/data.rs +++ b/macros/src/data.rs @@ -3,8 +3,8 @@ use std::ops::Deref; use proc_macro2::TokenStream; -use quote::{quote, ToTokens}; -use syn::{spanned::Spanned, Field, Fields, Ident, Index, Member, Token}; +use quote::{ToTokens, quote}; +use syn::{Field, Fields, Ident, Index, Member, Token, spanned::Spanned}; //----------- Struct --------------------------------------------------------- diff --git a/macros/src/impls.rs b/macros/src/impls.rs index bdb9b9cfa..fe14b503f 100644 --- a/macros/src/impls.rs +++ b/macros/src/impls.rs @@ -1,11 +1,11 @@ //! Helpers for generating `impl` blocks. use proc_macro2::{Span, TokenStream}; -use quote::{format_ident, quote, ToTokens}; +use quote::{ToTokens, format_ident, quote}; use syn::{ - punctuated::Punctuated, visit::Visit, ConstParam, GenericArgument, - GenericParam, Ident, Lifetime, LifetimeParam, Token, TypeParam, - TypeParamBound, WhereClause, WherePredicate, + ConstParam, GenericArgument, GenericParam, Ident, Lifetime, + LifetimeParam, Token, TypeParam, TypeParamBound, WhereClause, + WherePredicate, punctuated::Punctuated, visit::Visit, }; //----------- ImplSkeleton --------------------------------------------------- diff --git a/macros/src/lib.rs b/macros/src/lib.rs index e74068c97..ac2e5ff08 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -4,7 +4,7 @@ use proc_macro as pm; use proc_macro2::TokenStream; -use quote::{format_ident, ToTokens}; +use quote::{ToTokens, format_ident}; use syn::{Error, Ident, Result}; mod impls; diff --git a/macros/src/repr.rs b/macros/src/repr.rs index b699b571b..3d810be49 100644 --- a/macros/src/repr.rs +++ b/macros/src/repr.rs @@ -2,8 +2,8 @@ use proc_macro2::Span; use syn::{ - punctuated::Punctuated, spanned::Spanned, Attribute, Error, LitInt, Meta, - Token, + Attribute, Error, LitInt, Meta, Token, punctuated::Punctuated, + spanned::Spanned, }; //----------- Repr ----------------------------------------------------------- @@ -50,8 +50,12 @@ impl Repr { } Meta::Path(p) if p.is_ident("Rust") => { - return Err(Error::new_spanned(p, - format!("repr(Rust) is not stable, cannot derive {bound} for it"))); + return Err(Error::new_spanned( + p, + format!( + "repr(Rust) is not stable, cannot derive {bound} for it" + ), + )); } Meta::Path(p) if p.is_ident("packed") => { @@ -66,8 +70,12 @@ impl Repr { let lit: LitInt = syn::parse2(meta.tokens)?; let n: usize = lit.base10_parse()?; if n != 1 { - return Err(Error::new(span, - format!("'Self' must be unaligned to derive {bound}"))); + return Err(Error::new( + span, + format!( + "'Self' must be unaligned to derive {bound}" + ), + )); } } diff --git a/src/base/charstr.rs b/src/base/charstr.rs index dfeb41b2d..c3eb23003 100644 --- a/src/base/charstr.rs +++ b/src/base/charstr.rs @@ -184,7 +184,7 @@ impl CharStr<[u8]> { #[must_use] pub unsafe fn from_slice_unchecked(slice: &[u8]) -> &Self { // SAFETY: Charstr has repr(transparent) - mem::transmute(slice) + unsafe { mem::transmute(slice) } } /// Creates a character string from a mutable slice without checking. @@ -195,7 +195,7 @@ impl CharStr<[u8]> { /// long. Otherwise, the behaviour is undefined. unsafe fn from_slice_mut_unchecked(slice: &mut [u8]) -> &mut Self { // SAFETY: Charstr has repr(transparent) - mem::transmute(slice) + unsafe { mem::transmute(slice) } } /// Checks whether an octets slice contains a correct character string. @@ -1242,7 +1242,7 @@ mod test { #[test] fn from_str() { - use std::str::{from_utf8, FromStr}; + use std::str::{FromStr, from_utf8}; type Cs = CharStr>; @@ -1350,7 +1350,7 @@ mod test { #[cfg(feature = "serde")] #[test] fn ser_de() { - use serde_test::{assert_tokens, Configure, Token}; + use serde_test::{Configure, Token, assert_tokens}; assert_tokens( &CharStr::from_octets(Vec::from(b"fo\x12 bar".as_ref())) diff --git a/src/base/dig_printer.rs b/src/base/dig_printer.rs index 4d8b86a89..8a4594dd2 100644 --- a/src/base/dig_printer.rs +++ b/src/base/dig_printer.rs @@ -2,9 +2,9 @@ use core::fmt; use crate::rdata::AllRecordData; -use super::zonefile_fmt::{DisplayKind, ZonefileFmt}; use super::ParsedRecord; -use super::{opt::AllOptData, Message, Rtype}; +use super::zonefile_fmt::{DisplayKind, ZonefileFmt}; +use super::{Message, Rtype, opt::AllOptData}; /// Interal type for printing a message in dig style /// diff --git a/src/base/iana/class.rs b/src/base/iana/class.rs index ae859d7e2..eb43c1e55 100644 --- a/src/base/iana/class.rs +++ b/src/base/iana/class.rs @@ -68,7 +68,7 @@ mod test { #[test] fn ser_de() { use super::Class; - use serde_test::{assert_tokens, Configure, Token}; + use serde_test::{Configure, Token, assert_tokens}; assert_tokens(&Class::IN.readable(), &[Token::Str("IN")]); assert_tokens(&Class(5).readable(), &[Token::Str("CLASS5")]); diff --git a/src/base/iana/digestalg.rs b/src/base/iana/digestalg.rs index 7498bde40..48fc42b43 100644 --- a/src/base/iana/digestalg.rs +++ b/src/base/iana/digestalg.rs @@ -53,7 +53,7 @@ mod test { #[test] fn ser_de() { use super::DigestAlgorithm; - use serde_test::{assert_tokens, Token}; + use serde_test::{Token, assert_tokens}; assert_tokens(&DigestAlgorithm::SHA384, &[Token::U8(4)]); assert_tokens(&DigestAlgorithm(100), &[Token::U8(100)]); diff --git a/src/base/iana/opt.rs b/src/base/iana/opt.rs index 0012353cc..14b94d206 100644 --- a/src/base/iana/opt.rs +++ b/src/base/iana/opt.rs @@ -181,7 +181,7 @@ mod test { #[test] fn ser_de() { use super::OptionCode; - use serde_test::{assert_tokens, Configure, Token}; + use serde_test::{Configure, Token, assert_tokens}; assert_tokens( &OptionCode::SERVER_TAG.readable(), diff --git a/src/base/message.rs b/src/base/message.rs index 3ee81e57a..4f64873de 100644 --- a/src/base/message.rs +++ b/src/base/message.rs @@ -218,7 +218,7 @@ impl Message<[u8]> { /// undefined. unsafe fn from_slice_unchecked(slice: &[u8]) -> &Self { // SAFETY: Message has repr(transparent) - mem::transmute(slice) + unsafe { mem::transmute(slice) } } /// Checks that the slice can be used for a message. diff --git a/src/base/message_builder.rs b/src/base/message_builder.rs index 9f7506016..331568003 100644 --- a/src/base/message_builder.rs +++ b/src/base/message_builder.rs @@ -150,7 +150,7 @@ use octseq::builder::infallible; use octseq::builder::{FreezeBuilder, OctetsBuilder, ShortBuf, Truncate}; use octseq::octets::Octets; #[cfg(feature = "std")] -use std::collections::{hash_map::RandomState, HashMap}; +use std::collections::{HashMap, hash_map::RandomState}; #[cfg(feature = "std")] use std::hash::BuildHasher; #[cfg(feature = "std")] @@ -2703,7 +2703,7 @@ mod test { use super::*; use crate::base::opt; use crate::base::{Name, Serial, Ttl}; - use crate::rdata::{Ns, Soa, A}; + use crate::rdata::{A, Ns, Soa}; use core::str::FromStr; #[test] diff --git a/src/base/name/absolute.rs b/src/base/name/absolute.rs index 7ffe6fae6..a923b8021 100644 --- a/src/base/name/absolute.rs +++ b/src/base/name/absolute.rs @@ -224,7 +224,7 @@ impl Name<[u8]> { /// Creates a domain name from an octet slice without checking, unsafe fn from_slice_unchecked(slice: &[u8]) -> &Self { // SAFETY: Name has repr(transparent) - mem::transmute(slice) + unsafe { mem::transmute(slice) } } /// Creates a domain name from an octets slice. @@ -610,7 +610,7 @@ impl + ?Sized> Name { where Octs: Octets, { - Name::from_octets_unchecked(self.0.range(begin..)) + unsafe { Name::from_octets_unchecked(self.0.range(begin..)) } } } @@ -2015,7 +2015,7 @@ pub(crate) mod test { #[cfg(all(feature = "serde", feature = "std"))] #[test] fn ser_de() { - use serde_test::{assert_tokens, Configure, Token}; + use serde_test::{Configure, Token, assert_tokens}; let name = Name::>::from_str("www.example.com.").unwrap(); assert_tokens( diff --git a/src/base/name/builder.rs b/src/base/name/builder.rs index 77f73d3e5..e709de72c 100644 --- a/src/base/name/builder.rs +++ b/src/base/name/builder.rs @@ -4,10 +4,10 @@ //! are re-exported by the parent module. use super::super::scan::{BadSymbol, Symbol, SymbolCharsError, Symbols}; +use super::Label; use super::absolute::Name; use super::relative::{RelativeName, RelativeNameError}; use super::traits::{ToName, ToRelativeName}; -use super::Label; #[cfg(feature = "bytes")] use bytes::BytesMut; use core::fmt; diff --git a/src/base/name/chain.rs b/src/base/name/chain.rs index a9f8cb3f8..f9a8869cb 100644 --- a/src/base/name/chain.rs +++ b/src/base/name/chain.rs @@ -4,11 +4,11 @@ //! crate. use super::super::scan::Scanner; +use super::Name; use super::label::Label; use super::relative::NameIter; use super::traits::{FlattenInto, ToLabelIter, ToName, ToRelativeName}; use super::uncertain::UncertainName; -use super::Name; use core::{fmt, iter}; use octseq::builder::{ BuilderAppendError, EmptyBuilder, FreezeBuilder, FromBuilder, @@ -454,18 +454,20 @@ mod test { ); assert!(left.clone().chain(six_abs.clone()).is_err()); assert!(left.clone().chain(six_rel).is_err()); - assert!(left - .clone() - .chain(five_rel.clone()) - .unwrap() - .chain(five_abs.clone()) - .is_err()); - assert!(left - .clone() - .chain(five_rel.clone()) - .unwrap() - .chain(five_rel) - .is_err()); + assert!( + left.clone() + .chain(five_rel.clone()) + .unwrap() + .chain(five_abs.clone()) + .is_err() + ); + assert!( + left.clone() + .chain(five_rel.clone()) + .unwrap() + .chain(five_rel) + .is_err() + ); let left = UncertainName::from(left); assert_eq!(left.clone().chain(five_abs).unwrap().compose_len(), 255); diff --git a/src/base/name/label.rs b/src/base/name/label.rs index 64d509e00..bf0bb594d 100644 --- a/src/base/name/label.rs +++ b/src/base/name/label.rs @@ -6,7 +6,7 @@ use super::super::scan::BadSymbol; use super::super::wire::{FormError, ParseError}; use super::builder::{ - parse_escape, LabelFromStrError, LabelFromStrErrorEnum, + LabelFromStrError, LabelFromStrErrorEnum, parse_escape, }; use core::str::FromStr; use core::{borrow, cmp, fmt, hash, iter, mem, ops, slice}; @@ -53,7 +53,7 @@ impl Label { /// The `slice` must be at most 63 octets long. pub(super) const unsafe fn from_slice_unchecked(slice: &[u8]) -> &Self { // SAFETY: Label has repr(transparent) - mem::transmute(slice) + unsafe { mem::transmute(slice) } } /// Creates a mutable label from the underlying slice without checking. @@ -65,7 +65,7 @@ impl Label { slice: &mut [u8], ) -> &mut Self { // SAFETY: Label has repr(transparent) - mem::transmute(slice) + unsafe { mem::transmute(slice) } } /// Returns a static reference to the root label. @@ -122,7 +122,7 @@ impl Label { 0x40..=0x7F => { return Err(SplitLabelError::BadType( LabelTypeError::Extended(head), - )) + )); } 0xC0..=0xFF => { if slice.len() < 2 { @@ -135,7 +135,7 @@ impl Label { _ => { return Err(SplitLabelError::BadType( LabelTypeError::Undefined, - )) + )); } }; if slice.len() < end { @@ -163,7 +163,7 @@ impl Label { 0x40..=0x7F => { return Err(SplitLabelError::BadType( LabelTypeError::Extended(head), - )) + )); } 0xC0..=0xFF => { let res = match slice.get(1) { @@ -176,7 +176,7 @@ impl Label { _ => { return Err(SplitLabelError::BadType( LabelTypeError::Undefined, - )) + )); } }; if slice.len() < end { @@ -1016,7 +1016,7 @@ mod test { #[cfg(feature = "serde")] #[test] fn owned_label_ser_de() { - use serde_test::{assert_tokens, Configure, Token}; + use serde_test::{Configure, Token, assert_tokens}; let label = OwnedLabel::from_label(Label::from_slice(b"fo.").unwrap()); diff --git a/src/base/name/relative.rs b/src/base/name/relative.rs index 495d668ea..0a1ef4341 100644 --- a/src/base/name/relative.rs +++ b/src/base/name/relative.rs @@ -135,7 +135,7 @@ impl RelativeName<[u8]> { /// [`from_octets_unchecked`]: RelativeName::from_octets_unchecked pub(super) const unsafe fn from_slice_unchecked(slice: &[u8]) -> &Self { // SAFETY: RelativeName has repr(transparent) - mem::transmute(slice) + unsafe { mem::transmute(slice) } } /// Creates a relative domain name from an octet slice. @@ -1819,7 +1819,7 @@ mod test { #[cfg(all(feature = "serde", feature = "std"))] #[test] fn ser_de() { - use serde_test::{assert_tokens, Configure, Token}; + use serde_test::{Configure, Token, assert_tokens}; let name = RelativeName::from_octets(Vec::from( b"\x03www\x07example\x03com".as_ref(), diff --git a/src/base/name/traits.rs b/src/base/name/traits.rs index dc58fbe19..b98742d44 100644 --- a/src/base/name/traits.rs +++ b/src/base/name/traits.rs @@ -11,8 +11,8 @@ use bytes::Bytes; use core::convert::Infallible; use core::{cmp, fmt}; use octseq::builder::{ - infallible, BuilderAppendError, EmptyBuilder, FreezeBuilder, FromBuilder, - OctetsBuilder, ShortBuf, + BuilderAppendError, EmptyBuilder, FreezeBuilder, FromBuilder, + OctetsBuilder, ShortBuf, infallible, }; #[cfg(feature = "std")] use std::borrow::Cow; diff --git a/src/base/name/uncertain.rs b/src/base/name/uncertain.rs index 00c0cd8e0..6d2d78343 100644 --- a/src/base/name/uncertain.rs +++ b/src/base/name/uncertain.rs @@ -727,7 +727,7 @@ mod test { #[cfg(feature = "serde")] #[test] fn ser_de() { - use serde_test::{assert_tokens, Configure, Token}; + use serde_test::{Configure, Token, assert_tokens}; let abs_name = UncertainName::>::from_str("www.example.com.").unwrap(); diff --git a/src/base/opt/algsig.rs b/src/base/opt/algsig.rs index e3c0acf2f..fdbe84b1d 100644 --- a/src/base/opt/algsig.rs +++ b/src/base/opt/algsig.rs @@ -153,7 +153,7 @@ impl Understood { #[must_use] pub unsafe fn from_slice_unchecked(slice: &[u8]) -> &Self { // SAFETY: Understood has repr(transparent) - mem::transmute(slice) + unsafe { mem::transmute(slice) } } /// Checks that a slice contains a correctly encoded value. diff --git a/src/base/opt/cookie.rs b/src/base/opt/cookie.rs index e736f576b..2b2b22a4b 100644 --- a/src/base/opt/cookie.rs +++ b/src/base/opt/cookie.rs @@ -738,9 +738,10 @@ mod test { Cookie::parse, ) .unwrap(); - assert!(request - .check_server_hash(CLIENT_1, &SECRET, |serial| serial - == Serial(1559731985))); + assert!( + request.check_server_hash(CLIENT_1, &SECRET, |serial| serial + == Serial(1559731985)) + ); assert_eq!( compose_vec(|vec| { @@ -770,9 +771,10 @@ mod test { Cookie::parse, ) .unwrap(); - assert!(request - .check_server_hash(CLIENT_2, &SECRET, |serial| serial - == Serial(1559727985))); + assert!( + request.check_server_hash(CLIENT_2, &SECRET, |serial| serial + == Serial(1559727985)) + ); assert_eq!( compose_vec(|vec| { diff --git a/src/base/opt/exterr.rs b/src/base/opt/exterr.rs index cf91e9179..4bba55880 100644 --- a/src/base/opt/exterr.rs +++ b/src/base/opt/exterr.rs @@ -5,10 +5,10 @@ //! //! The option is defined in [RFC 8914](https://tools.ietf.org/html/rfc8914). +use super::super::iana::OptionCode; use super::super::iana::exterr::{ - ExtendedErrorCode, EDE_PRIVATE_RANGE_BEGIN, + EDE_PRIVATE_RANGE_BEGIN, ExtendedErrorCode, }; -use super::super::iana::OptionCode; use super::super::message_builder::OptBuilder; use super::super::wire::ParseError; use super::super::wire::{Compose, Composer}; diff --git a/src/base/opt/keytag.rs b/src/base/opt/keytag.rs index d5b8c58f5..275ef7595 100644 --- a/src/base/opt/keytag.rs +++ b/src/base/opt/keytag.rs @@ -91,7 +91,7 @@ impl KeyTag<[u8]> { #[must_use] pub unsafe fn from_slice_unchecked(slice: &[u8]) -> &Self { // SAFETY: KeyTag has repr(transparent) - mem::transmute(slice) + unsafe { mem::transmute(slice) } } /// Checkes that the length of an octets sequence is valid. diff --git a/src/base/opt/mod.rs b/src/base/opt/mod.rs index a1fba611f..68198a1c3 100644 --- a/src/base/opt/mod.rs +++ b/src/base/opt/mod.rs @@ -170,7 +170,7 @@ impl Opt<[u8]> { /// be correct. unsafe fn from_slice_unchecked(slice: &[u8]) -> &Self { // SAFETY: Opt has repr(transparent) - mem::transmute(slice) + unsafe { mem::transmute(slice) } } /// Checks that the slice contains acceptable OPT record data. @@ -1164,7 +1164,7 @@ pub(super) mod test { use super::*; use crate::base::rdata::test::{test_compose_parse, test_rdlen}; use crate::base::record::ParsedRecord; - use crate::base::{opt, MessageBuilder}; + use crate::base::{MessageBuilder, opt}; use bytes::{Bytes, BytesMut}; use core::fmt::Debug; use octseq::builder::infallible; diff --git a/src/base/opt/nsid.rs b/src/base/opt/nsid.rs index 06866e171..e07b3dada 100644 --- a/src/base/opt/nsid.rs +++ b/src/base/opt/nsid.rs @@ -104,7 +104,7 @@ impl Nsid<[u8]> { #[must_use] pub unsafe fn from_slice_unchecked(slice: &[u8]) -> &Self { // SAFETY: Nsid has repr(transparent) - mem::transmute(slice) + unsafe { mem::transmute(slice) } } /// Creates an empty NSID option value. diff --git a/src/base/opt/subnet.rs b/src/base/opt/subnet.rs index f5bbe5ddb..c7fd9e137 100644 --- a/src/base/opt/subnet.rs +++ b/src/base/opt/subnet.rs @@ -155,7 +155,7 @@ impl ClientSubnet { return Err(FormError::new( "invalid client subnet address family", ) - .into()) + .into()); } }; diff --git a/src/base/question.rs b/src/base/question.rs index 5b34abf87..e942064e0 100644 --- a/src/base/question.rs +++ b/src/base/question.rs @@ -149,7 +149,9 @@ impl> FromStr for Question { let class_or_qtype = match s.next() { Some(value) => value, None => { - return Err(PresentationErrorEnum::MissingClassAndQtype.into()) + return Err( + PresentationErrorEnum::MissingClassAndQtype.into() + ); } }; let res = match Class::from_str(class_or_qtype) { @@ -157,13 +159,15 @@ impl> FromStr for Question { let qtype = match s.next() { Some(qtype) => qtype, None => { - return Err(PresentationErrorEnum::MissingQtype.into()) + return Err( + PresentationErrorEnum::MissingQtype.into() + ); } }; match Rtype::from_str(qtype) { Ok(qtype) => Self::new(qname, qtype, class), Err(_) => { - return Err(PresentationErrorEnum::BadQtype.into()) + return Err(PresentationErrorEnum::BadQtype.into()); } } } @@ -171,7 +175,7 @@ impl> FromStr for Question { let qtype = match Rtype::from_str(class_or_qtype) { Ok(qtype) => qtype, Err(_) => { - return Err(PresentationErrorEnum::BadQtype.into()) + return Err(PresentationErrorEnum::BadQtype.into()); } }; let class = match s.next() { @@ -181,7 +185,7 @@ impl> FromStr for Question { match Class::from_str(class) { Ok(class) => Self::new(qname, qtype, class), Err(_) => { - return Err(PresentationErrorEnum::BadClass.into()) + return Err(PresentationErrorEnum::BadClass.into()); } } } diff --git a/src/base/record.rs b/src/base/record.rs index b711dddcc..e9449352f 100644 --- a/src/base/record.rs +++ b/src/base/record.rs @@ -26,10 +26,10 @@ use super::zonefile_fmt::{self, Formatter, ZonefileFmt}; use core::cmp::Ordering; use core::time::Duration; use core::{fmt, hash}; +use octseq::OctetsBuilder; use octseq::builder::ShortBuf; use octseq::octets::{Octets, OctetsFrom}; use octseq::parse::Parser; -use octseq::OctetsBuilder; //------------ Record -------------------------------------------------------- diff --git a/src/base/scan.rs b/src/base/scan.rs index 6e7545b41..c9230a3b3 100644 --- a/src/base/scan.rs +++ b/src/base/scan.rs @@ -326,7 +326,7 @@ pub trait ConvertSymbols { /// If the method returns some data, it will be appended to the output /// octets sequence. fn process_symbol(&mut self, symbol: Sym) - -> Result, Error>; + -> Result, Error>; /// Process the end of token. /// diff --git a/src/base/zonefile_fmt.rs b/src/base/zonefile_fmt.rs index a137e6392..aa41937ac 100644 --- a/src/base/zonefile_fmt.rs +++ b/src/base/zonefile_fmt.rs @@ -323,7 +323,7 @@ mod test { use crate::base::zonefile_fmt::{DisplayKind, ZonefileFmt}; use crate::base::{Name, Record, Ttl}; use crate::rdata::caa::{CaaFlags, CaaTag}; - use crate::rdata::{Cds, Cname, Ds, Mx, Txt, A}; + use crate::rdata::{A, Cds, Cname, Ds, Mx, Txt}; fn create_record(data: Data) -> Record<&'static Name<[u8]>, Data> { let name = Name::from_slice(b"\x07example\x03com\x00").unwrap(); diff --git a/src/crypto/common.rs b/src/crypto/common.rs index 3b98bea16..4ce4e9e94 100644 --- a/src/crypto/common.rs +++ b/src/crypto/common.rs @@ -181,7 +181,9 @@ impl PublicKey { return Ok(Self::Openssl(openssl::PublicKey::from_dnskey(dnskey)?)); #[cfg(not(any(feature = "ring", feature = "openssl")))] - compile_error!("Either feature \"ring\" or \"openssl\" must be enabled for this crate."); + compile_error!( + "Either feature \"ring\" or \"openssl\" must be enabled for this crate." + ); } /// Verify a signature. diff --git a/src/crypto/openssl.rs b/src/crypto/openssl.rs index 9ae32fd98..fa1ca0a4d 100644 --- a/src/crypto/openssl.rs +++ b/src/crypto/openssl.rs @@ -26,7 +26,7 @@ use openssl::rsa::Rsa; use openssl::sign::Verifier; use super::common::{ - rsa_encode, rsa_exponent_modulus, AlgorithmError, DigestType, + AlgorithmError, DigestType, rsa_encode, rsa_exponent_modulus, }; use crate::base::iana::SecurityAlgorithm; use crate::rdata::Dnskey; diff --git a/src/crypto/ring.rs b/src/crypto/ring.rs index 318bd9b14..9c47b0552 100644 --- a/src/crypto/ring.rs +++ b/src/crypto/ring.rs @@ -22,7 +22,7 @@ use ring::rsa::PublicKeyComponents; use ring::signature::{self, RsaParameters, UnparsedPublicKey}; use super::common::{ - rsa_encode, rsa_exponent_modulus, AlgorithmError, DigestType, + AlgorithmError, DigestType, rsa_encode, rsa_exponent_modulus, }; use crate::base::iana::SecurityAlgorithm; diff --git a/src/crypto/sign.rs b/src/crypto/sign.rs index f493427d5..31f5cfb68 100644 --- a/src/crypto/sign.rs +++ b/src/crypto/sign.rs @@ -1092,7 +1092,7 @@ mod tests { use crate::base::iana::SecurityAlgorithm; use crate::crypto::sign::{ - generate, GenerateParams, KeyPair, SecretKeyBytes, + GenerateParams, KeyPair, SecretKeyBytes, generate, }; const KEYS: &[(SecurityAlgorithm, u16)] = &[ (SecurityAlgorithm::RSASHA256, 60616), diff --git a/src/dnssec/sign/denial/nsec.rs b/src/dnssec/sign/denial/nsec.rs index 86f098b17..dfab244dd 100644 --- a/src/dnssec/sign/denial/nsec.rs +++ b/src/dnssec/sign/denial/nsec.rs @@ -182,7 +182,7 @@ where let soa_rr = rrset.first(); // Check that the RDATA for the SOA record can be parsed. - let ZoneRecordData::Soa(ref soa_data) = soa_rr.data() else { + let ZoneRecordData::Soa(soa_data) = soa_rr.data() else { return Err(SigningError::SoaRecordCouldNotBeDetermined); }; @@ -224,8 +224,8 @@ mod tests { use crate::base::{Name, Ttl}; use crate::dnssec::sign::records::SortedRecords; use crate::dnssec::sign::test_util::*; - use crate::zonetree::types::StoredRecordData; use crate::zonetree::StoredName; + use crate::zonetree::types::StoredRecordData; use super::*; use core::str::FromStr; diff --git a/src/dnssec/sign/denial/nsec3.rs b/src/dnssec/sign/denial/nsec3.rs index f77573923..00877cc0d 100644 --- a/src/dnssec/sign/denial/nsec3.rs +++ b/src/dnssec/sign/denial/nsec3.rs @@ -8,14 +8,14 @@ use std::hash::Hash; use std::string::String; use std::vec::Vec; -use octseq::builder::{EmptyBuilder, FromBuilder, OctetsBuilder, Truncate}; use octseq::OctetsFrom; +use octseq::builder::{EmptyBuilder, FromBuilder, OctetsBuilder, Truncate}; use tracing::{debug, trace}; use crate::base::iana::{Class, Nsec3HashAlgorithm, Rtype}; use crate::base::name::{ToLabelIter, ToName}; use crate::base::{CanonicalOrd, Name, NameBuilder, Record, Ttl}; -use crate::dnssec::common::{nsec3_hash, Nsec3HashError}; +use crate::dnssec::common::{Nsec3HashError, nsec3_hash}; use crate::dnssec::sign::error::SigningError; use crate::dnssec::sign::records::{DefaultSorter, RecordsIter, Sorter}; use crate::rdata::dnssec::{RtypeBitmap, RtypeBitmapBuilder}; @@ -257,7 +257,10 @@ where && cut.is_some() && !has_ds { - debug!("Excluding owner {} as it is an insecure delegation (lacks a DS RR) and opt-out is enabled",owner_rrs.owner()); + debug!( + "Excluding owner {} as it is an insecure delegation (lacks a DS RR) and opt-out is enabled", + owner_rrs.owner() + ); continue; } @@ -342,7 +345,9 @@ where // DS RRsets, and any RRSIG RRs associated with these RRsets are // authoritative for this zone. if cut.is_none() || has_ds { - trace!("Adding RRSIG to the bitmap as the RRSET is authoritative (not at zone cut or has a DS RR)"); + trace!( + "Adding RRSIG to the bitmap as the RRSET is authoritative (not at zone cut or has a DS RR)" + ); bitmap.add(Rtype::RRSIG).unwrap(); } @@ -434,7 +439,7 @@ where let soa_rr = rrset.first(); // Check that the RDATA for the SOA record can be parsed. - let ZoneRecordData::Soa(ref soa_data) = soa_rr.data() else { + let ZoneRecordData::Soa(soa_data) = soa_rr.data() else { return Err(SigningError::SoaRecordCouldNotBeDetermined); }; @@ -457,10 +462,14 @@ where } if distance_to_apex == 0 { - trace!("Adding NSEC3PARAM to the bitmap as we are at the apex and RRSIG RRs are expected to be added"); + trace!( + "Adding NSEC3PARAM to the bitmap as we are at the apex and RRSIG RRs are expected to be added" + ); bitmap.add(Rtype::NSEC3PARAM).unwrap(); if config.assume_dnskeys_will_be_added { - trace!("Adding DNSKEY to the bitmap as we are at the apex and DNSKEY RRs are expected to be added"); + trace!( + "Adding DNSKEY to the bitmap as we are at the apex and DNSKEY RRs are expected to be added" + ); bitmap.add(Rtype::DNSKEY).unwrap(); } } @@ -583,7 +592,9 @@ where } else { // This shouldn't happen. Could it maybe happen if the input // data were unsorted? - unreachable!("All RTYPEs for a single owner name should have been combined into a single NSEC3 RR. Was the input NSEC3 canonically ordered?"); + unreachable!( + "All RTYPEs for a single owner name should have been combined into a single NSEC3 RR. Was the input NSEC3 canonically ordered?" + ); } } diff --git a/src/dnssec/sign/keys/keyset.rs b/src/dnssec/sign/keys/keyset.rs index f4961c522..0f1c5df1c 100644 --- a/src/dnssec/sign/keys/keyset.rs +++ b/src/dnssec/sign/keys/keyset.rs @@ -57,11 +57,11 @@ // TODO: // - add support for undo/abort. -use crate::base::iana::SecurityAlgorithm; use crate::base::Name; +use crate::base::iana::SecurityAlgorithm; use crate::rdata::dnssec::Timestamp; use serde::{Deserialize, Serialize}; -use std::collections::{hash_map, HashMap, HashSet}; +use std::collections::{HashMap, HashSet, hash_map}; use std::fmt; use std::fmt::{Debug, Display, Formatter}; use std::ops::Add; @@ -318,7 +318,7 @@ impl KeySet { ksk_keystate.at_parent = value; } KeyType::Zsk(_) | KeyType::Include(_) => { - return Err(Error::WrongKeyType) + return Err(Error::WrongKeyType); } }; } diff --git a/src/dnssec/sign/keys/signingkey.rs b/src/dnssec/sign/keys/signingkey.rs index dd27fdc96..ba62fd703 100644 --- a/src/dnssec/sign/keys/signingkey.rs +++ b/src/dnssec/sign/keys/signingkey.rs @@ -1,5 +1,5 @@ -use crate::base::iana::SecurityAlgorithm; use crate::base::Name; +use crate::base::iana::SecurityAlgorithm; use crate::crypto::sign::SignRaw; use crate::rdata::Dnskey; use std::fmt::Debug; diff --git a/src/dnssec/sign/mod.rs b/src/dnssec/sign/mod.rs index e5047b71b..a6a3548cc 100644 --- a/src/dnssec/sign/mod.rs +++ b/src/dnssec/sign/mod.rs @@ -153,14 +153,14 @@ use crate::rdata::ZoneRecordData; use denial::config::DenialConfig; use denial::nsec::generate_nsecs; -use denial::nsec3::{generate_nsec3s, Nsec3Records}; +use denial::nsec3::{Nsec3Records, generate_nsec3s}; use error::SigningError; use keys::SigningKey; use octseq::{ EmptyBuilder, FromBuilder, OctetsBuilder, OctetsFrom, Truncate, }; use records::{RecordsIter, Sorter}; -use signatures::rrsigs::{sign_sorted_zone_records, GenerateRrsigConfig}; +use signatures::rrsigs::{GenerateRrsigConfig, sign_sorted_zone_records}; use traits::{SignableZone, SortedExtend}; //------------ SignableZoneInOut --------------------------------------------- @@ -425,13 +425,13 @@ where // Nothing to do. } - DenialConfig::Nsec(ref cfg) => { + DenialConfig::Nsec(cfg) => { let nsecs = generate_nsecs(apex_owner, owner_rrs, cfg)?; in_out.sorted_extend(nsecs.into_iter().map(Record::from_record)); } - DenialConfig::Nsec3(ref cfg) => { + DenialConfig::Nsec3(cfg) => { // RFC 5155 7.1 step 5: "Sort the set of NSEC3 RRs into hash // order." We store the NSEC3s as we create them and sort them // afterwards. diff --git a/src/dnssec/sign/records.rs b/src/dnssec/sign/records.rs index 1788142d7..f4cda2744 100644 --- a/src/dnssec/sign/records.rs +++ b/src/dnssec/sign/records.rs @@ -9,12 +9,12 @@ use core::slice::Iter; use std::vec::Vec; use std::{fmt, slice}; +use crate::base::Ttl; use crate::base::cmp::CanonicalOrd; use crate::base::iana::{Class, Rtype}; use crate::base::name::ToName; use crate::base::rdata::RecordData; use crate::base::record::Record; -use crate::base::Ttl; use super::error::SigningError; diff --git a/src/dnssec/sign/signatures/rrsigs.rs b/src/dnssec/sign/signatures/rrsigs.rs index 8b265163a..16311d29e 100644 --- a/src/dnssec/sign/signatures/rrsigs.rs +++ b/src/dnssec/sign/signatures/rrsigs.rs @@ -12,12 +12,12 @@ use octseq::builder::FromBuilder; use octseq::{OctetsFrom, OctetsInto}; use tracing::debug; +use crate::base::Name; use crate::base::cmp::CanonicalOrd; use crate::base::iana::Rtype; use crate::base::name::ToName; use crate::base::rdata::{ComposeRecordData, RecordData}; use crate::base::record::Record; -use crate::base::Name; use crate::crypto::sign::SignRaw; use crate::dnssec::sign::error::SigningError; use crate::dnssec::sign::keys::signingkey::SigningKey; @@ -364,14 +364,14 @@ mod tests { use pretty_assertions::assert_eq; use rand::RngExt; - use crate::base::iana::SecurityAlgorithm; use crate::base::Serial; + use crate::base::iana::SecurityAlgorithm; use crate::crypto::sign::{KeyPair, SignError, Signature}; use crate::dnssec::sign::records::SortedRecords; use crate::dnssec::sign::test_util; use crate::dnssec::sign::test_util::*; - use crate::rdata::dnssec::Timestamp; use crate::rdata::Dnskey; + use crate::rdata::dnssec::Timestamp; use crate::zonetree::StoredName; use super::*; diff --git a/src/dnssec/sign/test_util/mod.rs b/src/dnssec/sign/test_util/mod.rs index b36c39d4c..6691a482a 100644 --- a/src/dnssec/sign/test_util/mod.rs +++ b/src/dnssec/sign/test_util/mod.rs @@ -14,12 +14,12 @@ use crate::dnssec::sign::denial::nsec3::mk_hashed_nsec3_owner_name; use crate::rdata::dnssec::{RtypeBitmap, Timestamp}; use crate::rdata::nsec3::OwnerHash; use crate::rdata::{ - Aaaa, Dnskey, Ns, Nsec, Nsec3, Nsec3param, Rrsig, Soa, A, + A, Aaaa, Dnskey, Ns, Nsec, Nsec3, Nsec3param, Rrsig, Soa, }; use crate::utils::base32; use crate::zonefile::inplace::{Entry, Zonefile}; -use crate::zonetree::types::StoredRecordData; use crate::zonetree::StoredName; +use crate::zonetree::types::StoredRecordData; use super::denial::nsec3::GenerateNsec3Config; use super::records::SortedRecords; diff --git a/src/dnssec/sign/traits.rs b/src/dnssec/sign/traits.rs index a8896c008..4eb1bfde9 100644 --- a/src/dnssec/sign/traits.rs +++ b/src/dnssec/sign/traits.rs @@ -12,24 +12,24 @@ use std::boxed::Box; use std::hash::Hash; use std::vec::Vec; -use octseq::builder::{EmptyBuilder, FromBuilder, OctetsBuilder, Truncate}; use octseq::OctetsFrom; +use octseq::builder::{EmptyBuilder, FromBuilder, OctetsBuilder, Truncate}; +use crate::base::Name; use crate::base::cmp::CanonicalOrd; use crate::base::name::ToName; use crate::base::record::Record; -use crate::base::Name; use crate::crypto::sign::SignRaw; +use crate::dnssec::sign::SignableZoneInOut; +use crate::dnssec::sign::SigningConfig; use crate::dnssec::sign::error::SigningError; use crate::dnssec::sign::keys::SigningKey; use crate::dnssec::sign::records::{ DefaultSorter, RecordsIter, Rrset, SortedRecords, Sorter, }; use crate::dnssec::sign::sign_zone; -use crate::dnssec::sign::signatures::rrsigs::sign_sorted_zone_records; use crate::dnssec::sign::signatures::rrsigs::GenerateRrsigConfig; -use crate::dnssec::sign::SignableZoneInOut; -use crate::dnssec::sign::SigningConfig; +use crate::dnssec::sign::signatures::rrsigs::sign_sorted_zone_records; use crate::rdata::dnssec::Timestamp; use crate::rdata::{Rrsig, ZoneRecordData}; diff --git a/src/dnssec/validator/base.rs b/src/dnssec/validator/base.rs index 85eb7170f..c8802010b 100644 --- a/src/dnssec/validator/base.rs +++ b/src/dnssec/validator/base.rs @@ -328,9 +328,9 @@ pub fn supported_algorithm(a: &SecurityAlgorithm) -> bool { #[cfg(feature = "std")] mod test { use super::*; + use crate::base::Ttl; use crate::base::iana::{Class, Rtype, SecurityAlgorithm}; use crate::base::scan::{IterScanner, Scanner}; - use crate::base::Ttl; use crate::dnssec::common::parse_from_bind; use crate::rdata::dnssec::Timestamp; use crate::rdata::{Mx, ZoneRecordData}; diff --git a/src/dnssec/validator/context.rs b/src/dnssec/validator/context.rs index 20e034f55..9186f3bf0 100644 --- a/src/dnssec/validator/context.rs +++ b/src/dnssec/validator/context.rs @@ -5,16 +5,16 @@ //! or evaluated results. use super::anchor::{TrustAnchor, TrustAnchors}; -use super::base::{supported_algorithm, supported_digest, DnskeyExt}; +use super::base::{DnskeyExt, supported_algorithm, supported_digest}; use super::group::{Group, GroupSet, SigCache, ValidatedGroup}; use super::nsec::{ - cached_nsec3_hash, nsec3_for_nodata, nsec3_for_nodata_wildcard, - nsec3_for_nxdomain, nsec3_in_range, nsec3_label_to_hash, nsec_for_nodata, - nsec_for_nodata_wildcard, nsec_for_nxdomain, nsec_in_range, - supported_nsec3_hash, + Nsec3Cache, Nsec3NXState, Nsec3State, NsecNXState, NsecState, }; use super::nsec::{ - Nsec3Cache, Nsec3NXState, Nsec3State, NsecNXState, NsecState, + cached_nsec3_hash, nsec_for_nodata, nsec_for_nodata_wildcard, + nsec_for_nxdomain, nsec_in_range, nsec3_for_nodata, + nsec3_for_nodata_wildcard, nsec3_for_nxdomain, nsec3_in_range, + nsec3_label_to_hash, supported_nsec3_hash, }; use super::utilities::{ check_not_exists_for_wildcard, do_cname_dname, get_answer_state, @@ -25,11 +25,11 @@ use crate::base::iana::{ExtendedErrorCode, OptRcode}; use crate::base::message::ShortMessage; use crate::base::name::{Chain, Label}; use crate::base::opt::ExtendedError; -use crate::base::{name, wire}; use crate::base::{ Message, MessageBuilder, Name, ParsedName, Record, RelativeName, Rtype, ToName, }; +use crate::base::{name, wire}; use crate::dep::octseq::{Octets, OctetsFrom, OctetsInto}; use crate::net::client::request::{ ComposeRequest, RequestMessage, SendRequest, @@ -571,7 +571,7 @@ impl ValidationContext { maybe_secure, ), ede, - )) + )); } NsecState::Nothing => (), // Try something else. } @@ -592,7 +592,7 @@ impl ValidationContext { maybe_secure, ), ede, - )) + )); } NsecState::Nothing => (), // Try something else. } @@ -616,16 +616,16 @@ impl ValidationContext { maybe_secure, ), None, - )) + )); } Nsec3State::Nothing => (), // Try something else. Nsec3State::NoDataInsecure => // totest, NSEC3 NODATA with opt-out { - return Ok((ValidationState::Insecure, ede)) + return Ok((ValidationState::Insecure, ede)); } Nsec3State::Bogus => { - return Ok((ValidationState::Bogus, ede)) + return Ok((ValidationState::Bogus, ede)); } } @@ -657,13 +657,13 @@ impl ValidationContext { Nsec3State::Nothing => // totest, missing NSEC3 for wildcard. { - return Ok((ValidationState::Bogus, ede)) + return Ok((ValidationState::Bogus, ede)); } Nsec3State::NoDataInsecure => { - return Ok((ValidationState::Insecure, ede)) + return Ok((ValidationState::Insecure, ede)); } Nsec3State::Bogus => { - return Ok((ValidationState::Bogus, ede)) + return Ok((ValidationState::Bogus, ede)); } } @@ -690,7 +690,7 @@ impl ValidationContext { return Ok(( map_maybe_secure(ValidationState::Secure, maybe_secure), ede, - )) + )); } NsecNXState::Nothing => (), // Try something else. } @@ -709,14 +709,14 @@ impl ValidationContext { return Ok(( map_maybe_secure(ValidationState::Secure, maybe_secure), None, - )) + )); } Nsec3NXState::DoesNotExistInsecure(_) => { return Ok((ValidationState::Insecure, ede)); } Nsec3NXState::Bogus => return Ok((ValidationState::Bogus, ede)), Nsec3NXState::Insecure => { - return Ok((ValidationState::Insecure, ede)) + return Ok((ValidationState::Insecure, ede)); } Nsec3NXState::Nothing => (), // Try something else. } @@ -791,7 +791,7 @@ impl ValidationContext { match node.validation_state() { ValidationState::Secure => (), // continue ValidationState::Insecure | ValidationState::Bogus => { - return Ok(node) + return Ok(node); } ValidationState::Indeterminate => { // totest, negative trust anchors @@ -1000,7 +1000,7 @@ impl ValidationContext { node.signer_name().clone(), ede, ttl, - )) + )); } CNsecState::Bogus => { return Ok(Node::new_delegation( @@ -1009,7 +1009,7 @@ impl ValidationContext { Vec::new(), ede, ttl, - )) + )); } CNsecState::Nothing => (), // Try NSEC3 next. } @@ -1031,7 +1031,7 @@ impl ValidationContext { Vec::new(), ede, ttl, - )) + )); } CNsecState::SecureIntermediate => { return Ok(Node::new_intermediate( @@ -1040,7 +1040,7 @@ impl ValidationContext { node.signer_name().clone(), ede, ttl, - )) + )); } CNsecState::Bogus => { return Ok(Node::new_delegation( @@ -1049,7 +1049,7 @@ impl ValidationContext { Vec::new(), ede, ttl, - )) + )); } CNsecState::Nothing => (), } @@ -1841,7 +1841,7 @@ async fn nsec_for_ds( // insecure and indeterminate should not happen. But it is // easier to treat them as bogus. { - return (CNsecState::Bogus, ttl, ede) + return (CNsecState::Bogus, ttl, ede); } ValidationState::Secure => (), } diff --git a/src/dnssec/validator/group.rs b/src/dnssec/validator/group.rs index 581869253..9bd0adfa3 100644 --- a/src/dnssec/validator/group.rs +++ b/src/dnssec/validator/group.rs @@ -11,8 +11,8 @@ use super::context::{ }; use super::utilities::{make_ede, map_dname, ttl_for_sig}; use crate::base::cmp::CanonicalOrd; -use crate::base::iana::class::Class; use crate::base::iana::ExtendedErrorCode; +use crate::base::iana::class::Class; use crate::base::name::ToName; use crate::base::opt::exterr::ExtendedError; use crate::base::rdata::ComposeRecordData; @@ -390,7 +390,7 @@ impl Group { None, node.extended_error(), None, - )) + )); } } let (state, wildcard, ede, _ttl, adjust_ttl) = self @@ -432,7 +432,13 @@ impl Group { ValidationState::Insecure | ValidationState::Bogus | ValidationState::Indeterminate => { - return (state, None, node.extended_error(), node.ttl(), None) + return ( + state, + None, + node.extended_error(), + node.ttl(), + None, + ); } ValidationState::Secure => (), } diff --git a/src/dnssec/validator/nsec.rs b/src/dnssec/validator/nsec.rs index 5b1ae351e..fa47b453b 100644 --- a/src/dnssec/validator/nsec.rs +++ b/src/dnssec/validator/nsec.rs @@ -235,12 +235,12 @@ pub fn nsec_for_not_exists( // proof non-existance. // This NSEC record cannot prove non-existance. return ( - NsecNXState::Exists, - make_ede( - ExtendedErrorCode::DNSSEC_BOGUS, - "Found NSEC with DNAME or delegation while trying to proof non-existance", - ), - ); + NsecNXState::Exists, + make_ede( + ExtendedErrorCode::DNSSEC_BOGUS, + "Found NSEC with DNAME or delegation while trying to proof non-existance", + ), + ); } } @@ -378,7 +378,7 @@ fn nsec_closest_encloser( // longest common suffix for target and each of them and return the longest // result. let mut owner_encloser = Name::root(); // Assume the root if we can't find - // anything. + // anything. for n in nsec_owner.iter_suffixes() { if target.ends_with(&n) { owner_encloser = n; @@ -387,7 +387,7 @@ fn nsec_closest_encloser( } let mut next_encloser: Name = Name::root(); // Assume the root if we can't find - // anything. + // anything. for n in nsec.next_name().iter_suffixes() { if target.ends_with(&n) { next_encloser = n.to_name(); @@ -469,20 +469,25 @@ pub async fn nsec3_for_nodata( } Err((state, ede)) => { match state { - ValidationState::Bogus => - // totest, NSEC3 with very high iteration count - return (Nsec3State::Bogus, ede), - ValidationState::Insecure => - // totest, NSEC3 with medium high iteration count - // With a high iteration count we don't compute the - // hash, so we just assume that the NSEC3 record - // proves whatever we want to have. But the - // result is insecure. - return (Nsec3State::NoDataInsecure, ede), - ValidationState::Secure - | ValidationState::Indeterminate => - panic!("get_checked_nsec3 should only return Bogus or Insecure"), - } + ValidationState::Bogus => + // totest, NSEC3 with very high iteration count + { + return (Nsec3State::Bogus, ede); + } + ValidationState::Insecure => + // totest, NSEC3 with medium high iteration count + // With a high iteration count we don't compute the + // hash, so we just assume that the NSEC3 record + // proves whatever we want to have. But the + // result is insecure. + { + return (Nsec3State::NoDataInsecure, ede); + } + ValidationState::Secure + | ValidationState::Indeterminate => panic!( + "get_checked_nsec3 should only return Bogus or Insecure" + ), + } } }; @@ -692,10 +697,10 @@ pub async fn nsec3_for_not_exists( } } Err((ValidationState::Bogus, ede)) => { - return (Nsec3NXState::Bogus, ede) + return (Nsec3NXState::Bogus, ede); } Err((ValidationState::Insecure, ede)) => { - return (Nsec3NXState::Insecure, ede) + return (Nsec3NXState::Insecure, ede); } Err(_) => panic!( "get_checked_nsec3 should on return Bogus or Insecure" @@ -728,12 +733,12 @@ pub async fn nsec3_for_not_exists( // proof non-existance. // This NSEC3 record cannot prove non-existance. return ( - Nsec3NXState::Nothing, - make_ede( - ExtendedErrorCode::DNSSEC_BOGUS, - "Found NSEC3 with DNAME or delegation while trying to proof non-existance", - ), - ); + Nsec3NXState::Nothing, + make_ede( + ExtendedErrorCode::DNSSEC_BOGUS, + "Found NSEC3 with DNAME or delegation while trying to proof non-existance", + ), + ); } maybe_ce = n; maybe_ce_exists = true; @@ -823,20 +828,25 @@ pub async fn nsec3_for_not_exists_no_ce( } Err((state, ede)) => { match state { - ValidationState::Bogus => - // totest, NSEC3 with very high iteration count - return (Nsec3NXStateNoCE::Bogus, ede), - ValidationState::Insecure => - // totest, NSEC3 with medium high iteration count - // With a high iteration count we don't compute the - // hash, so we just assume that the NSEC3 record - // proves whatever we want to have. But the - // result is insecure. - return (Nsec3NXStateNoCE::DoesNotExistInsecure, ede), - ValidationState::Secure - | ValidationState::Indeterminate => - panic!("get_checked_nsec3 should only return Bogus or Insecure"), - } + ValidationState::Bogus => + // totest, NSEC3 with very high iteration count + { + return (Nsec3NXStateNoCE::Bogus, ede); + } + ValidationState::Insecure => + // totest, NSEC3 with medium high iteration count + // With a high iteration count we don't compute the + // hash, so we just assume that the NSEC3 record + // proves whatever we want to have. But the + // result is insecure. + { + return (Nsec3NXStateNoCE::DoesNotExistInsecure, ede); + } + ValidationState::Secure + | ValidationState::Indeterminate => panic!( + "get_checked_nsec3 should only return Bogus or Insecure" + ), + } } }; @@ -1081,7 +1091,7 @@ fn get_checked_nsec3( ExtendedErrorCode::DNSSEC_BOGUS, "NSEC3 with bad owner hash", ), - )) + )); } }; diff --git a/src/dnssec/validator/utilities.rs b/src/dnssec/validator/utilities.rs index 4b87ad463..eebbf661b 100644 --- a/src/dnssec/validator/utilities.rs +++ b/src/dnssec/validator/utilities.rs @@ -2,8 +2,8 @@ use super::context::{Config, Error, ValidationState}; use super::group::ValidatedGroup; -use super::nsec::{nsec3_for_not_exists_no_ce, nsec_for_not_exists}; use super::nsec::{Nsec3Cache, Nsec3NXStateNoCE, NsecNXState}; +use super::nsec::{nsec_for_not_exists, nsec3_for_not_exists_no_ce}; use crate::base::iana::{Class, ExtendedErrorCode}; use crate::base::name::Label; use crate::base::opt::ExtendedError; @@ -283,7 +283,9 @@ fn get_child_of_ce(target: &Name, ce: &Name) -> Name { } // Something weird. - panic!("Get child of closest encloser(ce), maybe target is not a decendent of ce?"); + panic!( + "Get child of closest encloser(ce), maybe target is not a decendent of ce?" + ); } /// Check that target name does not exist. This typically happens if there @@ -343,7 +345,7 @@ pub async fn check_not_exists_for_wildcard( return (true, ValidationState::Insecure, None); } Nsec3NXStateNoCE::Bogus => { - return (false, ValidationState::Bogus, ede) + return (false, ValidationState::Bogus, ede); } Nsec3NXStateNoCE::Nothing => (), // Continue. } diff --git a/src/net/client/dgram.rs b/src/net/client/dgram.rs index 3dbca9cb4..ab99ceebb 100644 --- a/src/net/client/dgram.rs +++ b/src/net/client/dgram.rs @@ -28,7 +28,7 @@ use std::sync::Arc; use std::vec::Vec; use std::{error, io}; use tokio::sync::Semaphore; -use tokio::time::{timeout_at, Duration, Instant}; +use tokio::time::{Duration, Instant, timeout_at}; use tracing::trace; //------------ Configuration Constants ---------------------------------------- @@ -303,7 +303,9 @@ where if !request.is_answer(answer.for_slice()) { // Wrong answer, go back to receiving - trace!("Received message is not the answer we were waiting for, reading more"); + trace!( + "Received message is not the answer we were waiting for, reading more" + ); buf = answer.into_octets(); continue; } diff --git a/src/net/client/dgram_stream.rs b/src/net/client/dgram_stream.rs index c5e830263..747adaeb6 100644 --- a/src/net/client/dgram_stream.rs +++ b/src/net/client/dgram_stream.rs @@ -212,7 +212,7 @@ where self.state = QueryState::GetUdpResponse(request); continue; } - QueryState::GetUdpResponse(ref mut request) => { + QueryState::GetUdpResponse(request) => { let response = request.get_response().await?; if response.header().tc() { self.state = QueryState::StartTcpRequest; @@ -226,7 +226,7 @@ where self.state = QueryState::GetTcpResponse(request); continue; } - QueryState::GetTcpResponse(ref mut query) => { + QueryState::GetTcpResponse(query) => { let response = query.get_response().await?; return Ok(response); } diff --git a/src/net/client/load_balancer.rs b/src/net/client/load_balancer.rs index 3a58aa5f0..14b0c6c51 100644 --- a/src/net/client/load_balancer.rs +++ b/src/net/client/load_balancer.rs @@ -42,19 +42,19 @@ //! also gets the request. If the probes upstream provides a suitable response //! before the next upstream then its estimated will be updated. -use crate::base::iana::OptRcode; -use crate::base::iana::Rcode; -use crate::base::opt::AllOptData; use crate::base::Message; use crate::base::MessageBuilder; use crate::base::StaticCompressor; +use crate::base::iana::OptRcode; +use crate::base::iana::Rcode; +use crate::base::opt::AllOptData; use crate::dep::octseq::OctetsInto; use crate::net::client::request::ComposeRequest; use crate::net::client::request::{Error, GetResponse, SendRequest}; use crate::utils::config::DefMinMax; use bytes::Bytes; -use futures_util::stream::FuturesUnordered; use futures_util::StreamExt; +use futures_util::stream::FuturesUnordered; use octseq::Octets; use rand::{random, random_range}; use std::boxed::Box; @@ -67,7 +67,7 @@ use std::string::ToString; use std::sync::Arc; use std::vec::Vec; use tokio::sync::{mpsc, oneshot}; -use tokio::time::{sleep_until, Duration, Instant}; +use tokio::time::{Duration, Instant, sleep_until}; /* Basic algorithm: @@ -822,7 +822,9 @@ impl Query { .expect("just checked for Some"); return Err(err); } - panic!("either deferred_reply or deferred_error should be present"); + panic!( + "either deferred_reply or deferred_error should be present" + ); } let res = self.fut_list.next().await; let res = res.expect("res should not be empty"); diff --git a/src/net/client/multi_stream.rs b/src/net/client/multi_stream.rs index 5d0652164..853898a72 100644 --- a/src/net/client/multi_stream.rs +++ b/src/net/client/multi_stream.rs @@ -11,8 +11,8 @@ use crate::net::client::request::{ use crate::net::client::stream; use crate::utils::config::DefMinMax; use bytes::Bytes; -use futures_util::stream::FuturesUnordered; use futures_util::StreamExt; +use futures_util::stream::FuturesUnordered; use rand::random; use std::boxed::Box; use std::fmt::Debug; @@ -25,7 +25,7 @@ use tokio::io; use tokio::io::{AsyncRead, AsyncWrite}; use tokio::sync::{mpsc, oneshot}; use tokio::time::timeout; -use tokio::time::{sleep_until, Instant}; +use tokio::time::{Instant, sleep_until}; //------------ Constants ----------------------------------------------------- @@ -375,7 +375,7 @@ impl Request { // fatal errors where retrying doesn’t make any // sense? Err(Error::WrongReplyForQuery) => { - return Err(Error::WrongReplyForQuery) + return Err(Error::WrongReplyForQuery); } Err(Error::ConnectionClosed) => { // The stream may immedately return that the diff --git a/src/net/client/redundant.rs b/src/net/client/redundant.rs index e2722be09..f4693d49f 100644 --- a/src/net/client/redundant.rs +++ b/src/net/client/redundant.rs @@ -2,8 +2,8 @@ use bytes::Bytes; -use futures_util::stream::FuturesUnordered; use futures_util::StreamExt; +use futures_util::stream::FuturesUnordered; use octseq::Octets; @@ -17,10 +17,10 @@ use std::pin::Pin; use std::vec::Vec; use tokio::sync::{mpsc, oneshot}; -use tokio::time::{sleep_until, Duration, Instant}; +use tokio::time::{Duration, Instant, sleep_until}; -use crate::base::iana::OptRcode; use crate::base::Message; +use crate::base::iana::OptRcode; use crate::net::client::request::{Error, GetResponse, SendRequest}; /* @@ -592,7 +592,9 @@ impl Query { .expect("just checked for Some"); return Err(err); } - panic!("either deferred_reply or deferred_error should be present"); + panic!( + "either deferred_reply or deferred_error should be present" + ); } let res = self.fut_list.next().await; let res = res.expect("res should not be empty"); diff --git a/src/net/client/stream.rs b/src/net/client/stream.rs index 03e110204..f797c4dec 100644 --- a/src/net/client/stream.rs +++ b/src/net/client/stream.rs @@ -806,7 +806,8 @@ where if curlen >= len { if curlen > len { panic!( - "reader: got too much data {curlen}, expetect {len}"); + "reader: got too much data {curlen}, expetect {len}" + ); } // We got what we need @@ -1136,7 +1137,7 @@ where XFRState::Error => // Keep the stream open. { - return (false, xfr_state, false) + return (false, xfr_state, false); } } diff --git a/src/net/client/tsig.rs b/src/net/client/tsig.rs index 2fbb5b70e..f995da085 100644 --- a/src/net/client/tsig.rs +++ b/src/net/client/tsig.rs @@ -60,11 +60,11 @@ use bytes::Bytes; use octseq::Octets; use tracing::trace; +use crate::base::Message; +use crate::base::StaticCompressor; use crate::base::message::CopyRecordsError; use crate::base::message_builder::AdditionalBuilder; use crate::base::wire::Composer; -use crate::base::Message; -use crate::base::StaticCompressor; use crate::net::client::request::{ ComposeRequest, ComposeRequestMulti, Error, GetResponse, GetResponseMulti, SendRequest, SendRequestMulti, @@ -771,7 +771,11 @@ mod tests { if let Ok(res) = res { // Verify that the mock response has had its TSIG RR stripped out // during validation. - assert_eq!(res.header_counts().arcount(), 0, "TSIG RR should have been removed from the additional section during response processing"); + assert_eq!( + res.header_counts().arcount(), + 0, + "TSIG RR should have been removed from the additional section during response processing" + ); } } @@ -827,7 +831,11 @@ mod tests { // Verify that the mock response has had its TSIG RR stripped out // during validation. - assert_eq!(res.header_counts().arcount(), 0, "TSIG RR should have been removed from the additional section during response processing"); + assert_eq!( + res.header_counts().arcount(), + 0, + "TSIG RR should have been removed from the additional section during response processing" + ); // Receive the second mock response, which may have been deliberately // invalidated. @@ -850,7 +858,11 @@ mod tests { // Verify that the mock response has had its TSIG RR stripped out // during validation. - assert_eq!(res.header_counts().arcount(), 0, "TSIG RR should have been removed from the additional section during response processing"); + assert_eq!( + res.header_counts().arcount(), + 0, + "TSIG RR should have been removed from the additional section during response processing" + ); // Receive the third and final mock response, which may have been // deliberately not signed, in order to test whether or not we @@ -868,16 +880,29 @@ mod tests { // during validation, or it was never added during response // generation. if dont_sign_last_response { - assert_eq!(res.header_counts().arcount(), 0, "TSIG RR should never have been added to the additional section during response generation"); + assert_eq!( + res.header_counts().arcount(), + 0, + "TSIG RR should never have been added to the additional section during response generation" + ); } else { - assert_eq!(res.header_counts().arcount(), 0, "TSIG RR should have been removed from the additional section during response processing"); + assert_eq!( + res.header_counts().arcount(), + 0, + "TSIG RR should have been removed from the additional section during response processing" + ); } if dont_sign_last_response { // Attempt to receive another response but discover that the // last response was not signed as it should have been. assert!( - matches!(req.get_response().await, Err(Error::Authentication(ValidationError::TooManyUnsigned))), + matches!( + req.get_response().await, + Err(Error::Authentication( + ValidationError::TooManyUnsigned + )) + ), "Receiving another response should have failed because the last response should have lacked a signature" ); } else { @@ -982,7 +1007,11 @@ mod tests { // Generate the wire format response message and sanity check it // before returning it. let res = builder.into_message(); - assert_eq!(res.header_counts().arcount(), 1, "Constructed response lacks a TSIG RR in the additional section"); + assert_eq!( + res.header_counts().arcount(), + 1, + "Constructed response lacks a TSIG RR in the additional section" + ); Box::pin(ready(Ok(res))) } } @@ -1102,7 +1131,11 @@ mod tests { // before returning it. let res = builder.into_message(); if sign { - assert_eq!(res.header_counts().arcount(), 1, "Constructed response lacks a TSIG RR in the additional section"); + assert_eq!( + res.header_counts().arcount(), + 1, + "Constructed response lacks a TSIG RR in the additional section" + ); let rec = res.additional().unwrap().next().unwrap().unwrap(); assert_eq!(rec.rtype(), Rtype::TSIG); } diff --git a/src/net/client/validator.rs b/src/net/client/validator.rs index 5652b1934..aae296a2d 100644 --- a/src/net/client/validator.rs +++ b/src/net/client/validator.rs @@ -379,12 +379,11 @@ where Ok(response_msg) } else { // Set AD if it was set in the request. - let msg = remove_dnssec( + remove_dnssec( response_msg, self.request_msg.header().ad(), false, - ); - msg + ) } } ValidationState::Bogus => { diff --git a/src/net/client/validator_test.rs b/src/net/client/validator_test.rs index 286875967..5f9e5dd9c 100644 --- a/src/net/client/validator_test.rs +++ b/src/net/client/validator_test.rs @@ -10,11 +10,11 @@ use std::sync::Mutex; use std::time::Duration; use std::vec::Vec; -use crate::stelline::client::do_client_simple; use crate::stelline::client::CurrStepValue; +use crate::stelline::client::do_client_simple; use crate::stelline::connect::Connect; -use crate::stelline::parse_stelline::parse_file; use crate::stelline::parse_stelline::Config; +use crate::stelline::parse_stelline::parse_file; use mock_instant::thread_local::MockClock; use rstest::rstest; @@ -108,7 +108,9 @@ fn parse_server_config(config: &Config) -> TrustAnchors { ta.add_u8(a.trim_matches('"').as_bytes()).unwrap(); } _ => { - eprintln!("Ignoring unknown server setting '{setting}' with value: {value:?}"); + eprintln!( + "Ignoring unknown server setting '{setting}' with value: {value:?}" + ); } } } diff --git a/src/net/server/adapter.rs b/src/net/server/adapter.rs index 5a9c785d6..460770be4 100644 --- a/src/net/server/adapter.rs +++ b/src/net/server/adapter.rs @@ -15,16 +15,16 @@ use super::message::Request; use super::service::{CallResult, Service, ServiceError, ServiceResult}; use super::single_service::{ComposeReply, SingleService}; use super::util::mk_error_response; +use crate::base::StreamTarget; use crate::base::iana::{ExtendedErrorCode, OptRcode}; use crate::base::message_builder::AdditionalBuilder; use crate::base::opt::ExtendedError; -use crate::base::StreamTarget; use crate::dep::octseq::Octets; use crate::net::client::request::{RequestMessage, SendRequest}; -use futures_util::stream::{once, Once}; +use futures_util::stream::{Once, once}; use std::boxed::Box; use std::fmt::Debug; -use std::future::{ready, Future, Ready}; +use std::future::{Future, Ready, ready}; use std::marker::PhantomData; use std::pin::Pin; use std::string::ToString; diff --git a/src/net/server/batcher.rs b/src/net/server/batcher.rs index 78cfa8928..172740ee6 100644 --- a/src/net/server/batcher.rs +++ b/src/net/server/batcher.rs @@ -328,7 +328,9 @@ where /// Notes via trace logging if an in-progress answer is dropped. fn drop(&mut self) { if self.answer.is_some() { - trace!("Dropping unfinished batcher, was that intentional or did you forget to call finish()?"); + trace!( + "Dropping unfinished batcher, was that intentional or did you forget to call finish()?" + ); } } } @@ -389,8 +391,8 @@ mod tests { batcher.callback_state().assert_eq(0, 2, 2); } - fn mk_counting_batcher( - ) -> CallbackBatcher, Vec, BatchCounter, Arc> + fn mk_counting_batcher() + -> CallbackBatcher, Vec, BatchCounter, Arc> { let req = Arc::new(MessageBuilder::new_vec().into_message()); let cnt = Arc::new(TestCounters::new()); diff --git a/src/net/server/connection.rs b/src/net/server/connection.rs index f6926f0f0..020a96104 100644 --- a/src/net/server/connection.rs +++ b/src/net/server/connection.rs @@ -12,7 +12,7 @@ use std::net::SocketAddr; use std::sync::Arc; use arc_swap::ArcSwap; -use log::{log_enabled, Level}; +use log::{Level, log_enabled}; use octseq::Octets; use tokio::io::{ AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, ReadHalf, WriteHalf, @@ -33,10 +33,10 @@ use crate::net::server::service::Service; use crate::net::server::util::{mk_error_response, to_pcap_text}; use crate::utils::config::DefMinMax; +use super::ServerCommand; use super::invoker::{InvokerStatus, ServiceInvoker}; use super::message::{NonUdpTransportContext, TransportSpecificContext}; use super::stream::Config as ServerConfig; -use super::ServerCommand; /// Limit on the amount of time to allow between client requests. /// @@ -695,7 +695,9 @@ where // message is a query (0), or a response (1)." Ok(msg) if msg.header().qr() => { // TO DO: Count this event? - trace!("Ignoring received message because it is a reply, not a query."); + trace!( + "Ignoring received message because it is a reply, not a query." + ); let response = mk_error_response::( &msg, @@ -1083,13 +1085,17 @@ where Ok(()) => { let pending_writes = self.result_q_tx.max_capacity() - self.result_q_tx.capacity(); - trace!("Queued message for sending: # pending writes={pending_writes}"); + trace!( + "Queued message for sending: # pending writes={pending_writes}" + ); self.metrics.set_num_pending_writes(pending_writes); break; } Err(TrySendError::Closed(_)) => { - error!("Unable to queue message for sending: connection is shutting down."); + error!( + "Unable to queue message for sending: connection is shutting down." + ); break; } @@ -1099,7 +1105,9 @@ where tokio::task::yield_now().await; response = unused_response; } else { - error!("Unable to queue message for sending: queue is full."); + error!( + "Unable to queue message for sending: queue is full." + ); break; } } diff --git a/src/net/server/dgram.rs b/src/net/server/dgram.rs index 296b8f107..f21c5f279 100644 --- a/src/net/server/dgram.rs +++ b/src/net/server/dgram.rs @@ -10,8 +10,8 @@ //! //! [Datagram]: https://en.wikipedia.org/wiki/Datagram use core::fmt::Debug; -use core::future::poll_fn; use core::future::Future; +use core::future::poll_fn; use core::ops::Deref; use core::pin::Pin; use core::time::Duration; @@ -24,22 +24,22 @@ use std::string::ToString; use std::sync::{Arc, Mutex}; use arc_swap::ArcSwap; -use log::{log_enabled, Level}; +use log::{Level, log_enabled}; use octseq::Octets; use tokio::io::ReadBuf; use tokio::net::UdpSocket; use tokio::sync::watch; -use tokio::time::interval; -use tokio::time::timeout; use tokio::time::Instant; use tokio::time::MissedTickBehavior; +use tokio::time::interval; +use tokio::time::timeout; use tracing::{error, trace, warn}; +use crate::base::Message; +use crate::base::StreamTarget; use crate::base::iana::OptRcode; use crate::base::message_builder::AdditionalBuilder; use crate::base::wire::Composer; -use crate::base::Message; -use crate::base::StreamTarget; use crate::net::server::buf::BufSource; use crate::net::server::error::Error; use crate::net::server::message::Request; @@ -50,10 +50,10 @@ use crate::net::server::util::mk_error_response; use crate::net::server::util::to_pcap_text; use crate::utils::config::DefMinMax; +use super::ServerCommand; use super::buf::VecBufSource; use super::invoker::{InvokerStatus, ServiceInvoker}; use super::message::{TransportSpecificContext, UdpTransportContext}; -use super::ServerCommand; /// A UDP transport based DNS server transport. /// @@ -572,7 +572,9 @@ where // a query (0), or a response (1)." Ok(msg) if msg.header().qr() => { // TO DO: Count this event? - trace!("Ignoring received message because it is a reply, not a query."); + trace!( + "Ignoring received message because it is a reply, not a query." + ); let response = mk_error_response::( &msg, OptRcode::FORMERR, diff --git a/src/net/server/invoker.rs b/src/net/server/invoker.rs index 6715b61db..f52f796de 100644 --- a/src/net/server/invoker.rs +++ b/src/net/server/invoker.rs @@ -102,11 +102,15 @@ where } if matches!(self.status(), InvokerStatus::Aborting) { - trace!("Aborting response stream processing for request id {request_id}"); + trace!( + "Aborting response stream processing for request id {request_id}" + ); break; } } - trace!("Finished processing service call results for request id {request_id}"); + trace!( + "Finished processing service call results for request id {request_id}" + ); }) } diff --git a/src/net/server/middleware/cookies.rs b/src/net/server/middleware/cookies.rs index 75845fe93..7d9b1cbf4 100644 --- a/src/net/server/middleware/cookies.rs +++ b/src/net/server/middleware/cookies.rs @@ -1,11 +1,11 @@ //! RFC 7873 DNS Cookies related message processing. -use core::future::{ready, Ready}; +use core::future::{Ready, ready}; use core::marker::PhantomData; use core::ops::ControlFlow; use std::vec::Vec; -use futures_util::stream::{once, Once, Stream}; +use futures_util::stream::{Once, Stream, once}; use octseq::Octets; use rand::Rng; use tracing::{debug, error, trace, warn}; @@ -172,10 +172,14 @@ where let too_new_at = now.add(FIVE_MINUTES_AS_SECS); let expires_at = serial.add(ONE_HOUR_AS_SECS); if now > expires_at { - trace!("Invalid server cookie: cookie has expired ({now} > {expires_at})"); + trace!( + "Invalid server cookie: cookie has expired ({now} > {expires_at})" + ); false } else if serial > too_new_at { - trace!("Invalid server cookie: cookie is too new ({serial} > {too_new_at})"); + trace!( + "Invalid server cookie: cookie is too new ({serial} > {too_new_at})" + ); false } else { true @@ -298,7 +302,9 @@ where if request.transport_ctx().is_udp() && self.ip_deny_list.contains(&request.client_addr().ip()) { - debug!("Rejecting cookie-less non-TCP request due to matching deny list entry"); + debug!( + "Rejecting cookie-less non-TCP request due to matching deny list entry" + ); let builder = mk_builder_for_target(); let mut additional = builder.additional(); additional.header_mut().set_rcode(Rcode::REFUSED); @@ -414,14 +420,16 @@ where // and no Server Cookie, the response SHALL have // the RCODE NOERROR." trace!( - "Replying to DNS cookie pre-fetch request with missing server cookie"); + "Replying to DNS cookie pre-fetch request with missing server cookie" + ); self.prefetch_cookie_response(request) } else { // "In this case, the response SHALL have the // RCODE BADCOOKIE if the Server Cookie sent with // the query was invalid" debug!( - "Rejecting pre-fetch request due to invalid server cookie"); + "Rejecting pre-fetch request due to invalid server cookie" + ); self.bad_cookie_response(request) }; return ControlFlow::Break(additional); @@ -431,7 +439,9 @@ where .contains(&request.client_addr().ip()) { let additional = self.bad_cookie_response(request); - debug!("Rejecting non-TCP request with invalid server cookie due to matching deny list entry"); + debug!( + "Rejecting non-TCP request with invalid server cookie due to matching deny list entry" + ); return ControlFlow::Break(additional); } } else if request.message().header_counts().qdcount() == 0 { @@ -448,7 +458,8 @@ where // TODO: Does the TCP check also apply to RFC 7873 section // 5.4 "Querying for a Server Cookie" too? trace!( - "Replying to DNS cookie pre-fetch request with valid server cookie"); + "Replying to DNS cookie pre-fetch request with valid server cookie" + ); let additional = self.prefetch_cookie_response(request); return ControlFlow::Break(additional); } else { @@ -511,8 +522,8 @@ mod tests { use tokio::time::Instant; use tokio_stream::StreamExt; - use crate::base::opt::cookie::ClientCookie; use crate::base::opt::Cookie; + use crate::base::opt::cookie::ClientCookie; use crate::base::{Message, MessageBuilder, Name, Rtype}; use crate::net::server::message::{Request, UdpTransportContext}; use crate::net::server::middleware::cookies::CookiesMiddlewareSvc; diff --git a/src/net/server/middleware/edns.rs b/src/net/server/middleware/edns.rs index cef77a066..e2cf5732f 100644 --- a/src/net/server/middleware/edns.rs +++ b/src/net/server/middleware/edns.rs @@ -1,10 +1,10 @@ //! RFC 6891 and related EDNS message processing. -use core::future::{ready, Ready}; +use core::future::{Ready, ready}; use core::marker::PhantomData; use core::ops::ControlFlow; -use futures_util::stream::{once, Once, Stream}; -use log::{log_enabled, Level}; +use futures_util::stream::{Once, Stream, once}; +use log::{Level, log_enabled}; use octseq::Octets; use tracing::{debug, error, trace, warn}; @@ -113,7 +113,9 @@ where if let Some(opt) = iter.next() { if iter.next().is_some() { // More than one OPT RR received. - debug!("RFC 6891 6.1.1 violation: request contains more than one OPT RR."); + debug!( + "RFC 6891 6.1.1 violation: request contains more than one OPT RR." + ); return ControlFlow::Break(mk_error_response( request.message(), OptRcode::FORMERR, @@ -123,7 +125,9 @@ where let opt = match opt { Ok(opt) => opt, Err(err) => { - debug!("RFC 6891 violation: unable to parse OPT RR: {err}"); + debug!( + "RFC 6891 violation: unable to parse OPT RR: {err}" + ); return ControlFlow::Break(mk_error_response( request.message(), OptRcode::FORMERR, @@ -138,7 +142,10 @@ where // "If a responder does not implement the VERSION level of // the request, then it MUST respond with RCODE=BADVERS." if opt_rec.version() > EDNS_VERSION_ZERO { - debug!("RFC 6891 6.1.3 violation: request EDNS version {} > 0", opt_rec.version()); + debug!( + "RFC 6891 6.1.3 violation: request EDNS version {} > 0", + opt_rec.version() + ); return ControlFlow::Break(mk_error_response( request.message(), OptRcode::BADVERS, @@ -155,7 +162,9 @@ where if log_enabled!(Level::Debug) && opt_rec.opt().tcp_keepalive().is_some() { - debug!("RFC 7828 3.2.1 violation: ignoring edns-tcp-keepalive option received via UDP"); + debug!( + "RFC 7828 3.2.1 violation: ignoring edns-tcp-keepalive option received via UDP" + ); } // https://datatracker.ietf.org/doc/html/rfc6891#section-6.2.3 @@ -176,7 +185,9 @@ where && requestors_udp_payload_size < MINIMUM_RESPONSE_BYTE_LEN { - debug!("RFC 6891 6.2.3 violation: OPT RR class (requestor's UDP payload size) < {MINIMUM_RESPONSE_BYTE_LEN}"); + debug!( + "RFC 6891 6.2.3 violation: OPT RR class (requestor's UDP payload size) < {MINIMUM_RESPONSE_BYTE_LEN}" + ); } // Clamp the lower bound of the size limit requested @@ -212,8 +223,12 @@ where }; if log_enabled!(Level::Trace) { - trace!("EDNS(0) response size negotation concluded: client requested={}, server requested={:?}, chosen value={}", - opt_rec.udp_payload_size(), server_max_response_size_hint, negotiated_hint); + trace!( + "EDNS(0) response size negotation concluded: client requested={}, server requested={:?}, chosen value={}", + opt_rec.udp_payload_size(), + server_max_response_size_hint, + negotiated_hint + ); } ctx.set_max_response_size_hint(Some(negotiated_hint)); @@ -230,7 +245,9 @@ where opt_rec.opt().tcp_keepalive() { if keep_alive.timeout().is_some() { - debug!("RFC 7828 3.2.1 violation: edns-tcp-keepalive option received via TCP contains timeout"); + debug!( + "RFC 7828 3.2.1 violation: edns-tcp-keepalive option received via TCP contains timeout" + ); return ControlFlow::Break( mk_error_response( request.message(), @@ -316,12 +333,16 @@ where }, ) { - warn!("Cannot add RFC 7828 edns-tcp-keepalive option to response: {err}"); + warn!( + "Cannot add RFC 7828 edns-tcp-keepalive option to response: {err}" + ); } } Err(err) => { - warn!("Cannot add RFC 7828 edns-tcp-keepalive option to response: invalid timeout: {err}"); + warn!( + "Cannot add RFC 7828 edns-tcp-keepalive option to response: invalid timeout: {err}" + ); } } } diff --git a/src/net/server/middleware/mandatory.rs b/src/net/server/middleware/mandatory.rs index 5174090b9..51948a3a0 100644 --- a/src/net/server/middleware/mandatory.rs +++ b/src/net/server/middleware/mandatory.rs @@ -1,11 +1,11 @@ //! RFC 1034, 1035 and other "core" DNS RFC related message processing. -use core::future::{ready, Ready}; +use core::future::{Ready, ready}; use core::marker::PhantomData; use core::ops::ControlFlow; use std::fmt::Display; -use futures_util::stream::{once, Once, Stream}; +use futures_util::stream::{Once, Stream, once}; use octseq::Octets; use tracing::{debug, error, trace, warn}; @@ -178,7 +178,9 @@ where let mut target = target.additional(); if let Some(opt) = source.opt() { if let Err(err) = target.push(opt.as_record()) { - warn!("Error while truncating response: unable to push OPT record: {err}"); + warn!( + "Error while truncating response: unable to push OPT record: {err}" + ); // As the client had an OPT record and RFC 6891 says // when truncating that there MUST be an OPT record, // attempt to push just the empty OPT record (as the @@ -191,13 +193,17 @@ where .set_udp_payload_size(opt.udp_payload_size()); Ok(()) }) { - error!("Error while truncating response: unable to add minimal OPT record: {err}"); + error!( + "Error while truncating response: unable to add minimal OPT record: {err}" + ); } } } let new_len = target.as_slice().len(); - trace!("Truncating response from {old_len} bytes to {new_len} bytes"); + trace!( + "Truncating response from {old_len} bytes to {new_len} bytes" + ); *response = target; } @@ -291,7 +297,9 @@ where && !request.message().header_counts().qdcount() == response.counts().qdcount() { - warn!("RFC 1035 violation: response question count != request question count"); + warn!( + "RFC 1035 violation: response question count != request question count" + ); } } @@ -413,7 +421,7 @@ mod tests { use crate::net::server::service::{CallResult, Service, ServiceResult}; use crate::net::server::util::{mk_builder_for_target, service_fn}; - use super::{MandatoryMiddlewareSvc, MINIMUM_RESPONSE_BYTE_LEN}; + use super::{MINIMUM_RESPONSE_BYTE_LEN, MandatoryMiddlewareSvc}; //------------ Constants ------------------------------------------------- diff --git a/src/net/server/middleware/notify.rs b/src/net/server/middleware/notify.rs index a34d30f69..ff8ec6864 100644 --- a/src/net/server/middleware/notify.rs +++ b/src/net/server/middleware/notify.rs @@ -42,7 +42,7 @@ //! //! [RFC 1996]: https://www.rfc-editor.org/info/rfc1996 -use core::future::{ready, Future, Ready}; +use core::future::{Future, Ready, ready}; use core::marker::PhantomData; use core::ops::ControlFlow; use core::pin::Pin; @@ -52,7 +52,7 @@ use std::fmt::Debug; use std::sync::Arc; use bytes::Bytes; -use futures_util::stream::{once, Once, Stream}; +use futures_util::stream::{Once, Stream, once}; use octseq::Octets; use tracing::{error, info, warn}; @@ -225,7 +225,8 @@ where .await { Err(NotifyError::NotAuthForZone) => { - warn!("Ignoring NOTIFY from {} for zone '{}': Not authoritative for zone", + warn!( + "Ignoring NOTIFY from {} for zone '{}': Not authoritative for zone", req.client_addr(), q.qname() ); diff --git a/src/net/server/middleware/stream.rs b/src/net/server/middleware/stream.rs index 36042f968..07d69c5e3 100644 --- a/src/net/server/middleware/stream.rs +++ b/src/net/server/middleware/stream.rs @@ -27,7 +27,7 @@ //! [`Service`]: crate::net::server::service::Service use core::future::Future; use core::ops::DerefMut; -use core::task::{ready, Context, Poll}; +use core::task::{Context, Poll, ready}; use std::pin::Pin; diff --git a/src/net/server/middleware/tsig.rs b/src/net/server/middleware/tsig.rs index 20c7a78f6..4a9027004 100644 --- a/src/net/server/middleware/tsig.rs +++ b/src/net/server/middleware/tsig.rs @@ -31,7 +31,7 @@ //! Time Signed value."_. This is not implemented. use core::convert::Infallible; -use core::future::{ready, Ready}; +use core::future::{Ready, ready}; use core::marker::PhantomData; use core::ops::ControlFlow; @@ -53,8 +53,8 @@ use crate::rdata::tsig::Time48; use crate::tsig::{self, KeyStore, ServerSequence, ServerTransaction}; use super::stream::{MiddlewareStream, PostprocessingStream}; -use futures_util::stream::{once, Once}; use futures_util::Stream; +use futures_util::stream::{Once, once}; //------------ TsigMiddlewareSvc ---------------------------------------------- @@ -245,7 +245,7 @@ where signer.answer(response, Time48::now()) } - Some(TsigSigner::Sequence(ref mut signer)) => { + Some(TsigSigner::Sequence(signer)) => { // Use the multi-response signer to sign the response. trace!( "Signing response stream with TSIG key '{}'", @@ -325,12 +325,16 @@ where Time48::now(), ) { Ok(None) => { - error!("Unable to create signer for truncated TSIG response: internal error: request is not signed but was expected to be"); + error!( + "Unable to create signer for truncated TSIG response: internal error: request is not signed but was expected to be" + ); Err(ServiceError::InternalError) } Err(err) => { - error!("Unable to create signer for truncated TSIG response: {err}"); + error!( + "Unable to create signer for truncated TSIG response: {err}" + ); Err(ServiceError::InternalError) } @@ -338,7 +342,9 @@ where if let Err(err) = signer.answer(&mut additional, Time48::now()) { - error!("Unable to sign truncated TSIG response: {err}"); + error!( + "Unable to sign truncated TSIG response: {err}" + ); Err(ServiceError::InternalError) } else { Ok(additional) diff --git a/src/net/server/middleware/xfr/axfr.rs b/src/net/server/middleware/xfr/axfr.rs index 8f8f640e4..8135661ec 100644 --- a/src/net/server/middleware/xfr/axfr.rs +++ b/src/net/server/middleware/xfr/axfr.rs @@ -2,8 +2,8 @@ use std::boxed::Box; use std::sync::Arc; use bytes::Bytes; -use tokio::sync::mpsc::Sender; use tokio::sync::Semaphore; +use tokio::sync::mpsc::Sender; use tracing::error; use crate::base::iana::OptRcode; @@ -41,7 +41,9 @@ impl ZoneFunneler { // Limit the number of concurrently running XFR related zone walking // operations. if self.zone_walk_semaphore.acquire().await.is_err() { - error!("Internal error: Failed to acquire XFR zone walking semaphore"); + error!( + "Internal error: Failed to acquire XFR zone walking semaphore" + ); return Err(OptRcode::SERVFAIL); } @@ -75,7 +77,9 @@ impl ZoneFunneler { .send((self.qname, self.zone_soa_rrset)) .await { - error!("Internal error: Failed to send final AXFR SOA to batcher: {err}"); + error!( + "Internal error: Failed to send final AXFR SOA to batcher: {err}" + ); return Err(OptRcode::SERVFAIL); } } @@ -86,7 +90,9 @@ impl ZoneFunneler { .batcher_tx .blocking_send((self.qname, self.zone_soa_rrset)) { - error!("Internal error: Failed to send final AXFR SOA to batcher: {err}"); + error!( + "Internal error: Failed to send final AXFR SOA to batcher: {err}" + ); // Note: The lack of the final SOA will be detected by the batcher. } }); diff --git a/src/net/server/middleware/xfr/batcher.rs b/src/net/server/middleware/xfr/batcher.rs index ae83d5d67..fead9d30a 100644 --- a/src/net/server/middleware/xfr/batcher.rs +++ b/src/net/server/middleware/xfr/batcher.rs @@ -187,7 +187,8 @@ where let ancount = answer.counts().ancount(); let limit_reached = ancount == hard_rr_limit; trace!( - "ancount={ancount}, hard_rr_limit={hard_rr_limit}, limit_reached={limit_reached}"); + "ancount={ancount}, hard_rr_limit={hard_rr_limit}, limit_reached={limit_reached}" + ); limit_reached } else { false diff --git a/src/net/server/middleware/xfr/data_provider.rs b/src/net/server/middleware/xfr/data_provider.rs index a274da5d8..fa16591c0 100644 --- a/src/net/server/middleware/xfr/data_provider.rs +++ b/src/net/server/middleware/xfr/data_provider.rs @@ -1,4 +1,4 @@ -use core::future::{ready, Future}; +use core::future::{Future, ready}; use core::ops::Deref; use core::pin::Pin; @@ -7,8 +7,8 @@ use octseq::Octets; use std::boxed::Box; use std::vec::Vec; -use crate::base::wire::ParseError; use crate::base::Serial; +use crate::base::wire::ParseError; use crate::net::server::message::Request; use crate::zonetree::types::EmptyZoneDiff; use crate::zonetree::{Zone, ZoneDiff, ZoneTree}; diff --git a/src/net/server/middleware/xfr/ixfr.rs b/src/net/server/middleware/xfr/ixfr.rs index 26361ba92..ec9fab74d 100644 --- a/src/net/server/middleware/xfr/ixfr.rs +++ b/src/net/server/middleware/xfr/ixfr.rs @@ -1,7 +1,7 @@ use std::vec::Vec; use bytes::Bytes; -use futures_util::{pin_mut, StreamExt}; +use futures_util::{StreamExt, pin_mut}; use tokio::sync::mpsc::Sender; use tracing::error; @@ -67,7 +67,9 @@ where .send((self.qname.clone(), self.zone_soa_rrset.clone())) .await { - error!("Internal error: Failed to send initial IXFR SOA to batcher: {err}"); + error!( + "Internal error: Failed to send initial IXFR SOA to batcher: {err}" + ); return Err(OptRcode::SERVFAIL); } @@ -107,7 +109,9 @@ where .send((qname.clone(), self.zone_soa_rrset)) .await { - error!("Internal error: Failed to send final IXFR SOA to batcher: {err}"); + error!( + "Internal error: Failed to send final IXFR SOA to batcher: {err}" + ); return Err(OptRcode::SERVFAIL); } @@ -135,7 +139,9 @@ where if let Err(err) = batcher_tx.send((owner.clone(), rrset.clone())).await { - error!("Internal error: Failed to send RRSET to batcher: {err}"); + error!( + "Internal error: Failed to send RRSET to batcher: {err}" + ); return Err(OptRcode::SERVFAIL); } } diff --git a/src/net/server/middleware/xfr/responder.rs b/src/net/server/middleware/xfr/responder.rs index 3b0f64b97..7b458881e 100644 --- a/src/net/server/middleware/xfr/responder.rs +++ b/src/net/server/middleware/xfr/responder.rs @@ -2,8 +2,8 @@ use std::sync::Arc; use bytes::Bytes; use octseq::Octets; -use tokio::sync::mpsc::{Receiver, UnboundedSender}; use tokio::sync::Semaphore; +use tokio::sync::mpsc::{Receiver, UnboundedSender}; use tracing::{debug, error}; use crate::base::iana::OptRcode; @@ -116,7 +116,9 @@ where // to inform the client that a TCP query // should be initiated." debug_assert!(self.must_fit_in_single_message); - debug!("Responding to IXFR with single SOA because response does not fit in a single UDP reply"); + debug!( + "Responding to IXFR with single SOA because response does not fit in a single UDP reply" + ); let builder = mk_builder_for_target(); @@ -130,12 +132,16 @@ where } BatchReadyError::PushError(err) => { - error!("Internal error: Failed to send RR to batcher: {err}"); + error!( + "Internal error: Failed to send RR to batcher: {err}" + ); return Err(OptRcode::SERVFAIL); } BatchReadyError::SendError => { - debug!("Batcher was unable to send completed batch. Was the receiver dropped?"); + debug!( + "Batcher was unable to send completed batch. Was the receiver dropped?" + ); return Err(OptRcode::SERVFAIL); } } diff --git a/src/net/server/middleware/xfr/service.rs b/src/net/server/middleware/xfr/service.rs index bb05cff4e..81e82d42f 100644 --- a/src/net/server/middleware/xfr/service.rs +++ b/src/net/server/middleware/xfr/service.rs @@ -1,4 +1,4 @@ -use core::future::{ready, Future, Ready}; +use core::future::{Future, Ready, ready}; use core::marker::PhantomData; use core::ops::ControlFlow; @@ -8,10 +8,10 @@ use std::pin::Pin; use std::sync::Arc; use std::vec::Vec; -use futures_util::stream::{once, Once, Stream}; +use futures_util::stream::{Once, Stream, once}; use octseq::Octets; -use tokio::sync::mpsc::unbounded_channel; use tokio::sync::Semaphore; +use tokio::sync::mpsc::unbounded_channel; use tokio_stream::wrappers::UnboundedReceiverStream; use tracing::{debug, error, info, trace, warn}; @@ -567,7 +567,9 @@ where // Errata https://www.rfc-editor.org/errata/eid3196 points out that // this is NOT "just as in AXFR" as AXFR does not do that. if query_serial >= soa.serial() { - trace!("Responding to IXFR with single SOA because query serial >= zone serial"); + trace!( + "Responding to IXFR with single SOA because query serial >= zone serial" + ); let builder = mk_builder_for_target(); let response = zone_soa_answer.to_message(msg, builder); let res = Ok(CallResult::new(response)); diff --git a/src/net/server/middleware/xfr/tests.rs b/src/net/server/middleware/xfr/tests.rs index 79beff5d6..55c33f5c9 100644 --- a/src/net/server/middleware/xfr/tests.rs +++ b/src/net/server/middleware/xfr/tests.rs @@ -1,4 +1,4 @@ -use core::future::{ready, Future, Ready}; +use core::future::{Future, Ready, ready}; use core::ops::ControlFlow; use core::pin::Pin; use core::str::FromStr; @@ -34,7 +34,7 @@ use crate::net::server::service::{ CallResult, Service, ServiceError, ServiceFeedback, ServiceResult, }; use crate::rdata::{ - Aaaa, AllRecordData, Cname, Ds, Mx, Ns, Soa, Txt, ZoneRecordData, A, + A, Aaaa, AllRecordData, Cname, Ds, Mx, Ns, Soa, Txt, ZoneRecordData, }; use crate::tsig::{Algorithm, Key, KeyName}; use crate::zonefile::inplace::Zonefile; diff --git a/src/net/server/qname_router.rs b/src/net/server/qname_router.rs index 46c2660e2..9915d3bd3 100644 --- a/src/net/server/qname_router.rs +++ b/src/net/server/qname_router.rs @@ -7,15 +7,15 @@ use super::message::Request; use super::service::ServiceError; use super::single_service::{ComposeReply, SingleService}; use super::util::mk_error_response; +use crate::base::StreamTarget; use crate::base::iana::{ExtendedErrorCode, OptRcode}; use crate::base::message_builder::AdditionalBuilder; use crate::base::opt::ExtendedError; -use crate::base::StreamTarget; use crate::base::{Name, ToName}; use crate::dep::octseq::{EmptyBuilder, FromBuilder, Octets, OctetsBuilder}; use std::boxed::Box; use std::convert::Infallible; -use std::future::{ready, Future}; +use std::future::{Future, ready}; use std::pin::Pin; use std::vec::Vec; use tracing::trace; diff --git a/src/net/server/service.rs b/src/net/server/service.rs index 5561f6dd5..941ebea88 100644 --- a/src/net/server/service.rs +++ b/src/net/server/service.rs @@ -8,10 +8,10 @@ use core::ops::Deref; use std::time::Duration; +use crate::base::StreamTarget; use crate::base::iana::Rcode; use crate::base::message_builder::{AdditionalBuilder, PushError}; use crate::base::wire::{Composer, ParseError}; -use crate::base::StreamTarget; use super::message::Request; diff --git a/src/net/server/sock.rs b/src/net/server/sock.rs index bbc7f8019..3815b1fbc 100644 --- a/src/net/server/sock.rs +++ b/src/net/server/sock.rs @@ -128,9 +128,7 @@ pub trait AsyncAccept { type StreamType; /// The type of [`std::future::Future`] that the trait impl returns. - type Future: std::future::Future< - Output = Result, - >; + type Future: std::future::Future>; /// Polls to accept a new incoming connection to this listener. /// diff --git a/src/net/server/stream.rs b/src/net/server/stream.rs index 8749bf1d5..0bf401c99 100644 --- a/src/net/server/stream.rs +++ b/src/net/server/stream.rs @@ -29,7 +29,7 @@ use octseq::Octets; use tokio::io::{AsyncRead, AsyncWrite}; use tokio::net::TcpListener; use tokio::sync::watch; -use tokio::time::{interval, timeout, MissedTickBehavior}; +use tokio::time::{MissedTickBehavior, interval, timeout}; use tracing::{error, trace, trace_span, warn}; use crate::net::server::buf::BufSource; @@ -39,9 +39,9 @@ use crate::net::server::service::Service; use crate::net::server::sock::AsyncAccept; use crate::utils::config::DefMinMax; +use super::ServerCommand; use super::buf::VecBufSource; use super::connection::{self, Connection}; -use super::ServerCommand; // TODO: Should this crate also provide a TLS listener implementation? diff --git a/src/net/server/tests/integration.rs b/src/net/server/tests/integration.rs index 9360559df..1e363e092 100644 --- a/src/net/server/tests/integration.rs +++ b/src/net/server/tests/integration.rs @@ -1,4 +1,4 @@ -use core::future::{ready, Future}; +use core::future::{Future, ready}; use core::ops::Deref; use core::pin::Pin; use core::str::FromStr; @@ -18,12 +18,12 @@ use rstest::rstest; use tracing::instrument; use tracing::{trace, warn}; -use crate::base::iana::{Class, Rcode}; -use crate::base::name::ToName; -use crate::base::net::IpAddr; use crate::base::Name; use crate::base::Rtype; use crate::base::Serial; +use crate::base::iana::{Class, Rcode}; +use crate::base::name::ToName; +use crate::base::net::IpAddr; use crate::logging::init_logging; use crate::net::client::request::{RequestMessage, RequestMessageMulti}; use crate::net::client::{dgram, stream, tsig}; @@ -44,10 +44,10 @@ use crate::net::server::stream::StreamServer; use crate::net::server::util::{mk_builder_for_target, service_fn}; use crate::stelline::channel::ClientServerChannel; use crate::stelline::client::{ - do_client, Client, ClientFactory, CurrStepValue, - PerClientAddressClientFactory, QueryTailoredClientFactory, + Client, ClientFactory, CurrStepValue, PerClientAddressClientFactory, + QueryTailoredClientFactory, do_client, }; -use crate::stelline::parse_stelline::{self, parse_file, Config, Matches}; +use crate::stelline::parse_stelline::{self, Config, Matches, parse_file}; use crate::stelline::simple_dgram_client; use crate::tsig::{Algorithm, Key, KeyName, KeyStore}; use crate::utils::base16; @@ -493,12 +493,16 @@ fn parse_server_config(config: &Config) -> ServerConfig<'_> { .ip_deny_list .push(ip); } else { - eprintln!("Ignoring malformed IP address '{ip}' in 'access-control' setting"); + eprintln!( + "Ignoring malformed IP address '{ip}' in 'access-control' setting" + ); } } _ => { - eprintln!("Ignoring unknown action '{action}' for 'access-control' setting"); + eprintln!( + "Ignoring unknown action '{action}' for 'access-control' setting" + ); } } } @@ -533,7 +537,9 @@ fn parse_server_config(config: &Config) -> ServerConfig<'_> { zone_name = Some(v.to_string()); } _ => { - eprintln!("Ignoring unknown server setting '{setting}' with value: {value:?}"); + eprintln!( + "Ignoring unknown server setting '{setting}' with value: {value:?}" + ); } } } @@ -569,7 +575,9 @@ impl Notifiable for TestNotifyTarget { ) -> Pin< Box> + Sync + Send + '_>, > { - trace!("Notify received from {source} of change to zone {apex_name} in class {class} with serial {serial:?}"); + trace!( + "Notify received from {source} of change to zone {apex_name} in class {class} with serial {serial:?}" + ); let res = match apex_name.to_string().to_lowercase().as_str() { "example.com" => Ok(()), diff --git a/src/net/server/tests/unit.rs b/src/net/server/tests/unit.rs index 17def6ef3..d4ccbdcd6 100644 --- a/src/net/server/tests/unit.rs +++ b/src/net/server/tests/unit.rs @@ -1,4 +1,4 @@ -use core::future::{ready, Ready}; +use core::future::{Ready, ready}; use core::pin::Pin; use core::str::FromStr; use core::sync::atomic::{AtomicBool, Ordering}; @@ -12,8 +12,8 @@ use std::sync::{Arc, Mutex}; use std::vec::Vec; use tokio::io::{AsyncRead, AsyncWrite}; -use tokio::time::sleep; use tokio::time::Instant; +use tokio::time::sleep; use tracing::trace; use crate::base::MessageBuilder; diff --git a/src/net/server/util.rs b/src/net/server/util.rs index 56fba3412..b42182443 100644 --- a/src/net/server/util.rs +++ b/src/net/server/util.rs @@ -1,5 +1,5 @@ //! Small utilities for building and working with servers. -use core::future::{ready, Ready}; +use core::future::{Ready, ready}; use core::marker::PhantomData; use std::string::{String, ToString}; @@ -8,12 +8,12 @@ use futures_util::stream::Once; use octseq::{Octets, OctetsBuilder}; use tracing::warn; +use crate::base::Message; use crate::base::iana::OptRcode; use crate::base::message_builder::{ AdditionalBuilder, OptBuilder, PushError, }; use crate::base::wire::Composer; -use crate::base::Message; use crate::base::{MessageBuilder, ParsedName, Rtype, StreamTarget}; use crate::rdata::AllRecordData; use crate::utils::base16; @@ -256,7 +256,9 @@ where let copied_response = response.as_slice().to_vec(); let Ok(copied_response) = Message::from_octets(&copied_response) else { - warn!("Internal error: Unable to create message from octets while adding EDNS option"); + warn!( + "Internal error: Unable to create message from octets while adding EDNS option" + ); return Ok(()); }; @@ -312,7 +314,9 @@ where let copied_response = response.as_slice().to_vec(); let Ok(copied_response) = Message::from_octets(&copied_response) else { - warn!("Internal error: Unable to create message from octets while adding EDNS option"); + warn!( + "Internal error: Unable to create message from octets while adding EDNS option" + ); return Ok(()); }; diff --git a/src/net/xfr/protocol/interpreter.rs b/src/net/xfr/protocol/interpreter.rs index 693e7cd8f..1507b5a67 100644 --- a/src/net/xfr/protocol/interpreter.rs +++ b/src/net/xfr/protocol/interpreter.rs @@ -7,9 +7,9 @@ use crate::base::{Message, ParsedName, Rtype}; use crate::rdata::{Soa, ZoneRecordData}; use crate::zonetree::types::ZoneUpdate; +use super::IterationError; use super::iterator::XfrZoneUpdateIterator; use super::types::{Error, IxfrUpdateMode, ParsedRecord, XfrType}; -use super::IterationError; //------------ XfrResponseInterpreter ----------------------------------------- diff --git a/src/net/xfr/protocol/tests.rs b/src/net/xfr/protocol/tests.rs index 760cf8cec..73c5e3373 100644 --- a/src/net/xfr/protocol/tests.rs +++ b/src/net/xfr/protocol/tests.rs @@ -16,7 +16,7 @@ use crate::base::{ }; use crate::base::{Name, ToName}; use crate::logging::init_logging; -use crate::rdata::{Aaaa, Soa, ZoneRecordData, A}; +use crate::rdata::{A, Aaaa, Soa, ZoneRecordData}; use crate::zonetree::types::{ZoneUpdate, ZoneUpdate as ZU}; use super::interpreter::XfrResponseInterpreter; diff --git a/src/net/xfr/protocol/types.rs b/src/net/xfr/protocol/types.rs index 1c8712344..a68c16f28 100644 --- a/src/net/xfr/protocol/types.rs +++ b/src/net/xfr/protocol/types.rs @@ -5,7 +5,7 @@ use bytes::Bytes; use crate::{ - base::{wire::ParseError, ParsedName, Record, Rtype}, + base::{ParsedName, Record, Rtype, wire::ParseError}, rdata::ZoneRecordData, }; diff --git a/src/new/base/build/message.rs b/src/new/base/build/message.rs index 37fedd70c..82a91e901 100644 --- a/src/new/base/build/message.rs +++ b/src/new/base/build/message.rs @@ -4,9 +4,9 @@ use core::fmt; use crate::{ new::base::{ - wire::{ParseBytesZC, U16}, Header, HeaderFlags, Message, MessageItem, Question, Record, SectionCounts, + wire::{ParseBytesZC, U16}, }, new::edns::EdnsRecord, }; @@ -339,7 +339,7 @@ mod test { use crate::new::base::{ HeaderFlags, QClass, QType, Question, RClass, RType, Record, TTL, }; - use crate::new::rdata::{RecordData, A}; + use crate::new::rdata::{A, RecordData}; use super::{MessageBuilder, NameCompressor}; diff --git a/src/new/base/charstr.rs b/src/new/base/charstr.rs index a044a7fe1..206bf016b 100644 --- a/src/new/base/charstr.rs +++ b/src/new/base/charstr.rs @@ -39,7 +39,7 @@ impl CharStr { pub const unsafe fn from_bytes_unchecked(bytes: &[u8]) -> &Self { // SAFETY: 'CharStr' is 'repr(transparent)' to '[u8]', so casting a // '[u8]' into a 'CharStr' is sound. - core::mem::transmute(bytes) + unsafe { core::mem::transmute(bytes) } } /// Assume a mutable byte sequence is a valid [`CharStr`]. @@ -51,7 +51,7 @@ impl CharStr { pub unsafe fn from_bytes_unchecked_mut(bytes: &mut [u8]) -> &mut Self { // SAFETY: 'CharStr' is 'repr(transparent)' to '[u8]', so casting a // '[u8]' into a 'CharStr' is sound. - core::mem::transmute(bytes) + unsafe { core::mem::transmute(bytes) } } } diff --git a/src/new/base/mod.rs b/src/new/base/mod.rs index 63a62ddaf..af5a3dc0d 100644 --- a/src/new/base/mod.rs +++ b/src/new/base/mod.rs @@ -190,7 +190,7 @@ pub use question::{QClass, QType, Question}; mod record; pub use record::{ CanonicalRecordData, ParseRecordData, ParseRecordDataBytes, RClass, - RType, Record, UnparsedRecordData, TTL, + RType, Record, TTL, UnparsedRecordData, }; //--- Elements of DNS messages diff --git a/src/new/base/name/absolute.rs b/src/new/base/name/absolute.rs index 52360516b..11f1a5536 100644 --- a/src/new/base/name/absolute.rs +++ b/src/new/base/name/absolute.rs @@ -59,7 +59,7 @@ impl Name { pub const unsafe fn from_bytes_unchecked(bytes: &[u8]) -> &Self { // SAFETY: 'Name' is 'repr(transparent)' to '[u8]', so casting a // '[u8]' into a 'Name' is sound. - core::mem::transmute(bytes) + unsafe { core::mem::transmute(bytes) } } /// Assume a mutable byte sequence is a valid [`Name`]. @@ -72,7 +72,7 @@ impl Name { pub unsafe fn from_bytes_unchecked_mut(bytes: &mut [u8]) -> &mut Self { // SAFETY: 'Name' is 'repr(transparent)' to '[u8]', so casting a // '[u8]' into a 'Name' is sound. - core::mem::transmute(bytes) + unsafe { core::mem::transmute(bytes) } } } diff --git a/src/new/base/name/reversed.rs b/src/new/base/name/reversed.rs index e06fddd6b..eb5e79654 100644 --- a/src/new/base/name/reversed.rs +++ b/src/new/base/name/reversed.rs @@ -63,7 +63,7 @@ impl RevName { pub const unsafe fn from_bytes_unchecked(bytes: &[u8]) -> &Self { // SAFETY: 'RevName' is 'repr(transparent)' to '[u8]', so casting a // '[u8]' into a 'RevName' is sound. - core::mem::transmute(bytes) + unsafe { core::mem::transmute(bytes) } } /// Assume a mutable byte sequence is a valid [`RevName`]. @@ -76,7 +76,7 @@ impl RevName { pub unsafe fn from_bytes_unchecked_mut(bytes: &mut [u8]) -> &mut Self { // SAFETY: 'RevName' is 'repr(transparent)' to '[u8]', so casting a // '[u8]' into a 'RevName' is sound. - core::mem::transmute(bytes) + unsafe { core::mem::transmute(bytes) } } } diff --git a/src/new/base/name/unparsed.rs b/src/new/base/name/unparsed.rs index d8ce92806..9b45d1af0 100644 --- a/src/new/base/name/unparsed.rs +++ b/src/new/base/name/unparsed.rs @@ -52,7 +52,7 @@ impl UnparsedName { pub const unsafe fn from_bytes_unchecked(bytes: &[u8]) -> &Self { // SAFETY: 'UnparsedName' is 'repr(transparent)' to '[u8]', so casting // a '[u8]' into an 'UnparsedName' is sound. - core::mem::transmute(bytes) + unsafe { core::mem::transmute(bytes) } } /// Assume a mutable byte sequence is a valid [`UnparsedName`]. @@ -65,7 +65,7 @@ impl UnparsedName { pub unsafe fn from_bytes_unchecked_mut(bytes: &mut [u8]) -> &mut Self { // SAFETY: 'UnparsedName' is 'repr(transparent)' to '[u8]', so casting // a '[u8]' into an 'UnparsedName' is sound. - core::mem::transmute(bytes) + unsafe { core::mem::transmute(bytes) } } } diff --git a/src/new/base/parse/message.rs b/src/new/base/parse/message.rs index b2e76d0f0..0f2a02fd9 100644 --- a/src/new/base/parse/message.rs +++ b/src/new/base/parse/message.rs @@ -4,8 +4,8 @@ use core::iter::FusedIterator; use crate::new::{ base::{ - name::{NameBuf, RevNameBuf}, Header, Message, MessageItem, + name::{NameBuf, RevNameBuf}, }, rdata::{Opt, RecordData}, }; diff --git a/src/new/base/record.rs b/src/new/base/record.rs index 8c9bceb29..d7ad702f6 100644 --- a/src/new/base/record.rs +++ b/src/new/base/record.rs @@ -624,7 +624,7 @@ impl UnparsedRecordData { pub const unsafe fn new_unchecked(bytes: &[u8]) -> &Self { // SAFETY: 'UnparsedRecordData' is 'repr(transparent)' to '[u8]', so // casting a '[u8]' into an 'UnparsedRecordData' is sound. - core::mem::transmute(bytes) + unsafe { core::mem::transmute(bytes) } } } @@ -700,7 +700,7 @@ impl Clone for alloc::boxed::Box { #[cfg(test)] mod test { - use super::{RClass, RType, Record, UnparsedRecordData, TTL}; + use super::{RClass, RType, Record, TTL, UnparsedRecordData}; use crate::new::base::{ name::Name, diff --git a/src/new/base/wire/parse.rs b/src/new/base/wire/parse.rs index 55a96783b..6da8a278f 100644 --- a/src/new/base/wire/parse.rs +++ b/src/new/base/wire/parse.rs @@ -399,7 +399,7 @@ pub unsafe trait SplitBytesZC: ParseBytesZC { /// - `bytes.len() == core::mem::size_of_val(this) + rest.len()`. /// - `bytes.as_ptr().offset(size_of_val(this)) == rest.as_ptr()`. fn split_bytes_by_ref(bytes: &[u8]) - -> Result<(&Self, &[u8]), ParseError>; + -> Result<(&Self, &[u8]), ParseError>; } unsafe impl SplitBytesZC for u8 { diff --git a/src/new/edns/cookie.rs b/src/new/edns/cookie.rs index 5c3a3acd2..b86e584a0 100644 --- a/src/new/edns/cookie.rs +++ b/src/new/edns/cookie.rs @@ -14,11 +14,11 @@ use core::ops::Range; use crate::{ new::base::{ + Serial, wire::{ AsBytes, BuildBytes, ParseBytes, ParseBytesZC, SplitBytes, SplitBytesZC, }, - Serial, }, utils::dst::UnsizedCopy, }; diff --git a/src/new/rdata/basic/soa.rs b/src/new/rdata/basic/soa.rs index 7a77ca2ae..5c2a03ae9 100644 --- a/src/new/rdata/basic/soa.rs +++ b/src/new/rdata/basic/soa.rs @@ -6,8 +6,8 @@ use crate::new::base::build::{BuildInMessage, NameCompressor}; use crate::new::base::name::CanonicalName; use crate::new::base::parse::{ParseMessageBytes, SplitMessageBytes}; use crate::new::base::{ - wire::*, CanonicalRecordData, ParseRecordData, ParseRecordDataBytes, - RType, Serial, + CanonicalRecordData, ParseRecordData, ParseRecordDataBytes, RType, + Serial, wire::*, }; //----------- Soa ------------------------------------------------------------ diff --git a/src/new/rdata/dnssec/dnskey.rs b/src/new/rdata/dnssec/dnskey.rs index 65ca58e70..1a97c411c 100644 --- a/src/new/rdata/dnssec/dnskey.rs +++ b/src/new/rdata/dnssec/dnskey.rs @@ -8,13 +8,13 @@ use core::{ use crate::{ new::base::{ + CanonicalRecordData, build::BuildInMessage, name::NameCompressor, wire::{ AsBytes, BuildBytes, ParseBytes, ParseBytesZC, SplitBytes, SplitBytesZC, TruncationError, U16, }, - CanonicalRecordData, }, utils::dst::UnsizedCopy, }; diff --git a/src/new/rdata/dnssec/ds.rs b/src/new/rdata/dnssec/ds.rs index 3d43ee990..1a142d098 100644 --- a/src/new/rdata/dnssec/ds.rs +++ b/src/new/rdata/dnssec/ds.rs @@ -5,11 +5,11 @@ use core::{cmp::Ordering, fmt}; use domain_macros::*; +use crate::new::base::CanonicalRecordData; use crate::new::base::build::{ BuildInMessage, NameCompressor, TruncationError, }; use crate::new::base::wire::{AsBytes, U16}; -use crate::new::base::CanonicalRecordData; use super::SecAlg; diff --git a/src/new/rdata/dnssec/nsec3.rs b/src/new/rdata/dnssec/nsec3.rs index 3c2005b7c..3190b4c1f 100644 --- a/src/new/rdata/dnssec/nsec3.rs +++ b/src/new/rdata/dnssec/nsec3.rs @@ -10,10 +10,10 @@ use domain_macros::*; use crate::{ new::base::{ + CanonicalRecordData, build::BuildInMessage, name::NameCompressor, wire::{AsBytes, BuildBytes, SizePrefixed, TruncationError, U16}, - CanonicalRecordData, }, utils::dst::UnsizedCopy, }; diff --git a/src/new/rdata/mod.rs b/src/new/rdata/mod.rs index d66d37306..a1b4b5a21 100644 --- a/src/new/rdata/mod.rs +++ b/src/new/rdata/mod.rs @@ -80,6 +80,7 @@ use alloc::boxed::Box; use crate::{ new::base::{ + CanonicalRecordData, ParseRecordData, ParseRecordDataBytes, RType, build::{BuildInMessage, NameCompressor}, name::CanonicalName, parse::{ParseMessageBytes, SplitMessageBytes}, @@ -87,7 +88,6 @@ use crate::{ AsBytes, BuildBytes, ParseBytes, ParseError, SplitBytes, TruncationError, }, - CanonicalRecordData, ParseRecordData, ParseRecordDataBytes, RType, }, utils::dst::UnsizedCopy, }; @@ -98,7 +98,7 @@ use crate::new::base::name::{Name, NameBuf}; //----------- Concrete record data types ------------------------------------- mod basic; -pub use basic::{CName, HInfo, Mx, Ns, Ptr, Soa, Txt, A}; +pub use basic::{A, CName, HInfo, Mx, Ns, Ptr, Soa, Txt}; mod dname; pub use dname::DName; diff --git a/src/new/rdata/rp.rs b/src/new/rdata/rp.rs index 8784a4162..8824cdf68 100644 --- a/src/new/rdata/rp.rs +++ b/src/new/rdata/rp.rs @@ -8,8 +8,8 @@ use crate::new::base::build::{BuildInMessage, NameCompressor}; use crate::new::base::name::CanonicalName; use crate::new::base::parse::{ParseMessageBytes, SplitMessageBytes}; use crate::new::base::{ - wire::*, CanonicalRecordData, ParseRecordData, ParseRecordDataBytes, - RType, + CanonicalRecordData, ParseRecordData, ParseRecordDataBytes, RType, + wire::*, }; //----------- Rp ------------------------------------------------------------- diff --git a/src/new/rdata/zonemd.rs b/src/new/rdata/zonemd.rs index 4775078d7..cf12f583e 100644 --- a/src/new/rdata/zonemd.rs +++ b/src/new/rdata/zonemd.rs @@ -6,14 +6,14 @@ use core::{cmp::Ordering, fmt}; use crate::{ new::base::{ + CanonicalRecordData, ParseRecordData, ParseRecordDataBytes, RType, + Serial, build::BuildInMessage, name::NameCompressor, wire::{ AsBytes, BuildBytes, ParseBytes, ParseBytesZC, ParseError, SplitBytes, SplitBytesZC, TruncationError, }, - CanonicalRecordData, ParseRecordData, ParseRecordDataBytes, RType, - Serial, }, utils::dst::UnsizedCopy, }; diff --git a/src/rdata/caa.rs b/src/rdata/caa.rs index 4e79b5d0e..b6a750915 100644 --- a/src/rdata/caa.rs +++ b/src/rdata/caa.rs @@ -5,22 +5,22 @@ //! [RFC 8659]: https://www.rfc-editor.org/info/rfc8659 use crate::base::{ + CanonicalOrd, CharStr, ParseRecordData, RecordData, Rtype, charstr::DisplayQuoted, name::FlattenInto, rdata::ComposeRecordData, scan::{Scan, Scanner, ScannerError}, wire::{Compose, Parse, ParseError}, zonefile_fmt::{self, Formatter, ZonefileFmt}, - CanonicalOrd, CharStr, ParseRecordData, RecordData, Rtype, }; use core::{cmp::Ordering, fmt, hash}; +use octseq::{Octets, OctetsBuilder, OctetsFrom, OctetsInto, Parser}; #[cfg(feature = "serde")] use octseq::{ builder::{EmptyBuilder, FromBuilder}, serde::DeserializeOctets, serde::SerializeOctets, }; -use octseq::{Octets, OctetsBuilder, OctetsFrom, OctetsInto, Parser}; //------------ Caa --------------------------------------------------------- @@ -389,7 +389,7 @@ impl CaaTag { /// The caller must ensure `octets` consists only of ASCII alphanumeric /// characters and is no longer than 255 octets, as required by RFC 8659. pub unsafe fn from_octets_unchecked(octets: Octs) -> Self { - CaaTag(CharStr::from_octets_unchecked(octets)) + CaaTag(unsafe { CharStr::from_octets_unchecked(octets) }) } } @@ -409,8 +409,10 @@ impl CaaTag<[u8]> { /// alphanumeric characters and is not longer than 255 bytes. pub unsafe fn from_slice_unchecked(slice: &[u8]) -> &Self { // SAFETY: CaaTag has repr(transparent) - &*(CharStr::from_slice_unchecked(slice) as *const CharStr<[u8]> - as *const Self) + unsafe { + &*(CharStr::from_slice_unchecked(slice) as *const CharStr<[u8]> + as *const Self) + } } fn check_slice(octets: &[u8]) -> Result<(), ParseError> { diff --git a/src/rdata/dnssec.rs b/src/rdata/dnssec.rs index 22fd2c034..9b13cdfe1 100644 --- a/src/rdata/dnssec.rs +++ b/src/rdata/dnssec.rs @@ -4,6 +4,7 @@ //! //! [RFC 4034]: https://tools.ietf.org/html/rfc4034 +use crate::base::Ttl; use crate::base::cmp::CanonicalOrd; use crate::base::iana::{DigestAlgorithm, Rtype, SecurityAlgorithm}; use crate::base::name::{FlattenInto, ParsedName, ToName}; @@ -14,7 +15,6 @@ use crate::base::scan::{Scan, Scanner, ScannerError}; use crate::base::serial::Serial; use crate::base::wire::{Compose, Composer, FormError, Parse, ParseError}; use crate::base::zonefile_fmt::{self, Formatter, ZonefileFmt}; -use crate::base::Ttl; use crate::utils::{base16, base64}; use core::cmp::Ordering; use core::convert::TryInto; @@ -2497,7 +2497,7 @@ where while pos < self.buf.as_ref().len() { match self.buf.as_ref()[pos].cmp(&block) { Ordering::Equal => { - return Ok(&mut self.buf.as_mut()[pos..pos + 34]) + return Ok(&mut self.buf.as_mut()[pos..pos + 34]); } Ordering::Greater => { // We need the length from before we add the new block @@ -2920,7 +2920,8 @@ mod test { KLZ02cRWXqM=" ) .unwrap() - ).unwrap() + ) + .unwrap() .key_tag(), 59944 ); diff --git a/src/rdata/ipseckey.rs b/src/rdata/ipseckey.rs index 435b3bbc2..501da42e2 100644 --- a/src/rdata/ipseckey.rs +++ b/src/rdata/ipseckey.rs @@ -23,7 +23,7 @@ use core::{fmt, hash}; use octseq::octets::{Octets, OctetsFrom, OctetsInto}; use octseq::parse::Parser; -use super::{Aaaa, A}; +use super::{A, Aaaa}; /// The IPSECKEY Resource Record is used to publish a public key that is to be /// associated with a domain name for use with the IPsec protocol suite. @@ -139,7 +139,9 @@ impl Ipseckey { let gateway = IpseckeyGateway::scan(scanner, gateway_type)?; let key = scanner.convert_entry(base64::SymbolConverter::new())?; if key.as_ref().is_empty() && algorithm != IpseckeyAlgorithm::NONE { - return Err(ScannerError::custom("Missing IPSECKEY public key field. The public key field may only be omitted when the algorithm is specified as 0")); + return Err(ScannerError::custom( + "Missing IPSECKEY public key field. The public key field may only be omitted when the algorithm is specified as 0", + )); } Ok(Self { @@ -400,7 +402,9 @@ where match self.gateway.partial_cmp(&other.gateway) { Some(Ordering::Equal) => {} Some(other) => return other, - None => unreachable!("The gateway will be the same variant and therefore have an ordering, because the gateway_type above was Equal"), + None => unreachable!( + "The gateway will be the same variant and therefore have an ordering, because the gateway_type above was Equal" + ), } self.key.as_ref().cmp(other.key.as_ref()) } @@ -423,7 +427,9 @@ impl, N: ToName> Ord for Ipseckey { match self.gateway.partial_cmp(&other.gateway) { Some(Ordering::Equal) => {} Some(other) => return other, - None => unreachable!("The gateway will be the same variant and therefore have an ordering, because the gateway_type above was Equal"), + None => unreachable!( + "The gateway will be the same variant and therefore have an ordering, because the gateway_type above was Equal" + ), } self.key.as_ref().cmp(other.key.as_ref()) } @@ -607,7 +613,7 @@ impl IpseckeyGateway> { _ => { return Err(ParseError::Form(FormError::new( "Unknown IPSECKEY gateway type", - ))) + ))); } }; let remaining = parser.remaining(); @@ -683,10 +689,10 @@ impl fmt::Debug for IpseckeyGateway { #[cfg(all(feature = "std", feature = "bytes"))] mod test { use super::*; + use crate::base::Name; use crate::base::rdata::test::{ test_compose_parse, test_rdlen, test_scan, }; - use crate::base::Name; use crate::utils::base64::decode; use core::str::FromStr; use std::net::{Ipv4Addr, Ipv6Addr}; diff --git a/src/rdata/naptr.rs b/src/rdata/naptr.rs index 0c103889e..fe7cd4c0a 100644 --- a/src/rdata/naptr.rs +++ b/src/rdata/naptr.rs @@ -5,13 +5,13 @@ //! [RFC 3403]: https://www.rfc-editor.org/info/rfc3403 use crate::base::{ + CanonicalOrd, CharStr, ParseRecordData, ParsedName, RecordData, Rtype, + ToName, name::FlattenInto, rdata::ComposeRecordData, scan::{Scan, Scanner}, wire::{Compose, Parse, ParseError}, zonefile_fmt::{self, Formatter, ZonefileFmt}, - CanonicalOrd, CharStr, ParseRecordData, ParsedName, RecordData, Rtype, - ToName, }; use core::{cmp::Ordering, fmt, hash}; #[cfg(feature = "serde")] @@ -515,8 +515,8 @@ mod test { use super::*; use crate::base::{ - rdata::test::{test_compose_parse, test_rdlen, test_scan}, Name, + rdata::test::{test_compose_parse, test_rdlen, test_scan}, }; use core::str::FromStr; use std::vec::Vec; diff --git a/src/rdata/nsec3.rs b/src/rdata/nsec3.rs index e28b5712d..841aba288 100644 --- a/src/rdata/nsec3.rs +++ b/src/rdata/nsec3.rs @@ -928,7 +928,7 @@ impl Nsec3Salt<[u8]> { /// The passed slice must be no longer than [`Nsec3Salt::MAX_LEN`]. unsafe fn from_slice_unchecked(slice: &[u8]) -> &Self { // SAFETY: Nsec3Salt has repr(transparent) - mem::transmute(slice) + unsafe { mem::transmute(slice) } } } @@ -969,9 +969,7 @@ impl Nsec3Salt { match self.0.as_mut() { None => unreachable!(), Some(None) => Err(Error::custom("illegal NSEC3 salt")), - Some(Some(ref mut base16)) => { - base16.process_symbol(symbol) - } + Some(Some(base16)) => base16.process_symbol(symbol), } } @@ -1397,7 +1395,7 @@ impl OwnerHash<[u8]> { /// The passed slice must be no longer than [`OwnerHash::MAX_LEN`]. unsafe fn from_slice_unchecked(slice: &[u8]) -> &Self { // SAFETY: OwnerHash has repr(transparent) - mem::transmute(slice) + unsafe { mem::transmute(slice) } } } diff --git a/src/rdata/rfc1035/null.rs b/src/rdata/rfc1035/null.rs index c2897c60e..abfc36247 100644 --- a/src/rdata/rfc1035/null.rs +++ b/src/rdata/rfc1035/null.rs @@ -90,7 +90,7 @@ impl Null<[u8]> { #[must_use] pub unsafe fn from_slice_unchecked(data: &[u8]) -> &Self { // SAFETY: Null has repr(transparent) - mem::transmute(data) + unsafe { mem::transmute(data) } } /// Checks that a slice can be used for NULL record data. diff --git a/src/rdata/rfc1035/txt.rs b/src/rdata/rfc1035/txt.rs index 452c804c2..33a6c3558 100644 --- a/src/rdata/rfc1035/txt.rs +++ b/src/rdata/rfc1035/txt.rs @@ -21,8 +21,8 @@ use core::cmp::Ordering; use core::convert::{Infallible, TryFrom}; use core::{fmt, hash, mem, str}; use octseq::builder::{ - infallible, EmptyBuilder, FreezeBuilder, FromBuilder, OctetsBuilder, - ShortBuf, + EmptyBuilder, FreezeBuilder, FromBuilder, OctetsBuilder, ShortBuf, + infallible, }; use octseq::octets::{Octets, OctetsFrom, OctetsInto}; use octseq::parse::Parser; @@ -156,7 +156,7 @@ impl Txt<[u8]> { /// See [`from_octets][Self::from_octets] for the required content. unsafe fn from_slice_unchecked(slice: &[u8]) -> &Self { // SAFETY: Txt has repr(transparent) - mem::transmute(slice) + unsafe { mem::transmute(slice) } } /// Checks that a slice contains correctly encoded TXT data. @@ -986,15 +986,19 @@ mod test { // Too long let mut builder: TxtBuilder> = TxtBuilder::new(); - assert!(builder - .append_slice(&b"\x00".repeat(u16::MAX as usize)) - .is_err()); + assert!( + builder + .append_slice(&b"\x00".repeat(u16::MAX as usize)) + .is_err() + ); // Incremental, reserve space for offsets let mut builder: TxtBuilder> = TxtBuilder::new(); - assert!(builder - .append_slice(&b"\x00".repeat(u16::MAX as usize - 512)) - .is_ok()); + assert!( + builder + .append_slice(&b"\x00".repeat(u16::MAX as usize - 512)) + .is_ok() + ); assert!(builder.append_slice(&b"\x00".repeat(512)).is_err()); } @@ -1060,7 +1064,7 @@ mod test { #[cfg(all(feature = "serde", feature = "std"))] #[test] fn txt_ser_de() { - use serde_test::{assert_tokens, Configure, Token}; + use serde_test::{Configure, Token, assert_tokens}; let txt = Txt::from_octets(Vec::from(b"\x03foo".as_ref())).unwrap(); assert_tokens( @@ -1107,7 +1111,7 @@ mod test { #[cfg(all(feature = "serde", feature = "std"))] #[test] fn txt_de_str() { - use serde_test::{assert_de_tokens, Configure, Token}; + use serde_test::{Configure, Token, assert_de_tokens}; assert_de_tokens( &Txt::from_octets(Vec::from(b"\x03foo".as_ref())) diff --git a/src/rdata/sshfp.rs b/src/rdata/sshfp.rs index f30da0a73..09d3e7dd1 100644 --- a/src/rdata/sshfp.rs +++ b/src/rdata/sshfp.rs @@ -12,13 +12,13 @@ // the allow attribute doesn't get copied to the code generated by serde. #![allow(clippy::needless_maybe_sized)] +use crate::base::Rtype; use crate::base::cmp::CanonicalOrd; use crate::base::iana::{SshfpAlgorithm, SshfpType}; use crate::base::rdata::{ComposeRecordData, RecordData}; use crate::base::scan::Scanner; use crate::base::wire::{Composer, ParseError}; use crate::base::zonefile_fmt::{self, Formatter, ZonefileFmt}; -use crate::base::Rtype; use crate::utils::base16; use core::cmp::Ordering; use core::{fmt, hash}; @@ -307,8 +307,8 @@ mod test { #[cfg(feature = "zonefile")] #[test] fn sshfp_parse_zonefile() { - use crate::base::iana::{SshfpAlgorithm, SshfpType}; use crate::base::Name; + use crate::base::iana::{SshfpAlgorithm, SshfpType}; use crate::rdata::ZoneRecordData; use crate::zonefile::inplace::{Entry, Zonefile}; diff --git a/src/rdata/svcb/params.rs b/src/rdata/svcb/params.rs index a850b29b6..672e489eb 100644 --- a/src/rdata/svcb/params.rs +++ b/src/rdata/svcb/params.rs @@ -23,10 +23,10 @@ use core::marker::PhantomData; #[cfg(feature = "std")] use core::str::FromStr; use core::{cmp, fmt, hash, mem}; +use octseq::FreezeBuilder; use octseq::builder::{EmptyBuilder, FromBuilder, OctetsBuilder, ShortBuf}; use octseq::octets::{Octets, OctetsFrom, OctetsInto}; use octseq::parse::{Parser, ShortInput}; -use octseq::FreezeBuilder; //------------ SvcParams ----------------------------------------------------- @@ -141,7 +141,7 @@ impl SvcParams<[u8]> { #[must_use] pub unsafe fn from_slice_unchecked(slice: &[u8]) -> &Self { // SAFETY: SvcParams has repr(transparent) - mem::transmute(slice) + unsafe { mem::transmute(slice) } } /// Checks that a slice contains a correctly encoded parameters sequence. @@ -308,7 +308,9 @@ impl> SvcParams { if let AllValues::Mandatory(m) = ¶m_value { for req in m.iter() { if !key_map.contains_key(&req) { - return Err(S::Error::custom("all SvcParamKeys listed in mandatory MUST appear in SvcParams")); + return Err(S::Error::custom( + "all SvcParamKeys listed in mandatory MUST appear in SvcParams", + )); } } } @@ -1398,8 +1400,10 @@ mod test { builder .push(&UnknownSvcParam::new(8.into(), b"225").unwrap()) .unwrap(); - assert!(builder - .push(&UnknownSvcParam::new(8.into(), b"224").unwrap()) - .is_err()); + assert!( + builder + .push(&UnknownSvcParam::new(8.into(), b"224").unwrap()) + .is_err() + ); } } diff --git a/src/rdata/svcb/rdata.rs b/src/rdata/svcb/rdata.rs index b8d44cf59..a2fdfc791 100644 --- a/src/rdata/svcb/rdata.rs +++ b/src/rdata/svcb/rdata.rs @@ -198,7 +198,9 @@ impl, Name: ToName> SvcbRdata { #[cfg(not(feature = "std"))] { let _ = scanner; - Err(S::Error::custom("zonefile parsing of SVCB RRs is not implemented without the domain std feature")) + Err(S::Error::custom( + "zonefile parsing of SVCB RRs is not implemented without the domain std feature", + )) } } } @@ -220,7 +222,9 @@ impl, Name: ToName> SvcbRdata { #[cfg(not(feature = "std"))] { let _ = scanner; - Err(S::Error::custom("zonefile parsing of HTTPS RRs is not implemented without the domain std feature")) + Err(S::Error::custom( + "zonefile parsing of HTTPS RRs is not implemented without the domain std feature", + )) } } } @@ -557,8 +561,8 @@ where #[cfg(test)] mod test { - use super::super::value::AllValues; use super::super::UnknownSvcParam; + use super::super::value::AllValues; use super::*; use crate::base::Name; use core::str::FromStr; diff --git a/src/rdata/svcb/value.rs b/src/rdata/svcb/value.rs index 9ae4a8953..d6ac1fcdc 100644 --- a/src/rdata/svcb/value.rs +++ b/src/rdata/svcb/value.rs @@ -298,7 +298,7 @@ macro_rules! octets_wrapper { #[must_use] pub unsafe fn from_slice_unchecked(slice: &[u8]) -> &Self { // SAFETY: Self has repr(transparent) - mem::transmute(slice) + unsafe { mem::transmute(slice) } } } diff --git a/src/rdata/tlsa.rs b/src/rdata/tlsa.rs index 56eb950cf..bcedd1574 100644 --- a/src/rdata/tlsa.rs +++ b/src/rdata/tlsa.rs @@ -337,10 +337,10 @@ mod test { #[cfg(feature = "zonefile")] #[test] fn tlsa_parse_zonefile() { + use crate::base::Name; use crate::base::iana::{ TlsaCertificateUsage, TlsaMatchingType, TlsaSelector, }; - use crate::base::Name; use crate::rdata::ZoneRecordData; use crate::zonefile::inplace::{Entry, Zonefile}; diff --git a/src/rdata/zonemd.rs b/src/rdata/zonemd.rs index 947fa1c75..c54cbaf15 100644 --- a/src/rdata/zonemd.rs +++ b/src/rdata/zonemd.rs @@ -338,8 +338,8 @@ mod test { #[cfg(feature = "zonefile")] #[test] fn zonemd_parse_zonefile() { - use crate::base::iana::ZonemdAlgorithm; use crate::base::Name; + use crate::base::iana::ZonemdAlgorithm; use crate::rdata::ZoneRecordData; use crate::zonefile::inplace::{Entry, Zonefile}; diff --git a/src/resolv/lookup/host.rs b/src/resolv/lookup/host.rs index d7e0e9783..c8837e0d4 100644 --- a/src/resolv/lookup/host.rs +++ b/src/resolv/lookup/host.rs @@ -3,7 +3,7 @@ use crate::base::iana::Rtype; use crate::base::message::RecordIter; use crate::base::name::{ParsedName, ToName, ToRelativeName}; -use crate::rdata::{Aaaa, A}; +use crate::rdata::{A, Aaaa}; use crate::resolv::resolver::{Resolver, SearchNames}; use octseq::octets::Octets; use std::io; diff --git a/src/resolv/lookup/srv.rs b/src/resolv/lookup/srv.rs index 66761ce9a..6f0c930e0 100644 --- a/src/resolv/lookup/srv.rs +++ b/src/resolv/lookup/srv.rs @@ -5,7 +5,7 @@ use crate::base::iana::{Class, Rtype}; use crate::base::message::Message; use crate::base::name::{Name, ToName, ToRelativeName}; use crate::base::wire::ParseError; -use crate::rdata::{Aaaa, Srv, A}; +use crate::rdata::{A, Aaaa, Srv}; use crate::resolv::resolver::Resolver; use core::fmt; use futures_util::stream::{self, Stream, StreamExt}; diff --git a/src/resolv/stub/mod.rs b/src/resolv/stub/mod.rs index 29ee95827..41ae4eb57 100644 --- a/src/resolv/stub/mod.rs +++ b/src/resolv/stub/mod.rs @@ -24,9 +24,9 @@ use crate::net::client::redundant; use crate::net::client::request::{ ComposeRequest, Error, RequestMessage, SendRequest, }; -use crate::resolv::lookup::addr::{lookup_addr, FoundAddrs}; -use crate::resolv::lookup::host::{lookup_host, search_host, FoundHosts}; -use crate::resolv::lookup::srv::{lookup_srv, FoundSrvs, SrvError}; +use crate::resolv::lookup::addr::{FoundAddrs, lookup_addr}; +use crate::resolv::lookup::host::{FoundHosts, lookup_host, search_host}; +use crate::resolv::lookup::srv::{FoundSrvs, SrvError, lookup_srv}; use crate::resolv::resolver::{Resolver, SearchNames}; use bytes::Bytes; use futures_util::stream::{FuturesUnordered, StreamExt}; @@ -37,8 +37,8 @@ use std::future::Future; use std::net::IpAddr; use std::pin::Pin; use std::string::ToString; -use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; +use std::sync::atomic::{AtomicBool, Ordering}; use std::vec::Vec; use std::{io, ops}; #[cfg(feature = "resolv-sync")] diff --git a/src/stelline/channel.rs b/src/stelline/channel.rs index 76886b115..c8e6ec026 100644 --- a/src/stelline/channel.rs +++ b/src/stelline/channel.rs @@ -6,8 +6,8 @@ use core::time::Duration; use std::boxed::Box; use std::collections::HashMap; -use std::future::ready; use std::future::Future; +use std::future::ready; use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use std::pin::Pin; use std::sync::{Arc, Mutex}; @@ -355,7 +355,10 @@ impl AsyncDgramRecv for ClientServerChannel { Poll::Ready(Ok(())) } Poll::Ready(None) => { - trace!("Broken pipe while reading in dgram client channel (is_closed={})", rx.is_closed()); + trace!( + "Broken pipe while reading in dgram client channel (is_closed={})", + rx.is_closed() + ); Poll::Ready(Err(io::Error::from(io::ErrorKind::BrokenPipe))) } Poll::Pending => { @@ -394,7 +397,8 @@ impl AsyncDgramSend for ClientServerChannel { } Poll::Ready(Err(_)) => { trace!( - "Broken pipe while sending in dgram client channel"); + "Broken pipe while sending in dgram client channel" + ); Poll::Ready(Err(io::Error::from( io::ErrorKind::BrokenPipe, ))) @@ -407,7 +411,9 @@ impl AsyncDgramSend for ClientServerChannel { } None => { - trace!("Unable to send bytes in dgram client channel: not connected"); + trace!( + "Unable to send bytes in dgram client channel: not connected" + ); Poll::Ready(Err(io::Error::from(io::ErrorKind::NotConnected))) } } @@ -474,7 +480,11 @@ impl AsyncDgramSock for ClientServerChannel { match rx.try_recv() { Ok(Data::DgramRequest(addr, data)) => { // TODO: use unread buf here to prevent overflow of given buf. - trace!("Reading {} bytes from {addr} into buffer of len {} in dgram server channel", data.len(), buf.remaining()); + trace!( + "Reading {} bytes from {addr} into buffer of len {} in dgram server channel", + data.len(), + buf.remaining() + ); buf.put_slice(&data); Ok((data.len(), addr)) } @@ -580,12 +590,17 @@ impl AsyncRead for ClientServerChannel { let rx = &mut client.rx.lock().unwrap(); match rx.poll_recv(cx) { Poll::Ready(Some(data)) => { - trace!("Reading {} bytes into internal buffer in client stream channel", data.len()); + trace!( + "Reading {} bytes into internal buffer in client stream channel", + data.len() + ); client.unread_buf.extend(data).fill(buf); Poll::Ready(Ok(())) } Poll::Ready(None) => { - trace!("Broken pipe while reading in client stream channel"); + trace!( + "Broken pipe while reading in client stream channel" + ); Poll::Ready(Err(io::Error::from( io::ErrorKind::BrokenPipe, ))) @@ -605,7 +620,10 @@ impl AsyncRead for ClientServerChannel { let rx = &mut server_socket.rx; match rx.poll_recv(cx) { Poll::Ready(Some(Data::StreamRequest(data))) => { - trace!("Reading {} bytes into internal buffer in server stream channel", data.len()); + trace!( + "Reading {} bytes into internal buffer in server stream channel", + data.len() + ); server_socket.unread_buf.extend(data).fill(buf); Poll::Ready(Ok(())) } @@ -616,7 +634,9 @@ impl AsyncRead for ClientServerChannel { unreachable!() } Poll::Ready(None) => { - trace!("Broken pipe while reading in server stream channel"); + trace!( + "Broken pipe while reading in server stream channel" + ); Poll::Ready(Err(io::Error::from( io::ErrorKind::BrokenPipe, @@ -670,7 +690,9 @@ impl AsyncWrite for ClientServerChannel { Poll::Ready(Ok(data.len())) } Poll::Ready(Err(_)) => { - trace!("Broken pipe while writing in client stream channel"); + trace!( + "Broken pipe while writing in client stream channel" + ); Poll::Ready(Err(io::Error::from( io::ErrorKind::BrokenPipe, ))) @@ -695,7 +717,9 @@ impl AsyncWrite for ClientServerChannel { Poll::Ready(Ok(data.len())) } Poll::Ready(Err(_)) => { - trace!("Broken pipe while writing in server stream channel"); + trace!( + "Broken pipe while writing in server stream channel" + ); Poll::Ready(Err(io::Error::from( io::ErrorKind::BrokenPipe, ))) @@ -706,7 +730,9 @@ impl AsyncWrite for ClientServerChannel { } } } else { - trace!("Failed write in server stream channel: not connected"); + trace!( + "Failed write in server stream channel: not connected" + ); Poll::Ready(Err(io::Error::from( io::ErrorKind::NotConnected, ))) diff --git a/src/stelline/client.rs b/src/stelline/client.rs index 71834631f..eb42e5002 100644 --- a/src/stelline/client.rs +++ b/src/stelline/client.rs @@ -3,7 +3,7 @@ use core::ops::Deref; use std::boxed::Box; use std::collections::HashMap; -use std::future::{ready, Future}; +use std::future::{Future, ready}; use std::net::IpAddr; use std::pin::Pin; use std::rc::Rc; diff --git a/src/stelline/connection.rs b/src/stelline/connection.rs index df5556c0d..6c334bab6 100644 --- a/src/stelline/connection.rs +++ b/src/stelline/connection.rs @@ -10,8 +10,8 @@ use super::server::do_server; use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; -use crate::base::message_builder::AdditionalBuilder; use crate::base::Message; +use crate::base::message_builder::AdditionalBuilder; #[derive(Debug)] pub struct Connection { diff --git a/src/stelline/dgram.rs b/src/stelline/dgram.rs index f6f7ec68d..3a4d3aff9 100644 --- a/src/stelline/dgram.rs +++ b/src/stelline/dgram.rs @@ -9,8 +9,8 @@ use std::vec::Vec; use tokio::io::ReadBuf; -use crate::base::message_builder::AdditionalBuilder; use crate::base::Message; +use crate::base::message_builder::AdditionalBuilder; use crate::net::client::protocol::{ AsyncConnect, AsyncDgramRecv, AsyncDgramSend, }; diff --git a/src/stelline/matches.rs b/src/stelline/matches.rs index 79b12cd10..326f1434a 100644 --- a/src/stelline/matches.rs +++ b/src/stelline/matches.rs @@ -197,7 +197,11 @@ impl Entry { allow_partial_match: bool, ) -> Result<(), DidNotMatch> { if !allow_partial_match && match_section.len() != msg_count as usize { - trace!("match_section: expected section length {} doesn't match message count {}", match_section.len(), msg_count); + trace!( + "match_section: expected section length {} doesn't match message count {}", + match_section.len(), + msg_count + ); if !match_section.is_empty() { trace!("expected sections:"); for section in match_section { @@ -397,7 +401,9 @@ impl Entry { for (name, r, h) in flags { if r != h { - trace!("match_msg: {name} does not match, got {r:?}, expected {h:?}"); + trace!( + "match_msg: {name} does not match, got {r:?}, expected {h:?}" + ); return Err(DidNotMatch); } } diff --git a/src/stelline/parse_stelline.rs b/src/stelline/parse_stelline.rs index b9946c3a6..626acdd2d 100644 --- a/src/stelline/parse_stelline.rs +++ b/src/stelline/parse_stelline.rs @@ -272,7 +272,9 @@ fn parse_step>( Some(KeyName::from_str(key_name).unwrap()); } (Some(param), Some(value)) => { - eprintln!("Ignoring unknown query parameter '{param}' with value '{value}'"); + eprintln!( + "Ignoring unknown query parameter '{param}' with value '{value}'" + ); } (Some(param), None) => { eprintln!( diff --git a/src/stelline/server.rs b/src/stelline/server.rs index 300c93b68..965762027 100644 --- a/src/stelline/server.rs +++ b/src/stelline/server.rs @@ -39,8 +39,7 @@ where for range in ranges { trace!( "Checking against range {} <= {}", - range.start_value, - range.end_value + range.start_value, range.end_value ); if step < range.start_value || step > range.end_value { continue; diff --git a/src/tsig/mod.rs b/src/tsig/mod.rs index fce4d9131..2185dbf9b 100644 --- a/src/tsig/mod.rs +++ b/src/tsig/mod.rs @@ -317,16 +317,15 @@ impl Key { + 2 // Original ID + 2 // Error + 2; // Other Len - //+ 0; // Other Data (assume a successful response) - let rr_len = self.name().compose_len() + //+ 0; // Other Data (assume a successful response) + + self.name().compose_len() + 2 // TYPE + 2 // CLASS + 4 // TTL + 2 // RDLENGTH - + rdata_len; - - rr_len + + rdata_len } /// Checks whether the key in the record is this key. @@ -1149,10 +1148,10 @@ impl> SigningContext { // > If the TSIG RR cannot be interpreted, the server MUST regard // > the message as corrupt and return a FORMERR to the server. Err(TsigError::Invalid) => { - return Err(ServerError::unsigned(TsigRcode::FORMERR)) + return Err(ServerError::unsigned(TsigRcode::FORMERR)); } Err(TsigError::ParseError) => { - return Err(ServerError::unsigned(TsigRcode::FORMERR)) + return Err(ServerError::unsigned(TsigRcode::FORMERR)); } Err(TsigError::Missing) => return Ok(None), }; @@ -1253,7 +1252,7 @@ impl> SigningContext { // > the message as corrupt and return a FORMERR to the server. Err(TsigError::Invalid) => return Err(ValidationError::FormErr), Err(TsigError::ParseError) => { - return Err(ValidationError::FormErr) + return Err(ValidationError::FormErr); } Err(TsigError::Missing) => return Ok(None), }; diff --git a/src/zonefile/inplace.rs b/src/zonefile/inplace.rs index 50ab88dff..0b5556b55 100644 --- a/src/zonefile/inplace.rs +++ b/src/zonefile/inplace.rs @@ -19,6 +19,7 @@ use bytes::buf::UninitSlice; use bytes::{Buf, BufMut, Bytes, BytesMut}; use octseq::str::Str; +use crate::base::Ttl; use crate::base::charstr::CharStr; use crate::base::iana::{Class, Rtype}; use crate::base::name::{Chain, Name, RelativeName, ToName}; @@ -27,7 +28,6 @@ use crate::base::scan::{ BadSymbol, ConvertSymbols, EntrySymbol, Scan, Scanner, ScannerError, Symbol, SymbolOctetsError, }; -use crate::base::Ttl; use crate::rdata::ZoneRecordData; //------------ Type Aliases -------------------------------------------------- @@ -177,7 +177,7 @@ unsafe impl BufMut for Zonefile { } unsafe fn advance_mut(&mut self, cnt: usize) { - self.buf.buf.advance_mut(cnt); + unsafe { self.buf.buf.advance_mut(cnt) }; } fn chunk_mut(&mut self) -> &mut UninitSlice { @@ -342,7 +342,7 @@ impl<'a> EntryScanner<'a> { match self.zonefile.last_owner.as_ref() { Some(owner) => owner.clone(), None => { - return Err(EntryError::missing_last_owner()) + return Err(EntryError::missing_last_owner()); } }, false, @@ -1188,11 +1188,7 @@ impl SourceBuf { Ok(None) | Err(_) => return None, }; - if sym.is_word_char() { - Some(sym) - } else { - None - } + if sym.is_word_char() { Some(sym) } else { None } } ItemCat::Quoted => { let sym = diff --git a/src/zonetree/answer.rs b/src/zonetree/answer.rs index ab7ff6112..4df0a978e 100644 --- a/src/zonetree/answer.rs +++ b/src/zonetree/answer.rs @@ -3,10 +3,10 @@ use std::vec::Vec; use octseq::Octets; +use crate::base::MessageBuilder; use crate::base::iana::Rcode; use crate::base::message_builder::AdditionalBuilder; use crate::base::wire::Composer; -use crate::base::MessageBuilder; use crate::base::{Message, Ttl}; use super::types::{StoredName, StoredRecord, StoredRecordData}; diff --git a/src/zonetree/error.rs b/src/zonetree/error.rs index 7e7903d94..c25099376 100644 --- a/src/zonetree/error.rs +++ b/src/zonetree/error.rs @@ -128,19 +128,34 @@ impl Display for RecordError { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match self { RecordError::ClassMismatch(rec, zone_class) => { - write!(f, "The class of the record does not match the class {zone_class} of the zone: {rec}") + write!( + f, + "The class of the record does not match the class {zone_class} of the zone: {rec}" + ) } RecordError::IllegalZoneCut(rec, existing_rtype) => { - write!(f, "Attempted to add zone cut records where non-zone cut records ({existing_rtype}) already exist: {rec}") + write!( + f, + "Attempted to add zone cut records where non-zone cut records ({existing_rtype}) already exist: {rec}" + ) } RecordError::IllegalRecord(rec, existing_rtype) => { - write!(f, "Attempted to add a normal record where a {existing_rtype} record already exists: {rec}") + write!( + f, + "Attempted to add a normal record where a {existing_rtype} record already exists: {rec}" + ) } RecordError::IllegalCname(rec, existing_rtype) => { - write!(f, "Attempted to add a CNAME record where a {existing_rtype} record already exists: {rec}") + write!( + f, + "Attempted to add a CNAME record where a {existing_rtype} record already exists: {rec}" + ) } RecordError::MultipleCnames(rec) => { - write!(f, "Attempted to add a CNAME record a CNAME record already exists: {rec}") + write!( + f, + "Attempted to add a CNAME record a CNAME record already exists: {rec}" + ) } RecordError::MalformedRecord(err) => { write!(f, "The record could not be parsed: {err}") diff --git a/src/zonetree/in_memory/nodes.rs b/src/zonetree/in_memory/nodes.rs index 9eb7f165a..b069e6b13 100644 --- a/src/zonetree/in_memory/nodes.rs +++ b/src/zonetree/in_memory/nodes.rs @@ -3,7 +3,7 @@ use core::any::Any; use std::boxed::Box; -use std::collections::{hash_map, HashMap}; +use std::collections::{HashMap, hash_map}; use std::future::Future; use std::pin::Pin; use std::sync::Arc; diff --git a/src/zonetree/in_memory/read.rs b/src/zonetree/in_memory/read.rs index cb3c06b1c..ed7e3332f 100644 --- a/src/zonetree/in_memory/read.rs +++ b/src/zonetree/in_memory/read.rs @@ -5,9 +5,9 @@ use std::sync::Arc; use bytes::Bytes; +use crate::base::Name; use crate::base::iana::{Rcode, Rtype}; use crate::base::name::Label; -use crate::base::Name; use crate::zonetree::answer::{Answer, AnswerAdditional, AnswerAuthority}; use crate::zonetree::error::OutOfZone; use crate::zonetree::types::ZoneCut; @@ -85,7 +85,7 @@ impl ReadZone { walk: WalkState, ) -> NodeAnswer { node.with_special(self.version, |special| match special { - Some(Special::Cut(ref cut)) => { + Some(Special::Cut(cut)) => { if walk.enabled() { walk.op(&cut.ns, true); if let Some(ds) = &cut.ds { @@ -414,10 +414,10 @@ impl NodeAnswer { #[cfg(test)] mod tests { use super::*; + use crate::base::Ttl; use crate::base::iana::Class; use crate::base::name::OwnedLabel; - use crate::base::Ttl; - use crate::rdata::{ZoneRecordData, A}; + use crate::rdata::{A, ZoneRecordData}; use crate::zonetree::StoredName; use core::str::FromStr; use core::sync::atomic::{AtomicU8, Ordering}; diff --git a/src/zonetree/in_memory/write.rs b/src/zonetree/in_memory/write.rs index df533ea43..130fcadcc 100644 --- a/src/zonetree/in_memory/write.rs +++ b/src/zonetree/in_memory/write.rs @@ -22,10 +22,10 @@ use crate::base::iana::Rtype; use crate::base::name::Label; use crate::base::{NameBuilder, Serial}; use crate::rdata::ZoneRecordData; +use crate::zonetree::StoredName; use crate::zonetree::types::{ InMemoryZoneDiff, InMemoryZoneDiffBuilder, ZoneCut, }; -use crate::zonetree::StoredName; use crate::zonetree::{Rrset, SharedRr}; use crate::zonetree::{SharedRrset, WritableZone, WritableZoneNode}; @@ -464,7 +464,9 @@ impl WriteNode { match (current_rrset.is_some(), !new_rrset.is_empty()) { (true, true) => { - trace!("Diff detected: update of existing RRSET - recording change of RRSET from {current_rrset:?} to {new_rrset:#?}"); + trace!( + "Diff detected: update of existing RRSET - recording change of RRSET from {current_rrset:?} to {new_rrset:#?}" + ); // Check each resource record in the RRset being updated // to see if it is missing from the new RRSet. @@ -514,7 +516,9 @@ impl WriteNode { } } (true, false) => { - trace!("Diff detected: update of existing RRSET - recording removal of the current RRSET {current_rrset:#?}"); + trace!( + "Diff detected: update of existing RRSET - recording removal of the current RRSET {current_rrset:#?}" + ); diff.lock().unwrap().remove( owner.clone(), new_rrset.rtype(), @@ -522,7 +526,9 @@ impl WriteNode { ); } (false, true) => { - trace!("Diff detected: update of existing RRSET - recording addition of new RRSET {new_rrset:#?}"); + trace!( + "Diff detected: update of existing RRSET - recording addition of new RRSET {new_rrset:#?}" + ); diff.lock().unwrap().add( owner.clone(), new_rrset.rtype(), diff --git a/src/zonetree/mod.rs b/src/zonetree/mod.rs index 5556f234e..254e245c3 100644 --- a/src/zonetree/mod.rs +++ b/src/zonetree/mod.rs @@ -128,11 +128,11 @@ pub use self::zone::Zone; /// Zone related utilities. pub mod util { - use crate::base::name::{Label, ToLabelIter}; use crate::base::ToName; + use crate::base::name::{Label, ToLabelIter}; - use super::error::OutOfZone; use super::StoredName; + use super::error::OutOfZone; /// Gets a reverse iterator to the relative part of a name. /// diff --git a/src/zonetree/parsed.rs b/src/zonetree/parsed.rs index de380dd84..a2e6a1c8e 100644 --- a/src/zonetree/parsed.rs +++ b/src/zonetree/parsed.rs @@ -3,9 +3,9 @@ use std::collections::{BTreeMap, HashMap}; use std::vec::Vec; +use crate::base::Name; use crate::base::iana::{Class, Rtype}; use crate::base::name::{FlattenInto, ToName}; -use crate::base::Name; use crate::rdata::ZoneRecordData; use crate::zonefile::inplace::{self, Entry}; use crate::zonetree::ZoneBuilder; @@ -399,7 +399,7 @@ impl Owners { // Now see if A/AAAA records exists for the name in // this zone. for (_rtype, rrset) in - normal.records.iter().filter(|(&rtype, _)| rtype.is_glue()) + normal.records.iter().filter(|(rtype, _)| rtype.is_glue()) { for rdata in rrset.data() { let glue_record = StoredRecord::new( diff --git a/src/zonetree/traits.rs b/src/zonetree/traits.rs index 1ac77dfbe..cd02f6af3 100644 --- a/src/zonetree/traits.rs +++ b/src/zonetree/traits.rs @@ -309,7 +309,7 @@ pub trait ZoneDiff { /// The serial number of the zone that resulted from the modifications. fn end_serial(&self) - -> Pin + Send + '_>>; + -> Pin + Send + '_>>; /// An stream of RRsets that were added to the zone. // TODO: Does this need to be Box>>? diff --git a/src/zonetree/tree.rs b/src/zonetree/tree.rs index 46873c1e9..effdc7c83 100644 --- a/src/zonetree/tree.rs +++ b/src/zonetree/tree.rs @@ -1,7 +1,7 @@ //! The known set of zones. -use std::collections::hash_map; use std::collections::HashMap; +use std::collections::hash_map; use std::vec::Vec; use crate::base::iana::Class; diff --git a/src/zonetree/types.rs b/src/zonetree/types.rs index 7600a73aa..0ee403419 100644 --- a/src/zonetree/types.rs +++ b/src/zonetree/types.rs @@ -1,11 +1,11 @@ //! Zone tree related types. -use core::future::{ready, Future}; +use core::future::{Future, ready}; use core::pin::Pin; use core::task::{Context, Poll}; use std::boxed::Box; -use std::collections::{hash_map, HashMap}; +use std::collections::{HashMap, hash_map}; use std::ops; use std::sync::Arc; use std::vec::Vec; @@ -19,8 +19,8 @@ use super::traits::{ZoneDiff, ZoneDiffItem}; use crate::base::name::Name; use crate::base::rdata::RecordData; use crate::base::record::Record; -use crate::base::{iana::Rtype, Ttl}; use crate::base::{Serial, ToName}; +use crate::base::{Ttl, iana::Rtype}; use crate::rdata::ZoneRecordData; //------------ Type Aliases -------------------------------------------------- @@ -378,7 +378,9 @@ impl InMemoryZoneDiff { .ok_or(ZoneDiffError::MissingEndSoa)?; if start_serial == end_serial || end_serial < start_serial { - trace!("Diff construction error: serial {start_serial} -> serial {end_serial}:\nremoved: {removed:#?}\nadded: {added:#?}\n"); + trace!( + "Diff construction error: serial {start_serial} -> serial {end_serial}:\nremoved: {removed:#?}\nadded: {added:#?}\n" + ); return Err(ZoneDiffError::InvalidSerialRange); } diff --git a/src/zonetree/update.rs b/src/zonetree/update.rs index 700df5b07..de1fef8cb 100644 --- a/src/zonetree/update.rs +++ b/src/zonetree/update.rs @@ -643,7 +643,7 @@ mod tests { }; use crate::logging::init_logging; use crate::net::xfr::protocol::XfrResponseInterpreter; - use crate::rdata::{Ns, Soa, A}; + use crate::rdata::{A, Ns, Soa}; use crate::zonetree::ZoneBuilder; use super::*; diff --git a/src/zonetree/walk.rs b/src/zonetree/walk.rs index f4a773019..81fc6b814 100644 --- a/src/zonetree/walk.rs +++ b/src/zonetree/walk.rs @@ -3,8 +3,8 @@ use std::boxed::Box; use std::sync::{Arc, Mutex}; use std::vec::Vec; -use crate::base::name::OwnedLabel; use crate::base::NameBuilder; +use crate::base::name::OwnedLabel; use super::{Rrset, SharedRrset, StoredName, StoredRecord}; diff --git a/src/zonetree/zone.rs b/src/zonetree/zone.rs index ef61793c8..9a171931b 100644 --- a/src/zonetree/zone.rs +++ b/src/zonetree/zone.rs @@ -11,7 +11,7 @@ use super::error::{RecordError, ZoneErrors}; use super::in_memory::ZoneBuilder; use super::traits::WritableZone; use super::types::StoredName; -use super::{parsed, ReadableZone, ZoneStore}; +use super::{ReadableZone, ZoneStore, parsed}; /// A single DNS zone. /// diff --git a/tests/interop.rs b/tests/interop.rs index d6b67c847..ec8549bdd 100644 --- a/tests/interop.rs +++ b/tests/interop.rs @@ -21,7 +21,7 @@ use domain::base::name::Name; use domain::base::opt::TcpKeepalive; use domain::base::record::Ttl; use domain::rdata::tsig::Time48; -use domain::rdata::{Soa, A}; +use domain::rdata::{A, Soa}; use domain::tsig; use domain::utils::base64; use ring::rand::SystemRandom; @@ -191,9 +191,11 @@ fn tsig_server_dig() { .expect("failed to start dig"); drop(join); assert!(output.status.success()); - assert!(!String::from_utf8(output.stdout) - .unwrap() - .contains("tsig verify failure")); + assert!( + !String::from_utf8(output.stdout) + .unwrap() + .contains("tsig verify failure") + ); } /// Test the client sequence implementation against NSD. @@ -350,9 +352,11 @@ fn tsig_server_sequence_dig() { .expect("failed to start dig"); drop(join); assert!(output.status.success()); - assert!(!String::from_utf8(output.stdout) - .unwrap() - .contains("tsig verify failure")); + assert!( + !String::from_utf8(output.stdout) + .unwrap() + .contains("tsig verify failure") + ); } //------------ Helpers ------------------------------------------------------ diff --git a/tests/net-client-cache.rs b/tests/net-client-cache.rs index 5f3f2b5e8..3b6c16224 100644 --- a/tests/net-client-cache.rs +++ b/tests/net-client-cache.rs @@ -4,8 +4,8 @@ use std::fs::File; use std::path::PathBuf; use std::sync::Arc; -use domain::stelline::client::do_client_simple; use domain::stelline::client::CurrStepValue; +use domain::stelline::client::do_client_simple; use domain::stelline::connect::Connect; use domain::stelline::parse_stelline::parse_file; diff --git a/tests/net-client.rs b/tests/net-client.rs index c0c54b481..dfcde000d 100644 --- a/tests/net-client.rs +++ b/tests/net-client.rs @@ -1,7 +1,7 @@ #![cfg(feature = "net")] -use domain::stelline::client::do_client_simple; use domain::stelline::client::CurrStepValue; +use domain::stelline::client::do_client_simple; use domain::stelline::connect::Connect; use domain::stelline::connection::Connection; use domain::stelline::dgram::Dgram; @@ -157,7 +157,7 @@ fn tcp() { /// Regression test: Ensure responses are not lost when a stream closes. #[test] fn stream_immediate_eof() { - use domain::base::{iana::Rcode, MessageBuilder, Name, Rtype}; + use domain::base::{MessageBuilder, Name, Rtype, iana::Rcode}; use domain::rdata::A; use futures_util::FutureExt as _; use tokio::io::{AsyncReadExt as _, AsyncWriteExt as _};