aboutsummaryrefslogtreecommitdiff
path: root/provider.go
diff options
context:
space:
mode:
Diffstat (limited to 'provider.go')
-rw-r--r--provider.go30
1 files changed, 19 insertions, 11 deletions
diff --git a/provider.go b/provider.go
index f671c32..f09ffdf 100644
--- a/provider.go
+++ b/provider.go
@@ -166,6 +166,7 @@ func (p *Provider) solve(s Signer, ch Challenge) error {
if err != nil {
return err
}
+ defer ch.Solved()
log.Println("poke solver", ch.Type)
r := &Challenge{
@@ -180,18 +181,10 @@ func (p *Provider) solve(s Signer, ch Challenge) error {
ns := parseHeader(resp)
log.Println("start polling")
- t := time.NewTicker(p.poll)
- defer t.Stop()
- for range t.C {
- done, err := p.queryStatus(ns.Location)
- if err != nil {
- return err
- }
- if done {
- break
- }
+ if err := p.pollStatus(ns.Location); err != nil {
+ return err
}
- return ch.Solved()
+ return nil
}
func (p *Provider) authz(s Signer, domain string, sol map[ChalType]Solver) error {
@@ -229,6 +222,21 @@ func (p *Provider) Authz(s Signer, d *Desire) error {
return nil
}
+func (p *Provider) pollStatus(uri string) error {
+ t := time.NewTicker(p.poll)
+ defer t.Stop()
+ for range t.C {
+ done, err := p.queryStatus(uri)
+ if err != nil {
+ return err
+ }
+ if done {
+ return nil
+ }
+ }
+ return nil
+}
+
func (p *Provider) queryStatus(uri string) (bool, error) {
resp, err := p.Get(uri)
if err != nil {