Chore: make fake ip pool start with the third ip

This commit is contained in:
yaling888
2022-03-18 05:17:47 +08:00
parent 8d0ae4284d
commit 546f2fa739
4 changed files with 32 additions and 28 deletions

View File

@ -147,10 +147,10 @@ type Options struct {
// New return Pool instance
func New(options Options) (*Pool, error) {
min := ipToUint(options.IPNet.IP) + 2
min := ipToUint(options.IPNet.IP) + 3
ones, bits := options.IPNet.Mask.Size()
total := 1<<uint(bits-ones) - 3
total := 1<<uint(bits-ones) - 4
if total <= 0 {
return nil, errors.New("ipnet don't have valid ip")
@ -160,7 +160,7 @@ func New(options Options) (*Pool, error) {
pool := &Pool{
min: min,
max: max,
gateway: min - 1,
gateway: min - 2,
broadcast: max + 1,
host: options.Host,
ipnet: options.IPNet,