From e84a39748e2d42c14383e04def549ccaa2d4a91c Mon Sep 17 00:00:00 2001 From: Vladimir Buyanov Date: Mon, 27 Nov 2023 17:58:59 +0200 Subject: [PATCH] Lint --- ip.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ip.go b/ip.go index 155cf4991..497c6a78a 100644 --- a/ip.go +++ b/ip.go @@ -225,11 +225,11 @@ func extractIP(req *http.Request) string { func ExtractIPFromRealIPHeader(options ...TrustOption) IPExtractor { checker := newIPChecker(options) return func(req *http.Request) string { - realIP := req.Header.Get(HeaderXRealIP) remoteIP := extractIP(req) + realIP := req.Header.Get(HeaderXRealIP) + realIP = strings.TrimPrefix(realIP, "[") + realIP = strings.TrimSuffix(realIP, "]") if checker.trust(remoteIP) && realIP != "" { - realIP = strings.TrimPrefix(realIP, "[") - realIP = strings.TrimSuffix(realIP, "]") if ip := net.ParseIP(realIP); ip != nil { return realIP }