From 2b6ee482ad38012fb1c477c2e591eab74bd66eb6 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Mon, 25 Jan 2016 19:16:22 +0100 Subject: Bikeshadding --- provider.go | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'provider.go') 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 { -- cgit v1.2.3