Skip to content

Commit

Permalink
fix: logging actual client ip; better handling netname not found
Browse files Browse the repository at this point in the history
  • Loading branch information
proffapt committed Jul 2, 2024
1 parent a259c16 commit 4d3de27
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func LoggerMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
recorder := &responseRecorder{w, http.StatusOK, 0}
next.ServeHTTP(recorder, r)
log.Printf("INFO:\t%s - %q %s %d %s\n", r.RemoteAddr, r.Method, r.RequestURI, recorder.status, http.StatusText(recorder.status))
log.Printf("INFO:\t%s - %q %s %d %s\n", r.Header.Get("X-Forwarded-For"), r.Method, r.RequestURI, recorder.status, http.StatusText(recorder.status))
})
}

Expand Down Expand Up @@ -153,8 +153,9 @@ func handleCampusCheck(res http.ResponseWriter, req *http.Request) {
res.WriteHeader(http.StatusUnauthorized)
}
} else {
fmt.Println("Netname not found in the whois response.")
fmt.Println("[NETNAME NOT FOUND]")
response["is_inside_kgp"] = false
res.WriteHeader(http.StatusUnauthorized)
}

res.Header().Set("Content-Type", "application/json")
Expand Down

0 comments on commit 4d3de27

Please sign in to comment.