From 0bcada7921a59c53db2d89297e0522688a1862d2 Mon Sep 17 00:00:00 2001 From: Daniel Albert <7432848+esclear@users.noreply.github.com> Date: Sat, 17 Sep 2022 18:20:41 +0200 Subject: [PATCH] pdns: notify secondary servers after updates (#1679) Co-authored-by: Fernandez Ludovic --- providers/dns/pdns/client.go | 11 +++++++++++ providers/dns/pdns/pdns.go | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/providers/dns/pdns/client.go b/providers/dns/pdns/client.go index 5c1187fa..154dbc26 100644 --- a/providers/dns/pdns/client.go +++ b/providers/dns/pdns/client.go @@ -137,6 +137,17 @@ func (d *DNSProvider) getAPIVersion() (int, error) { 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) { req, err := d.makeRequest(method, uri, body) if err != nil { diff --git a/providers/dns/pdns/pdns.go b/providers/dns/pdns/pdns.go index 0410a22e..e73b4072 100644 --- a/providers/dns/pdns/pdns.go +++ b/providers/dns/pdns/pdns.go @@ -172,6 +172,16 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { if err != nil { 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 } @@ -210,5 +220,15 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { if err != nil { 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 }