Skip to content

Commit e84a397

Browse files
committed
Lint
1 parent 681f645 commit e84a397

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ip.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,11 @@ func extractIP(req *http.Request) string {
225225
func ExtractIPFromRealIPHeader(options ...TrustOption) IPExtractor {
226226
checker := newIPChecker(options)
227227
return func(req *http.Request) string {
228-
realIP := req.Header.Get(HeaderXRealIP)
229228
remoteIP := extractIP(req)
229+
realIP := req.Header.Get(HeaderXRealIP)
230+
realIP = strings.TrimPrefix(realIP, "[")
231+
realIP = strings.TrimSuffix(realIP, "]")
230232
if checker.trust(remoteIP) && realIP != "" {
231-
realIP = strings.TrimPrefix(realIP, "[")
232-
realIP = strings.TrimSuffix(realIP, "]")
233233
if ip := net.ParseIP(realIP); ip != nil {
234234
return realIP
235235
}

0 commit comments

Comments
 (0)