1
Fork 0

Fix error handling at connection start.

This commit is contained in:
Juliusz Chroboczek 2020-04-25 19:58:54 +02:00
parent 965b59c9d5
commit 563545bd13
1 changed files with 4 additions and 3 deletions

View File

@ -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)
}