diff --git a/main.go b/main.go index 77633b9..3796ce8 100644 --- a/main.go +++ b/main.go @@ -105,6 +105,9 @@ func genStudents() map[string]map[string]*Submission { } func ServeJSON(w http.ResponseWriter, r *http.Request) { + if addr := r.Header.Get("X-Forwarded-For"); addr != "" { + r.RemoteAddr = addr + } log.Printf("Handling %s request from %s: %s [%s]\n", r.Method, r.RemoteAddr, r.URL.Path, r.UserAgent()) w.Header().Set("Content-Type", "application/json") @@ -146,6 +149,9 @@ func genStudent(login string) map[string]*Submission { } func ServeJSONStudent(w http.ResponseWriter, r *http.Request) { + if addr := r.Header.Get("X-Forwarded-For"); addr != "" { + r.RemoteAddr = addr + } log.Printf("Handling %s request from %s: %s [%s]\n", r.Method, r.RemoteAddr, r.URL.Path, r.UserAgent()) w.Header().Set("Content-Type", "application/json")