Skip to content

Commit f430897

Browse files
committed
ipn/wg: note latest handshake time
1 parent c9c1636 commit f430897

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

intra/ipn/wg/stats.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ package wg
1515

1616
import (
1717
"errors"
18-
"math"
1918
"strconv"
2019
"strings"
2120
"time"
@@ -98,12 +97,10 @@ func (s *ifstats) TotalTx() int64 {
9897
return total
9998
}
10099

101-
func (s *ifstats) LeastRecentHandshake() int64 {
102-
least := int64(math.MaxInt64)
100+
func (s *ifstats) LatestRecentHandshake() int64 {
101+
least := int64(0)
103102
for _, stats := range s.stats {
104-
if stats.LatestHandshakeEpochMillis < least {
105-
least = stats.LatestHandshakeEpochMillis
106-
}
103+
least = max(least, stats.LatestHandshakeEpochMillis)
107104
}
108105
return least
109106
}

intra/ipn/wgproxy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ func (w *wgproxy) Stats() (out x.Stats) {
679679
stat := wg.ReadStats(w.id, cfg)
680680
out.Rx = stat.TotalRx()
681681
out.Tx = stat.TotalTx()
682-
out.LastOK = stat.LeastRecentHandshake()
682+
out.LastOK = stat.LatestRecentHandshake()
683683
out.Addr = w.IfAddr() // may be empty
684684
out.ErrRx = w.errRx
685685
out.ErrTx = w.errTx

0 commit comments

Comments
 (0)