mirror of
				https://github.com/go-acme/lego.git
				synced 2025-10-31 08:27:38 +02:00 
			
		
		
		
	pdns: fix usage of notify only when zone kind is Master or Slave (#1781)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
This commit is contained in:
		| @@ -28,6 +28,7 @@ type hostedZone struct { | ||||
| 	ID     string  `json:"id"` | ||||
| 	Name   string  `json:"name"` | ||||
| 	URL    string  `json:"url"` | ||||
| 	Kind   string  `json:"kind"` | ||||
| 	RRSets []rrSet `json:"rrsets"` | ||||
|  | ||||
| 	// pre-v1 API | ||||
| @@ -137,14 +138,16 @@ 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 | ||||
| 		} | ||||
| func (d *DNSProvider) notify(zone *hostedZone) error { | ||||
| 	if d.apiVersion < 1 || zone.Kind != "Master" && zone.Kind != "Slave" { | ||||
| 		return nil | ||||
| 	} | ||||
|  | ||||
| 	_, err := d.sendRequest(http.MethodPut, path.Join(zone.URL, "/notify"), nil) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -173,16 +173,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { | ||||
| 		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 d.notify(zone) | ||||
| } | ||||
|  | ||||
| // CleanUp removes the TXT record matching the specified parameters. | ||||
| @@ -221,14 +212,5 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { | ||||
| 		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 d.notify(zone) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user