1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-10 02:35:58 +01:00

Add timeout for initial handshake.

This commit is contained in:
Juliusz Chroboczek 2020-04-25 22:49:07 +02:00
parent b201c3d93c
commit c86b1c87d5

View file

@ -108,11 +108,23 @@ type closeMessage struct {
func startClient(conn *websocket.Conn) (err error) {
var m clientMessage
err = conn.SetReadDeadline(time.Now().Add(15 * time.Second))
if err != nil {
conn.Close()
return
}
err = conn.ReadJSON(&m)
if err != nil {
conn.Close()
return
}
err = conn.SetReadDeadline(time.Time{})
if err != nil {
conn.Close()
return
}
if m.Type != "handshake" {
conn.Close()
return