Fix data length field

This commit is contained in:
Martin 2022-02-06 22:19:04 +01:00
parent 559b1857b9
commit 8b280c3971
Signed by: mawalu
GPG Key ID: BF556F989760A7C8
1 changed files with 3 additions and 2 deletions

View File

@ -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