From cef0a474f8fb1a09e4ce3191ff000fcc21858284 Mon Sep 17 00:00:00 2001 From: Mihai Parparita Date: Mon, 10 Apr 2023 16:41:01 -0700 Subject: [PATCH] ipn/ipnlocal: check that sockstatLogger is available in c2n endpoint Otherwise there may be a panic if it's nil (and the control side of the c2n call will just time out). Signed-off-by: Mihai Parparita --- ipn/ipnlocal/c2n.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ipn/ipnlocal/c2n.go b/ipn/ipnlocal/c2n.go index 85c95dad2..68c1e7e72 100644 --- a/ipn/ipnlocal/c2n.go +++ b/ipn/ipnlocal/c2n.go @@ -89,6 +89,10 @@ func (b *LocalBackend) handleC2N(w http.ResponseWriter, r *http.Request) { return } w.Header().Set("Content-Type", "text/plain") + if b.sockstatLogger == nil { + http.Error(w, "no sockstatLogger", http.StatusInternalServerError) + return + } b.sockstatLogger.Flush() fmt.Fprintln(w, b.sockstatLogger.LogID()) default: