Skip to content

Commit

Permalink
Fix: Fix client IP extraction by handling multiple IPs correctly
Browse files Browse the repository at this point in the history
Separated IPs by comma without space in `Split` function. Updated to use the last IP after trimming spaces, ensuring proper client IP extraction.

Signed-off-by: Christian Roessner <c@roessner.co>
  • Loading branch information
Christian Roessner committed Sep 17, 2024
1 parent 146eb65 commit 56fe033
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,9 +451,9 @@ func ProcessXForwardedFor(ctx *gin.Context, clientIP, clientPort *string) {

*clientIP = fwdAddress

multipleIPs := strings.Split(fwdAddress, ", ")
multipleIPs := strings.Split(fwdAddress, ",")
if len(multipleIPs) > 1 {
*clientIP = multipleIPs[0]
*clientIP = strings.TrimSpace(multipleIPs[len(multipleIPs)-1])
}

*clientPort = global.NotAvailable
Expand Down

0 comments on commit 56fe033

Please sign in to comment.