pdns: notify secondary servers after updates (#1679)

Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
This commit is contained in:
Daniel Albert 2022-09-17 18:20:41 +02:00 committed by GitHub
parent 60bd1c205e
commit 0bcada7921
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 0 deletions

View file

@ -137,6 +137,17 @@ func (d *DNSProvider) getAPIVersion() (int, error) {
return latestVersion, err return latestVersion, err
} }
func (d *DNSProvider) notify(zoneURL string) error {
if d.apiVersion >= 1 {
p := path.Join(zoneURL, "/notify")
_, err := d.sendRequest(http.MethodPut, p, nil)
if err != nil {
return err
}
}
return nil
}
func (d *DNSProvider) sendRequest(method, uri string, body io.Reader) (json.RawMessage, error) { func (d *DNSProvider) sendRequest(method, uri string, body io.Reader) (json.RawMessage, error) {
req, err := d.makeRequest(method, uri, body) req, err := d.makeRequest(method, uri, body)
if err != nil { if err != nil {

View file

@ -172,6 +172,16 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error {
if err != nil { if err != nil {
return fmt.Errorf("pdns: %w", err) return fmt.Errorf("pdns: %w", err)
} }
if d.apiVersion < 1 {
return nil
}
err = d.notify(zone.URL)
if err != nil {
return fmt.Errorf("pdns: %w", err)
}
return nil return nil
} }
@ -210,5 +220,15 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
if err != nil { if err != nil {
return fmt.Errorf("pdns: %w", err) return fmt.Errorf("pdns: %w", err)
} }
if d.apiVersion < 1 {
return nil
}
err = d.notify(zone.URL)
if err != nil {
return fmt.Errorf("pdns: %w", err)
}
return nil return nil
} }