Skip to content

Commit

Permalink
Verify the IP address range
Browse files Browse the repository at this point in the history
  • Loading branch information
XinRoom committed Oct 31, 2021
1 parent 4b4d021 commit 12f9cac
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,22 +142,22 @@ func NewIter(ipStr string) (it *Iter, err error) {
if len(ipClasses) == 4 || len(ipClasses) == 16 {
for _, v := range ipClasses {
l0 := strings.Split(v, "-") // range
var l0s int64
var l0s uint64
if it.isIpv4 {
l0s, err = strconv.ParseInt(l0[0], 10, 16)
l0s, err = strconv.ParseUint(l0[0], 10, 8)
} else {
// ipv6 is hex
l0s, err = strconv.ParseInt(l0[0], 16, 16)
l0s, err = strconv.ParseUint(l0[0], 16, 8)
}
l0e := l0s // The default start and end are the same
if len(l0) > 2 && err != nil {
if len(l0) > 2 || err != nil {
return nil, err
}
if len(l0) == 2 {
if it.isIpv4 {
l0e, err = strconv.ParseInt(l0[1], 10, 16)
l0e, err = strconv.ParseUint(l0[1], 10, 8)
} else {
l0e, err = strconv.ParseInt(l0[1], 16, 16)
l0e, err = strconv.ParseUint(l0[1], 16, 8)
}
if err != nil {
return nil, err
Expand Down

0 comments on commit 12f9cac

Please sign in to comment.