From a00601772cc372ca2167f8eed36cbf21d135d8b8 Mon Sep 17 00:00:00 2001 From: Xre0uS Date: Sat, 5 Jul 2025 02:11:15 +0800 Subject: [PATCH] Use X-Forwarded-For only if enabled and present --- Extenders/listener_beacon_http/pl_http.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Extenders/listener_beacon_http/pl_http.go b/Extenders/listener_beacon_http/pl_http.go index 5bc190a6..892aaed3 100644 --- a/Extenders/listener_beacon_http/pl_http.go +++ b/Extenders/listener_beacon_http/pl_http.go @@ -205,9 +205,10 @@ func (handler *HTTP) processRequest(ctx *gin.Context) { return } - ExternalIP = strings.Split(ctx.Request.RemoteAddr, ":")[0] - if handler.Config.TrustXForwardedFor { + if handler.Config.TrustXForwardedFor && ctx.Request.Header.Get("X-Forwarded-For") != "" { ExternalIP = ctx.Request.Header.Get("X-Forwarded-For") + } else { + ExternalIP = strings.Split(ctx.Request.RemoteAddr, ":")[0] } agentType, agentId, beat, bodyData, err = handler.parseBeatAndData(ctx)