mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-27 10:47:35 +00:00
ipn/ipnstate, wgengine: make PeerStatusLite.LastHandshake zero Time means none
... rather than 1970. Code was using IsZero against the 1970 team (which isn't a zero value), but fortunately not anywhere that seems to have mattered. Updates #cleanup Change-Id: I708a3f2a9398aaaedc9503678b4a8a311e0e019e Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
3dd8ae2f26
commit
74b8985e19
@ -188,14 +188,22 @@ func (s *Status) Peers() []key.NodePublic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type PeerStatusLite struct {
|
type PeerStatusLite struct {
|
||||||
// TxBytes/RxBytes is the total number of bytes transmitted to/received from this peer.
|
|
||||||
TxBytes, RxBytes int64
|
|
||||||
// LastHandshake is the last time a handshake succeeded with this peer.
|
|
||||||
// (Or we got key confirmation via the first data message,
|
|
||||||
// which is approximately the same thing.)
|
|
||||||
LastHandshake time.Time
|
|
||||||
// NodeKey is this peer's public node key.
|
// NodeKey is this peer's public node key.
|
||||||
NodeKey key.NodePublic
|
NodeKey key.NodePublic
|
||||||
|
|
||||||
|
// TxBytes/RxBytes are the total number of bytes transmitted to/received
|
||||||
|
// from this peer.
|
||||||
|
TxBytes, RxBytes int64
|
||||||
|
|
||||||
|
// LastHandshake is the last time a handshake succeeded with this peer. (Or
|
||||||
|
// we got key confirmation via the first data message, which is
|
||||||
|
// approximately the same thing.)
|
||||||
|
//
|
||||||
|
// The time.Time zero value means that no handshake has succeeded, at least
|
||||||
|
// since this peer was last known to WireGuard. (Tailscale removes peers
|
||||||
|
// from the wireguard peer that are idle.)
|
||||||
|
LastHandshake time.Time
|
||||||
|
|
||||||
// HandshakeAttempts is how many failed attempts there have been at
|
// HandshakeAttempts is how many failed attempts there have been at
|
||||||
// completing the current WireGuard handshake. This resets to zero on every
|
// completing the current WireGuard handshake. This resets to zero on every
|
||||||
// successful handshake.
|
// successful handshake.
|
||||||
|
@ -1025,8 +1025,10 @@ func (e *userspaceEngine) getPeerStatusLite(pk key.NodePublic) (status ipnstate.
|
|||||||
status.NodeKey = pk
|
status.NodeKey = pk
|
||||||
status.RxBytes = int64(wgint.PeerRxBytes(peer))
|
status.RxBytes = int64(wgint.PeerRxBytes(peer))
|
||||||
status.TxBytes = int64(wgint.PeerTxBytes(peer))
|
status.TxBytes = int64(wgint.PeerTxBytes(peer))
|
||||||
status.LastHandshake = time.Unix(0, wgint.PeerLastHandshakeNano(peer))
|
|
||||||
status.HandshakeAttempts = wgint.PeerHandshakeAttempts(peer)
|
status.HandshakeAttempts = wgint.PeerHandshakeAttempts(peer)
|
||||||
|
if nano := wgint.PeerLastHandshakeNano(peer); nano != 0 {
|
||||||
|
status.LastHandshake = time.Unix(0, nano)
|
||||||
|
}
|
||||||
return status, true
|
return status, true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user