derp: add debug traffic handler

This adds a handler on the DERP server for logging bytes send and received by clients of the
server, by holding open a connection and recording if there is a difference between the number
of bytes sent and received. It sends a JSON marshalled object if there is an increase in the
number of bytes.

Signed-off-by: julianknodt <julianknodt@gmail.com>
This commit is contained in:
julianknodt
2021-06-17 21:34:01 -07:00
committed by Brad Fitzpatrick
parent 2f4817fe20
commit 3728634af9
4 changed files with 147 additions and 25 deletions

View File

@@ -171,6 +171,7 @@ func main() {
io.WriteString(w, "derp.Server ConsistencyCheck okay")
}
}))
debug.Handle("traffic", "Traffic check", http.HandlerFunc(s.ServeDebugTraffic))
if *runSTUN {
go serveSTUN()