diff --git a/main.go b/main.go index 5a9e6a5..0bc9550 100644 --- a/main.go +++ b/main.go @@ -90,6 +90,7 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) { "Content-Type": "application/json", } + // Check if client sent X-Real-IP Header if r.Header.Get("X-Real-IP") != "" && handler.IsInternalIP(r.RemoteAddr) { UploadHeaders["X-Real-IP"] = r.Header.Get("X-Real-IP") } @@ -134,6 +135,7 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) { "Content-Type": "application/json", } + // Check if client sent X-Real-IP Header if r.Header.Get("X-Real-IP") != "" && handler.IsInternalIP(r.RemoteAddr) { ProcessHeaders["X-Real-IP"] = r.Header.Get("X-Real-IP") } diff --git a/src/handler/net.go b/src/handler/net.go index 518505c..8f9fb8b 100644 --- a/src/handler/net.go +++ b/src/handler/net.go @@ -5,8 +5,8 @@ import ( "strings" ) +// Check if request IP Address is in internal ranges func IsInternalIP(ip string) bool { - parts := strings.Split(ip, ":") ip = parts[0]