Skip to content

Commit

Permalink
support IP addresses and CIDRs
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-nettica committed Jul 1, 2024
1 parent 7fc8f42 commit 1e11b6f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ func IsInCidr(cidr string, subnet string) bool {
if err != nil {
return false
}
parts := strings.Split(cidr, "/")
if len(parts) == 1 {
ip := net.ParseIP(cidr)
if ip == nil {
return false
}
return ipnet.Contains(ip)
}

ip, _, err := net.ParseCIDR(cidr)
if err != nil {
return false
Expand Down

0 comments on commit 1e11b6f

Please sign in to comment.