mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-11-04 03:27:23 -05:00 
			
		
		
		
	- 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
		
			
				
	
	
		
			30 lines
		
	
	
		
			496 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			30 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)
 | 
						|
	}
 | 
						|
}
 |