Skip to content

Commit

Permalink
Merge pull request Place1#126 from DasSkelett/fix/metadata-nil-handshake
Browse files Browse the repository at this point in the history
  • Loading branch information
DasSkelett authored Mar 6, 2022
2 parents e7c2151 + cb90ac1 commit fbdd66c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
3 changes: 0 additions & 3 deletions internal/devices/devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
2 changes: 1 addition & 1 deletion internal/devices/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit fbdd66c

Please sign in to comment.