mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-30 22:34:15 -05:00
6f78cc49d1
- Using xenolf/lego's likely-temporary acmev2 branch - Cleaned up vendor folder a little bit (probably more to do) - Temporarily set default CA URL to v2 staging endpoint - Refactored user management a bit; updated tests (biggest change is how we get the email address, which now requires being able to make an ACME client with a User with a private key so that we can get the current ToS URL) - Automatic HTTPS now allows specific wildcard pattern hostnames - Commented out (but kept) the TLS-SNI code, as the challenge type may return in the future in a similar form
29 lines
496 B
Go
29 lines
496 B
Go
package acme
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
// 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)
|
|
for {
|
|
select {
|
|
case <-timeup:
|
|
return fmt.Errorf("Time limit exceeded. Last error: %s", lastErr)
|
|
default:
|
|
}
|
|
|
|
stop, err := f()
|
|
if stop {
|
|
return nil
|
|
}
|
|
if err != nil {
|
|
lastErr = err.Error()
|
|
}
|
|
|
|
time.Sleep(interval)
|
|
}
|
|
}
|