Skip to content

Commit

Permalink
fix parsing of X-Forwarded-For header
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Nov 3, 2023
1 parent 6437ae8 commit 59a2c72
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions proxy/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ func (proxy *BeaconProxy) getSessionForRequest(r *http.Request) *ProxySession {
var ip string

if proxy.config.ProxyCount > 0 {
forwardIps := strings.Split(r.Header.Get("X-Forwarded-For"), ", ")
forwardIps := strings.Split(r.Header.Get("X-Forwarded-For"), ",")
forwardIdx := len(forwardIps) - int(proxy.config.ProxyCount)
if forwardIdx >= 0 {
ip = forwardIps[forwardIdx]
ip = strings.Trim(forwardIps[forwardIdx], " ")
}
}
if ip == "" {
Expand Down

0 comments on commit 59a2c72

Please sign in to comment.