Rename *all* dynamic update function
Be more consistent with the rest of the function names. I also started on implementinf the dynamic update function to the zone implementation. Those names will also be in sync.
This commit is contained in:
parent
878955c688
commit
89cb935efe
47
update.go
47
update.go
|
@ -14,10 +14,10 @@
|
||||||
// CLASS TYPE RDATA Meaning Function
|
// CLASS TYPE RDATA Meaning Function
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// ANY ANY empty Name is in use NameUsed
|
// ANY ANY empty Name is in use NameUsed
|
||||||
// ANY rrset empty RRset exists (value indep) RRsetUsedNoRdata
|
// ANY rrset empty RRset exists (value indep) RRsetUsed
|
||||||
// NONE ANY empty Name is not in use NameNotUsed
|
// NONE ANY empty Name is not in use NameNotUsed
|
||||||
// NONE rrset empty RRset does not exist RRsetNotUsed
|
// NONE rrset empty RRset does not exist RRsetNotUsed
|
||||||
// zone rrset rr RRset exists (value dep) RRsetUsedRdata
|
// zone rrset rr RRset exists (value dep) RRUsed
|
||||||
//
|
//
|
||||||
// The prerequisite section can also be left empty.
|
// The prerequisite section can also be left empty.
|
||||||
// If you have decided on the prerequisites you can tell what RRs should
|
// If you have decided on the prerequisites you can tell what RRs should
|
||||||
|
@ -28,10 +28,10 @@
|
||||||
//
|
//
|
||||||
// CLASS TYPE RDATA Meaning Function
|
// CLASS TYPE RDATA Meaning Function
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// ANY ANY empty Delete all RRsets from name NameDelete
|
// ANY ANY empty Delete all RRsets from name RemoveName
|
||||||
// ANY rrset empty Delete an RRset RRsetDelete
|
// ANY rrset empty Delete an RRset RemoveRRset
|
||||||
// NONE rrset rr Delete an RR from RRset RRsetDeleteRR
|
// NONE rrset rr Delete an RR from RRset RemoveRR
|
||||||
// zone rrset rr Add to an RRset RRsetAddRdata
|
// zone rrset rr Add to an RRset AddRR
|
||||||
//
|
//
|
||||||
package dns
|
package dns
|
||||||
|
|
||||||
|
@ -53,9 +53,9 @@ func (u *Msg) NameNotUsed(rr []RR) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// RRsetUsedRdata sets the RRs in the prereq section to
|
// RRUsed 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 *Msg) RRsetUsedRdata(rr []RR) {
|
func (u *Msg) RRUsed(rr []RR) {
|
||||||
if len(u.Question) == 0 {
|
if len(u.Question) == 0 {
|
||||||
panic("dns: empty question section")
|
panic("dns: empty question section")
|
||||||
}
|
}
|
||||||
|
@ -66,9 +66,9 @@ func (u *Msg) RRsetUsedRdata(rr []RR) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// RRsetUsedNoRdata 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 *Msg) RRsetUsedNoRdata(rr []RR) {
|
func (u *Msg) RRsetUsed(rr []RR) {
|
||||||
u.Answer = make([]RR, len(rr))
|
u.Answer = make([]RR, len(rr))
|
||||||
for i, r := range rr {
|
for i, r := range rr {
|
||||||
u.Answer[i] = r
|
u.Answer[i] = r
|
||||||
|
@ -90,19 +90,8 @@ func (u *Msg) RRsetNotUsed(rr []RR) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The table from RFC 2136 supplemented with the Go DNS function.
|
// AddRR creates a dynamic update packet that adds an complete RRset, see RFC 2136 section 2.5.1.
|
||||||
//
|
func (u *Msg) AddRR(rr []RR) {
|
||||||
// 3.4.2.6 - Table Of Metavalues Used In Update Section
|
|
||||||
//
|
|
||||||
// CLASS TYPE RDATA Meaning Function
|
|
||||||
// -----------------------------------------------------------------
|
|
||||||
// ANY ANY empty Delete all RRsets from name NameDelete
|
|
||||||
// ANY rrset empty Delete an RRset RRsetDelete
|
|
||||||
// NONE rrset rr Delete an RR from RRset RRsetDeleteRR
|
|
||||||
// zone rrset rr Add to an RRset RRsetAddRdata
|
|
||||||
|
|
||||||
// RRsetAddRdata creates a dynamic update packet that adds an complete RRset, see RFC 2136 section 2.5.1
|
|
||||||
func (u *Msg) RRsetAddRdata(rr []RR) {
|
|
||||||
if len(u.Question) == 0 {
|
if len(u.Question) == 0 {
|
||||||
panic("dns: empty question section")
|
panic("dns: empty question section")
|
||||||
}
|
}
|
||||||
|
@ -113,8 +102,8 @@ func (u *Msg) RRsetAddRdata(rr []RR) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// RRsetDelete 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) RRsetDelete(rr []RR) {
|
func (u *Msg) RemoveRRset(rr []RR) {
|
||||||
u.Ns = make([]RR, len(rr))
|
u.Ns = make([]RR, len(rr))
|
||||||
for i, r := range rr {
|
for i, r := range rr {
|
||||||
u.Ns[i] = r
|
u.Ns[i] = r
|
||||||
|
@ -124,16 +113,16 @@ func (u *Msg) RRsetDelete(rr []RR) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NameDelete creates a dynamic update packet that deletes all RRsets of a name, see RFC 2136 section 2.5.3
|
// RemoveName creates a dynamic update packet that deletes all RRsets of a name, see RFC 2136 section 2.5.3
|
||||||
func (u *Msg) NameDelete(rr []RR) {
|
func (u *Msg) RemoveName(rr []RR) {
|
||||||
u.Ns = make([]RR, len(rr))
|
u.Ns = make([]RR, len(rr))
|
||||||
for i, r := range rr {
|
for i, r := range rr {
|
||||||
u.Ns[i] = &RR_ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: TypeANY, Class: ClassANY}}
|
u.Ns[i] = &RR_ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: TypeANY, Class: ClassANY}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// RRsetDeleteRR creates a dynamic update packet deletes RR from the RRSset, see RFC 2136 section 2.5.4
|
// RRsetRemoveRR creates a dynamic update packet deletes RR from the RRSset, see RFC 2136 section 2.5.4
|
||||||
func (u *Msg) RRsetDeleteRR(rr []RR) {
|
func (u *Msg) RemoveRR(rr []RR) {
|
||||||
u.Ns = make([]RR, len(rr))
|
u.Ns = make([]RR, len(rr))
|
||||||
for i, r := range rr {
|
for i, r := range rr {
|
||||||
u.Ns[i] = r
|
u.Ns[i] = r
|
||||||
|
|
25
zone.go
25
zone.go
|
@ -148,6 +148,7 @@ func toRadixName(d string) string {
|
||||||
// // z contains the zone
|
// // z contains the zone
|
||||||
// z.Radix.DoNext(func(i interface{}) {
|
// z.Radix.DoNext(func(i interface{}) {
|
||||||
// fmt.Printf("%s", i.(*dns.ZoneData).String()) })
|
// fmt.Printf("%s", i.(*dns.ZoneData).String()) })
|
||||||
|
//
|
||||||
func (zd *ZoneData) String() string {
|
func (zd *ZoneData) String() string {
|
||||||
var (
|
var (
|
||||||
s string
|
s string
|
||||||
|
@ -312,6 +313,30 @@ func (z *Zone) Remove(r RR) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RemoveName removes all the RRs with ownername matching s from the zone. Typical use of this
|
||||||
|
// function is when processing a RemoveName dynamic update packet.
|
||||||
|
func (z *Zone) RemoveName(s string) error {
|
||||||
|
key := toRadixName(s)
|
||||||
|
z.Lock()
|
||||||
|
zd, exact := z.Radix.Find(key)
|
||||||
|
if !exact {
|
||||||
|
defer z.Unlock()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
z.Unlock()
|
||||||
|
zd.Value.(*ZoneData).mutex.Lock()
|
||||||
|
defer zd.Value.(*ZoneData).mutex.Unlock()
|
||||||
|
zd.Value = nil // remove the lot
|
||||||
|
|
||||||
|
if len(s) > 1 && s[0] == '*' && s[1] == '.' {
|
||||||
|
z.Wildcard--
|
||||||
|
if z.Wildcard < 0 {
|
||||||
|
z.Wildcard = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Find looks up the ownername s in the zone and returns the
|
// Find looks up the ownername s in the zone and returns the
|
||||||
// data and true when an exact match is found. If an exact find isn't
|
// data and true when an exact match is found. If an exact find isn't
|
||||||
// possible the first parent node with a non-nil Value is returned and
|
// possible the first parent node with a non-nil Value is returned and
|
||||||
|
|
Loading…
Reference in New Issue