mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2024-12-30 02:37:01 +00:00
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user