From eebe7afad70f683185ef8f7fdd43b4d2782adc81 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Wed, 27 Oct 2021 09:41:25 -0700 Subject: [PATCH] derp/derphttp: only log about a weird upgrade if any was specified Otherwise random browser requests to /derp cause log spam. Change-Id: I7bdf991d2106f0323868e651156c788a877a90d5 Signed-off-by: Brad Fitzpatrick --- derp/derphttp/derphttp_server.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/derp/derphttp/derphttp_server.go b/derp/derphttp/derphttp_server.go index e476a6223..e12e72c65 100644 --- a/derp/derphttp/derphttp_server.go +++ b/derp/derphttp/derphttp_server.go @@ -23,7 +23,9 @@ func Handler(s *derp.Server) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { up := strings.ToLower(r.Header.Get("Upgrade")) if up != "websocket" && up != "derp" { - log.Printf("Weird upgrade: %q", up) + if up != "" { + log.Printf("Weird upgrade: %q", up) + } http.Error(w, "DERP requires connection upgrade", http.StatusUpgradeRequired) return }