From 59a2c72acc09f5d8e20eee3462e4a24aa8f592e5 Mon Sep 17 00:00:00 2001 From: pk910 Date: Fri, 3 Nov 2023 06:24:27 +0100 Subject: [PATCH] fix parsing of `X-Forwarded-For` header --- proxy/session.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proxy/session.go b/proxy/session.go index d063a9a..56327f2 100644 --- a/proxy/session.go +++ b/proxy/session.go @@ -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 == "" {