forked from extern/smegmesh
74-perform-dad
- Fixing nil pointer dereference
This commit is contained in:
parent
90cfe820d2
commit
d0b1913796
@ -288,12 +288,12 @@ func (s *MeshManagerImpl) AddSelf(params *AddSelfParams) error {
|
|||||||
|
|
||||||
collisionCount := uint8(0)
|
collisionCount := uint8(0)
|
||||||
|
|
||||||
var nodeIP *net.IPNet
|
var nodeIP net.IP
|
||||||
|
|
||||||
// Perform Duplicate Address Detection with the nodes
|
// Perform Duplicate Address Detection with the nodes
|
||||||
// that are already in the network
|
// that are already in the network
|
||||||
for {
|
for {
|
||||||
nodeIP, err := s.ipAllocator.GetIP(pubKey, params.MeshId, collisionCount)
|
generatedIP, err := s.ipAllocator.GetIP(pubKey, params.MeshId, collisionCount)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -313,13 +313,14 @@ func (s *MeshManagerImpl) AddSelf(params *AddSelfParams) error {
|
|||||||
if lib.Contains(lib.MapValues(snapshot.GetNodes()), proposition) {
|
if lib.Contains(lib.MapValues(snapshot.GetNodes()), proposition) {
|
||||||
collisionCount++
|
collisionCount++
|
||||||
} else {
|
} else {
|
||||||
|
nodeIP = generatedIP
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
node := s.nodeFactory.Build(&MeshNodeFactoryParams{
|
node := s.nodeFactory.Build(&MeshNodeFactoryParams{
|
||||||
PublicKey: &pubKey,
|
PublicKey: &pubKey,
|
||||||
NodeIP: nodeIP.IP,
|
NodeIP: nodeIP,
|
||||||
WgPort: params.WgPort,
|
WgPort: params.WgPort,
|
||||||
Endpoint: params.Endpoint,
|
Endpoint: params.Endpoint,
|
||||||
MeshConfig: mesh.GetConfiguration(),
|
MeshConfig: mesh.GetConfiguration(),
|
||||||
|
Loading…
Reference in New Issue
Block a user