middleware/file: notify better error reporting

Slightly better errors reporting for failing to sent a notify.
This commit is contained in:
Miek Gieben
2016-11-08 21:45:27 +00:00
parent fb7fcff982
commit 0f8cb5094d

View File

@@ -56,10 +56,12 @@ func notify(zone string, to []string) error {
return nil return nil
} }
func notifyAddr(c *dns.Client, m *dns.Msg, s string) error { func notifyAddr(c *dns.Client, m *dns.Msg, s string) (err error) {
code := dns.RcodeSuccess ret := new(dns.Msg)
code := dns.RcodeServerFailure
for i := 0; i < 3; i++ { for i := 0; i < 3; i++ {
ret, _, err := c.Exchange(m, s) ret, _, err = c.Exchange(m, s)
if err != nil { if err != nil {
continue continue
} }
@@ -68,5 +70,8 @@ func notifyAddr(c *dns.Client, m *dns.Msg, s string) error {
return nil return nil
} }
} }
if err != nil {
return err
}
return fmt.Errorf("Notify for zone %q was not accepted by %q: rcode was %q", m.Question[0].Name, s, rcode.ToString(code)) return fmt.Errorf("Notify for zone %q was not accepted by %q: rcode was %q", m.Question[0].Name, s, rcode.ToString(code))
} }