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