From 1bd663882a69604569eaaaaa1d9207088e1281ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9opold=20Jacquot?= Date: Thu, 30 Sep 2021 21:06:22 +0200 Subject: [PATCH] infomaniak: fix subzone support (#1497) --- docs/content/dns/zz_gen_infomaniak.md | 1 - providers/dns/infomaniak/infomaniak.go | 25 ++++-------------------- providers/dns/infomaniak/infomaniak.toml | 1 - 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/docs/content/dns/zz_gen_infomaniak.md b/docs/content/dns/zz_gen_infomaniak.md index e62f0c3c..a33130fd 100644 --- a/docs/content/dns/zz_gen_infomaniak.md +++ b/docs/content/dns/zz_gen_infomaniak.md @@ -55,7 +55,6 @@ More information [here](/lego/dns/#configuration-and-credentials). Access token can be created at the url https://manager.infomaniak.com/v3/infomaniak-api. You will need domain scope. -``` diff --git a/providers/dns/infomaniak/infomaniak.go b/providers/dns/infomaniak/infomaniak.go index 5d8aba41..0d5e75ca 100644 --- a/providers/dns/infomaniak/infomaniak.go +++ b/providers/dns/infomaniak/infomaniak.go @@ -5,7 +5,6 @@ import ( "errors" "fmt" "net/http" - "strings" "sync" "time" @@ -113,11 +112,6 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) { func (d *DNSProvider) Present(domain, token, keyAuth string) error { fqdn, value := dns01.GetRecord(domain, keyAuth) - authZone, err := getZone(fqdn) - if err != nil { - return fmt.Errorf("infomaniak: %w", err) - } - ikDomain, err := d.client.GetDomainByName(domain) if err != nil { return fmt.Errorf("infomaniak: could not get domain %q: %w", domain, err) @@ -128,7 +122,7 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { d.domainIDsMu.Unlock() record := internal.Record{ - Source: extractRecordName(fqdn, authZone), + Source: extractRecordName(fqdn, ikDomain.CustomerName), Target: value, Type: "TXT", TTL: d.config.TTL, @@ -190,19 +184,8 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) { return d.config.PropagationTimeout, d.config.PollingInterval } -func getZone(fqdn string) (string, error) { - authZone, err := dns01.FindZoneByFqdn(fqdn) - if err != nil { - return "", err - } - - return dns01.UnFqdn(authZone), nil -} - -func extractRecordName(fqdn, zone string) string { +func extractRecordName(fqdn, domain string) string { name := dns01.UnFqdn(fqdn) - if idx := strings.Index(name, "."+zone); idx != -1 { - return name[:idx] - } - return name + + return name[:len(name)-len(domain)-1] } diff --git a/providers/dns/infomaniak/infomaniak.toml b/providers/dns/infomaniak/infomaniak.toml index a5583eef..1606f580 100644 --- a/providers/dns/infomaniak/infomaniak.toml +++ b/providers/dns/infomaniak/infomaniak.toml @@ -14,7 +14,6 @@ Additional = ''' Access token can be created at the url https://manager.infomaniak.com/v3/infomaniak-api. You will need domain scope. -``` ''' [Configuration]