Unintuitive IPv6 address search in Screened IPs

It’s not very easily possible to search for an IPv6 address in Screened IPs:

Contrast this with the IPv4 behaviour:

Maybe if we detect we only have a partial address we can do a simple string comparison as well to make it more intuitive?

discourse(prod)> ScreenedIpAddress.all.filter{ _1.ip_address.to_s.starts_with? '2001' }.pluck(:ip_address)
=> 
[#<IPAddr: IPv6:2001:0db8:0666:0000:0000:0000:0000:0000/ffff:ffff:ffff:0000:0000:0000:0000:0000>,
 #<IPAddr: IPv6:2001:0db8:0666:0000:0000:0000:1234:5678/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff>,
 #<IPAddr: IPv6:2001:0db8:0666:0000:0000:0000:0000:0001/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff>]
4 Likes