From eddb36b5416c06417030ae75c82484ae9a9e0c24 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sat, 7 Jul 2018 22:01:35 +0200 Subject: [PATCH] Ignore the class for OPT records --- src/dns.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/dns.rs b/src/dns.rs index bf77067..4d9e9c4 100644 --- a/src/dns.rs +++ b/src/dns.rs @@ -1,4 +1,3 @@ -const DNS_CLASS_IN: u16 = 1; const DNS_HEADER_SIZE: usize = 12; const DNS_MAX_HOSTNAME_LEN: usize = 256; const DNS_MAX_PACKET_SIZE: usize = 65_535; @@ -100,17 +99,14 @@ pub fn min_ttl( return Err("Short packet"); } let qtype = u16::from(packet[offset]) << 8 | u16::from(packet[offset + 1]); - let qclass = u16::from(packet[offset + 2]) << 8 | u16::from(packet[offset + 3]); let ttl = u32::from(packet[offset + 4]) << 24 | u32::from(packet[offset + 5]) << 16 | u32::from(packet[offset + 6]) << 8 | u32::from(packet[offset + 7]); let rdlen = (u16::from(packet[offset + 8]) << 8 | u16::from(packet[offset + 9])) as usize; offset += 10; - if !(qtype == DNS_TYPE_OPT && qclass == DNS_CLASS_IN) { - if ttl < found_min_ttl { - found_min_ttl = ttl; - } + if qtype != DNS_TYPE_OPT && ttl < found_min_ttl { + found_min_ttl = ttl; } if rdlen > packet_len - offset { return Err("Record length would exceed packet length");