mirror of
https://github.com/netbirdio/netbird.git
synced 2026-08-24 16:41:30 +02:00
[client] Do not wrap a nil connection listener in the mobile bindings
The listener adapter introduced with the network state work turned a nil listener into a non-nil peer.Listener holding a nil delegate, so the notifier's nil check passed it through and setListener panicked on its immediate OnAddressChanged callback. EngineRunner already forwards null, so the path is reachable. Drop the listener instead when it is nil, on Android and iOS alike.
This commit is contained in:
@@ -538,6 +538,10 @@ func (c *Client) OnUpdatedHostDNS(list *DNSList) error {
|
||||
|
||||
// SetConnectionListener set the network connection listener
|
||||
func (c *Client) SetConnectionListener(listener ConnectionListener) {
|
||||
if listener == nil {
|
||||
c.recorder.RemoveConnectionListener()
|
||||
return
|
||||
}
|
||||
c.recorder.SetConnectionListener(connectionListenerAdapter{listener})
|
||||
}
|
||||
|
||||
|
||||
@@ -344,6 +344,10 @@ func (c *Client) GetStatusDetails() *StatusDetails {
|
||||
|
||||
// SetConnectionListener set the network connection listener
|
||||
func (c *Client) SetConnectionListener(listener ConnectionListener) {
|
||||
if listener == nil {
|
||||
c.recorder.RemoveConnectionListener()
|
||||
return
|
||||
}
|
||||
c.recorder.SetConnectionListener(connectionListenerAdapter{listener})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user