Updating filepath in auto plugin if existing zone's file changes location (#1901) (#1910)

Exporting Zone.File to avoid getters and setters

Updating getter and setter for Zone.File to be less racy

Renaming GetFile to File in zone plugin
This commit is contained in:
Joey Espinosa
2018-07-03 06:20:39 -04:00
committed by Miek Gieben
parent 908d4fbd23
commit c2780f42c4
4 changed files with 68 additions and 5 deletions

View File

@@ -124,6 +124,20 @@ func (z *Zone) Insert(r dns.RR) error {
// Delete deletes r from z.
func (z *Zone) Delete(r dns.RR) { z.Tree.Delete(r) }
// File retrieves the file path in a safe way
func (z *Zone) File() string {
z.reloadMu.Lock()
defer z.reloadMu.Unlock()
return z.file
}
// SetFile updates the file path in a safe way
func (z *Zone) SetFile(path string) {
z.reloadMu.Lock()
z.file = path
z.reloadMu.Unlock()
}
// TransferAllowed checks if incoming request for transferring the zone is allowed according to the ACLs.
func (z *Zone) TransferAllowed(state request.Request) bool {
for _, t := range z.TransferTo {