handle IPv6 sourceIPs properly (#15005)

This commit is contained in:
Harshavardhana
2022-05-31 06:04:12 -07:00
committed by GitHub
parent 52221db7ef
commit 7b2198f7e5
3 changed files with 6 additions and 3 deletions

View File

@@ -123,5 +123,8 @@ func GetSourceIP(r *http.Request) string {
// Default to remote address if headers not set.
addr, _, _ = net.SplitHostPort(r.RemoteAddr)
if strings.ContainsRune(addr, ':') {
return "[" + addr + "]"
}
return addr
}