aboutsummaryrefslogtreecommitdiff
path: root/challange_http.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-12-25 16:46:51 +0100
committerDimitri Sokolyuk <demon@dim13.org>2015-12-25 16:46:51 +0100
commit74347b1655791ad59718e6313051dd22d43dace1 (patch)
tree5216bcd6610b0534636cb0a4d4319e219d8ce362 /challange_http.go
parentfd22e783696f2984e0fb252ea7d205576e1d49c7 (diff)
KISS
Diffstat (limited to 'challange_http.go')
-rw-r--r--challange_http.go16
1 files changed, 7 insertions, 9 deletions
diff --git a/challange_http.go b/challange_http.go
index 7b2de54..bcc4691 100644
--- a/challange_http.go
+++ b/challange_http.go
@@ -7,7 +7,6 @@ import (
"net/http"
"os"
"path"
- "sync"
)
const wellKnown = `/.well-known/acme-challenge/`
@@ -19,30 +18,29 @@ func init() {
type httpChallenge struct {
Challenge
Addr string
- wg sync.WaitGroup
+ l net.Listener
}
func (c *httpChallenge) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == path.Join(wellKnown, c.Token) {
io.WriteString(w, c.KeyAuthorization)
- c.wg.Done()
+ c.l.Close()
}
}
func (c *httpChallenge) Solve() error {
- l, err := net.Listen("tcp", c.Addr)
+ var err error
+ c.l, err = net.Listen("tcp", c.Addr)
if err != nil {
return err
}
- defer l.Close()
- c.wg.Add(1)
- go http.Serve(l, c)
- c.wg.Wait()
+ defer c.l.Close()
+ http.Serve(c.l, c)
return nil
}
func (c *httpChallenge) Abort() error {
- c.wg.Done()
+ c.l.Close()
return nil
}