From fa91ece5b4db47fa50026aa2fe6790230a5182a3 Mon Sep 17 00:00:00 2001 From: Juan Font Alonso Date: Sun, 26 Jun 2022 12:25:26 +0200 Subject: [PATCH] Lint fixes 6/n --- poll.go | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/poll.go b/poll.go index 72e293a5..3469e235 100644 --- a/poll.go +++ b/poll.go @@ -335,7 +335,18 @@ func (h *Headscale) PollNetMapStream( return } - writer.(http.Flusher).Flush() + + flusher, ok := writer.(http.Flusher) + if !ok { + log.Error(). + Caller(). + Str("handler", "PollNetMapStream"). + Str("machine", machine.Hostname). + Str("channel", "pollData"). + Msg("Cannot cast writer to http.Flusher") + } else { + flusher.Flush() + } log.Trace(). Str("handler", "PollNetMapStream"). @@ -403,7 +414,17 @@ func (h *Headscale) PollNetMapStream( return } - writer.(http.Flusher).Flush() + flusher, ok := writer.(http.Flusher) + if !ok { + log.Error(). + Caller(). + Str("handler", "PollNetMapStream"). + Str("machine", machine.Hostname). + Str("channel", "keepAlive"). + Msg("Cannot cast writer to http.Flusher") + } else { + flusher.Flush() + } log.Trace(). Str("handler", "PollNetMapStream"). @@ -492,7 +513,18 @@ func (h *Headscale) PollNetMapStream( return } - writer.(http.Flusher).Flush() + + flusher, ok := writer.(http.Flusher) + if !ok { + log.Error(). + Caller(). + Str("handler", "PollNetMapStream"). + Str("machine", machine.Hostname). + Str("channel", "update"). + Msg("Cannot cast writer to http.Flusher") + } else { + flusher.Flush() + } log.Trace(). Str("handler", "PollNetMapStream").