Fixed server crash from client malformed data
This commit is contained in:
parent
e93564e777
commit
db91c5e08b
11
client.go
11
client.go
@ -67,17 +67,18 @@ func (c *Client) handleIncoming() {
|
|||||||
c.Server.AddClient(c)
|
c.Server.AddClient(c)
|
||||||
for {
|
for {
|
||||||
message, err := c.Decode()
|
message, err := c.Decode()
|
||||||
if err != nil || message == nil {
|
if err != nil {
|
||||||
|
|
||||||
_, closedError := err.(*net.OpError)
|
_, closedError := err.(*net.OpError)
|
||||||
if err == io.EOF || err == io.ErrClosedPipe || closedError || strings.Contains(err.Error(), "use of closed network connection") {
|
if err == io.EOF || err == io.ErrClosedPipe || closedError || strings.Contains(err.Error(), "use of closed network connection") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
println("Error decoding incoming message", err.Error())
|
|
||||||
return
|
continue
|
||||||
//continue
|
}
|
||||||
|
if message == nil || message.Len() == 0 {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
//println(message.String())
|
|
||||||
|
|
||||||
c.idleTimer.Stop()
|
c.idleTimer.Stop()
|
||||||
c.idleTimer = time.AfterFunc(time.Minute, c.idle)
|
c.idleTimer = time.AfterFunc(time.Minute, c.idle)
|
||||||
|
Loading…
Reference in New Issue
Block a user