add: comment on X-Real-IP

This commit is contained in:
minoplhy 2024-04-11 22:29:42 +07:00
parent 2650a8c31f
commit 53c6992ef6
Signed by: minoplhy
GPG Key ID: 41D406044E2434BF
2 changed files with 3 additions and 1 deletions

View File

@ -90,6 +90,7 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) {
"Content-Type": "application/json", "Content-Type": "application/json",
} }
// Check if client sent X-Real-IP Header
if r.Header.Get("X-Real-IP") != "" && handler.IsInternalIP(r.RemoteAddr) { if r.Header.Get("X-Real-IP") != "" && handler.IsInternalIP(r.RemoteAddr) {
UploadHeaders["X-Real-IP"] = r.Header.Get("X-Real-IP") 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", "Content-Type": "application/json",
} }
// Check if client sent X-Real-IP Header
if r.Header.Get("X-Real-IP") != "" && handler.IsInternalIP(r.RemoteAddr) { if r.Header.Get("X-Real-IP") != "" && handler.IsInternalIP(r.RemoteAddr) {
ProcessHeaders["X-Real-IP"] = r.Header.Get("X-Real-IP") ProcessHeaders["X-Real-IP"] = r.Header.Get("X-Real-IP")
} }

View File

@ -5,8 +5,8 @@ import (
"strings" "strings"
) )
// Check if request IP Address is in internal ranges
func IsInternalIP(ip string) bool { func IsInternalIP(ip string) bool {
parts := strings.Split(ip, ":") parts := strings.Split(ip, ":")
ip = parts[0] ip = parts[0]