fix: Split host and port before storing IP (#2594)

The IP was always nil prior, and this fixes the test to
check for that as well!
This commit is contained in:
Kyle Carberry
2022-06-26 21:22:03 +00:00
committed by GitHub
parent 545a9f3435
commit 4851d932c4
3 changed files with 8 additions and 5 deletions
+2 -1
View File
@@ -782,7 +782,8 @@ func (api *API) createAPIKey(rw http.ResponseWriter, r *http.Request, params dat
}
}
ip := net.ParseIP(r.RemoteAddr)
host, _, _ := net.SplitHostPort(r.RemoteAddr)
ip := net.ParseIP(host)
if ip == nil {
ip = net.IPv4(0, 0, 0, 0)
}