diff options
author | maride <maride@darknebu.la> | 2019-02-15 17:14:41 +0100 |
---|---|---|
committer | maride <maride@darknebu.la> | 2019-02-15 17:14:41 +0100 |
commit | d3d7a27560b339655b15d2d569f7476a957e2a09 (patch) | |
tree | 2377ee0689c7fe2b42db6b3a151edf115ff48945 | |
parent | f1bd309910e6540bbd6b40adee8def114f62ea85 (diff) |
Actually raise stats only if the auth is correct
-rw-r--r-- | main.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/main.go b/main.go index 92e2d9c..40a66db 100644 --- a/main.go +++ b/main.go @@ -23,16 +23,16 @@ func main() { // Handling incoming HTTP connections func httpHandler(w http.ResponseWriter, r *http.Request) { - // Raise stats - metrics_num_passwords++ - - // Log user/pass combo + // Get user/pass combo user, pass, ok := r.BasicAuth() if ok { // This also includes empty user/pass combos (if they are correctly encoded) // To avoid them, use `len(user) > 0 && len(pass) > 0` log.Printf("%s: %s %s:%s@%s%s", r.RemoteAddr, r.Method, user, pass, r.Host, r.URL.Path) + + // Raise stats + metrics_num_passwords++ } else { log.Printf("%s: %s %s%s", r.RemoteAddr, r.Method, r.Host, r.URL.Path) } |