From 563545bd131fe3fc4320575fa92220c1949aac34 Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Sat, 25 Apr 2020 19:58:54 +0200 Subject: [PATCH] Fix error handling at connection start. --- client.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client.go b/client.go index 897f29f..f5f90c5 100644 --- a/client.go +++ b/client.go @@ -110,10 +110,11 @@ func startClient(conn *websocket.Conn) (err error) { var m clientMessage err = conn.ReadJSON(&m) if err != nil { + conn.Close() return } if m.Type != "handshake" { - err = protocolError("expected handshake") + conn.Close() return } @@ -755,12 +756,12 @@ func clientLoop(c *client, conn *websocket.Conn) error { Type: "permissions", Permissions: c.permissions, }) - if(!c.permissions.Present) { + if !c.permissions.Present { ids := getUpConns(c) for _, id := range ids { c.write(clientMessage{ Type: "abort", - Id: id, + Id: id, }) delUpConn(c, id) }