googledomains.go raw
1 // Package googledomains implements a DNS provider for solving the DNS-01 challenge using Google Domains DNS API.
2 package googledomains
3
4 import (
5 "errors"
6 "net/http"
7 "time"
8
9 "github.com/go-acme/lego/v4/challenge"
10 "github.com/go-acme/lego/v4/challenge/dns01"
11 )
12
13 // Environment variables names.
14 const (
15 envNamespace = "GOOGLE_DOMAINS_"
16
17 EnvAccessToken = envNamespace + "ACCESS_TOKEN"
18 EnvPropagationTimeout = envNamespace + "PROPAGATION_TIMEOUT"
19 EnvPollingInterval = envNamespace + "POLLING_INTERVAL"
20 EnvHTTPTimeout = envNamespace + "HTTP_TIMEOUT"
21 )
22
23 var _ challenge.ProviderTimeout = (*DNSProvider)(nil)
24
25 // Config is used to configure the creation of the DNSProvider.
26 type Config struct {
27 AccessToken string
28 PollingInterval time.Duration
29 PropagationTimeout time.Duration
30 HTTPClient *http.Client
31 }
32
33 // NewDefaultConfig returns a default configuration for the DNSProvider.
34 func NewDefaultConfig() *Config {
35 return &Config{}
36 }
37
38 type DNSProvider struct{}
39
40 // NewDNSProvider returns the Google Domains DNS provider with a default configuration.
41 func NewDNSProvider() (*DNSProvider, error) {
42 return NewDNSProviderConfig(&Config{})
43 }
44
45 // NewDNSProviderConfig returns the Google Domains DNS provider with the provided config.
46 func NewDNSProviderConfig(_ *Config) (*DNSProvider, error) {
47 return nil, errors.New("googledomains: provider has shut down")
48 }
49
50 func (d *DNSProvider) Present(_, _, _ string) error {
51 return nil
52 }
53
54 func (d *DNSProvider) CleanUp(_, _, _ string) error {
55 return nil
56 }
57
58 func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
59 return dns01.DefaultPropagationTimeout, dns01.DefaultPollingInterval
60 }
61