This does a less restrictive (and more correct) check on the IP address, and also allows the fully qualified "localhost.".
This commit is contained in:
@@ -1560,9 +1560,14 @@ func addressIsLocalhost(addr string) bool {
|
||||
host = addr
|
||||
}
|
||||
switch strings.ToLower(host) {
|
||||
case "127.0.0.1", "::1", "localhost":
|
||||
case "localhost", "localhost.":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
ip := net.ParseIP(host)
|
||||
if ip == nil {
|
||||
// not an IP address
|
||||
return false
|
||||
}
|
||||
return ip.IsLoopback()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user