mirror of
https://github.com/danderson/netboot.git
synced 2025-12-02 16:11:58 +01:00
Replaced custom function for generation of random uint64s with rand.Uint64.
This commit is contained in:
parent
3268bf94a3
commit
1ae9c3ab68
@ -94,7 +94,7 @@ func (p *RandomAddressPool) ReserveAddresses(clientID []byte, interfaceIDs [][]b
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
// we assume that ip addresses adhere to high 64 bits for net and subnet ids, low 64 bits are for host id rule
|
// we assume that ip addresses adhere to high 64 bits for net and subnet ids, low 64 bits are for host id rule
|
||||||
hostOffset := randomUint64(rng) % p.poolSize
|
hostOffset := rand.Uint64() % p.poolSize
|
||||||
newIP := big.NewInt(0).Add(p.poolStartAddress, big.NewInt(0).SetUint64(hostOffset))
|
newIP := big.NewInt(0).Add(p.poolStartAddress, big.NewInt(0).SetUint64(hostOffset))
|
||||||
_, exists := p.usedIps[newIP.Uint64()];
|
_, exists := p.usedIps[newIP.Uint64()];
|
||||||
if !exists {
|
if !exists {
|
||||||
@ -153,7 +153,3 @@ func (p *RandomAddressPool) calculateIAIDHash(clientID, interfaceID []byte) uint
|
|||||||
h.Write(interfaceID)
|
h.Write(interfaceID)
|
||||||
return h.Sum64()
|
return h.Sum64()
|
||||||
}
|
}
|
||||||
|
|
||||||
func randomUint64(rng *rand.Rand) uint64 {
|
|
||||||
return uint64(rng.Uint32())<<32 + uint64(rand.Uint32())
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user