aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-01-25 19:16:22 +0100
committerDimitri Sokolyuk <demon@dim13.org>2016-01-25 19:16:22 +0100
commit2b6ee482ad38012fb1c477c2e591eab74bd66eb6 (patch)
treea0b6e7ef62df708cf2cc9d4d80777108eb67e5bc
parent201b1c88ab95818f8fbfe02658962bf06638b0f2 (diff)
Bikeshadding
-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 {