From 095b13e6bd993d342cf4b43b8d9a454f0ec56e5e Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Mon, 26 Aug 2024 23:39:10 +0200 Subject: [PATCH 01/24] feat: add DNS provider for Lima-City --- providers/dns/dns_providers.go | 3 + providers/dns/limacity/internal/client.go | 199 ++++++++++++++++++ .../dns/limacity/internal/client_test.go | 189 +++++++++++++++++ .../dns/limacity/internal/fixtures/error.json | 8 + .../internal/fixtures/get-domains.json | 16 ++ .../internal/fixtures/get-records.json | 12 ++ .../dns/limacity/internal/fixtures/ok.json | 3 + providers/dns/limacity/internal/types.go | 49 +++++ providers/dns/limacity/limacity.go | 190 +++++++++++++++++ providers/dns/limacity/limacity.toml | 22 ++ providers/dns/limacity/limacity_test.go | 113 ++++++++++ 11 files changed, 804 insertions(+) create mode 100644 providers/dns/limacity/internal/client.go create mode 100644 providers/dns/limacity/internal/client_test.go create mode 100644 providers/dns/limacity/internal/fixtures/error.json create mode 100644 providers/dns/limacity/internal/fixtures/get-domains.json create mode 100644 providers/dns/limacity/internal/fixtures/get-records.json create mode 100644 providers/dns/limacity/internal/fixtures/ok.json create mode 100644 providers/dns/limacity/internal/types.go create mode 100644 providers/dns/limacity/limacity.go create mode 100644 providers/dns/limacity/limacity.toml create mode 100644 providers/dns/limacity/limacity_test.go diff --git a/providers/dns/dns_providers.go b/providers/dns/dns_providers.go index 52e4fc94a9..0bcfdee622 100644 --- a/providers/dns/dns_providers.go +++ b/providers/dns/dns_providers.go @@ -76,6 +76,7 @@ import ( "github.com/go-acme/lego/v4/providers/dns/joker" "github.com/go-acme/lego/v4/providers/dns/liara" "github.com/go-acme/lego/v4/providers/dns/lightsail" + "github.com/go-acme/lego/v4/providers/dns/limacity" "github.com/go-acme/lego/v4/providers/dns/linode" "github.com/go-acme/lego/v4/providers/dns/liquidweb" "github.com/go-acme/lego/v4/providers/dns/loopia" @@ -284,6 +285,8 @@ func NewDNSChallengeProviderByName(name string) (challenge.Provider, error) { return liara.NewDNSProvider() case "lightsail": return lightsail.NewDNSProvider() + case "limacity": + return limacity.NewDNSProvider() case "linode", "linodev4": // "linodev4" is for compatibility with v3, must be dropped in v5 return linode.NewDNSProvider() case "liquidweb": diff --git a/providers/dns/limacity/internal/client.go b/providers/dns/limacity/internal/client.go new file mode 100644 index 0000000000..f7efcaca0d --- /dev/null +++ b/providers/dns/limacity/internal/client.go @@ -0,0 +1,199 @@ +package internal + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "io" + "net/http" + "net/url" + "time" + + "github.com/go-acme/lego/v4/providers/dns/internal/errutils" +) + +const defaultBaseURL = "https://www.lima-city.de/usercp" + +const success = "ok" + +type Client struct { + apiKey string + baseURL *url.URL + HTTPClient *http.Client +} + +func NewClient(apiKey string) *Client { + baseURL, _ := url.Parse(defaultBaseURL) + + return &Client{ + apiKey: apiKey, + baseURL: baseURL, + HTTPClient: &http.Client{Timeout: 10 * time.Second}, + } +} + +func (c Client) GetDomains(ctx context.Context) ([]Domain, error) { + endpoint := c.baseURL.JoinPath("domains.json") + + req, err := newJSONRequest(ctx, http.MethodGet, endpoint, nil) + if err != nil { + return nil, err + } + + var results DomainsResponse + err = c.do(req, &results) + if err != nil { + return nil, err + } + + return results.Data, nil +} + +func (c Client) GetRecords(ctx context.Context, domainID string) ([]Record, error) { + endpoint := c.baseURL.JoinPath("domains", domainID, "records.json") + + req, err := newJSONRequest(ctx, http.MethodGet, endpoint, nil) + if err != nil { + return nil, err + } + + var results RecordsResponse + err = c.do(req, &results) + if err != nil { + return nil, err + } + + return results.Data, nil +} + +func (c Client) AddRecord(ctx context.Context, domainID string, record Record) error { + endpoint := c.baseURL.JoinPath("domains", domainID, "records.json") + + req, err := newJSONRequest(ctx, http.MethodPost, endpoint, record) + if err != nil { + return err + } + + var results APIResponse + err = c.do(req, &results) + if err != nil { + return err + } + + if results.Status != success { + return results + } + + return nil +} + +func (c Client) UpdateRecord(ctx context.Context, domainID, recordID string, record Record) error { + endpoint := c.baseURL.JoinPath("domains", domainID, "records", recordID) + + req, err := newJSONRequest(ctx, http.MethodPut, endpoint, record) + if err != nil { + return err + } + + var results APIResponse + err = c.do(req, &results) + if err != nil { + return err + } + + if results.Status != success { + return results + } + + return nil +} + +func (c Client) DeleteRecord(ctx context.Context, domainID, recordID string) error { + // /domains/{domainId}/records/{recordId} DELETE + endpoint := c.baseURL.JoinPath("domains", domainID, "records", recordID) + + req, err := newJSONRequest(ctx, http.MethodDelete, endpoint, nil) + if err != nil { + return err + } + + var results APIResponse + err = c.do(req, &results) + if err != nil { + return err + } + + if results.Status != success { + return results + } + + return nil +} + +func (c Client) do(req *http.Request, result any) error { + req.SetBasicAuth("api", c.apiKey) + + resp, err := c.HTTPClient.Do(req) + if err != nil { + return errutils.NewHTTPDoError(req, err) + } + + defer func() { _ = resp.Body.Close() }() + + if resp.StatusCode/100 != 2 { + return parseError(req, resp) + } + + if result == nil { + return nil + } + + raw, err := io.ReadAll(resp.Body) + if err != nil { + return errutils.NewReadResponseError(req, resp.StatusCode, err) + } + + err = json.Unmarshal(raw, result) + if err != nil { + return errutils.NewUnmarshalError(req, resp.StatusCode, raw, err) + } + + return nil +} + +func newJSONRequest(ctx context.Context, method string, endpoint *url.URL, payload any) (*http.Request, error) { + buf := new(bytes.Buffer) + + if payload != nil { + err := json.NewEncoder(buf).Encode(payload) + if err != nil { + return nil, fmt.Errorf("failed to create request JSON body: %w", err) + } + } + + req, err := http.NewRequestWithContext(ctx, method, endpoint.String(), buf) + if err != nil { + return nil, fmt.Errorf("unable to create request: %w", err) + } + + req.Header.Set("Accept", "application/json") + + if payload != nil { + req.Header.Set("Content-Type", "application/json") + } + + return req, nil +} + +func parseError(req *http.Request, resp *http.Response) error { + raw, _ := io.ReadAll(resp.Body) + + var errAPI APIResponse + err := json.Unmarshal(raw, &errAPI) + if err != nil { + return errutils.NewUnexpectedStatusCodeError(req, resp.StatusCode, raw) + } + + return fmt.Errorf("[status code: %d] %w", resp.StatusCode, &errAPI) +} diff --git a/providers/dns/limacity/internal/client_test.go b/providers/dns/limacity/internal/client_test.go new file mode 100644 index 0000000000..46fa06557b --- /dev/null +++ b/providers/dns/limacity/internal/client_test.go @@ -0,0 +1,189 @@ +package internal + +import ( + "context" + "fmt" + "io" + "net/http" + "net/http/httptest" + "net/url" + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +const apiKey = "secret" + +func setupTest(t *testing.T) (*Client, *http.ServeMux) { + t.Helper() + + mux := http.NewServeMux() + server := httptest.NewServer(mux) + t.Cleanup(server.Close) + + client := NewClient(apiKey) + client.baseURL, _ = url.Parse(server.URL) + + return client, mux +} + +func testHandler(filename string, method string, statusCode int) http.HandlerFunc { + return func(rw http.ResponseWriter, req *http.Request) { + if req.Method != method { + http.Error(rw, fmt.Sprintf("unsupported method: %s", req.Method), http.StatusMethodNotAllowed) + return + } + + username, key, ok := req.BasicAuth() + if username != "api" || key != apiKey || !ok { + http.Error(rw, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized) + return + } + + file, err := os.Open(filepath.Join("fixtures", filename)) + if err != nil { + http.Error(rw, err.Error(), http.StatusInternalServerError) + return + } + + defer func() { _ = file.Close() }() + + rw.WriteHeader(statusCode) + + _, err = io.Copy(rw, file) + if err != nil { + http.Error(rw, err.Error(), http.StatusInternalServerError) + return + } + } +} + +func TestClient_GetDomains(t *testing.T) { + client, mux := setupTest(t) + + mux.HandleFunc("/domains.json", testHandler("get-domains.json", http.MethodGet, http.StatusOK)) + + domains, err := client.GetDomains(context.Background()) + require.NoError(t, err) + + expected := []Domain{{ + ID: "123", + UnicodeFqdn: "example.com", + Domain: "example", + TLD: "com", + Status: "ok", + }} + assert.Equal(t, expected, domains) +} + +func TestClient_GetDomains_error(t *testing.T) { + client, mux := setupTest(t) + + mux.HandleFunc("/domains.json", testHandler("error.json", http.MethodGet, http.StatusBadRequest)) + + _, err := client.GetDomains(context.Background()) + require.EqualError(t, err, "[status code: 400] status: invalid_resource, details: name: [muss ausgefüllt werden]") +} + +func TestClient_GetRecords(t *testing.T) { + client, mux := setupTest(t) + + mux.HandleFunc("/domains/123/records.json", testHandler("get-records.json", http.MethodGet, http.StatusOK)) + + records, err := client.GetRecords(context.Background(), "123") + require.NoError(t, err) + + expected := []Record{{ + Content: "ns1.lima-city.de", + ID: "1234", + Name: "example.com", + Subdomain: "", + TTL: 36000, + Type: "NS", + }} + assert.Equal(t, expected, records) +} + +func TestClient_GetRecords_error(t *testing.T) { + client, mux := setupTest(t) + + mux.HandleFunc("/domains/123/records.json", testHandler("error.json", http.MethodGet, http.StatusBadRequest)) + + _, err := client.GetRecords(context.Background(), "123") + require.EqualError(t, err, "[status code: 400] status: invalid_resource, details: name: [muss ausgefüllt werden]") +} + +func TestClient_AddRecord(t *testing.T) { + client, mux := setupTest(t) + + mux.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) { + fmt.Println(req) + }) + mux.HandleFunc("/domains/123/records.json", testHandler("ok.json", http.MethodPost, http.StatusOK)) + + err := client.AddRecord(context.Background(), "123", Record{}) + require.NoError(t, err) +} + +func TestClient_AddRecord_error(t *testing.T) { + client, mux := setupTest(t) + + mux.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) { + fmt.Println(req) + }) + mux.HandleFunc("/domains/123/records.json", testHandler("error.json", http.MethodPost, http.StatusBadRequest)) + + err := client.AddRecord(context.Background(), "123", Record{}) + require.EqualError(t, err, "[status code: 400] status: invalid_resource, details: name: [muss ausgefüllt werden]") +} + +func TestClient_UpdateRecord(t *testing.T) { + client, mux := setupTest(t) + + mux.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) { + fmt.Println(req) + }) + mux.HandleFunc("/domains/123/records/456", testHandler("ok.json", http.MethodPut, http.StatusOK)) + + err := client.UpdateRecord(context.Background(), "123", "456", Record{}) + require.NoError(t, err) +} + +func TestClient_UpdateRecord_error(t *testing.T) { + client, mux := setupTest(t) + + mux.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) { + fmt.Println(req) + }) + mux.HandleFunc("/domains/123/records/456", testHandler("error.json", http.MethodPut, http.StatusBadRequest)) + + err := client.UpdateRecord(context.Background(), "123", "456", Record{}) + require.EqualError(t, err, "[status code: 400] status: invalid_resource, details: name: [muss ausgefüllt werden]") +} + +func TestClient_DeleteRecord(t *testing.T) { + client, mux := setupTest(t) + + mux.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) { + fmt.Println(req) + }) + mux.HandleFunc("/domains/123/records/456", testHandler("ok.json", http.MethodDelete, http.StatusOK)) + + err := client.DeleteRecord(context.Background(), "123", "456") + require.NoError(t, err) +} + +func TestClient_DeleteRecord_error(t *testing.T) { + client, mux := setupTest(t) + + mux.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) { + fmt.Println(req) + }) + mux.HandleFunc("/domains/123/records/456", testHandler("error.json", http.MethodDelete, http.StatusBadRequest)) + + err := client.DeleteRecord(context.Background(), "123", "456") + require.EqualError(t, err, "[status code: 400] status: invalid_resource, details: name: [muss ausgefüllt werden]") +} diff --git a/providers/dns/limacity/internal/fixtures/error.json b/providers/dns/limacity/internal/fixtures/error.json new file mode 100644 index 0000000000..99dee169ca --- /dev/null +++ b/providers/dns/limacity/internal/fixtures/error.json @@ -0,0 +1,8 @@ +{ + "status": "invalid_resource", + "errors": { + "name": [ + "muss ausgefüllt werden" + ] + } +} diff --git a/providers/dns/limacity/internal/fixtures/get-domains.json b/providers/dns/limacity/internal/fixtures/get-domains.json new file mode 100644 index 0000000000..c11115602b --- /dev/null +++ b/providers/dns/limacity/internal/fixtures/get-domains.json @@ -0,0 +1,16 @@ +{ + "domains": [ + { + "id": "123", + "mode": "CREATE", + "tld": "com", + "domain": "example", + "in_subscription": false, + "auto_renew": false, + "status": "ok", + "unicode_fqdn": "example.com", + "registered_at": "1970-01-01T00:00:00+00:00", + "registered_until": "2000-01-01T00:00:00+00:00" + } + ] +} diff --git a/providers/dns/limacity/internal/fixtures/get-records.json b/providers/dns/limacity/internal/fixtures/get-records.json new file mode 100644 index 0000000000..3c89925c8c --- /dev/null +++ b/providers/dns/limacity/internal/fixtures/get-records.json @@ -0,0 +1,12 @@ +{ + "records": [ + { + "content": "ns1.lima-city.de", + "id": "1234", + "name": "example.com", + "subdomain": "", + "ttl": 36000, + "type": "NS" + } + ] +} diff --git a/providers/dns/limacity/internal/fixtures/ok.json b/providers/dns/limacity/internal/fixtures/ok.json new file mode 100644 index 0000000000..bc4e01029d --- /dev/null +++ b/providers/dns/limacity/internal/fixtures/ok.json @@ -0,0 +1,3 @@ +{ + "status": "ok" +} diff --git a/providers/dns/limacity/internal/types.go b/providers/dns/limacity/internal/types.go new file mode 100644 index 0000000000..7041f22acc --- /dev/null +++ b/providers/dns/limacity/internal/types.go @@ -0,0 +1,49 @@ +package internal + +import ( + "fmt" + "strings" +) + +type RecordsResponse struct { + Data []Record `json:"records,omitempty"` +} + +type NameserverRecordPayload struct { + Data *Record `json:"nameserver_record,omitempty"` +} + +type DomainsResponse struct { + Data []Domain `json:"domains,omitempty"` +} + +type APIResponse struct { + Status string `json:"status,omitempty"` + Details map[string][]string `json:"errors,omitempty"` +} + +func (a APIResponse) Error() string { + var details []string + for k, v := range a.Details { + details = append(details, fmt.Sprintf("%s: %s", k, v)) + } + + return fmt.Sprintf("status: %s, details: %s", a.Status, strings.Join(details, ",")) +} + +type Record struct { + ID string `json:"id,omitempty"` + Content string `json:"content,omitempty"` + Name string `json:"name,omitempty"` + Subdomain string `json:"subdomain,omitempty"` + TTL int `json:"ttl,omitempty"` + Type string `json:"type,omitempty"` +} + +type Domain struct { + ID string `json:"id,omitempty"` + UnicodeFqdn string `json:"unicode_fqdn,omitempty"` + Domain string `json:"domain,omitempty"` + TLD string `json:"tld,omitempty"` + Status string `json:"status,omitempty"` +} diff --git a/providers/dns/limacity/limacity.go b/providers/dns/limacity/limacity.go new file mode 100644 index 0000000000..cfded66687 --- /dev/null +++ b/providers/dns/limacity/limacity.go @@ -0,0 +1,190 @@ +// Package limacity implements a DNS provider for solving the DNS-01 challenge using Lima-City DNS. +package limacity + +import ( + "context" + "errors" + "fmt" + "net/http" + "sync" + "time" + + "github.com/go-acme/lego/v4/challenge/dns01" + "github.com/go-acme/lego/v4/platform/config/env" + "github.com/go-acme/lego/v4/providers/dns/limacity/internal" + "github.com/miekg/dns" +) + +// Environment variables names. +const ( + envNamespace = "LIMACITY_" + + EnvAPIKey = envNamespace + "API_KEY" + + EnvTTL = envNamespace + "TTL" + EnvPropagationTimeout = envNamespace + "PROPAGATION_TIMEOUT" + EnvPollingInterval = envNamespace + "POLLING_INTERVAL" + EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT" +) + +// Config is used to configure the creation of the DNSProvider. +type Config struct { + APIKey string + TTL int + PropagationTimeout time.Duration + PollingInterval time.Duration + HTTPClient *http.Client +} + +// NewDefaultConfig returns a default configuration for the DNSProvider. +func NewDefaultConfig() *Config { + return &Config{ + TTL: env.GetOrDefaultInt(EnvTTL, 3600), + PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout), + PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval), + HTTPClient: &http.Client{ + Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second), + }, + } +} + +// DNSProvider implements the challenge.Provider interface. +type DNSProvider struct { + config *Config + client *internal.Client + + domainIDs map[string]string + domainIDsMu sync.Mutex +} + +// NewDNSProvider returns a DNSProvider instance configured for Lima-City DNS. +// LIMACITY_API_KEY must be passed in the environment variables. +func NewDNSProvider() (*DNSProvider, error) { + values, err := env.Get(EnvAPIKey) + if err != nil { + return nil, fmt.Errorf("limacity: %w", err) + } + + config := NewDefaultConfig() + config.APIKey = values[EnvAPIKey] + + return NewDNSProviderConfig(config) +} + +// NewDNSProviderConfig return a DNSProvider instance configured for Lima-City DNS. +func NewDNSProviderConfig(config *Config) (*DNSProvider, error) { + if config == nil { + return nil, errors.New("limacity: the configuration of the DNS provider is nil") + } + + if config.APIKey == "" { + return nil, errors.New("limacity: APIKey is missing") + } + + client := internal.NewClient(config.APIKey) + + return &DNSProvider{ + config: config, + client: client, + domainIDs: make(map[string]string), + }, nil +} + +// Timeout returns the timeout and interval to use when checking for DNS propagation. +// Adjusting here to cope with spikes in propagation times. +func (d *DNSProvider) Timeout() (timeout, interval time.Duration) { + return d.config.PropagationTimeout, d.config.PollingInterval +} + +// Present creates a TXT record to fulfill the dns-01 challenge. +func (d *DNSProvider) Present(domain, token, keyAuth string) error { + info := dns01.GetChallengeInfo(domain, keyAuth) + + domains, err := d.client.GetDomains(context.Background()) + if err != nil { + return fmt.Errorf("limacity: get domains: %w", err) + } + + dom, err := findDomain(domains, info.EffectiveFQDN) + if err != nil { + return fmt.Errorf("limacity: find domain: %w", err) + } + + subDomain, err := dns01.ExtractSubDomain(info.EffectiveFQDN, dom.UnicodeFqdn) + if err != nil { + return fmt.Errorf("limacity: %w", err) + } + + record := internal.Record{ + Content: info.Value, + Name: dns01.UnFqdn(dom.UnicodeFqdn), + Subdomain: subDomain, + TTL: d.config.TTL, + Type: "TXT", + } + + err = d.client.AddRecord(context.Background(), dom.ID, record) + if err != nil { + return fmt.Errorf("limacity: add record: %w", err) + } + + d.domainIDsMu.Lock() + d.domainIDs[token] = dom.ID + d.domainIDsMu.Unlock() + + return nil +} + +// CleanUp removes the TXT record. +func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { + info := dns01.GetChallengeInfo(domain, keyAuth) + + // gets the domain's unique ID + d.domainIDsMu.Lock() + domainID, ok := d.domainIDs[token] + d.domainIDsMu.Unlock() + if !ok { + return fmt.Errorf("liara: unknown domain ID for '%s' '%s'", info.EffectiveFQDN, token) + } + + records, err := d.client.GetRecords(context.Background(), domainID) + if err != nil { + return fmt.Errorf("limacity: get records: %w", err) + } + + var recordID string + for _, record := range records { + if record.Type == "TXT" && record.Content == info.Value { + recordID = record.ID + break + } + } + + if recordID == "" { + return errors.New("limacity: TXT record not found") + } + + err = d.client.DeleteRecord(context.Background(), domainID, recordID) + if err != nil { + return fmt.Errorf("limacity: delete record (domain ID=%s, record ID=%s): %w", domainID, recordID, err) + } + + return nil +} + +func findDomain(domains []internal.Domain, fqdn string) (internal.Domain, error) { + labelIndexes := dns.Split(fqdn) + + for _, index := range labelIndexes { + f := fqdn[index:] + domain := dns01.UnFqdn(f) + + for _, dom := range domains { + if dom.UnicodeFqdn == domain || dom.UnicodeFqdn == f { + return dom, nil + } + } + } + + return internal.Domain{}, fmt.Errorf("domain %s not found", fqdn) +} diff --git a/providers/dns/limacity/limacity.toml b/providers/dns/limacity/limacity.toml new file mode 100644 index 0000000000..c617a9024a --- /dev/null +++ b/providers/dns/limacity/limacity.toml @@ -0,0 +1,22 @@ +Name = "Lima-City" +Description = '''''' +URL = "https://www.lima-city.de" +Code = "limacity" +Since = "v4.18.0" + +Example = ''' +LIMACITY_API_KEY="xxxxxxxxxxxxxxxxxxxxx" \ +lego --email myemail@example.com --dns limacity --domains my.example.org run +''' + +[Configuration] + [Configuration.Credentials] + LIMACITY_API_KEY = "The API key" + [Configuration.Additional] + LIMACITY_POLLING_INTERVAL = "Time between DNS propagation check" + LIMACITY_PROPAGATION_TIMEOUT = "Maximum waiting time for DNS propagation" + LIMACITY_TTL = "The TTL of the TXT record used for the DNS challenge" + LIMACITY_HTTP_TIMEOUT = "API request timeout" + +[Links] + API = "https://www.lima-city.de/hilfe/lima-city-api" diff --git a/providers/dns/limacity/limacity_test.go b/providers/dns/limacity/limacity_test.go new file mode 100644 index 0000000000..2834a5f1fb --- /dev/null +++ b/providers/dns/limacity/limacity_test.go @@ -0,0 +1,113 @@ +package limacity + +import ( + "testing" + + "github.com/go-acme/lego/v4/platform/tester" + "github.com/stretchr/testify/require" +) + +const envDomain = envNamespace + "DOMAIN" + +var envTest = tester.NewEnvTest(EnvAPIKey).WithDomain(envDomain) + +func TestNewDNSProvider(t *testing.T) { + testCases := []struct { + desc string + envVars map[string]string + expected string + }{ + { + desc: "success", + envVars: map[string]string{ + EnvAPIKey: "key", + }, + }, + { + desc: "missing API key", + envVars: map[string]string{}, + expected: "limacity: some credentials information are missing: LIMACITY_API_KEY", + }, + } + + for _, test := range testCases { + t.Run(test.desc, func(t *testing.T) { + defer envTest.RestoreEnv() + envTest.ClearEnv() + + envTest.Apply(test.envVars) + + p, err := NewDNSProvider() + + if test.expected == "" { + require.NoError(t, err) + require.NotNil(t, p) + require.NotNil(t, p.config) + require.NotNil(t, p.client) + } else { + require.EqualError(t, err, test.expected) + } + }) + } +} + +func TestNewDNSProviderConfig(t *testing.T) { + testCases := []struct { + desc string + apiKey string + expected string + }{ + { + desc: "success", + apiKey: "key", + }, + { + desc: "missing API key", + expected: "limacity: APIKey is missing", + }, + } + + for _, test := range testCases { + t.Run(test.desc, func(t *testing.T) { + config := NewDefaultConfig() + config.APIKey = test.apiKey + + p, err := NewDNSProviderConfig(config) + + if test.expected == "" { + require.NoError(t, err) + require.NotNil(t, p) + require.NotNil(t, p.config) + require.NotNil(t, p.client) + } else { + require.EqualError(t, err, test.expected) + } + }) + } +} + +func TestLivePresent(t *testing.T) { + if !envTest.IsLiveTest() { + t.Skip("skipping live test") + } + + envTest.RestoreEnv() + provider, err := NewDNSProvider() + require.NoError(t, err) + + err = provider.Present(envTest.GetDomain(), "", "123d==") + require.NoError(t, err) +} + +func TestLiveCleanUp(t *testing.T) { + if !envTest.IsLiveTest() { + t.Skip("skipping live test") + } + + envTest.RestoreEnv() + provider, err := NewDNSProvider() + require.NoError(t, err) + + err = provider.CleanUp(envTest.GetDomain(), "", "123d==") + require.NoError(t, err) +} From 4677666258cd9e4cbbf32ed4ca379439c8841b6d Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 27 Aug 2024 13:52:55 +0200 Subject: [PATCH 02/24] chore: generate --- README.md | 32 +++++++------- cmd/zz_gen_cmd_dnshelp.go | 21 +++++++++ docs/content/dns/zz_gen_limacity.md | 67 +++++++++++++++++++++++++++++ docs/data/zz_cli_help.toml | 2 +- 4 files changed, 105 insertions(+), 17 deletions(-) create mode 100644 docs/content/dns/zz_gen_limacity.md diff --git a/README.md b/README.md index 9b756d79f7..0cb0427678 100644 --- a/README.md +++ b/README.md @@ -71,22 +71,22 @@ Detailed documentation is available [here](https://go-acme.github.io/lego/dns). | [IIJ DNS Platform Service](https://go-acme.github.io/lego/dns/iijdpf/) | [Infoblox](https://go-acme.github.io/lego/dns/infoblox/) | [Infomaniak](https://go-acme.github.io/lego/dns/infomaniak/) | [Internet Initiative Japan](https://go-acme.github.io/lego/dns/iij/) | | [Internet.bs](https://go-acme.github.io/lego/dns/internetbs/) | [INWX](https://go-acme.github.io/lego/dns/inwx/) | [Ionos](https://go-acme.github.io/lego/dns/ionos/) | [IPv64](https://go-acme.github.io/lego/dns/ipv64/) | | [iwantmyname](https://go-acme.github.io/lego/dns/iwantmyname/) | [Joker](https://go-acme.github.io/lego/dns/joker/) | [Joohoi's ACME-DNS](https://go-acme.github.io/lego/dns/acme-dns/) | [Liara](https://go-acme.github.io/lego/dns/liara/) | -| [Linode (v4)](https://go-acme.github.io/lego/dns/linode/) | [Liquid Web](https://go-acme.github.io/lego/dns/liquidweb/) | [Loopia](https://go-acme.github.io/lego/dns/loopia/) | [LuaDNS](https://go-acme.github.io/lego/dns/luadns/) | -| [Mail-in-a-Box](https://go-acme.github.io/lego/dns/mailinabox/) | [Manual](https://go-acme.github.io/lego/dns/manual/) | [Metaname](https://go-acme.github.io/lego/dns/metaname/) | [mijn.host](https://go-acme.github.io/lego/dns/mijnhost/) | -| [MyDNS.jp](https://go-acme.github.io/lego/dns/mydnsjp/) | [MythicBeasts](https://go-acme.github.io/lego/dns/mythicbeasts/) | [Name.com](https://go-acme.github.io/lego/dns/namedotcom/) | [Namecheap](https://go-acme.github.io/lego/dns/namecheap/) | -| [Namesilo](https://go-acme.github.io/lego/dns/namesilo/) | [NearlyFreeSpeech.NET](https://go-acme.github.io/lego/dns/nearlyfreespeech/) | [Netcup](https://go-acme.github.io/lego/dns/netcup/) | [Netlify](https://go-acme.github.io/lego/dns/netlify/) | -| [Nicmanager](https://go-acme.github.io/lego/dns/nicmanager/) | [NIFCloud](https://go-acme.github.io/lego/dns/nifcloud/) | [Njalla](https://go-acme.github.io/lego/dns/njalla/) | [Nodion](https://go-acme.github.io/lego/dns/nodion/) | -| [NS1](https://go-acme.github.io/lego/dns/ns1/) | [Open Telekom Cloud](https://go-acme.github.io/lego/dns/otc/) | [Oracle Cloud](https://go-acme.github.io/lego/dns/oraclecloud/) | [OVH](https://go-acme.github.io/lego/dns/ovh/) | -| [plesk.com](https://go-acme.github.io/lego/dns/plesk/) | [Porkbun](https://go-acme.github.io/lego/dns/porkbun/) | [PowerDNS](https://go-acme.github.io/lego/dns/pdns/) | [Rackspace](https://go-acme.github.io/lego/dns/rackspace/) | -| [RcodeZero](https://go-acme.github.io/lego/dns/rcodezero/) | [reg.ru](https://go-acme.github.io/lego/dns/regru/) | [RFC2136](https://go-acme.github.io/lego/dns/rfc2136/) | [RimuHosting](https://go-acme.github.io/lego/dns/rimuhosting/) | -| [Sakura Cloud](https://go-acme.github.io/lego/dns/sakuracloud/) | [Scaleway](https://go-acme.github.io/lego/dns/scaleway/) | [Selectel v2](https://go-acme.github.io/lego/dns/selectelv2/) | [Selectel](https://go-acme.github.io/lego/dns/selectel/) | -| [Servercow](https://go-acme.github.io/lego/dns/servercow/) | [Shellrent](https://go-acme.github.io/lego/dns/shellrent/) | [Simply.com](https://go-acme.github.io/lego/dns/simply/) | [Sonic](https://go-acme.github.io/lego/dns/sonic/) | -| [Stackpath](https://go-acme.github.io/lego/dns/stackpath/) | [Tencent Cloud DNS](https://go-acme.github.io/lego/dns/tencentcloud/) | [TransIP](https://go-acme.github.io/lego/dns/transip/) | [UKFast SafeDNS](https://go-acme.github.io/lego/dns/safedns/) | -| [Ultradns](https://go-acme.github.io/lego/dns/ultradns/) | [Variomedia](https://go-acme.github.io/lego/dns/variomedia/) | [VegaDNS](https://go-acme.github.io/lego/dns/vegadns/) | [Vercel](https://go-acme.github.io/lego/dns/vercel/) | -| [Versio.[nl/eu/uk]](https://go-acme.github.io/lego/dns/versio/) | [VinylDNS](https://go-acme.github.io/lego/dns/vinyldns/) | [VK Cloud](https://go-acme.github.io/lego/dns/vkcloud/) | [Vscale](https://go-acme.github.io/lego/dns/vscale/) | -| [Vultr](https://go-acme.github.io/lego/dns/vultr/) | [Webnames](https://go-acme.github.io/lego/dns/webnames/) | [Websupport](https://go-acme.github.io/lego/dns/websupport/) | [WEDOS](https://go-acme.github.io/lego/dns/wedos/) | -| [Yandex 360](https://go-acme.github.io/lego/dns/yandex360/) | [Yandex Cloud](https://go-acme.github.io/lego/dns/yandexcloud/) | [Yandex PDD](https://go-acme.github.io/lego/dns/yandex/) | [Zone.ee](https://go-acme.github.io/lego/dns/zoneee/) | -| [Zonomi](https://go-acme.github.io/lego/dns/zonomi/) | | | | +| [Lima-City](https://go-acme.github.io/lego/dns/limacity/) | [Linode (v4)](https://go-acme.github.io/lego/dns/linode/) | [Liquid Web](https://go-acme.github.io/lego/dns/liquidweb/) | [Loopia](https://go-acme.github.io/lego/dns/loopia/) | +| [LuaDNS](https://go-acme.github.io/lego/dns/luadns/) | [Mail-in-a-Box](https://go-acme.github.io/lego/dns/mailinabox/) | [Manual](https://go-acme.github.io/lego/dns/manual/) | [Metaname](https://go-acme.github.io/lego/dns/metaname/) | +| [mijn.host](https://go-acme.github.io/lego/dns/mijnhost/) | [MyDNS.jp](https://go-acme.github.io/lego/dns/mydnsjp/) | [MythicBeasts](https://go-acme.github.io/lego/dns/mythicbeasts/) | [Name.com](https://go-acme.github.io/lego/dns/namedotcom/) | +| [Namecheap](https://go-acme.github.io/lego/dns/namecheap/) | [Namesilo](https://go-acme.github.io/lego/dns/namesilo/) | [NearlyFreeSpeech.NET](https://go-acme.github.io/lego/dns/nearlyfreespeech/) | [Netcup](https://go-acme.github.io/lego/dns/netcup/) | +| [Netlify](https://go-acme.github.io/lego/dns/netlify/) | [Nicmanager](https://go-acme.github.io/lego/dns/nicmanager/) | [NIFCloud](https://go-acme.github.io/lego/dns/nifcloud/) | [Njalla](https://go-acme.github.io/lego/dns/njalla/) | +| [Nodion](https://go-acme.github.io/lego/dns/nodion/) | [NS1](https://go-acme.github.io/lego/dns/ns1/) | [Open Telekom Cloud](https://go-acme.github.io/lego/dns/otc/) | [Oracle Cloud](https://go-acme.github.io/lego/dns/oraclecloud/) | +| [OVH](https://go-acme.github.io/lego/dns/ovh/) | [plesk.com](https://go-acme.github.io/lego/dns/plesk/) | [Porkbun](https://go-acme.github.io/lego/dns/porkbun/) | [PowerDNS](https://go-acme.github.io/lego/dns/pdns/) | +| [Rackspace](https://go-acme.github.io/lego/dns/rackspace/) | [RcodeZero](https://go-acme.github.io/lego/dns/rcodezero/) | [reg.ru](https://go-acme.github.io/lego/dns/regru/) | [RFC2136](https://go-acme.github.io/lego/dns/rfc2136/) | +| [RimuHosting](https://go-acme.github.io/lego/dns/rimuhosting/) | [Sakura Cloud](https://go-acme.github.io/lego/dns/sakuracloud/) | [Scaleway](https://go-acme.github.io/lego/dns/scaleway/) | [Selectel v2](https://go-acme.github.io/lego/dns/selectelv2/) | +| [Selectel](https://go-acme.github.io/lego/dns/selectel/) | [Servercow](https://go-acme.github.io/lego/dns/servercow/) | [Shellrent](https://go-acme.github.io/lego/dns/shellrent/) | [Simply.com](https://go-acme.github.io/lego/dns/simply/) | +| [Sonic](https://go-acme.github.io/lego/dns/sonic/) | [Stackpath](https://go-acme.github.io/lego/dns/stackpath/) | [Tencent Cloud DNS](https://go-acme.github.io/lego/dns/tencentcloud/) | [TransIP](https://go-acme.github.io/lego/dns/transip/) | +| [UKFast SafeDNS](https://go-acme.github.io/lego/dns/safedns/) | [Ultradns](https://go-acme.github.io/lego/dns/ultradns/) | [Variomedia](https://go-acme.github.io/lego/dns/variomedia/) | [VegaDNS](https://go-acme.github.io/lego/dns/vegadns/) | +| [Vercel](https://go-acme.github.io/lego/dns/vercel/) | [Versio.[nl/eu/uk]](https://go-acme.github.io/lego/dns/versio/) | [VinylDNS](https://go-acme.github.io/lego/dns/vinyldns/) | [VK Cloud](https://go-acme.github.io/lego/dns/vkcloud/) | +| [Vscale](https://go-acme.github.io/lego/dns/vscale/) | [Vultr](https://go-acme.github.io/lego/dns/vultr/) | [Webnames](https://go-acme.github.io/lego/dns/webnames/) | [Websupport](https://go-acme.github.io/lego/dns/websupport/) | +| [WEDOS](https://go-acme.github.io/lego/dns/wedos/) | [Yandex 360](https://go-acme.github.io/lego/dns/yandex360/) | [Yandex Cloud](https://go-acme.github.io/lego/dns/yandexcloud/) | [Yandex PDD](https://go-acme.github.io/lego/dns/yandex/) | +| [Zone.ee](https://go-acme.github.io/lego/dns/zoneee/) | [Zonomi](https://go-acme.github.io/lego/dns/zonomi/) | | | diff --git a/cmd/zz_gen_cmd_dnshelp.go b/cmd/zz_gen_cmd_dnshelp.go index 34b36be968..a4291e3c51 100644 --- a/cmd/zz_gen_cmd_dnshelp.go +++ b/cmd/zz_gen_cmd_dnshelp.go @@ -85,6 +85,7 @@ func allDNSCodes() string { "joker", "liara", "lightsail", + "limacity", "linode", "liquidweb", "loopia", @@ -1666,6 +1667,26 @@ func displayDNSHelp(w io.Writer, name string) error { ew.writeln() ew.writeln(`More information: https://go-acme.github.io/lego/dns/lightsail`) + case "limacity": + // generated from: providers/dns/limacity/limacity.toml + ew.writeln(`Configuration for Lima-City.`) + ew.writeln(`Code: 'limacity'`) + ew.writeln(`Since: 'v4.18.0'`) + ew.writeln() + + ew.writeln(`Credentials:`) + ew.writeln(` - "LIMACITY_API_KEY": The API key`) + ew.writeln() + + ew.writeln(`Additional Configuration:`) + ew.writeln(` - "LIMACITY_HTTP_TIMEOUT": API request timeout`) + ew.writeln(` - "LIMACITY_POLLING_INTERVAL": Time between DNS propagation check`) + ew.writeln(` - "LIMACITY_PROPAGATION_TIMEOUT": Maximum waiting time for DNS propagation`) + ew.writeln(` - "LIMACITY_TTL": The TTL of the TXT record used for the DNS challenge`) + + ew.writeln() + ew.writeln(`More information: https://go-acme.github.io/lego/dns/limacity`) + case "linode": // generated from: providers/dns/linode/linode.toml ew.writeln(`Configuration for Linode (v4).`) diff --git a/docs/content/dns/zz_gen_limacity.md b/docs/content/dns/zz_gen_limacity.md new file mode 100644 index 0000000000..f293c0c05d --- /dev/null +++ b/docs/content/dns/zz_gen_limacity.md @@ -0,0 +1,67 @@ +--- +title: "Lima-City" +date: 2019-03-03T16:39:46+01:00 +draft: false +slug: limacity +dnsprovider: + since: "v4.18.0" + code: "limacity" + url: "https://www.lima-city.de" +--- + + + + + + +Configuration for [Lima-City](https://www.lima-city.de). + + + + +- Code: `limacity` +- Since: v4.18.0 + + +Here is an example bash command using the Lima-City provider: + +```bash +LIMACITY_API_KEY="xxxxxxxxxxxxxxxxxxxxx" \ +lego --email myemail@example.com --dns limacity --domains my.example.org run +``` + + + + +## Credentials + +| Environment Variable Name | Description | +|-----------------------|-------------| +| `LIMACITY_API_KEY` | The API key | + +The environment variable names can be suffixed by `_FILE` to reference a file instead of a value. +More information [here]({{% ref "dns#configuration-and-credentials" %}}). + + +## Additional Configuration + +| Environment Variable Name | Description | +|--------------------------------|-------------| +| `LIMACITY_HTTP_TIMEOUT` | API request timeout | +| `LIMACITY_POLLING_INTERVAL` | Time between DNS propagation check | +| `LIMACITY_PROPAGATION_TIMEOUT` | Maximum waiting time for DNS propagation | +| `LIMACITY_TTL` | The TTL of the TXT record used for the DNS challenge | + +The environment variable names can be suffixed by `_FILE` to reference a file instead of a value. +More information [here]({{% ref "dns#configuration-and-credentials" %}}). + + + + +## More information + +- [API documentation](https://www.lima-city.de/hilfe/lima-city-api) + + + + diff --git a/docs/data/zz_cli_help.toml b/docs/data/zz_cli_help.toml index b237cf7bc0..6fc404858d 100644 --- a/docs/data/zz_cli_help.toml +++ b/docs/data/zz_cli_help.toml @@ -138,7 +138,7 @@ To display the documentation for a specific DNS provider, run: $ lego dnshelp -c code Supported DNS providers: - acme-dns, alidns, allinkl, arvancloud, auroradns, autodns, azure, azuredns, bindman, bluecat, brandit, bunny, checkdomain, civo, clouddns, cloudflare, cloudns, cloudru, cloudxns, conoha, constellix, cpanel, derak, desec, designate, digitalocean, directadmin, dnshomede, dnsimple, dnsmadeeasy, dnspod, dode, domeneshop, dreamhost, duckdns, dyn, dynu, easydns, edgedns, efficientip, epik, exec, exoscale, freemyip, gandi, gandiv5, gcloud, gcore, glesys, godaddy, googledomains, hetzner, hostingde, hosttech, httpnet, httpreq, hurricane, hyperone, ibmcloud, iij, iijdpf, infoblox, infomaniak, internetbs, inwx, ionos, ipv64, iwantmyname, joker, liara, lightsail, linode, liquidweb, loopia, luadns, mailinabox, manual, metaname, mijnhost, mydnsjp, mythicbeasts, namecheap, namedotcom, namesilo, nearlyfreespeech, netcup, netlify, nicmanager, nifcloud, njalla, nodion, ns1, oraclecloud, otc, ovh, pdns, plesk, porkbun, rackspace, rcodezero, regru, rfc2136, rimuhosting, route53, safedns, sakuracloud, scaleway, selectel, selectelv2, servercow, shellrent, simply, sonic, stackpath, tencentcloud, transip, ultradns, variomedia, vegadns, vercel, versio, vinyldns, vkcloud, vscale, vultr, webnames, websupport, wedos, yandex, yandex360, yandexcloud, zoneee, zonomi + acme-dns, alidns, allinkl, arvancloud, auroradns, autodns, azure, azuredns, bindman, bluecat, brandit, bunny, checkdomain, civo, clouddns, cloudflare, cloudns, cloudru, cloudxns, conoha, constellix, cpanel, derak, desec, designate, digitalocean, directadmin, dnshomede, dnsimple, dnsmadeeasy, dnspod, dode, domeneshop, dreamhost, duckdns, dyn, dynu, easydns, edgedns, efficientip, epik, exec, exoscale, freemyip, gandi, gandiv5, gcloud, gcore, glesys, godaddy, googledomains, hetzner, hostingde, hosttech, httpnet, httpreq, hurricane, hyperone, ibmcloud, iij, iijdpf, infoblox, infomaniak, internetbs, inwx, ionos, ipv64, iwantmyname, joker, liara, lightsail, limacity, linode, liquidweb, loopia, luadns, mailinabox, manual, metaname, mijnhost, mydnsjp, mythicbeasts, namecheap, namedotcom, namesilo, nearlyfreespeech, netcup, netlify, nicmanager, nifcloud, njalla, nodion, ns1, oraclecloud, otc, ovh, pdns, plesk, porkbun, rackspace, rcodezero, regru, rfc2136, rimuhosting, route53, safedns, sakuracloud, scaleway, selectel, selectelv2, servercow, shellrent, simply, sonic, stackpath, tencentcloud, transip, ultradns, variomedia, vegadns, vercel, versio, vinyldns, vkcloud, vscale, vultr, webnames, websupport, wedos, yandex, yandex360, yandexcloud, zoneee, zonomi More information: https://go-acme.github.io/lego/dns """ From e4191f76764bfc13fcd20c8a2c410946aceff19d Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 27 Aug 2024 15:00:42 +0200 Subject: [PATCH 03/24] fix: type --- providers/dns/limacity/internal/client_test.go | 2 +- providers/dns/limacity/internal/fixtures/get-domains.json | 2 +- providers/dns/limacity/internal/types.go | 2 +- providers/dns/limacity/limacity.go | 7 +++++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/providers/dns/limacity/internal/client_test.go b/providers/dns/limacity/internal/client_test.go index 46fa06557b..14d97cd277 100644 --- a/providers/dns/limacity/internal/client_test.go +++ b/providers/dns/limacity/internal/client_test.go @@ -70,7 +70,7 @@ func TestClient_GetDomains(t *testing.T) { require.NoError(t, err) expected := []Domain{{ - ID: "123", + ID: 123, UnicodeFqdn: "example.com", Domain: "example", TLD: "com", diff --git a/providers/dns/limacity/internal/fixtures/get-domains.json b/providers/dns/limacity/internal/fixtures/get-domains.json index c11115602b..1643a17662 100644 --- a/providers/dns/limacity/internal/fixtures/get-domains.json +++ b/providers/dns/limacity/internal/fixtures/get-domains.json @@ -1,7 +1,7 @@ { "domains": [ { - "id": "123", + "id": 123, "mode": "CREATE", "tld": "com", "domain": "example", diff --git a/providers/dns/limacity/internal/types.go b/providers/dns/limacity/internal/types.go index 7041f22acc..a19b0096e1 100644 --- a/providers/dns/limacity/internal/types.go +++ b/providers/dns/limacity/internal/types.go @@ -41,7 +41,7 @@ type Record struct { } type Domain struct { - ID string `json:"id,omitempty"` + ID int `json:"id,omitempty"` UnicodeFqdn string `json:"unicode_fqdn,omitempty"` Domain string `json:"domain,omitempty"` TLD string `json:"tld,omitempty"` diff --git a/providers/dns/limacity/limacity.go b/providers/dns/limacity/limacity.go index cfded66687..55c040c6ad 100644 --- a/providers/dns/limacity/limacity.go +++ b/providers/dns/limacity/limacity.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "net/http" + "strconv" "sync" "time" @@ -123,13 +124,15 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { Type: "TXT", } - err = d.client.AddRecord(context.Background(), dom.ID, record) + domainID := strconv.Itoa(dom.ID) + + err = d.client.AddRecord(context.Background(), domainID, record) if err != nil { return fmt.Errorf("limacity: add record: %w", err) } d.domainIDsMu.Lock() - d.domainIDs[token] = dom.ID + d.domainIDs[token] = domainID d.domainIDsMu.Unlock() return nil From abcf23743c1429d14fc39ca385cde5434ef1a899 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 27 Aug 2024 15:21:35 +0200 Subject: [PATCH 04/24] fix: add record --- providers/dns/limacity/internal/client.go | 18 ++---------------- providers/dns/limacity/internal/types.go | 2 +- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/providers/dns/limacity/internal/client.go b/providers/dns/limacity/internal/client.go index f7efcaca0d..53482df82a 100644 --- a/providers/dns/limacity/internal/client.go +++ b/providers/dns/limacity/internal/client.go @@ -15,8 +15,6 @@ import ( const defaultBaseURL = "https://www.lima-city.de/usercp" -const success = "ok" - type Client struct { apiKey string baseURL *url.URL @@ -70,7 +68,7 @@ func (c Client) GetRecords(ctx context.Context, domainID string) ([]Record, erro func (c Client) AddRecord(ctx context.Context, domainID string, record Record) error { endpoint := c.baseURL.JoinPath("domains", domainID, "records.json") - req, err := newJSONRequest(ctx, http.MethodPost, endpoint, record) + req, err := newJSONRequest(ctx, http.MethodPost, endpoint, NameserverRecordPayload{Data: record}) if err != nil { return err } @@ -81,17 +79,13 @@ func (c Client) AddRecord(ctx context.Context, domainID string, record Record) e return err } - if results.Status != success { - return results - } - return nil } func (c Client) UpdateRecord(ctx context.Context, domainID, recordID string, record Record) error { endpoint := c.baseURL.JoinPath("domains", domainID, "records", recordID) - req, err := newJSONRequest(ctx, http.MethodPut, endpoint, record) + req, err := newJSONRequest(ctx, http.MethodPut, endpoint, NameserverRecordPayload{Data: record}) if err != nil { return err } @@ -102,10 +96,6 @@ func (c Client) UpdateRecord(ctx context.Context, domainID, recordID string, rec return err } - if results.Status != success { - return results - } - return nil } @@ -124,10 +114,6 @@ func (c Client) DeleteRecord(ctx context.Context, domainID, recordID string) err return err } - if results.Status != success { - return results - } - return nil } diff --git a/providers/dns/limacity/internal/types.go b/providers/dns/limacity/internal/types.go index a19b0096e1..0abf3f947c 100644 --- a/providers/dns/limacity/internal/types.go +++ b/providers/dns/limacity/internal/types.go @@ -10,7 +10,7 @@ type RecordsResponse struct { } type NameserverRecordPayload struct { - Data *Record `json:"nameserver_record,omitempty"` + Data Record `json:"nameserver_record,omitempty"` } type DomainsResponse struct { From f600011631ca9f62272b9336038e9b48c11a3bf9 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 27 Aug 2024 15:52:43 +0200 Subject: [PATCH 05/24] fix: types --- providers/dns/limacity/internal/client.go | 17 +++++++++-------- providers/dns/limacity/internal/client_test.go | 18 +++++++++--------- .../internal/fixtures/get-records.json | 2 +- providers/dns/limacity/internal/types.go | 2 +- providers/dns/limacity/limacity.go | 15 ++++++--------- 5 files changed, 26 insertions(+), 28 deletions(-) diff --git a/providers/dns/limacity/internal/client.go b/providers/dns/limacity/internal/client.go index 53482df82a..8a8b93adba 100644 --- a/providers/dns/limacity/internal/client.go +++ b/providers/dns/limacity/internal/client.go @@ -8,6 +8,7 @@ import ( "io" "net/http" "net/url" + "strconv" "time" "github.com/go-acme/lego/v4/providers/dns/internal/errutils" @@ -48,8 +49,8 @@ func (c Client) GetDomains(ctx context.Context) ([]Domain, error) { return results.Data, nil } -func (c Client) GetRecords(ctx context.Context, domainID string) ([]Record, error) { - endpoint := c.baseURL.JoinPath("domains", domainID, "records.json") +func (c Client) GetRecords(ctx context.Context, domainID int) ([]Record, error) { + endpoint := c.baseURL.JoinPath("domains", strconv.Itoa(domainID), "records.json") req, err := newJSONRequest(ctx, http.MethodGet, endpoint, nil) if err != nil { @@ -65,8 +66,8 @@ func (c Client) GetRecords(ctx context.Context, domainID string) ([]Record, erro return results.Data, nil } -func (c Client) AddRecord(ctx context.Context, domainID string, record Record) error { - endpoint := c.baseURL.JoinPath("domains", domainID, "records.json") +func (c Client) AddRecord(ctx context.Context, domainID int, record Record) error { + endpoint := c.baseURL.JoinPath("domains", strconv.Itoa(domainID), "records.json") req, err := newJSONRequest(ctx, http.MethodPost, endpoint, NameserverRecordPayload{Data: record}) if err != nil { @@ -82,8 +83,8 @@ func (c Client) AddRecord(ctx context.Context, domainID string, record Record) e return nil } -func (c Client) UpdateRecord(ctx context.Context, domainID, recordID string, record Record) error { - endpoint := c.baseURL.JoinPath("domains", domainID, "records", recordID) +func (c Client) UpdateRecord(ctx context.Context, domainID, recordID int, record Record) error { + endpoint := c.baseURL.JoinPath("domains", strconv.Itoa(domainID), "records", strconv.Itoa(recordID)) req, err := newJSONRequest(ctx, http.MethodPut, endpoint, NameserverRecordPayload{Data: record}) if err != nil { @@ -99,9 +100,9 @@ func (c Client) UpdateRecord(ctx context.Context, domainID, recordID string, rec return nil } -func (c Client) DeleteRecord(ctx context.Context, domainID, recordID string) error { +func (c Client) DeleteRecord(ctx context.Context, domainID, recordID int) error { // /domains/{domainId}/records/{recordId} DELETE - endpoint := c.baseURL.JoinPath("domains", domainID, "records", recordID) + endpoint := c.baseURL.JoinPath("domains", strconv.Itoa(domainID), "records", strconv.Itoa(recordID)) req, err := newJSONRequest(ctx, http.MethodDelete, endpoint, nil) if err != nil { diff --git a/providers/dns/limacity/internal/client_test.go b/providers/dns/limacity/internal/client_test.go index 14d97cd277..70eb233b2e 100644 --- a/providers/dns/limacity/internal/client_test.go +++ b/providers/dns/limacity/internal/client_test.go @@ -93,12 +93,12 @@ func TestClient_GetRecords(t *testing.T) { mux.HandleFunc("/domains/123/records.json", testHandler("get-records.json", http.MethodGet, http.StatusOK)) - records, err := client.GetRecords(context.Background(), "123") + records, err := client.GetRecords(context.Background(), 123) require.NoError(t, err) expected := []Record{{ + ID: 1234, Content: "ns1.lima-city.de", - ID: "1234", Name: "example.com", Subdomain: "", TTL: 36000, @@ -112,7 +112,7 @@ func TestClient_GetRecords_error(t *testing.T) { mux.HandleFunc("/domains/123/records.json", testHandler("error.json", http.MethodGet, http.StatusBadRequest)) - _, err := client.GetRecords(context.Background(), "123") + _, err := client.GetRecords(context.Background(), 123) require.EqualError(t, err, "[status code: 400] status: invalid_resource, details: name: [muss ausgefüllt werden]") } @@ -124,7 +124,7 @@ func TestClient_AddRecord(t *testing.T) { }) mux.HandleFunc("/domains/123/records.json", testHandler("ok.json", http.MethodPost, http.StatusOK)) - err := client.AddRecord(context.Background(), "123", Record{}) + err := client.AddRecord(context.Background(), 123, Record{}) require.NoError(t, err) } @@ -136,7 +136,7 @@ func TestClient_AddRecord_error(t *testing.T) { }) mux.HandleFunc("/domains/123/records.json", testHandler("error.json", http.MethodPost, http.StatusBadRequest)) - err := client.AddRecord(context.Background(), "123", Record{}) + err := client.AddRecord(context.Background(), 123, Record{}) require.EqualError(t, err, "[status code: 400] status: invalid_resource, details: name: [muss ausgefüllt werden]") } @@ -148,7 +148,7 @@ func TestClient_UpdateRecord(t *testing.T) { }) mux.HandleFunc("/domains/123/records/456", testHandler("ok.json", http.MethodPut, http.StatusOK)) - err := client.UpdateRecord(context.Background(), "123", "456", Record{}) + err := client.UpdateRecord(context.Background(), 123, 456, Record{}) require.NoError(t, err) } @@ -160,7 +160,7 @@ func TestClient_UpdateRecord_error(t *testing.T) { }) mux.HandleFunc("/domains/123/records/456", testHandler("error.json", http.MethodPut, http.StatusBadRequest)) - err := client.UpdateRecord(context.Background(), "123", "456", Record{}) + err := client.UpdateRecord(context.Background(), 123, 456, Record{}) require.EqualError(t, err, "[status code: 400] status: invalid_resource, details: name: [muss ausgefüllt werden]") } @@ -172,7 +172,7 @@ func TestClient_DeleteRecord(t *testing.T) { }) mux.HandleFunc("/domains/123/records/456", testHandler("ok.json", http.MethodDelete, http.StatusOK)) - err := client.DeleteRecord(context.Background(), "123", "456") + err := client.DeleteRecord(context.Background(), 123, 456) require.NoError(t, err) } @@ -184,6 +184,6 @@ func TestClient_DeleteRecord_error(t *testing.T) { }) mux.HandleFunc("/domains/123/records/456", testHandler("error.json", http.MethodDelete, http.StatusBadRequest)) - err := client.DeleteRecord(context.Background(), "123", "456") + err := client.DeleteRecord(context.Background(), 123, 456) require.EqualError(t, err, "[status code: 400] status: invalid_resource, details: name: [muss ausgefüllt werden]") } diff --git a/providers/dns/limacity/internal/fixtures/get-records.json b/providers/dns/limacity/internal/fixtures/get-records.json index 3c89925c8c..c8637a1d3f 100644 --- a/providers/dns/limacity/internal/fixtures/get-records.json +++ b/providers/dns/limacity/internal/fixtures/get-records.json @@ -1,8 +1,8 @@ { "records": [ { + "id": 1234, "content": "ns1.lima-city.de", - "id": "1234", "name": "example.com", "subdomain": "", "ttl": 36000, diff --git a/providers/dns/limacity/internal/types.go b/providers/dns/limacity/internal/types.go index 0abf3f947c..cdd9a1953e 100644 --- a/providers/dns/limacity/internal/types.go +++ b/providers/dns/limacity/internal/types.go @@ -32,7 +32,7 @@ func (a APIResponse) Error() string { } type Record struct { - ID string `json:"id,omitempty"` + ID int `json:"id,omitempty"` Content string `json:"content,omitempty"` Name string `json:"name,omitempty"` Subdomain string `json:"subdomain,omitempty"` diff --git a/providers/dns/limacity/limacity.go b/providers/dns/limacity/limacity.go index 55c040c6ad..bd44c2d1e1 100644 --- a/providers/dns/limacity/limacity.go +++ b/providers/dns/limacity/limacity.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "net/http" - "strconv" "sync" "time" @@ -54,7 +53,7 @@ type DNSProvider struct { config *Config client *internal.Client - domainIDs map[string]string + domainIDs map[string]int domainIDsMu sync.Mutex } @@ -87,7 +86,7 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) { return &DNSProvider{ config: config, client: client, - domainIDs: make(map[string]string), + domainIDs: make(map[string]int), }, nil } @@ -124,15 +123,13 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { Type: "TXT", } - domainID := strconv.Itoa(dom.ID) - - err = d.client.AddRecord(context.Background(), domainID, record) + err = d.client.AddRecord(context.Background(), dom.ID, record) if err != nil { return fmt.Errorf("limacity: add record: %w", err) } d.domainIDsMu.Lock() - d.domainIDs[token] = domainID + d.domainIDs[token] = dom.ID d.domainIDsMu.Unlock() return nil @@ -155,7 +152,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { return fmt.Errorf("limacity: get records: %w", err) } - var recordID string + var recordID int for _, record := range records { if record.Type == "TXT" && record.Content == info.Value { recordID = record.ID @@ -163,7 +160,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { } } - if recordID == "" { + if recordID == 0 { return errors.New("limacity: TXT record not found") } From 3e9d622decaa06c8958529e708938dd3271d1506 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 27 Aug 2024 15:55:45 +0200 Subject: [PATCH 06/24] fix: types again --- providers/dns/limacity/limacity.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers/dns/limacity/limacity.go b/providers/dns/limacity/limacity.go index bd44c2d1e1..8afc41654f 100644 --- a/providers/dns/limacity/limacity.go +++ b/providers/dns/limacity/limacity.go @@ -166,7 +166,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { err = d.client.DeleteRecord(context.Background(), domainID, recordID) if err != nil { - return fmt.Errorf("limacity: delete record (domain ID=%s, record ID=%s): %w", domainID, recordID, err) + return fmt.Errorf("limacity: delete record (domain ID=%d, record ID=%d): %w", domainID, recordID, err) } return nil From c42b5e95f7cc9360ba8b1723f5e249d37530f97a Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 27 Aug 2024 16:15:07 +0200 Subject: [PATCH 07/24] fix: subdomain is a boolean... --- providers/dns/limacity/internal/client_test.go | 11 +++++------ .../dns/limacity/internal/fixtures/get-records.json | 2 +- providers/dns/limacity/internal/types.go | 2 +- providers/dns/limacity/limacity.go | 4 ++-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/providers/dns/limacity/internal/client_test.go b/providers/dns/limacity/internal/client_test.go index 70eb233b2e..8a9ad56f02 100644 --- a/providers/dns/limacity/internal/client_test.go +++ b/providers/dns/limacity/internal/client_test.go @@ -97,12 +97,11 @@ func TestClient_GetRecords(t *testing.T) { require.NoError(t, err) expected := []Record{{ - ID: 1234, - Content: "ns1.lima-city.de", - Name: "example.com", - Subdomain: "", - TTL: 36000, - Type: "NS", + ID: 1234, + Content: "ns1.lima-city.de", + Name: "example.com", + TTL: 36000, + Type: "NS", }} assert.Equal(t, expected, records) } diff --git a/providers/dns/limacity/internal/fixtures/get-records.json b/providers/dns/limacity/internal/fixtures/get-records.json index c8637a1d3f..6f2c158fc1 100644 --- a/providers/dns/limacity/internal/fixtures/get-records.json +++ b/providers/dns/limacity/internal/fixtures/get-records.json @@ -4,7 +4,7 @@ "id": 1234, "content": "ns1.lima-city.de", "name": "example.com", - "subdomain": "", + "subdomain": false, "ttl": 36000, "type": "NS" } diff --git a/providers/dns/limacity/internal/types.go b/providers/dns/limacity/internal/types.go index cdd9a1953e..fac52d1fcc 100644 --- a/providers/dns/limacity/internal/types.go +++ b/providers/dns/limacity/internal/types.go @@ -35,7 +35,7 @@ type Record struct { ID int `json:"id,omitempty"` Content string `json:"content,omitempty"` Name string `json:"name,omitempty"` - Subdomain string `json:"subdomain,omitempty"` + Subdomain bool `json:"subdomain,omitempty"` TTL int `json:"ttl,omitempty"` Type string `json:"type,omitempty"` } diff --git a/providers/dns/limacity/limacity.go b/providers/dns/limacity/limacity.go index 8afc41654f..a9116b70e9 100644 --- a/providers/dns/limacity/limacity.go +++ b/providers/dns/limacity/limacity.go @@ -116,9 +116,9 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { } record := internal.Record{ + Name: subDomain, Content: info.Value, - Name: dns01.UnFqdn(dom.UnicodeFqdn), - Subdomain: subDomain, + Subdomain: true, TTL: d.config.TTL, Type: "TXT", } From 92c09b2590fd1f2c7ad0e78427e5b22bae3cefa3 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 27 Aug 2024 16:38:34 +0200 Subject: [PATCH 08/24] fix: subdomain is a cameleon --- .../dns/limacity/internal/client_test.go | 24 +++++++++++++------ .../internal/fixtures/get-records.json | 13 ++++++++-- providers/dns/limacity/internal/types.go | 2 +- providers/dns/limacity/limacity.go | 9 ++++--- 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/providers/dns/limacity/internal/client_test.go b/providers/dns/limacity/internal/client_test.go index 8a9ad56f02..3d1b0869e9 100644 --- a/providers/dns/limacity/internal/client_test.go +++ b/providers/dns/limacity/internal/client_test.go @@ -96,13 +96,23 @@ func TestClient_GetRecords(t *testing.T) { records, err := client.GetRecords(context.Background(), 123) require.NoError(t, err) - expected := []Record{{ - ID: 1234, - Content: "ns1.lima-city.de", - Name: "example.com", - TTL: 36000, - Type: "NS", - }} + expected := []Record{ + { + ID: 1234, + Content: "ns1.lima-city.de", + Name: "example.com", + TTL: 36000, + Type: "NS", + }, + { + ID: 5678, + Content: "foobar", + Name: "_acme-challenge.example.com", + Subdomain: "_acme-challenge", + TTL: 36000, + Type: "TXT", + }, + } assert.Equal(t, expected, records) } diff --git a/providers/dns/limacity/internal/fixtures/get-records.json b/providers/dns/limacity/internal/fixtures/get-records.json index 6f2c158fc1..c15c7c8c49 100644 --- a/providers/dns/limacity/internal/fixtures/get-records.json +++ b/providers/dns/limacity/internal/fixtures/get-records.json @@ -4,9 +4,18 @@ "id": 1234, "content": "ns1.lima-city.de", "name": "example.com", - "subdomain": false, "ttl": 36000, - "type": "NS" + "type": "NS", + "priority": null + }, + { + "id": 5678, + "content": "foobar", + "name": "_acme-challenge.example.com", + "subdomain": "_acme-challenge", + "ttl": 36000, + "type": "TXT", + "priority": null } ] } diff --git a/providers/dns/limacity/internal/types.go b/providers/dns/limacity/internal/types.go index fac52d1fcc..cdd9a1953e 100644 --- a/providers/dns/limacity/internal/types.go +++ b/providers/dns/limacity/internal/types.go @@ -35,7 +35,7 @@ type Record struct { ID int `json:"id,omitempty"` Content string `json:"content,omitempty"` Name string `json:"name,omitempty"` - Subdomain bool `json:"subdomain,omitempty"` + Subdomain string `json:"subdomain,omitempty"` TTL int `json:"ttl,omitempty"` Type string `json:"type,omitempty"` } diff --git a/providers/dns/limacity/limacity.go b/providers/dns/limacity/limacity.go index a9116b70e9..9793e29d2b 100644 --- a/providers/dns/limacity/limacity.go +++ b/providers/dns/limacity/limacity.go @@ -116,11 +116,10 @@ func (d *DNSProvider) Present(domain, token, keyAuth string) error { } record := internal.Record{ - Name: subDomain, - Content: info.Value, - Subdomain: true, - TTL: d.config.TTL, - Type: "TXT", + Name: subDomain, + Content: info.Value, + TTL: d.config.TTL, + Type: "TXT", } err = d.client.AddRecord(context.Background(), dom.ID, record) From 5892fd4b8965d40f22e9b65c65d4cc4cbe978b5f Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 27 Aug 2024 16:47:05 +0200 Subject: [PATCH 09/24] chore: remove subdmain --- providers/dns/limacity/internal/client_test.go | 11 +++++------ providers/dns/limacity/internal/types.go | 11 +++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/providers/dns/limacity/internal/client_test.go b/providers/dns/limacity/internal/client_test.go index 3d1b0869e9..06f037dda7 100644 --- a/providers/dns/limacity/internal/client_test.go +++ b/providers/dns/limacity/internal/client_test.go @@ -105,12 +105,11 @@ func TestClient_GetRecords(t *testing.T) { Type: "NS", }, { - ID: 5678, - Content: "foobar", - Name: "_acme-challenge.example.com", - Subdomain: "_acme-challenge", - TTL: 36000, - Type: "TXT", + ID: 5678, + Content: "foobar", + Name: "_acme-challenge.example.com", + TTL: 36000, + Type: "TXT", }, } assert.Equal(t, expected, records) diff --git a/providers/dns/limacity/internal/types.go b/providers/dns/limacity/internal/types.go index cdd9a1953e..5fdbacef98 100644 --- a/providers/dns/limacity/internal/types.go +++ b/providers/dns/limacity/internal/types.go @@ -32,12 +32,11 @@ func (a APIResponse) Error() string { } type Record struct { - ID int `json:"id,omitempty"` - Content string `json:"content,omitempty"` - Name string `json:"name,omitempty"` - Subdomain string `json:"subdomain,omitempty"` - TTL int `json:"ttl,omitempty"` - Type string `json:"type,omitempty"` + ID int `json:"id,omitempty"` + Name string `json:"name,omitempty"` + Content string `json:"content,omitempty"` + TTL int `json:"ttl,omitempty"` + Type string `json:"type,omitempty"` } type Domain struct { From 801bb16a07a81b062770fe2ed85f01cdfb139216 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 27 Aug 2024 17:39:02 +0200 Subject: [PATCH 10/24] chore: reduce TTL --- providers/dns/limacity/limacity.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers/dns/limacity/limacity.go b/providers/dns/limacity/limacity.go index 9793e29d2b..e8b5266732 100644 --- a/providers/dns/limacity/limacity.go +++ b/providers/dns/limacity/limacity.go @@ -39,7 +39,7 @@ type Config struct { // NewDefaultConfig returns a default configuration for the DNSProvider. func NewDefaultConfig() *Config { return &Config{ - TTL: env.GetOrDefaultInt(EnvTTL, 3600), + TTL: env.GetOrDefaultInt(EnvTTL, 60), PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout), PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval), HTTPClient: &http.Client{ From 456eca3b7f16898b527598f9ee08c2ce96e4df9e Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 27 Aug 2024 17:52:02 +0200 Subject: [PATCH 11/24] chore: increase default propagation timeout --- providers/dns/limacity/limacity.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers/dns/limacity/limacity.go b/providers/dns/limacity/limacity.go index e8b5266732..5849c56845 100644 --- a/providers/dns/limacity/limacity.go +++ b/providers/dns/limacity/limacity.go @@ -40,7 +40,7 @@ type Config struct { func NewDefaultConfig() *Config { return &Config{ TTL: env.GetOrDefaultInt(EnvTTL, 60), - PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout), + PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, 3*time.Minute), PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval), HTTPClient: &http.Client{ Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second), From 280117c56d82fea1e9d599a38b7e75040dbd2b1d Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 27 Aug 2024 18:19:49 +0200 Subject: [PATCH 12/24] fix: records cleaning --- providers/dns/limacity/limacity.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/providers/dns/limacity/limacity.go b/providers/dns/limacity/limacity.go index 5849c56845..c1d5edfa2b 100644 --- a/providers/dns/limacity/limacity.go +++ b/providers/dns/limacity/limacity.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "net/http" + "strconv" "sync" "time" @@ -153,7 +154,7 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error { var recordID int for _, record := range records { - if record.Type == "TXT" && record.Content == info.Value { + if record.Type == "TXT" && record.Content == strconv.Quote(info.Value) { recordID = record.ID break } From 2387cabac17a4c51078ee419ba418be06966bf86 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 27 Aug 2024 18:23:19 +0200 Subject: [PATCH 13/24] chore: more realistic record value (quote) inside tests --- providers/dns/limacity/internal/client_test.go | 2 +- providers/dns/limacity/internal/fixtures/get-records.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/providers/dns/limacity/internal/client_test.go b/providers/dns/limacity/internal/client_test.go index 06f037dda7..398dbfed0a 100644 --- a/providers/dns/limacity/internal/client_test.go +++ b/providers/dns/limacity/internal/client_test.go @@ -106,7 +106,7 @@ func TestClient_GetRecords(t *testing.T) { }, { ID: 5678, - Content: "foobar", + Content: `"foobar"`, Name: "_acme-challenge.example.com", TTL: 36000, Type: "TXT", diff --git a/providers/dns/limacity/internal/fixtures/get-records.json b/providers/dns/limacity/internal/fixtures/get-records.json index c15c7c8c49..10f543464d 100644 --- a/providers/dns/limacity/internal/fixtures/get-records.json +++ b/providers/dns/limacity/internal/fixtures/get-records.json @@ -10,7 +10,7 @@ }, { "id": 5678, - "content": "foobar", + "content": "\"foobar\"", "name": "_acme-challenge.example.com", "subdomain": "_acme-challenge", "ttl": 36000, From f03853c704b38585316f772a64da4d5bb76214b7 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Wed, 28 Aug 2024 00:28:46 +0200 Subject: [PATCH 14/24] chore: remove useless code inside tests --- .../dns/limacity/internal/client_test.go | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/providers/dns/limacity/internal/client_test.go b/providers/dns/limacity/internal/client_test.go index 398dbfed0a..b9a13bdab5 100644 --- a/providers/dns/limacity/internal/client_test.go +++ b/providers/dns/limacity/internal/client_test.go @@ -127,33 +127,38 @@ func TestClient_GetRecords_error(t *testing.T) { func TestClient_AddRecord(t *testing.T) { client, mux := setupTest(t) - mux.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) { - fmt.Println(req) - }) mux.HandleFunc("/domains/123/records.json", testHandler("ok.json", http.MethodPost, http.StatusOK)) - err := client.AddRecord(context.Background(), 123, Record{}) + record := Record{ + Name: "foo", + Content: "bar", + TTL: 12, + Type: "TXT", + } + + err := client.AddRecord(context.Background(), 123, record) require.NoError(t, err) } func TestClient_AddRecord_error(t *testing.T) { client, mux := setupTest(t) - mux.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) { - fmt.Println(req) - }) mux.HandleFunc("/domains/123/records.json", testHandler("error.json", http.MethodPost, http.StatusBadRequest)) - err := client.AddRecord(context.Background(), 123, Record{}) + record := Record{ + Name: "foo", + Content: "bar", + TTL: 12, + Type: "TXT", + } + + err := client.AddRecord(context.Background(), 123, record) require.EqualError(t, err, "[status code: 400] status: invalid_resource, details: name: [muss ausgefüllt werden]") } func TestClient_UpdateRecord(t *testing.T) { client, mux := setupTest(t) - mux.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) { - fmt.Println(req) - }) mux.HandleFunc("/domains/123/records/456", testHandler("ok.json", http.MethodPut, http.StatusOK)) err := client.UpdateRecord(context.Background(), 123, 456, Record{}) @@ -163,9 +168,6 @@ func TestClient_UpdateRecord(t *testing.T) { func TestClient_UpdateRecord_error(t *testing.T) { client, mux := setupTest(t) - mux.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) { - fmt.Println(req) - }) mux.HandleFunc("/domains/123/records/456", testHandler("error.json", http.MethodPut, http.StatusBadRequest)) err := client.UpdateRecord(context.Background(), 123, 456, Record{}) @@ -175,9 +177,6 @@ func TestClient_UpdateRecord_error(t *testing.T) { func TestClient_DeleteRecord(t *testing.T) { client, mux := setupTest(t) - mux.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) { - fmt.Println(req) - }) mux.HandleFunc("/domains/123/records/456", testHandler("ok.json", http.MethodDelete, http.StatusOK)) err := client.DeleteRecord(context.Background(), 123, 456) @@ -187,9 +186,6 @@ func TestClient_DeleteRecord(t *testing.T) { func TestClient_DeleteRecord_error(t *testing.T) { client, mux := setupTest(t) - mux.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) { - fmt.Println(req) - }) mux.HandleFunc("/domains/123/records/456", testHandler("error.json", http.MethodDelete, http.StatusBadRequest)) err := client.DeleteRecord(context.Background(), 123, 456) From b1860e9fceff63dff02e2c0bce2847b9a796cad6 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Wed, 28 Aug 2024 17:31:31 +0200 Subject: [PATCH 15/24] wip: at least one --- challenge/dns01/precheck.go | 52 ++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/challenge/dns01/precheck.go b/challenge/dns01/precheck.go index f65dfb5af8..933a2512bc 100644 --- a/challenge/dns01/precheck.go +++ b/challenge/dns01/precheck.go @@ -72,7 +72,8 @@ func (p preCheck) checkDNSPropagation(fqdn, value string) (bool, error) { return false, err } - return checkAuthoritativeNss(fqdn, value, authoritativeNss) + // TODO only for debug + return atLeastOneAuthoritativeNss(fqdn, value, authoritativeNss) } // checkAuthoritativeNss queries each of the given nameservers for the expected TXT record. @@ -108,3 +109,52 @@ func checkAuthoritativeNss(fqdn, value string, nameservers []string) (bool, erro return true, nil } + +// TODO only for debug +func atLeastOneAuthoritativeNss(fqdn, value string, nameservers []string) (bool, error) { + var lastErr error + + for _, ns := range nameservers { + found, err := hasTXTEntry(fqdn, value, ns) + if err != nil { + lastErr = err + continue + } + + return found, nil + } + + return false, lastErr +} + +// TODO only for debug +func hasTXTEntry(fqdn, value, ns string) (bool, error) { + r, err := dnsQuery(fqdn, dns.TypeTXT, []string{net.JoinHostPort(ns, "53")}, false) + if err != nil { + return false, err + } + + if r.Rcode != dns.RcodeSuccess { + return false, fmt.Errorf("NS %s returned %s for %s", ns, dns.RcodeToString[r.Rcode], fqdn) + } + + var records []string + + var found bool + for _, rr := range r.Answer { + if txt, ok := rr.(*dns.TXT); ok { + record := strings.Join(txt.Txt, "") + records = append(records, record) + if record == value { + found = true + break + } + } + } + + if !found { + return false, fmt.Errorf("NS %s did not return the expected TXT record [fqdn: %s, value: %s]: %s", ns, fqdn, value, strings.Join(records, " ,")) + } + + return true, nil +} From 8f27ba747602d4bf43a3f63b027812a91afd64c4 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Wed, 28 Aug 2024 17:53:57 +0200 Subject: [PATCH 16/24] Revert "wip: at least one" This reverts commit e2ac1b06a730b8a8c76dfbccd30a65145fac33e2. --- challenge/dns01/precheck.go | 52 +------------------------------------ 1 file changed, 1 insertion(+), 51 deletions(-) diff --git a/challenge/dns01/precheck.go b/challenge/dns01/precheck.go index 933a2512bc..f65dfb5af8 100644 --- a/challenge/dns01/precheck.go +++ b/challenge/dns01/precheck.go @@ -72,8 +72,7 @@ func (p preCheck) checkDNSPropagation(fqdn, value string) (bool, error) { return false, err } - // TODO only for debug - return atLeastOneAuthoritativeNss(fqdn, value, authoritativeNss) + return checkAuthoritativeNss(fqdn, value, authoritativeNss) } // checkAuthoritativeNss queries each of the given nameservers for the expected TXT record. @@ -109,52 +108,3 @@ func checkAuthoritativeNss(fqdn, value string, nameservers []string) (bool, erro return true, nil } - -// TODO only for debug -func atLeastOneAuthoritativeNss(fqdn, value string, nameservers []string) (bool, error) { - var lastErr error - - for _, ns := range nameservers { - found, err := hasTXTEntry(fqdn, value, ns) - if err != nil { - lastErr = err - continue - } - - return found, nil - } - - return false, lastErr -} - -// TODO only for debug -func hasTXTEntry(fqdn, value, ns string) (bool, error) { - r, err := dnsQuery(fqdn, dns.TypeTXT, []string{net.JoinHostPort(ns, "53")}, false) - if err != nil { - return false, err - } - - if r.Rcode != dns.RcodeSuccess { - return false, fmt.Errorf("NS %s returned %s for %s", ns, dns.RcodeToString[r.Rcode], fqdn) - } - - var records []string - - var found bool - for _, rr := range r.Answer { - if txt, ok := rr.(*dns.TXT); ok { - record := strings.Join(txt.Txt, "") - records = append(records, record) - if record == value { - found = true - break - } - } - } - - if !found { - return false, fmt.Errorf("NS %s did not return the expected TXT record [fqdn: %s, value: %s]: %s", ns, fqdn, value, strings.Join(records, " ,")) - } - - return true, nil -} From a52ca762ed9e043634ce070a6ceed79b9b2da1c8 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Wed, 28 Aug 2024 17:56:25 +0200 Subject: [PATCH 17/24] wip: try a sequential approach --- providers/dns/limacity/limacity.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/providers/dns/limacity/limacity.go b/providers/dns/limacity/limacity.go index c1d5edfa2b..075a374f7d 100644 --- a/providers/dns/limacity/limacity.go +++ b/providers/dns/limacity/limacity.go @@ -26,6 +26,7 @@ const ( EnvPropagationTimeout = envNamespace + "PROPAGATION_TIMEOUT" EnvPollingInterval = envNamespace + "POLLING_INTERVAL" EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT" + EnvSequenceInterval = envNamespace + "SEQUENCE_INTERVAL" ) // Config is used to configure the creation of the DNSProvider. @@ -34,6 +35,7 @@ type Config struct { TTL int PropagationTimeout time.Duration PollingInterval time.Duration + SequenceInterval time.Duration HTTPClient *http.Client } @@ -43,6 +45,7 @@ func NewDefaultConfig() *Config { TTL: env.GetOrDefaultInt(EnvTTL, 60), PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, 3*time.Minute), PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval), + SequenceInterval: env.GetOrDefaultSecond(EnvSequenceInterval, dns01.DefaultPropagationTimeout), HTTPClient: &http.Client{ Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second), }, @@ -97,6 +100,12 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) { return d.config.PropagationTimeout, d.config.PollingInterval } +// Sequential All DNS challenges for this provider will be resolved sequentially. +// Returns the interval between each iteration. +func (d *DNSProvider) Sequential() time.Duration { + return d.config.SequenceInterval +} + // Present creates a TXT record to fulfill the dns-01 challenge. func (d *DNSProvider) Present(domain, token, keyAuth string) error { info := dns01.GetChallengeInfo(domain, keyAuth) From e4733905821a87b7ef20627cccd39bd964facf64 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Wed, 28 Aug 2024 21:20:36 +0200 Subject: [PATCH 18/24] Revert "wip: try a sequential approach" This reverts commit 82d8ccad6e1f104aed012de4ad690c6e34b499f0. --- providers/dns/limacity/limacity.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/providers/dns/limacity/limacity.go b/providers/dns/limacity/limacity.go index 075a374f7d..c1d5edfa2b 100644 --- a/providers/dns/limacity/limacity.go +++ b/providers/dns/limacity/limacity.go @@ -26,7 +26,6 @@ const ( EnvPropagationTimeout = envNamespace + "PROPAGATION_TIMEOUT" EnvPollingInterval = envNamespace + "POLLING_INTERVAL" EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT" - EnvSequenceInterval = envNamespace + "SEQUENCE_INTERVAL" ) // Config is used to configure the creation of the DNSProvider. @@ -35,7 +34,6 @@ type Config struct { TTL int PropagationTimeout time.Duration PollingInterval time.Duration - SequenceInterval time.Duration HTTPClient *http.Client } @@ -45,7 +43,6 @@ func NewDefaultConfig() *Config { TTL: env.GetOrDefaultInt(EnvTTL, 60), PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, 3*time.Minute), PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval), - SequenceInterval: env.GetOrDefaultSecond(EnvSequenceInterval, dns01.DefaultPropagationTimeout), HTTPClient: &http.Client{ Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second), }, @@ -100,12 +97,6 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) { return d.config.PropagationTimeout, d.config.PollingInterval } -// Sequential All DNS challenges for this provider will be resolved sequentially. -// Returns the interval between each iteration. -func (d *DNSProvider) Sequential() time.Duration { - return d.config.SequenceInterval -} - // Present creates a TXT record to fulfill the dns-01 challenge. func (d *DNSProvider) Present(domain, token, keyAuth string) error { info := dns01.GetChallengeInfo(domain, keyAuth) From 2fe92173f2e19136f27672591474d293fd30a305 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Wed, 28 Aug 2024 21:24:54 +0200 Subject: [PATCH 19/24] Reapply "wip: try a sequential approach" This reverts commit caa982209e2dd3478a82000926f766293c37efd7. --- providers/dns/limacity/limacity.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/providers/dns/limacity/limacity.go b/providers/dns/limacity/limacity.go index c1d5edfa2b..075a374f7d 100644 --- a/providers/dns/limacity/limacity.go +++ b/providers/dns/limacity/limacity.go @@ -26,6 +26,7 @@ const ( EnvPropagationTimeout = envNamespace + "PROPAGATION_TIMEOUT" EnvPollingInterval = envNamespace + "POLLING_INTERVAL" EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT" + EnvSequenceInterval = envNamespace + "SEQUENCE_INTERVAL" ) // Config is used to configure the creation of the DNSProvider. @@ -34,6 +35,7 @@ type Config struct { TTL int PropagationTimeout time.Duration PollingInterval time.Duration + SequenceInterval time.Duration HTTPClient *http.Client } @@ -43,6 +45,7 @@ func NewDefaultConfig() *Config { TTL: env.GetOrDefaultInt(EnvTTL, 60), PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, 3*time.Minute), PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval), + SequenceInterval: env.GetOrDefaultSecond(EnvSequenceInterval, dns01.DefaultPropagationTimeout), HTTPClient: &http.Client{ Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second), }, @@ -97,6 +100,12 @@ func (d *DNSProvider) Timeout() (timeout, interval time.Duration) { return d.config.PropagationTimeout, d.config.PollingInterval } +// Sequential All DNS challenges for this provider will be resolved sequentially. +// Returns the interval between each iteration. +func (d *DNSProvider) Sequential() time.Duration { + return d.config.SequenceInterval +} + // Present creates a TXT record to fulfill the dns-01 challenge. func (d *DNSProvider) Present(domain, token, keyAuth string) error { info := dns01.GetChallengeInfo(domain, keyAuth) From d94be8ef3ff0ca6749edfba1a4854ae3c563d8da Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Wed, 28 Aug 2024 22:35:04 +0200 Subject: [PATCH 20/24] feat: use standard default values --- providers/dns/limacity/limacity.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/providers/dns/limacity/limacity.go b/providers/dns/limacity/limacity.go index 075a374f7d..1283348c59 100644 --- a/providers/dns/limacity/limacity.go +++ b/providers/dns/limacity/limacity.go @@ -42,8 +42,8 @@ type Config struct { // NewDefaultConfig returns a default configuration for the DNSProvider. func NewDefaultConfig() *Config { return &Config{ - TTL: env.GetOrDefaultInt(EnvTTL, 60), - PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, 3*time.Minute), + TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL), + PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout), PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval), SequenceInterval: env.GetOrDefaultSecond(EnvSequenceInterval, dns01.DefaultPropagationTimeout), HTTPClient: &http.Client{ From 7f7cdb153f9334e9568e9fde693267362f4e1d59 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Thu, 29 Aug 2024 00:45:18 +0200 Subject: [PATCH 21/24] chore: generate --- cmd/zz_gen_cmd_dnshelp.go | 1 + docs/content/dns/zz_gen_limacity.md | 1 + providers/dns/limacity/limacity.toml | 1 + 3 files changed, 3 insertions(+) diff --git a/cmd/zz_gen_cmd_dnshelp.go b/cmd/zz_gen_cmd_dnshelp.go index a4291e3c51..c39cabcd49 100644 --- a/cmd/zz_gen_cmd_dnshelp.go +++ b/cmd/zz_gen_cmd_dnshelp.go @@ -1682,6 +1682,7 @@ func displayDNSHelp(w io.Writer, name string) error { ew.writeln(` - "LIMACITY_HTTP_TIMEOUT": API request timeout`) ew.writeln(` - "LIMACITY_POLLING_INTERVAL": Time between DNS propagation check`) ew.writeln(` - "LIMACITY_PROPAGATION_TIMEOUT": Maximum waiting time for DNS propagation`) + ew.writeln(` - "LIMACITY_SEQUENCE_INTERVAL": Time between sequential requests`) ew.writeln(` - "LIMACITY_TTL": The TTL of the TXT record used for the DNS challenge`) ew.writeln() diff --git a/docs/content/dns/zz_gen_limacity.md b/docs/content/dns/zz_gen_limacity.md index f293c0c05d..80e7390c84 100644 --- a/docs/content/dns/zz_gen_limacity.md +++ b/docs/content/dns/zz_gen_limacity.md @@ -50,6 +50,7 @@ More information [here]({{% ref "dns#configuration-and-credentials" %}}). | `LIMACITY_HTTP_TIMEOUT` | API request timeout | | `LIMACITY_POLLING_INTERVAL` | Time between DNS propagation check | | `LIMACITY_PROPAGATION_TIMEOUT` | Maximum waiting time for DNS propagation | +| `LIMACITY_SEQUENCE_INTERVAL` | Time between sequential requests | | `LIMACITY_TTL` | The TTL of the TXT record used for the DNS challenge | The environment variable names can be suffixed by `_FILE` to reference a file instead of a value. diff --git a/providers/dns/limacity/limacity.toml b/providers/dns/limacity/limacity.toml index c617a9024a..68766a3151 100644 --- a/providers/dns/limacity/limacity.toml +++ b/providers/dns/limacity/limacity.toml @@ -15,6 +15,7 @@ lego --email myemail@example.com --dns limacity --domains my.example.org run [Configuration.Additional] LIMACITY_POLLING_INTERVAL = "Time between DNS propagation check" LIMACITY_PROPAGATION_TIMEOUT = "Maximum waiting time for DNS propagation" + LIMACITY_SEQUENCE_INTERVAL = "Time between sequential requests" LIMACITY_TTL = "The TTL of the TXT record used for the DNS challenge" LIMACITY_HTTP_TIMEOUT = "API request timeout" From d7b93bb7304173f94b91cf256722ebcfff518ba8 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Thu, 29 Aug 2024 16:02:29 +0200 Subject: [PATCH 22/24] feat: new default values --- providers/dns/limacity/limacity.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/providers/dns/limacity/limacity.go b/providers/dns/limacity/limacity.go index 1283348c59..6457dfa10b 100644 --- a/providers/dns/limacity/limacity.go +++ b/providers/dns/limacity/limacity.go @@ -42,10 +42,10 @@ type Config struct { // NewDefaultConfig returns a default configuration for the DNSProvider. func NewDefaultConfig() *Config { return &Config{ - TTL: env.GetOrDefaultInt(EnvTTL, dns01.DefaultTTL), - PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout), - PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval), - SequenceInterval: env.GetOrDefaultSecond(EnvSequenceInterval, dns01.DefaultPropagationTimeout), + TTL: env.GetOrDefaultInt(EnvTTL, 60), + PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, 4*time.Minute), + PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, 10*time.Second), + SequenceInterval: env.GetOrDefaultSecond(EnvSequenceInterval, 90*time.Second), HTTPClient: &http.Client{ Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second), }, From 65afb6dcd61d9306648d90d9f3e0f7f44539890b Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Thu, 29 Aug 2024 17:18:16 +0200 Subject: [PATCH 23/24] feat: new default values --- providers/dns/limacity/limacity.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers/dns/limacity/limacity.go b/providers/dns/limacity/limacity.go index 6457dfa10b..c23ce6c84d 100644 --- a/providers/dns/limacity/limacity.go +++ b/providers/dns/limacity/limacity.go @@ -44,7 +44,7 @@ func NewDefaultConfig() *Config { return &Config{ TTL: env.GetOrDefaultInt(EnvTTL, 60), PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, 4*time.Minute), - PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, 10*time.Second), + PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, 80*time.Second), SequenceInterval: env.GetOrDefaultSecond(EnvSequenceInterval, 90*time.Second), HTTPClient: &http.Client{ Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 30*time.Second), From 03ef938e77225b63651f899fab13b091469d6583 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Fri, 30 Aug 2024 00:13:06 +0200 Subject: [PATCH 24/24] chore: LIMACITY_PROPAGATION_TIMEOUT -> 480 --- providers/dns/limacity/limacity.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers/dns/limacity/limacity.go b/providers/dns/limacity/limacity.go index c23ce6c84d..87b7d37aab 100644 --- a/providers/dns/limacity/limacity.go +++ b/providers/dns/limacity/limacity.go @@ -43,7 +43,7 @@ type Config struct { func NewDefaultConfig() *Config { return &Config{ TTL: env.GetOrDefaultInt(EnvTTL, 60), - PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, 4*time.Minute), + PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, 8*time.Minute), PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, 80*time.Second), SequenceInterval: env.GetOrDefaultSecond(EnvSequenceInterval, 90*time.Second), HTTPClient: &http.Client{