cloudxns.go raw
1 // Package cloudxns implements a DNS provider for solving the DNS-01 challenge using CloudXNS DNS.
2 package cloudxns
3
4 import (
5 "errors"
6 "net/http"
7 "time"
8
9 "github.com/go-acme/lego/v4/challenge/dns01"
10 )
11
12 // Environment variables names.
13 const (
14 envNamespace = "CLOUDXNS_"
15
16 EnvAPIKey = envNamespace + "API_KEY"
17 EnvSecretKey = envNamespace + "SECRET_KEY"
18
19 EnvTTL = envNamespace + "TTL"
20 EnvPropagationTimeout = envNamespace + "PROPAGATION_TIMEOUT"
21 EnvPollingInterval = envNamespace + "POLLING_INTERVAL"
22 EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
23 )
24
25 // Config is used to configure the creation of the DNSProvider.
26 type Config struct {
27 APIKey string
28 SecretKey string
29 PropagationTimeout time.Duration
30 PollingInterval time.Duration
31 TTL int
32 HTTPClient *http.Client
33 }
34
35 // NewDefaultConfig returns a default configuration for the DNSProvider.
36 func NewDefaultConfig() *Config {
37 return &Config{}
38 }
39
40 // DNSProvider implements the challenge.Provider interface.
41 type DNSProvider struct{}
42
43 // NewDNSProvider returns a DNSProvider instance configured for CloudXNS.
44 func NewDNSProvider() (*DNSProvider, error) {
45 return NewDNSProviderConfig(&Config{})
46 }
47
48 // NewDNSProviderConfig return a DNSProvider instance configured for CloudXNS.
49 func NewDNSProviderConfig(_ *Config) (*DNSProvider, error) {
50 return nil, errors.New("cloudxns: provider has shut down")
51 }
52
53 // Present creates a TXT record to fulfill the dns-01 challenge.
54 func (d *DNSProvider) Present(_, _, _ string) error {
55 return nil
56 }
57
58 // CleanUp removes the TXT record matching the specified parameters.
59 func (d *DNSProvider) CleanUp(_, _, _ string) error {
60 return nil
61 }
62
63 // Timeout returns the timeout and interval to use when checking for DNS propagation.
64 // Adjusting here to cope with spikes in propagation times.
65 func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
66 return dns01.DefaultPropagationTimeout, dns01.DefaultPollingInterval
67 }
68