From b5dfbf53950946c5d23a46281a090c29f91050d5 Mon Sep 17 00:00:00 2001 From: minoplhy Date: Thu, 11 Apr 2024 21:15:21 +0700 Subject: [PATCH] fix: X-Real-IP condition --- main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 643261b..5a9e6a5 100644 --- a/main.go +++ b/main.go @@ -90,8 +90,8 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) { "Content-Type": "application/json", } - if handler.IsInternalIP(r.RemoteAddr) { - UploadHeaders["X-Real-IP"] = r.RemoteAddr + if r.Header.Get("X-Real-IP") != "" && handler.IsInternalIP(r.RemoteAddr) { + UploadHeaders["X-Real-IP"] = r.Header.Get("X-Real-IP") } chibisafe_post, err := handler.UploadPost(Chibisafe_basepath, UploadHeaders, PostData) @@ -134,8 +134,8 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) { "Content-Type": "application/json", } - if handler.IsInternalIP(r.RemoteAddr) { - ProcessHeaders["X-Real-IP"] = r.RemoteAddr + if r.Header.Get("X-Real-IP") != "" && handler.IsInternalIP(r.RemoteAddr) { + ProcessHeaders["X-Real-IP"] = r.Header.Get("X-Real-IP") } PostProcess, err := handler.UploadProcessPost(Chibisafe_basepath, ProcessHeaders, PostProcessData)