Merge pull request #148 from xi2/challenge-provider-custom-timeout

Add ChallengeProviderTimeout type to acme package
This commit is contained in:
xenolf 2016-03-17 13:34:37 +01:00
commit faed8af4f2
2 changed files with 27 additions and 1 deletions

View file

@ -69,7 +69,15 @@ func (s *dnsChallenge) Solve(chlng challenge, domain string) error {
logf("[INFO][%s] Checking DNS record propagation...", domain)
err = WaitFor(60*time.Second, 2*time.Second, func() (bool, error) {
var timeout, interval time.Duration
switch provider := s.provider.(type) {
case ChallengeProviderTimeout:
timeout, interval = provider.Timeout()
default:
timeout, interval = 60*time.Second, 2*time.Second
}
err = WaitFor(timeout, interval, func() (bool, error) {
return preCheckDNS(fqdn, value)
})
if err != nil {

View file

@ -1,5 +1,7 @@
package acme
import "time"
// ChallengeProvider enables implementing a custom challenge
// provider. Present presents the solution to a challenge available to
// be solved. CleanUp will be called by the challenge if Present ends
@ -8,3 +10,19 @@ type ChallengeProvider interface {
Present(domain, token, keyAuth string) error
CleanUp(domain, token, keyAuth string) error
}
// ChallengeProviderTimeout allows for implementing a
// ChallengeProvider where an unusually long timeout is required when
// waiting for an ACME challenge to be satisfied, such as when
// checking for DNS record progagation. If an implementor of a
// ChallengeProvider provides a Timeout method, then the return values
// of the Timeout method will be used when appropriate by the acme
// package. The interval value is the time between checks.
//
// The default values used for timeout and interval are 60 seconds and
// 2 seconds respectively. These are used when no Timeout method is
// defined for the ChallengeProvider.
type ChallengeProviderTimeout interface {
ChallengeProvider
Timeout() (timeout, interval time.Duration)
}