Revert "Update pool.go"

This reverts commit 24543d5dcd.
This commit is contained in:
Jason
2019-08-19 17:06:09 +08:00
parent 43420be4c0
commit 1a39d72460
+3 -7
View File
@@ -86,15 +86,11 @@ func uintToIP(v uint32) net.IP {
}
// New return Pool instance
func New(ipnet *net.IPNet, offset, size int) (*Pool, error) {
if offset < 2 {
return nil, errors.New("offset must not less than 2")
}
min := ipToUint(ipnet.IP) + uint32(offset)
func New(ipnet *net.IPNet, size int) (*Pool, error) {
min := ipToUint(ipnet.IP) + 2
ones, bits := ipnet.Mask.Size()
total := 1<<uint(bits-ones) - uint32(offset)
total := 1<<uint(bits-ones) - 2
if total <= 0 {
return nil, errors.New("ipnet don't have valid ip")