mirror of
https://github.com/jech/galene.git
synced 2024-11-22 16:45:58 +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) {
|
func startClient(conn *websocket.Conn) (err error) {
|
||||||
var m clientMessage
|
var m clientMessage
|
||||||
|
|
||||||
|
err = conn.SetReadDeadline(time.Now().Add(15 * time.Second))
|
||||||
|
if err != nil {
|
||||||
|
conn.Close()
|
||||||
|
return
|
||||||
|
}
|
||||||
err = conn.ReadJSON(&m)
|
err = conn.ReadJSON(&m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
conn.Close()
|
conn.Close()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
err = conn.SetReadDeadline(time.Time{})
|
||||||
|
if err != nil {
|
||||||
|
conn.Close()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if m.Type != "handshake" {
|
if m.Type != "handshake" {
|
||||||
conn.Close()
|
conn.Close()
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue