forked from TrueCloudLab/lego
Fix WaitFor calls
This commit is contained in:
parent
c50baa67cb
commit
3252b0bcb9
4 changed files with 7 additions and 6 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
"log"
|
||||
"net"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
"golang.org/x/net/publicsuffix"
|
||||
|
@ -68,7 +69,7 @@ func (s *dnsChallenge) Solve(chlng challenge, domain string) error {
|
|||
|
||||
logf("[INFO][%s] Checking DNS record propagation...", domain)
|
||||
|
||||
err = WaitFor(30, 2, func() (bool, error) {
|
||||
err = WaitFor(60*time.Second, 2*time.Second, func() (bool, error) {
|
||||
return preCheckDNS(fqdn, value)
|
||||
})
|
||||
if err != nil {
|
||||
|
|
|
@ -5,10 +5,10 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
// WaitFor polls the given function 'f', once every 'interval' seconds, up to 'timeout' seconds.
|
||||
// WaitFor polls the given function 'f', once every 'interval', up to 'timeout'.
|
||||
func WaitFor(timeout, interval time.Duration, f func() (bool, error)) error {
|
||||
var lastErr string
|
||||
timeup := time.After(timeout * time.Second)
|
||||
timeup := time.After(timeout)
|
||||
for {
|
||||
select {
|
||||
case <-timeup:
|
||||
|
@ -24,6 +24,6 @@ func WaitFor(timeout, interval time.Duration, f func() (bool, error)) error {
|
|||
lastErr = err.Error()
|
||||
}
|
||||
|
||||
time.Sleep(interval * time.Second)
|
||||
time.Sleep(interval)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
func TestWaitForTimeout(t *testing.T) {
|
||||
c := make(chan error)
|
||||
go func() {
|
||||
err := WaitFor(3, 1, func() (bool, error) {
|
||||
err := WaitFor(3*time.Second, 1*time.Second, func() (bool, error) {
|
||||
return false, nil
|
||||
})
|
||||
c <- err
|
||||
|
|
|
@ -71,7 +71,7 @@ func (r *DNSProvider) changeRecord(action, fqdn, value string, ttl int) error {
|
|||
return err
|
||||
}
|
||||
|
||||
return acme.WaitFor(90, 5, func() (bool, error) {
|
||||
return acme.WaitFor(90*time.Second, 5*time.Second, func() (bool, error) {
|
||||
status, err := r.client.GetChange(resp.ChangeInfo.ID)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
|
Loading…
Reference in a new issue