mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-16 11:41:39 +00:00
wgengine/magicsock: fix panic in http debug server
Fixes an panic in `(*magicsock.Conn).ServeHTTPDebug` when the `recentPongs` ring buffer for an endpoint wraps around. Signed-off-by: Colin Adler <colin1adler@gmail.com>
This commit is contained in:
parent
9240f5c1e2
commit
9c8bbc7888
@ -172,6 +172,11 @@ func printEndpointHTML(w io.Writer, ep *endpoint) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
pos := (int(s.recentPong) - i) % len(s.recentPongs)
|
pos := (int(s.recentPong) - i) % len(s.recentPongs)
|
||||||
|
// If s.recentPongs wraps around pos will be negative, so start
|
||||||
|
// again from the end of the slice.
|
||||||
|
if pos < 0 {
|
||||||
|
pos += len(s.recentPongs)
|
||||||
|
}
|
||||||
pr := s.recentPongs[pos]
|
pr := s.recentPongs[pos]
|
||||||
fmt.Fprintf(w, "<li>pong %v ago: in %v, from %v src %v</li>\n",
|
fmt.Fprintf(w, "<li>pong %v ago: in %v, from %v src %v</li>\n",
|
||||||
fmtMono(pr.pongAt), pr.latency.Round(time.Millisecond/10),
|
fmtMono(pr.pongAt), pr.latency.Round(time.Millisecond/10),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user