From 24543d5dcd3e48bee5b9fae02185a1660d23653b Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 19 Aug 2019 14:42:47 +0800 Subject: [PATCH] Update pool.go --- common/fakeip/pool.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/common/fakeip/pool.go b/common/fakeip/pool.go index 1427e80..430b0c6 100755 --- a/common/fakeip/pool.go +++ b/common/fakeip/pool.go @@ -86,11 +86,15 @@ func uintToIP(v uint32) net.IP { } // New return Pool instance -func New(ipnet *net.IPNet, size int) (*Pool, error) { - min := ipToUint(ipnet.IP) + 2 +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) ones, bits := ipnet.Mask.Size() - total := 1<