mirror of
https://github.com/go-acme/lego.git
synced 2024-11-29 01:42:09 +02:00
pdns: get exact zone instead of all zones (#1296)
This commit is contained in:
parent
cabd839feb
commit
4f7f557a5c
@ -11,6 +11,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/go-acme/lego/v4/challenge/dns01"
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
type Record struct {
|
||||
@ -60,37 +61,19 @@ type apiVersion struct {
|
||||
}
|
||||
|
||||
func (d *DNSProvider) getHostedZone(fqdn string) (*hostedZone, error) {
|
||||
var zone hostedZone
|
||||
authZone, err := dns01.FindZoneByFqdn(fqdn)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
u := "/servers/localhost/zones"
|
||||
result, err := d.sendRequest(http.MethodGet, u, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var zones []hostedZone
|
||||
err = json.Unmarshal(result, &zones)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
u = ""
|
||||
for _, zone := range zones {
|
||||
if dns01.UnFqdn(zone.Name) == dns01.UnFqdn(authZone) {
|
||||
u = zone.URL
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
result, err = d.sendRequest(http.MethodGet, u, nil)
|
||||
p := path.Join("/servers/localhost/zones/", dns.Fqdn(authZone))
|
||||
|
||||
result, err := d.sendRequest(http.MethodGet, p, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var zone hostedZone
|
||||
err = json.Unmarshal(result, &zone)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Loading…
Reference in New Issue
Block a user