From cb3c4c7937576f20a0f018766fdf4825742565b9 Mon Sep 17 00:00:00 2001 From: smartwang <407718756@qq.com> Date: Thu, 20 Dec 2018 18:52:34 +0800 Subject: [PATCH] alidns: add support to handle more than 20 domains (#739) --- providers/dns/alidns/alidns.go | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/providers/dns/alidns/alidns.go b/providers/dns/alidns/alidns.go index 3a8d76e6..e7ea22ef 100644 --- a/providers/dns/alidns/alidns.go +++ b/providers/dns/alidns/alidns.go @@ -136,9 +136,25 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { func (d *DNSProvider) getHostedZone(domain string) (string, string, error) { request := alidns.CreateDescribeDomainsRequest() - zones, err := d.client.DescribeDomains(request) - if err != nil { - return "", "", fmt.Errorf("API call failed: %v", err) + + var domains []alidns.Domain + startPage := 1 + + for { + request.PageNumber = requests.NewInteger(startPage) + + response, err := d.client.DescribeDomains(request) + if err != nil { + return "", "", fmt.Errorf("API call failed: %v", err) + } + + domains = append(domains, response.Domains.Domain...) + + if response.PageNumber >= response.PageSize { + break + } + + startPage++ } authZone, err := dns01.FindZoneByFqdn(dns01.ToFqdn(domain)) @@ -147,7 +163,7 @@ func (d *DNSProvider) getHostedZone(domain string) (string, string, error) { } var hostedZone alidns.Domain - for _, zone := range zones.Domains.Domain { + for _, zone := range domains { if zone.DomainName == dns01.UnFqdn(authZone) { hostedZone = zone }