Fix data length field
This commit is contained in:
parent
559b1857b9
commit
8b280c3971
|
@ -158,13 +158,14 @@ func parseResourceRecord*(data: string, startOffset: uint16): (DnsRecord, uint16
|
||||||
|
|
||||||
func packResourceRecord*(data: DnsRecord): string =
|
func packResourceRecord*(data: DnsRecord): string =
|
||||||
var record = ""
|
var record = ""
|
||||||
|
let body = (if data.rtype == DnsType.NS: packNameField(data.rdata) else: data.rdata)
|
||||||
|
|
||||||
record.add(packNameField(data.name))
|
record.add(packNameField(data.name))
|
||||||
record.add(uint16ToString(data.rtype.uint16))
|
record.add(uint16ToString(data.rtype.uint16))
|
||||||
record.add(uint16ToString(data.class.uint16))
|
record.add(uint16ToString(data.class.uint16))
|
||||||
record.add(uint32ToString(data.ttl.uint32))
|
record.add(uint32ToString(data.ttl.uint32))
|
||||||
record.add(uint16ToString(data.rdlength.uint16))
|
record.add(uint16ToString(body.len.uint16))
|
||||||
record.add((if data.rtype == DnsType.NS: packNameField(data.rdata) else: data.rdata))
|
record.add(body)
|
||||||
|
|
||||||
return record
|
return record
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue