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 <mihai@tailscale.com>
This commit is contained in:
Mihai Parparita 2023-04-10 16:41:01 -07:00 committed by Mihai Parparita
parent 03b2c44a21
commit cef0a474f8

View File

@ -89,6 +89,10 @@ func (b *LocalBackend) handleC2N(w http.ResponseWriter, r *http.Request) {
return return
} }
w.Header().Set("Content-Type", "text/plain") w.Header().Set("Content-Type", "text/plain")
if b.sockstatLogger == nil {
http.Error(w, "no sockstatLogger", http.StatusInternalServerError)
return
}
b.sockstatLogger.Flush() b.sockstatLogger.Flush()
fmt.Fprintln(w, b.sockstatLogger.LogID()) fmt.Fprintln(w, b.sockstatLogger.LogID())
default: default: