fix: use valid ip mask in api keys when remote address is ipv6 (#2695)

This commit is contained in:
Colin Adler
2022-06-27 15:31:18 -05:00
committed by GitHub
parent 69f27efead
commit a494489ffa
2 changed files with 4 additions and 2 deletions

View File

@ -172,10 +172,11 @@ func ExtractAPIKey(db database.Store, oauth *OAuth2Configs) func(http.Handler) h
if remoteIP == nil {
remoteIP = net.IPv4(0, 0, 0, 0)
}
bitlen := len(remoteIP) * 8
key.IPAddress = pqtype.Inet{
IPNet: net.IPNet{
IP: remoteIP,
Mask: remoteIP.DefaultMask(),
Mask: net.CIDRMask(bitlen, bitlen),
},
Valid: true,
}