fix invalid ip suggestions (#185)

This commit is contained in:
Christoph Haas
2023-10-20 12:13:39 +02:00
parent d78b4f49bd
commit b49ff66c41
4 changed files with 31 additions and 8 deletions

View File

@@ -199,3 +199,10 @@ func CidrsToStringSlice(slice []Cidr) []string {
return cidrs
}
func (c Cidr) Contains(other Cidr) bool {
_, subnet, _ := net.ParseCIDR(c.String())
otherIP, _, _ := net.ParseCIDR(other.String())
return subnet.Contains(otherIP)
}