2016-01-08 16:56:01 -05:00
|
|
|
package dns
|
|
|
|
|
|
|
|
// NameUsed sets the RRs in the prereq section to
|
|
|
|
// "Name is in use" RRs. RFC 2136 section 2.4.4.
|
|
|
|
func (u *Msg) NameUsed(rr []RR) {
|
2018-06-01 10:24:59 -04:00
|
|
|
if u.Answer == nil {
|
|
|
|
u.Answer = make([]RR, 0, len(rr))
|
|
|
|
}
|
|
|
|
for _, r := range rr {
|
|
|
|
u.Answer = append(u.Answer, &ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: TypeANY, Class: ClassANY}})
|
2016-01-08 16:56:01 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NameNotUsed sets the RRs in the prereq section to
|
|
|
|
// "Name is in not use" RRs. RFC 2136 section 2.4.5.
|
|
|
|
func (u *Msg) NameNotUsed(rr []RR) {
|
2018-06-01 10:24:59 -04:00
|
|
|
if u.Answer == nil {
|
|
|
|
u.Answer = make([]RR, 0, len(rr))
|
|
|
|
}
|
|
|
|
for _, r := range rr {
|
|
|
|
u.Answer = append(u.Answer, &ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: TypeANY, Class: ClassNONE}})
|
2016-01-08 16:56:01 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Used sets the RRs in the prereq section to
|
|
|
|
// "RRset exists (value dependent -- with rdata)" RRs. RFC 2136 section 2.4.2.
|
|
|
|
func (u *Msg) Used(rr []RR) {
|
|
|
|
if len(u.Question) == 0 {
|
|
|
|
panic("dns: empty question section")
|
|
|
|
}
|
2018-06-01 10:24:59 -04:00
|
|
|
if u.Answer == nil {
|
|
|
|
u.Answer = make([]RR, 0, len(rr))
|
|
|
|
}
|
|
|
|
for _, r := range rr {
|
|
|
|
r.Header().Class = u.Question[0].Qclass
|
|
|
|
u.Answer = append(u.Answer, r)
|
2016-01-08 16:56:01 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// RRsetUsed sets the RRs in the prereq section to
|
|
|
|
// "RRset exists (value independent -- no rdata)" RRs. RFC 2136 section 2.4.1.
|
|
|
|
func (u *Msg) RRsetUsed(rr []RR) {
|
2018-06-01 10:24:59 -04:00
|
|
|
if u.Answer == nil {
|
|
|
|
u.Answer = make([]RR, 0, len(rr))
|
|
|
|
}
|
|
|
|
for _, r := range rr {
|
|
|
|
u.Answer = append(u.Answer, &ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: r.Header().Rrtype, Class: ClassANY}})
|
2016-01-08 16:56:01 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// RRsetNotUsed sets the RRs in the prereq section to
|
|
|
|
// "RRset does not exist" RRs. RFC 2136 section 2.4.3.
|
|
|
|
func (u *Msg) RRsetNotUsed(rr []RR) {
|
2018-06-01 10:24:59 -04:00
|
|
|
if u.Answer == nil {
|
|
|
|
u.Answer = make([]RR, 0, len(rr))
|
|
|
|
}
|
|
|
|
for _, r := range rr {
|
|
|
|
u.Answer = append(u.Answer, &ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: r.Header().Rrtype, Class: ClassNONE}})
|
2016-01-08 16:56:01 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Insert creates a dynamic update packet that adds an complete RRset, see RFC 2136 section 2.5.1.
|
|
|
|
func (u *Msg) Insert(rr []RR) {
|
|
|
|
if len(u.Question) == 0 {
|
|
|
|
panic("dns: empty question section")
|
|
|
|
}
|
2018-06-01 10:24:59 -04:00
|
|
|
if u.Ns == nil {
|
|
|
|
u.Ns = make([]RR, 0, len(rr))
|
|
|
|
}
|
|
|
|
for _, r := range rr {
|
|
|
|
r.Header().Class = u.Question[0].Qclass
|
|
|
|
u.Ns = append(u.Ns, r)
|
2016-01-08 16:56:01 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemoveRRset creates a dynamic update packet that deletes an RRset, see RFC 2136 section 2.5.2.
|
|
|
|
func (u *Msg) RemoveRRset(rr []RR) {
|
2018-06-01 10:24:59 -04:00
|
|
|
if u.Ns == nil {
|
|
|
|
u.Ns = make([]RR, 0, len(rr))
|
|
|
|
}
|
|
|
|
for _, r := range rr {
|
|
|
|
u.Ns = append(u.Ns, &ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: r.Header().Rrtype, Class: ClassANY}})
|
2016-01-08 16:56:01 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemoveName creates a dynamic update packet that deletes all RRsets of a name, see RFC 2136 section 2.5.3
|
|
|
|
func (u *Msg) RemoveName(rr []RR) {
|
2018-06-01 10:24:59 -04:00
|
|
|
if u.Ns == nil {
|
|
|
|
u.Ns = make([]RR, 0, len(rr))
|
|
|
|
}
|
|
|
|
for _, r := range rr {
|
|
|
|
u.Ns = append(u.Ns, &ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: TypeANY, Class: ClassANY}})
|
2016-01-08 16:56:01 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-01 10:24:59 -04:00
|
|
|
// Remove creates a dynamic update packet deletes RR from a RRSset, see RFC 2136 section 2.5.4
|
2016-01-08 16:56:01 -05:00
|
|
|
func (u *Msg) Remove(rr []RR) {
|
2018-06-01 10:24:59 -04:00
|
|
|
if u.Ns == nil {
|
|
|
|
u.Ns = make([]RR, 0, len(rr))
|
|
|
|
}
|
|
|
|
for _, r := range rr {
|
|
|
|
r.Header().Class = ClassNONE
|
|
|
|
r.Header().Ttl = 0
|
|
|
|
u.Ns = append(u.Ns, r)
|
2016-01-08 16:56:01 -05:00
|
|
|
}
|
|
|
|
}
|