More dyn update stuff
This commit is contained in:
parent
9fcbef5edc
commit
1ebb11deaf
60
update.go
60
update.go
|
@ -1,7 +1,5 @@
|
||||||
package dns
|
package dns
|
||||||
|
|
||||||
import ()
|
|
||||||
|
|
||||||
// Implements wrapper functions for dealing with dynamic update packets.
|
// Implements wrapper functions for dealing with dynamic update packets.
|
||||||
// Dynamic update packets are identical to normal DNS messages, but the
|
// Dynamic update packets are identical to normal DNS messages, but the
|
||||||
// names are redefined. See RFC 2136 for the details.
|
// names are redefined. See RFC 2136 for the details.
|
||||||
|
@ -27,6 +25,15 @@ func (u *Update) Additional() []RR {
|
||||||
return u.Msg.Extra
|
return u.Msg.Extra
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewUpdate creats a new DNS update packet.
|
||||||
|
func NewUpdate(zone string, class uint16) *Update {
|
||||||
|
u := new(Update)
|
||||||
|
u.MsgHdr.Opcode = OpcodeUpdate
|
||||||
|
u.Question = make([]Question, 1)
|
||||||
|
u.Question[0] = Question{zone, TypeSOA, class}
|
||||||
|
return u
|
||||||
|
}
|
||||||
|
|
||||||
// 3.2.4 - Table Of Metavalues Used In Prerequisite Section
|
// 3.2.4 - Table Of Metavalues Used In Prerequisite Section
|
||||||
//
|
//
|
||||||
// CLASS TYPE RDATA Meaning
|
// CLASS TYPE RDATA Meaning
|
||||||
|
@ -37,55 +44,52 @@ func (u *Update) Additional() []RR {
|
||||||
// NONE rrset empty RRset does not exist
|
// NONE rrset empty RRset does not exist
|
||||||
// zone rrset rr RRset exists (value dependent)
|
// zone rrset rr RRset exists (value dependent)
|
||||||
|
|
||||||
// PrereqNameUsed sets the RRs in the prereq section to
|
// NameUsed sets the RRs in the prereq section to
|
||||||
// "Name is in use" RRs. RFC 2136 section 2.4.4.
|
// "Name is in use" RRs. RFC 2136 section 2.4.4.
|
||||||
func (u *Update) PrereqNameUsed(rr []RR) {
|
func (u *Update) NameUsed(rr []RR) {
|
||||||
u.Msg.Answer = make([]RR, len(rr))
|
u.Answer = make([]RR, len(rr))
|
||||||
for i, r := range rr {
|
for i, r := range rr {
|
||||||
u.Msg.Answer[i] = &RR_ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: TypeANY, Class: ClassANY}}
|
u.Answer[i] = &RR_ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: TypeANY, Class: ClassANY}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrereqNameNotUsed sets the RRs in the prereq section to
|
// NameNotUsed sets the RRs in the prereq section to
|
||||||
// "Name is in not use" RRs. RFC 2136 section 2.4.5.
|
// "Name is in not use" RRs. RFC 2136 section 2.4.5.
|
||||||
func (u *Update) PrereqNameNotUsed(rr []RR) {
|
func (u *Update) NameNotUsed(rr []RR) {
|
||||||
u.Msg.Answer = make([]RR, len(rr))
|
u.Answer = make([]RR, len(rr))
|
||||||
for i, r := range rr {
|
for i, r := range rr {
|
||||||
u.Msg.Answer[i] = &RR_ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: TypeANY, Class: ClassNONE}}
|
u.Answer[i] = &RR_ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: TypeANY, Class: ClassNONE}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrereqRRsetUsedFull sets the RRs in the prereq section to
|
// RRsetUsedFull sets the RRs in the prereq section to
|
||||||
// "RRset exists (value dependent -- with rdata)" RRs. RFC 2136 section 2.4.2.
|
// "RRset exists (value dependent -- with rdata)" RRs. RFC 2136 section 2.4.2.
|
||||||
func (u *Update) PrereqRRsetUsedFull(rr []RR) {
|
func (u *Update) RRsetUsedFull(rr []RR) {
|
||||||
u.Msg.Answer = make([]RR, len(rr))
|
u.Answer = make([]RR, len(rr))
|
||||||
for i, r := range rr {
|
for i, r := range rr {
|
||||||
u.Msg.Answer[i] = r
|
u.Answer[i] = r
|
||||||
u.Msg.Answer[i].Header().Class = u.Msg.Question[0].Qclass // TODO crashes if question is zero
|
u.Answer[i].Header().Class = u.Msg.Question[0].Qclass // TODO crashes if question is zero
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrereqRRsetUsed sets the RRs in the prereq section to
|
// RRsetUsed sets the RRs in the prereq section to
|
||||||
// "RRset exists (value independent -- no rdata)" RRs. RFC 2136 section 2.4.1.
|
// "RRset exists (value independent -- no rdata)" RRs. RFC 2136 section 2.4.1.
|
||||||
func (u *Update) PrereqRRsetUsed(rr []RR) {
|
func (u *Update) RRsetUsed(rr []RR) {
|
||||||
u.Msg.Answer = make([]RR, len(rr))
|
u.Answer = make([]RR, len(rr))
|
||||||
for i, r := range rr {
|
for i, r := range rr {
|
||||||
u.Msg.Answer[i] = r
|
u.Answer[i] = r
|
||||||
u.Msg.Answer[i].Header().Class = ClassANY
|
u.Answer[i].Header().Class = ClassANY
|
||||||
/* rdata should be cleared */
|
/* rdata should be cleared */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrereqRRsetNotUsed sets the RRs in the prereq section to
|
// RRsetNotUsed sets the RRs in the prereq section to
|
||||||
// "RRset does not exist" RRs. RFC 2136 section 2.4.3.
|
// "RRset does not exist" RRs. RFC 2136 section 2.4.3.
|
||||||
func (u *Update) PrereqRRsetNotUsed(rr []RR) {
|
func (u *Update) RRsetNotUsed(rr []RR) {
|
||||||
u.Msg.Answer = make([]RR, len(rr))
|
u.Answer = make([]RR, len(rr))
|
||||||
for i, r := range rr {
|
for i, r := range rr {
|
||||||
u.Msg.Answer[i] = r
|
u.Answer[i] = r
|
||||||
u.Msg.Answer[i].Header().Class = ClassNONE
|
u.Answer[i].Header().Class = ClassNONE
|
||||||
/* rdata should be cleared */
|
/* rdata should be cleared */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue