func (d *DNSProvider) Timeout() (time.Duration, time.Duration) {
	timeout := d.config.PropagationTimeout
	if d.config.PropagationTimeout <= 0 {
		minsRemaining := dnsUpdateFreqMins - (time.Now().Minute() % dnsUpdateFreqMins)
		timeout = (time.Duration(minsRemaining) * time.Minute) +
			(minTTL * time.Second) +
			(dnsUpdateFudgeSecs * time.Second)
	}
	return timeout, d.config.PollingInterval
}
Timeout returns the timeout and interval to use when checking for DNS
propagation.  Adjusting here to cope with spikes in propagation times.
package linode
import (
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"net/http"
	"strings"
	"time"
	"github.com/go-acme/lego/v4/challenge/dns01"
	"github.com/go-acme/lego/v4/platform/config/env"
	"github.com/linode/linodego"
	"golang.org/x/oauth2"
)
const (
	minTTL             = 300
	dnsUpdateFreqMins  = 15
	dnsUpdateFudgeSecs = 120
)
const (
	envNamespace = "LINODE_"
	EnvToken = envNamespace + "TOKEN"
	EnvTTL                = envNamespace + "TTL"
	EnvPropagationTimeout = envNamespace + "PROPAGATION_TIMEOUT"
	EnvPollingInterval    = envNamespace + "POLLING_INTERVAL"
	EnvHTTPTimeout        = envNamespace + "HTTP_TIMEOUT"
)
type Config struct {
	Token              string
	PropagationTimeout time.Duration
	PollingInterval    time.Duration
	TTL                int
	HTTPTimeout        time.Duration
}
func NewDefaultConfig() *Config {
	return &Config{
		TTL:                env.GetOrDefaultInt(EnvTTL, minTTL),
		PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, 0),
		PollingInterval:    env.GetOrDefaultSecond(EnvPollingInterval, 15*time.Second),
		HTTPTimeout:        env.GetOrDefaultSecond(EnvHTTPTimeout, 0),
	}
}
type hostedZoneInfo struct {
	domainID     int
	resourceName string
}
type DNSProvider struct {
	config *Config
	client *linodego.Client
}
func NewDNSProvider() (*DNSProvider, error) {
	values, err := env.Get(EnvToken)
	if err != nil {
		return nil, fmt.Errorf("linode: %w", err)
	}
	config := NewDefaultConfig()
	config.Token = values[EnvToken]
	return NewDNSProviderConfig(config)
}
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
	if config == nil {
		return nil, errors.New("linode: the configuration of the DNS provider is nil")
	}
	if config.Token == "" {
		return nil, errors.New("linode: Linode Access Token missing")
	}
	if config.TTL < minTTL {
		return nil, fmt.Errorf("linode: invalid TTL, TTL (%d) must be greater than %d", config.TTL, minTTL)
	}
	tokenSource := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: config.Token})
	oauth2Client := &http.Client{
		Timeout: config.HTTPTimeout,
		Transport: &oauth2.Transport{
			Source: tokenSource,
		},
	}
	client := linodego.NewClient(oauth2Client)
	client.SetUserAgent("lego-dns https://github.com/linode/linodego")
	return &DNSProvider{
		config: config,
		client: &client,
	}, nil
}