diff --git a/defaults.go b/defaults.go index 1f487b14..7aa1b0ca 100644 --- a/defaults.go +++ b/defaults.go @@ -42,7 +42,7 @@ func (dns *Msg) SetRcode(request *Msg, rcode int) { dns.Question[0] = request.Question[0] } -// IsRocde checks if the header of the packet has rcode set. +// IsRcode checks if the header of the packet has rcode set. func (dns *Msg) IsRcode(rcode int) (ok bool) { if len(dns.Question) == 0 { return false @@ -69,7 +69,7 @@ func (dns *Msg) IsRcodeFormatError() (ok bool) { return } -// Is the message a dynamic update packet? +// IsUpdate checks if the message is a dynamic update packet? func (dns *Msg) IsUpdate() (ok bool) { if len(dns.Question) == 0 { return false @@ -79,6 +79,14 @@ func (dns *Msg) IsUpdate() (ok bool) { return } +// SetUpdate makes the message a dynamic update packet. It +// sets the ZONE section to: z, TypeSOA, classINET. +func (dns *Msg) SetUpdate(z string) { + dns.MsgHdr.Opcode = OpcodeUpdate + dns.Question = make([]Question, 1) + dns.Question[0] = Question{z, TypeSOA, ClassINET} +} + // Is the message a valid notify packet? func (dns *Msg) IsNotify() (ok bool) { if len(dns.Question) == 0 {