Add complete secondary support

Respond to notifies and allow a secondary to follow the SOA parameters

to update a zone from a primary. Also sprinkle it with logging.



Also extend monitoring to include qtype in more metrics.
This commit is contained in:
Miek Gieben
2016-04-05 10:53:23 +01:00
parent 20e16491ec
commit c961acbb6e
8 changed files with 207 additions and 21 deletions

View File

@@ -14,6 +14,16 @@ func File(c *Controller) (middleware.Middleware, error) {
return nil, err
}
// Add startup functions to notify the master.
for _, n := range zones.Names {
if len(zones.Z[n].TransferTo) > 0 {
c.Startup = append(c.Startup, func() error {
zones.Z[n].Notify()
return err
})
}
}
return func(next middleware.Handler) middleware.Handler {
return file.File{Next: next, Zones: zones}
}, nil
@@ -58,7 +68,9 @@ func fileParse(c *Controller) (file.Zones, error) {
}
// discard from, here, maybe check and show log when we do?
for _, origin := range origins {
z[origin].TransferTo = append(z[origin].TransferTo, t)
if t != "" {
z[origin].TransferTo = append(z[origin].TransferTo, t)
}
}
}
}

View File

@@ -13,13 +13,19 @@ func Secondary(c *Controller) (middleware.Middleware, error) {
return nil, err
}
// Setup retrieve the zone.
// Add startup functions to retrieve the zone and keep it up to date.
for _, n := range zones.Names {
if len(zones.Z[n].TransferFrom) > 0 {
c.Startup = append(c.Startup, func() error {
err := zones.Z[n].TransferIn()
return err
})
c.Startup = append(c.Startup, func() error {
go func() {
zones.Z[n].Update()
}()
return nil
})
}
}
@@ -52,8 +58,12 @@ func secondaryParse(c *Controller) (file.Zones, error) {
return file.Zones{}, e
}
for _, origin := range origins {
z[origin].TransferTo = append(z[origin].TransferTo, t)
z[origin].TransferFrom = append(z[origin].TransferFrom, f)
if t != "" {
z[origin].TransferTo = append(z[origin].TransferTo, t)
}
if f != "" {
z[origin].TransferFrom = append(z[origin].TransferFrom, f)
}
}
}
}