From 3c5d45ee21717d225af44873356e44c65ead78fa Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sat, 28 Apr 2018 16:23:42 +0200 Subject: [PATCH] add Upgrade Response status code check to begin/abort websocket client --- ws/server.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ws/server.go b/ws/server.go index e81dd70..9c36426 100644 --- a/ws/server.go +++ b/ws/server.go @@ -76,6 +76,12 @@ func (s *Server) Launch() error { upgrader, err := upgrader.Upgrade(sock) if err != nil { fmt.Printf(" - upgrade error: %s\n", err) + sock.Close() + continue + } + if upgrader.Response.GetStatusCode() != 101 { + fmt.Printf(" - upgrade bad request\n") + sock.Close() continue }