Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
cl-bvl committed Nov 27, 2023
1 parent 681f645 commit e84a397
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit e84a397

Please sign in to comment.