mirror of
https://github.com/netbirdio/netbird.git
synced 2026-09-30 02:29:08 +02:00
[management] handle nil ptr in sendInitialSync() when the peer is deleted (#7315)
* fix a nil-ptr error occuring in sendInitialSync when the peer being synced is deleted Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io> * handle a nil ptr in GetPeerNetworkMapComponents Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io> --------- Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
This commit is contained in:
@@ -112,8 +112,6 @@ func (a *Account) GetPeerNetworkMapComponents(
|
||||
return EmptyNetworkMapComponents(&NetworkMapComponents{
|
||||
PeerID: peerID,
|
||||
Network: a.Network.Copy(),
|
||||
// must include the target peer as it's required on the client
|
||||
Peers: map[string]*ComponentPeer{peerID: peer.ToComponent()},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/netbirdio/netbird/dns"
|
||||
"github.com/netbirdio/netbird/shared/management/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGetPeerNetworkMapComponents_PeerMissingFromAcount(t *testing.T) {
|
||||
account := Account{Network: NewNetwork()}
|
||||
nmapcomponets := account.GetPeerNetworkMapComponents(context.TODO(), "missing-peer", dns.CustomZone{}, nil, nil, nil, nil, nil)
|
||||
|
||||
assert.Equal(t, EmptyNetworkMapComponents(&types.NetworkMapComponents{
|
||||
PeerID: "missing-peer",
|
||||
Network: account.Network,
|
||||
}), nmapcomponets)
|
||||
}
|
||||
Reference in New Issue
Block a user