From 8b280c3971bf4f3dc29792728f827d91a9b0358f Mon Sep 17 00:00:00 2001 From: mawalu Date: Sun, 6 Feb 2022 22:19:04 +0100 Subject: [PATCH] Fix data length field --- lib/dns.nim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/dns.nim b/lib/dns.nim index f3089e7..c98032f 100644 --- a/lib/dns.nim +++ b/lib/dns.nim @@ -158,13 +158,14 @@ func parseResourceRecord*(data: string, startOffset: uint16): (DnsRecord, uint16 func packResourceRecord*(data: DnsRecord): string = var record = "" + let body = (if data.rtype == DnsType.NS: packNameField(data.rdata) else: data.rdata) record.add(packNameField(data.name)) record.add(uint16ToString(data.rtype.uint16)) record.add(uint16ToString(data.class.uint16)) record.add(uint32ToString(data.ttl.uint32)) - record.add(uint16ToString(data.rdlength.uint16)) - record.add((if data.rtype == DnsType.NS: packNameField(data.rdata) else: data.rdata)) + record.add(uint16ToString(body.len.uint16)) + record.add(body) return record