aboutsummaryrefslogtreecommitdiff
path: root/challange_http.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-12-25 16:03:37 +0100
committerDimitri Sokolyuk <demon@dim13.org>2015-12-25 16:03:37 +0100
commit1e28cc43c5691f90aae4d2b77e5ecaf52432f2eb (patch)
tree7e1877c324ffd145b84be15d99409647acb7a661 /challange_http.go
parenta262e55aab59f23ccce5b4ebe3771a1c5e792dc2 (diff)
timeout
Diffstat (limited to 'challange_http.go')
-rw-r--r--challange_http.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/challange_http.go b/challange_http.go
index 09f1db1..f971d87 100644
--- a/challange_http.go
+++ b/challange_http.go
@@ -22,8 +22,10 @@ type httpChallenge struct {
}
func (c *httpChallenge) ServeHTTP(w http.ResponseWriter, r *http.Request) {
- io.WriteString(w, c.KeyAuthorization)
- c.done <- true
+ if r.URL.Path == path.Join(wellKnown, c.Token) {
+ io.WriteString(w, c.KeyAuthorization)
+ c.done <- true
+ }
}
func (c *httpChallenge) Solve() error {
@@ -33,14 +35,12 @@ func (c *httpChallenge) Solve() error {
return err
}
defer l.Close()
- s := &http.Server{Handler: c}
- s.SetKeepAlivesEnabled(false)
- go s.Serve(l)
+ go http.Serve(l, c)
<-c.done
return nil
}
-func (c *httpChallenge) Solved() error {
+func (c *httpChallenge) Abort() error {
c.done <- true
return nil
}
@@ -58,7 +58,7 @@ func (c *webRoot) Solve() error {
return ioutil.WriteFile(file, []byte(c.KeyAuthorization), 0644)
}
-func (c *webRoot) Solved() error {
+func (c *webRoot) Abort() error {
file := path.Join(c.Webroot, wellKnown, c.Token)
return os.Remove(file)
}