forked from TrueCloudLab/lego
pdns: notify secondary servers after updates (#1679)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
This commit is contained in:
parent
60bd1c205e
commit
0bcada7921
2 changed files with 31 additions and 0 deletions
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue