Merge pull request #100 from Xre0uS/xff-detection

Use X-Forwarded-For only if enabled and present
This commit is contained in:
Ralf
2025-07-07 09:36:48 +03:00
committed by GitHub
+3 -2
View File
@@ -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)