1
0
mirror of https://github.com/go-acme/lego.git synced 2025-01-07 00:37:37 +02:00
lego/providers/dns/cloudxns/cloudxns.go

68 lines
1.9 KiB
Go
Raw Normal View History

// Package cloudxns implements a DNS provider for solving the DNS-01 challenge using CloudXNS DNS.
2019-03-11 18:56:48 +02:00
package cloudxns
2018-05-30 19:53:04 +02:00
import (
2018-09-15 19:26:45 +02:00
"errors"
2018-05-30 19:53:04 +02:00
"net/http"
"time"
2020-09-02 03:20:01 +02:00
"github.com/go-acme/lego/v4/challenge/dns01"
2018-05-30 19:53:04 +02:00
)
// Environment variables names.
const (
envNamespace = "CLOUDXNS_"
EnvAPIKey = envNamespace + "API_KEY"
EnvSecretKey = envNamespace + "SECRET_KEY"
EnvTTL = envNamespace + "TTL"
EnvPropagationTimeout = envNamespace + "PROPAGATION_TIMEOUT"
EnvPollingInterval = envNamespace + "POLLING_INTERVAL"
EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
)
2020-05-08 19:35:25 +02:00
// Config is used to configure the creation of the DNSProvider.
2018-09-15 19:26:45 +02:00
type Config struct {
APIKey string
SecretKey string
PropagationTimeout time.Duration
PollingInterval time.Duration
TTL int
HTTPClient *http.Client
}
2020-05-08 19:35:25 +02:00
// NewDefaultConfig returns a default configuration for the DNSProvider.
2018-09-15 19:26:45 +02:00
func NewDefaultConfig() *Config {
2024-11-07 00:58:56 +02:00
return &Config{}
2018-09-15 19:26:45 +02:00
}
2018-05-30 19:53:04 +02:00
2020-05-08 19:35:25 +02:00
// DNSProvider implements the challenge.Provider interface.
2024-11-07 00:58:56 +02:00
type DNSProvider struct{}
2018-05-30 19:53:04 +02:00
2018-09-15 19:26:45 +02:00
// NewDNSProvider returns a DNSProvider instance configured for CloudXNS.
2018-05-30 19:53:04 +02:00
func NewDNSProvider() (*DNSProvider, error) {
2024-11-07 00:58:56 +02:00
return NewDNSProviderConfig(&Config{})
2018-05-30 19:53:04 +02:00
}
2018-09-15 19:26:45 +02:00
// NewDNSProviderConfig return a DNSProvider instance configured for CloudXNS.
2024-11-07 00:58:56 +02:00
func NewDNSProviderConfig(_ *Config) (*DNSProvider, error) {
return nil, errors.New("cloudxns: provider has shut down")
2018-05-30 19:53:04 +02:00
}
// Present creates a TXT record to fulfill the dns-01 challenge.
2024-11-07 00:58:56 +02:00
func (d *DNSProvider) Present(_, _, _ string) error {
2023-05-05 09:49:38 +02:00
return nil
2018-05-30 19:53:04 +02:00
}
2018-09-15 19:26:45 +02:00
// CleanUp removes the TXT record matching the specified parameters.
2024-11-07 00:58:56 +02:00
func (d *DNSProvider) CleanUp(_, _, _ string) error {
2023-05-05 09:49:38 +02:00
return nil
2018-05-30 19:53:04 +02:00
}
2018-09-15 19:26:45 +02:00
// 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) {
2024-11-07 00:58:56 +02:00
return dns01.DefaultPropagationTimeout, dns01.DefaultPollingInterval
2018-05-30 19:53:04 +02:00
}