From d3d7a27560b339655b15d2d569f7476a957e2a09 Mon Sep 17 00:00:00 2001 From: maride Date: Fri, 15 Feb 2019 17:14:41 +0100 Subject: Actually raise stats only if the auth is correct --- main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'main.go') 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) } -- cgit 1.4.1