~kf5jwc/dns-server-rs

77b26c44e536ebfba637194ef3411206f660fec9 — Kyle Jones 6 months ago 66a267d
bugfix: Don't pull 4 u32's for a u32 address.
1 files changed, 2 insertions(+), 3 deletions(-)

M src/dns_packet/dns_record.rs
M src/dns_packet/dns_record.rs => src/dns_packet/dns_record.rs +2 -3
@@ 29,10 29,9 @@ impl DnsRecord {

        match qtype {
            QueryType::A => {
                let raw_addrs: Vec<u32> = (0..4).map(|_| buffer.read_u32().expect("Next raw address group")).collect();
                let mut raw_addrs_iter = raw_addrs.iter();
                let raw_addr = buffer.read_u32().expect("Next raw address group");
                let addr_groups: Vec<u8> = [24u8, 16, 8, 0].iter()
                    .map(|shift| ((raw_addrs_iter.next().expect("Next address group") >> shift) & 0xFF) as u8)
                    .map(|shift| ((raw_addr >> shift) & 0xFF) as u8)
                    .collect();
                let addr = Ipv4Addr::new(addr_groups[0], addr_groups[1], addr_groups[2], addr_groups[3]);