diff --git a/simple-dns/Cargo.toml b/simple-dns/Cargo.toml index c7acbdf..9614a87 100644 --- a/simple-dns/Cargo.toml +++ b/simple-dns/Cargo.toml @@ -11,10 +11,10 @@ categories = ["parser-implementations", "network-programming"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -bitflags = "1.3" +bitflags = "2.4" [dev-dependencies] -criterion = "0.3" +criterion = "0.5" [lib] bench = false diff --git a/simple-dns/src/dns/header.rs b/simple-dns/src/dns/header.rs index a109389..3714392 100644 --- a/simple-dns/src/dns/header.rs +++ b/simple-dns/src/dns/header.rs @@ -74,7 +74,7 @@ impl<'a> Header<'a> { id: u16::from_be_bytes(data[..2].try_into()?), opcode: ((flags & masks::OPCODE_MASK) >> masks::OPCODE_MASK.trailing_zeros()).into(), response_code: (flags & masks::RESPONSE_CODE_MASK).into(), - z_flags: PacketFlag { bits: flags }, + z_flags: PacketFlag::from_bits_truncate(flags), opt: None, }; Ok(header) diff --git a/simple-dns/src/dns/header_buffer.rs b/simple-dns/src/dns/header_buffer.rs index 0346c02..012c85f 100644 --- a/simple-dns/src/dns/header_buffer.rs +++ b/simple-dns/src/dns/header_buffer.rs @@ -115,7 +115,7 @@ pub fn has_flags(buffer: &[u8], flags: PacketFlag) -> crate::Result { buffer[2..4] .try_into() .map(u16::from_be_bytes) - .map(|bits| PacketFlag { bits }.contains(flags)) + .map(|bits| PacketFlag::from_bits_truncate(bits).contains(flags)) .map_err(|_| crate::SimpleDnsError::InvalidHeaderData) } diff --git a/simple-dns/src/dns/mod.rs b/simple-dns/src/dns/mod.rs index 41d7539..e901e65 100644 --- a/simple-dns/src/dns/mod.rs +++ b/simple-dns/src/dns/mod.rs @@ -36,6 +36,7 @@ const MAX_NULL_LENGTH: usize = 65535; bitflags! { /// Possible Packet Flags + #[derive(Debug, Clone)] pub struct PacketFlag: u16 { /// Indicates if this packet is a query or a response. This is the QR flag in the DNS /// specifications, this flag is called Response here to be more ergonomic diff --git a/simple-mdns/Cargo.toml b/simple-mdns/Cargo.toml index 7f188c7..a75c588 100644 --- a/simple-mdns/Cargo.toml +++ b/simple-mdns/Cargo.toml @@ -13,18 +13,22 @@ categories = ["network-programming"] all-features = true [features] -default = [] +default = [] sync = [] async-tokio = ["dep:tokio"] [dependencies] simple-dns = { path = "../simple-dns", version = "0.5" } -socket2 = { version = "^0.4", features = ["all"] } +socket2 = { version = "0.5", features = ["all"] } log = "^0.4" lazy_static = "^1.4.0" radix_trie = "^0.2.1" -tokio = { version = "^1.22", features = ["net", "sync", "rt"], optional = true, default-features=false } +tokio = { version = "1.32", features = [ + "net", + "sync", + "rt", +], optional = true, default-features = false } [dev-dependencies] stderrlog = "^0.5" -tokio = { version = "^1.22", features = ["full"] } +tokio = { version = "1.32", features = ["full"] }