mirror of
https://github.com/netbirdio/netbird.git
synced 2025-02-02 11:29:46 +01:00
Remove the number of status notifications on disconnected peers (#946)
Only send notifications when disconnected once, at peer's IP update
This commit is contained in:
parent
a0296f7839
commit
c331cef242
@ -146,8 +146,7 @@ func (d *Status) UpdatePeerState(receivedState State) error {
|
||||
|
||||
d.peers[receivedState.PubKey] = peerState
|
||||
|
||||
if receivedState.ConnStatus == StatusConnecting ||
|
||||
(receivedState.ConnStatus == StatusDisconnected && peerState.ConnStatus == StatusConnecting) {
|
||||
if shouldSkipNotify(receivedState, peerState) {
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -161,6 +160,19 @@ func (d *Status) UpdatePeerState(receivedState State) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func shouldSkipNotify(new, curr State) bool {
|
||||
switch {
|
||||
case new.ConnStatus == StatusConnecting:
|
||||
return true
|
||||
case new.ConnStatus == StatusDisconnected && curr.ConnStatus == StatusConnecting:
|
||||
return true
|
||||
case new.ConnStatus == StatusDisconnected && curr.ConnStatus == StatusDisconnected:
|
||||
return curr.IP != ""
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// UpdatePeerFQDN update peer's state fqdn only
|
||||
func (d *Status) UpdatePeerFQDN(peerPubKey, fqdn string) error {
|
||||
d.mux.Lock()
|
||||
|
Loading…
Reference in New Issue
Block a user