Skip to content

Commit ad481b3

Browse files
committed
middleware.RealIP: short-circuit ip test
1 parent 06573a6 commit ad481b3

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎middleware/realip.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func realIP(r *http.Request) string {
5353
}
5454
ip = xff[:i]
5555
}
56-
if net.ParseIP(ip) == nil {
56+
if ip == "" || net.ParseIP(ip) == nil {
5757
return ""
5858
}
5959
return ip

0 commit comments

Comments
 (0)