diff --git a/Cargo.toml b/Cargo.toml index 88e5e3c..7285fef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "packeteer" description = "An attempt at a Rust library that can be used to assist in programmatically analysing, serving and handling received protocol packets." -version = "0.4.1" +version = "0.4.2" edition = "2021" authors = ["Celeste "] license = "MPL-2.0" diff --git a/src/dns.rs b/src/dns.rs index 098a130..b9a4647 100644 --- a/src/dns.rs +++ b/src/dns.rs @@ -163,6 +163,9 @@ pub fn construct(packet: Vec) -> DnsPacket { i = i + 1; v = v - 1; } + if zrtype == RecordType::TXT { + data.remove(0 as usize); + } let ans = DnsAnswer { name: 0xc00c, rtype: zrtype, class: class, ttl: ttl, data: data }; answerz.push(ans); } @@ -217,9 +220,16 @@ pub fn unpack_answer(answer: DnsAnswer) -> Vec { raw.push((low_ttl >> 8) as u8); raw.push((low_ttl & 0xff) as u8); let datums = answer.data; - let len = datums.len() as u16; + let mut len = datums.len() as u16; + if rtype == 16 { + len = len + 1; + } raw.push((len >> 8) as u8); raw.push((len & 0xff) as u8); + if rtype == 16 { + len = len - 1; + raw.push((len & 0xff) as u8); + } for byte in datums { raw.push(byte); }