Skip to content

Commit

Permalink
Merge pull request #19 from getlantern/issue17
Browse files Browse the repository at this point in the history
print out token in log if mismatch
uaalto committed Nov 24, 2015

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 05aa504 + 344a0fc commit ec4de5c
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions tokenfilter/tokenfilter.go
Original file line number Diff line number Diff line change
@@ -48,12 +48,21 @@ func (f *TokenFilter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
log.Tracef("Token Filter Middleware received request:\n%s", reqStr)
}

if f.token == "" {
f.next.ServeHTTP(w, req)
return
}

token := req.Header.Get(tokenHeader)
if f.token != "" && (token == "" || token != f.token) {
log.Debugf("Token from %s doesn't match, mimicking apache", req.RemoteAddr)
mimic.MimicApache(w, req)
} else {
switch token {
case f.token:
req.Header.Del(tokenHeader)
f.next.ServeHTTP(w, req)
case "":
log.Debugf("No token provided from %s, mimicking apache", req.RemoteAddr)
mimic.MimicApache(w, req)
default:
log.Debugf("Mismatched token %s from %s, mimicking apache", token, req.RemoteAddr)
mimic.MimicApache(w, req)
}
}

0 comments on commit ec4de5c

Please sign in to comment.