mirror of
https://github.com/danderson/netboot.git
synced 2025-08-09 08:07:11 +02:00
For compatibility with 1.7 replaced rand.Uint64() call with calls to rand.Uint32()
This commit is contained in:
parent
43551d9de3
commit
11a8e61c10
@ -96,7 +96,7 @@ func (p *RandomAddressPool) ReserveAddresses(clientId []byte, interfaceIds [][]b
|
||||
|
||||
for {
|
||||
// we assume that ip addresses adhere to high 64 bits for net and subnet ids, low 64 bits are for host id rule
|
||||
hostOffset := rng.Uint64() % p.poolSize
|
||||
hostOffset := randomUint64(rng) % p.poolSize
|
||||
newIp := big.NewInt(0).Add(p.poolStartAddress, big.NewInt(0).SetUint64(hostOffset))
|
||||
_, exists := p.usedIps[newIp.Uint64()];
|
||||
if !exists {
|
||||
@ -155,3 +155,7 @@ func (p *RandomAddressPool) calculateIaIdHash(clientId, interfaceId []byte) uint
|
||||
h.Write(interfaceId)
|
||||
return h.Sum64()
|
||||
}
|
||||
|
||||
func randomUint64(rng *rand.Rand) uint64 {
|
||||
return uint64(rng.Uint32())<<32 + uint64(rand.Uint32())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user