Lose a loop in Msg.RemoveRRset() and use copyHeader()
Per @miekg's advice
This commit is contained in:
parent
104b206d2c
commit
022d2d4a01
22
update.go
22
update.go
|
@ -105,19 +105,17 @@ func (u *Msg) Insert(rr []RR) {
|
||||||
// RemoveRRset creates a dynamic update packet that deletes an RRset, see RFC 2136 section 2.5.2.
|
// RemoveRRset creates a dynamic update packet that deletes an RRset, see RFC 2136 section 2.5.2.
|
||||||
func (u *Msg) RemoveRRset(rr []RR) {
|
func (u *Msg) RemoveRRset(rr []RR) {
|
||||||
m := make(map[RR_Header]struct{})
|
m := make(map[RR_Header]struct{})
|
||||||
|
u.Ns = make([]RR, 0, len(rr))
|
||||||
for _, r := range rr {
|
for _, r := range rr {
|
||||||
h := r.Header()
|
h := *r.Header().copyHeader()
|
||||||
m[RR_Header{
|
h.Class = ClassANY
|
||||||
Name: h.Name,
|
h.Ttl = 0
|
||||||
Rrtype: h.Rrtype,
|
h.Rdlength = 0
|
||||||
Class: ClassANY,
|
if _, ok := m[h]; ok {
|
||||||
Ttl: 0,
|
continue
|
||||||
Rdlength: 0,
|
}
|
||||||
}] = struct{}{}
|
m[h] = struct{}{}
|
||||||
}
|
u.Ns = append(u.Ns, &ANY{h})
|
||||||
u.Ns = make([]RR, 0, len(m))
|
|
||||||
for t := range m {
|
|
||||||
u.Ns = append(u.Ns, &ANY{t})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue