Add mtime to the zone structure
This commit is contained in:
parent
25e58e4edd
commit
885aba5fad
18
zone.go
18
zone.go
|
@ -16,13 +16,13 @@ import (
|
||||||
// Zone represents a DNS zone. It's safe for concurrent use by
|
// Zone represents a DNS zone. It's safe for concurrent use by
|
||||||
// multilpe goroutines.
|
// multilpe goroutines.
|
||||||
type Zone struct {
|
type Zone struct {
|
||||||
Origin string // Origin of the zone
|
Origin string // Origin of the zone
|
||||||
olabels []string // origin cut up in labels, just to speed up the isSubDomain method
|
olabels []string // origin cut up in labels, just to speed up the isSubDomain method
|
||||||
Wildcard int // Whenever we see a wildcard name, this is incremented
|
Wildcard int // Whenever we see a wildcard name, this is incremented
|
||||||
*radix.Radix // Zone data
|
expired bool // Slave zone is expired
|
||||||
|
mtime time.Time // When is the zone last modified
|
||||||
|
*radix.Radix // Zone data
|
||||||
*sync.RWMutex
|
*sync.RWMutex
|
||||||
expired bool // Slave zone is expired
|
|
||||||
// Do we need a timemodified?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type uint16Slice []uint16
|
type uint16Slice []uint16
|
||||||
|
@ -84,6 +84,7 @@ func NewZone(origin string) *Zone {
|
||||||
z.olabels = SplitLabels(z.Origin)
|
z.olabels = SplitLabels(z.Origin)
|
||||||
z.Radix = radix.New()
|
z.Radix = radix.New()
|
||||||
z.RWMutex = new(sync.RWMutex)
|
z.RWMutex = new(sync.RWMutex)
|
||||||
|
z.mtime = time.Now().UTC()
|
||||||
return z
|
return z
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,6 +203,7 @@ func (z *Zone) Insert(r RR) error {
|
||||||
|
|
||||||
key := toRadixName(r.Header().Name)
|
key := toRadixName(r.Header().Name)
|
||||||
z.Lock()
|
z.Lock()
|
||||||
|
z.mtime = time.Now.UTC()
|
||||||
zd, exact := z.Radix.Find(key)
|
zd, exact := z.Radix.Find(key)
|
||||||
if !exact {
|
if !exact {
|
||||||
// Not an exact match, so insert new value
|
// Not an exact match, so insert new value
|
||||||
|
@ -251,6 +253,7 @@ func (z *Zone) Insert(r RR) error {
|
||||||
func (z *Zone) Remove(r RR) error {
|
func (z *Zone) Remove(r RR) error {
|
||||||
key := toRadixName(r.Header().Name)
|
key := toRadixName(r.Header().Name)
|
||||||
z.Lock()
|
z.Lock()
|
||||||
|
m.mtime = time.Now.UTC()
|
||||||
zd, exact := z.Radix.Find(key)
|
zd, exact := z.Radix.Find(key)
|
||||||
if !exact {
|
if !exact {
|
||||||
defer z.Unlock()
|
defer z.Unlock()
|
||||||
|
@ -312,6 +315,7 @@ func (z *Zone) Remove(r RR) error {
|
||||||
func (z *Zone) RemoveName(s string) error {
|
func (z *Zone) RemoveName(s string) error {
|
||||||
key := toRadixName(s)
|
key := toRadixName(s)
|
||||||
z.Lock()
|
z.Lock()
|
||||||
|
z.mtime = time.Now().UTC()
|
||||||
defer z.Unlock()
|
defer z.Unlock()
|
||||||
z.Radix.Remove(key)
|
z.Radix.Remove(key)
|
||||||
if len(s) > 1 && s[0] == '*' && s[1] == '.' {
|
if len(s) > 1 && s[0] == '*' && s[1] == '.' {
|
||||||
|
@ -327,6 +331,7 @@ func (z *Zone) RemoveName(s string) error {
|
||||||
// Typical use of this method is when processing a RemoveRRset dynamic update packet.
|
// Typical use of this method is when processing a RemoveRRset dynamic update packet.
|
||||||
func (z *Zone) RemoveRRset(s string, t uint16) error {
|
func (z *Zone) RemoveRRset(s string, t uint16) error {
|
||||||
z.Lock()
|
z.Lock()
|
||||||
|
z.mtime = time.Now().UTC()
|
||||||
zd, exact := z.Radix.Find(toRadixName(s))
|
zd, exact := z.Radix.Find(toRadixName(s))
|
||||||
if !exact {
|
if !exact {
|
||||||
defer z.Unlock()
|
defer z.Unlock()
|
||||||
|
@ -418,6 +423,7 @@ func (z *Zone) isSubDomain(child string) bool {
|
||||||
// // Admire your signed zone...
|
// // Admire your signed zone...
|
||||||
func (z *Zone) Sign(keys map[*RR_DNSKEY]PrivateKey, config *SignatureConfig) error {
|
func (z *Zone) Sign(keys map[*RR_DNSKEY]PrivateKey, config *SignatureConfig) error {
|
||||||
z.Lock()
|
z.Lock()
|
||||||
|
z.mtime = time.Now().UTC()
|
||||||
defer z.Unlock()
|
defer z.Unlock()
|
||||||
if config == nil {
|
if config == nil {
|
||||||
config = DefaultSignatureConfig
|
config = DefaultSignatureConfig
|
||||||
|
|
Loading…
Reference in New Issue