ipn: add c2n endpoint for sockstats logs

Signed-off-by: Will Norris <will@tailscale.com>
This commit is contained in:
Will Norris
2023-03-10 14:33:26 -08:00
committed by Will Norris
parent a1d9f65354
commit 09e0ccf4c2
3 changed files with 33 additions and 3 deletions

View File

@@ -83,6 +83,9 @@ func (b *LocalBackend) handleC2N(w http.ResponseWriter, r *http.Request) {
return
}
writeJSON(res)
case "/sockstats":
w.Header().Set("Content-Type", "text/plain")
b.sockstatLogger.WriteLogs(w)
default:
http.Error(w, "unknown c2n path", http.StatusBadRequest)
}

View File

@@ -310,7 +310,7 @@ func NewLocalBackend(logf logger.Logf, logid string, store ipn.StateStore, diale
// for now, only log sockstats on unstable builds
if version.IsUnstableBuild() {
b.sockstatLogger, err = sockstatlog.NewLogger(logpolicy.LogsDir(logf))
b.sockstatLogger, err = sockstatlog.NewLogger(logpolicy.LogsDir(logf), logf)
if err != nil {
log.Printf("error setting up sockstat logger: %v", err)
}