forked from TrueCloudLab/lego
linodev4: configurable propagation timeout. (#961)
This commit is contained in:
parent
d7d75bea51
commit
6bbba5bbaa
4 changed files with 27 additions and 19 deletions
|
@ -833,6 +833,7 @@ func displayDNSHelp(name string) error {
|
|||
ew.writeln(`Additional Configuration:`)
|
||||
ew.writeln(` - "LINODE_HTTP_TIMEOUT": API request timeout`)
|
||||
ew.writeln(` - "LINODE_POLLING_INTERVAL": Time between DNS propagation check`)
|
||||
ew.writeln(` - "LINODE_PROPAGATION_TIMEOUT": Maximum waiting time for DNS propagation`)
|
||||
ew.writeln(` - "LINODE_TTL": The TTL of the TXT record used for the DNS challenge`)
|
||||
|
||||
ew.writeln()
|
||||
|
|
|
@ -41,6 +41,7 @@ More information [here](/lego/dns/#configuration-and-credentials).
|
|||
|--------------------------------|-------------|
|
||||
| `LINODE_HTTP_TIMEOUT` | API request timeout |
|
||||
| `LINODE_POLLING_INTERVAL` | Time between DNS propagation check |
|
||||
| `LINODE_PROPAGATION_TIMEOUT` | Maximum waiting time for DNS propagation |
|
||||
| `LINODE_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.
|
||||
|
|
|
@ -24,18 +24,20 @@ const (
|
|||
|
||||
// Config is used to configure the creation of the DNSProvider
|
||||
type Config struct {
|
||||
Token string
|
||||
PollingInterval time.Duration
|
||||
TTL int
|
||||
HTTPTimeout time.Duration
|
||||
Token string
|
||||
PropagationTimeout time.Duration
|
||||
PollingInterval time.Duration
|
||||
TTL int
|
||||
HTTPTimeout time.Duration
|
||||
}
|
||||
|
||||
// NewDefaultConfig returns a default configuration for the DNSProvider
|
||||
func NewDefaultConfig() *Config {
|
||||
return &Config{
|
||||
PollingInterval: env.GetOrDefaultSecond("LINODE_POLLING_INTERVAL", 15*time.Second),
|
||||
TTL: env.GetOrDefaultInt("LINODE_TTL", minTTL),
|
||||
HTTPTimeout: env.GetOrDefaultSecond("LINODE_HTTP_TIMEOUT", 0),
|
||||
PropagationTimeout: env.GetOrDefaultSecond("LINODE_PROPAGATION_TIMEOUT", 0),
|
||||
PollingInterval: env.GetOrDefaultSecond("LINODE_POLLING_INTERVAL", 15*time.Second),
|
||||
TTL: env.GetOrDefaultInt("LINODE_TTL", minTTL),
|
||||
HTTPTimeout: env.GetOrDefaultSecond("LINODE_HTTP_TIMEOUT", 0),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,19 +99,22 @@ func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
|
|||
|
||||
// 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) {
|
||||
// Since Linode only updates their zone files every X minutes, we need
|
||||
// to figure out how many minutes we have to wait until we hit the next
|
||||
// interval of X. We then wait another couple of minutes, just to be
|
||||
// safe. Hopefully at some point during all of this, the record will
|
||||
// have propagated throughout Linode's network.
|
||||
minsRemaining := dnsUpdateFreqMins - (time.Now().Minute() % dnsUpdateFreqMins)
|
||||
func (d *DNSProvider) Timeout() (time.Duration, time.Duration) {
|
||||
timeout := d.config.PropagationTimeout
|
||||
if d.config.PropagationTimeout <= 0 {
|
||||
// Since Linode only updates their zone files every X minutes, we need
|
||||
// to figure out how many minutes we have to wait until we hit the next
|
||||
// interval of X. We then wait another couple of minutes, just to be
|
||||
// safe. Hopefully at some point during all of this, the record will
|
||||
// have propagated throughout Linode's network.
|
||||
minsRemaining := dnsUpdateFreqMins - (time.Now().Minute() % dnsUpdateFreqMins)
|
||||
|
||||
timeout = (time.Duration(minsRemaining) * time.Minute) +
|
||||
(minTTL * time.Second) +
|
||||
(dnsUpdateFudgeSecs * time.Second)
|
||||
interval = d.config.PollingInterval
|
||||
return
|
||||
timeout = (time.Duration(minsRemaining) * time.Minute) +
|
||||
(minTTL * time.Second) +
|
||||
(dnsUpdateFudgeSecs * time.Second)
|
||||
}
|
||||
|
||||
return timeout, d.config.PollingInterval
|
||||
}
|
||||
|
||||
// Present creates a TXT record using the specified parameters.
|
||||
|
|
|
@ -11,6 +11,7 @@ Example = ''''''
|
|||
LINODE_TOKEN = "API token"
|
||||
[Configuration.Additional]
|
||||
LINODE_POLLING_INTERVAL = "Time between DNS propagation check"
|
||||
LINODE_PROPAGATION_TIMEOUT = "Maximum waiting time for DNS propagation"
|
||||
LINODE_TTL = "The TTL of the TXT record used for the DNS challenge"
|
||||
LINODE_HTTP_TIMEOUT = "API request timeout"
|
||||
|
||||
|
|
Loading…
Reference in a new issue