Skip to content

Commit

Permalink
add judge before use index
Browse files Browse the repository at this point in the history
  • Loading branch information
pengbinbin1 committed May 11, 2021
1 parent e7d1bf0 commit c733c7e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/util/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ func AddressCount(network *net.IPNet) float64 {
}

func GenerateRandomV4IP(cidr string) string {
if len(strings.Split(cidr, "/")) != 2 {
return ""
}
ip := strings.Split(cidr, "/")[0]
netMask, _ := strconv.Atoi(strings.Split(cidr, "/")[1])
hostNum := 32 - netMask
Expand Down

0 comments on commit c733c7e

Please sign in to comment.