From 02fc36f723ae6d7b2f28b2d3b4be84f03af5b3de Mon Sep 17 00:00:00 2001 From: Andrea Fazzi Date: Sun, 10 Jan 2021 18:04:34 +0100 Subject: [PATCH] Replace r.RemoteAddr with r.Header.Get("X-Forwarded-For") --- orm/usermodifier.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/orm/usermodifier.go b/orm/usermodifier.go index f8479126..308b559c 100644 --- a/orm/usermodifier.go +++ b/orm/usermodifier.go @@ -1,7 +1,6 @@ package orm import ( - "log" "net/http" ) @@ -54,12 +53,11 @@ func (um UserModifier) UpdatedBy() *User { func WriteCreator(r *http.Request, modifier Modifier) { modifier.SetCreatorID(getUserIDFromTokenAsUint(r)) modifier.SetCreatorRole(getUserRole(r)) - modifier.SetCreatorIP(r.RemoteAddr) + modifier.SetCreatorIP(r.Header.Get("X-Forwarded-For")) } func WriteUpdater(r *http.Request, modifier Modifier) { modifier.SetUpdaterID(getUserIDFromTokenAsUint(r)) modifier.SetUpdaterRole(getUserRole(r)) - modifier.SetUpdaterIP(r.RemoteAddr) - log.Printf("Forwarded IP address: %v", r.Header.Get("X-Forwarded-For")) + modifier.SetUpdaterIP(r.Header.Get("X-Forwarded-For")) }