diff --git a/internal/devices/devices.go b/internal/devices/devices.go index 98fb1f08..b04e4458 100644 --- a/internal/devices/devices.go +++ b/internal/devices/devices.go @@ -280,8 +280,5 @@ func deviceListContains(devices []*storage.Device, publicKey string) bool { } func IsConnected(lastHandshake time.Time) bool { - // if lastHandshake == nil { - // return false - // } return lastHandshake.After(time.Now().Add(-3 * time.Minute)) } diff --git a/internal/devices/metadata.go b/internal/devices/metadata.go index a5a21bc5..9d2bb6b3 100644 --- a/internal/devices/metadata.go +++ b/internal/devices/metadata.go @@ -30,7 +30,7 @@ func syncMetrics(d *DeviceManager) { // they may actually be connected to another replica. if peer.Endpoint != nil { if device, err := d.GetByPublicKey(peer.PublicKey.String()); err == nil { - if !IsConnected(peer.LastHandshakeTime) && !IsConnected(*device.LastHandshakeTime) { + if !IsConnected(peer.LastHandshakeTime) && device.LastHandshakeTime != nil && !IsConnected(*device.LastHandshakeTime) { // Not connected, and we haven't been the last time either, nothing to update continue }