mirror of
https://github.com/jech/galene.git
synced 2024-12-22 23:35:46 +01:00
Add timeout for initial handshake.
This commit is contained in:
parent
b201c3d93c
commit
c86b1c87d5
1 changed files with 12 additions and 0 deletions
12
client.go
12
client.go
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue