mirror of
https://github.com/netbirdio/netbird.git
synced 2025-02-02 19:39:17 +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
|
d.peers[receivedState.PubKey] = peerState
|
||||||
|
|
||||||
if receivedState.ConnStatus == StatusConnecting ||
|
if shouldSkipNotify(receivedState, peerState) {
|
||||||
(receivedState.ConnStatus == StatusDisconnected && peerState.ConnStatus == StatusConnecting) {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,6 +160,19 @@ func (d *Status) UpdatePeerState(receivedState State) error {
|
|||||||
return nil
|
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
|
// UpdatePeerFQDN update peer's state fqdn only
|
||||||
func (d *Status) UpdatePeerFQDN(peerPubKey, fqdn string) error {
|
func (d *Status) UpdatePeerFQDN(peerPubKey, fqdn string) error {
|
||||||
d.mux.Lock()
|
d.mux.Lock()
|
||||||
|
Loading…
Reference in New Issue
Block a user