1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-09-15 17:46:55 +00:00

Close the connection if we get corrupted commands.

This commit is contained in:
Kane York 2015-11-19 16:55:03 -08:00
parent cf238bf650
commit 62c9659430
4 changed files with 23 additions and 9 deletions

View file

@ -15,6 +15,7 @@ import (
"sync"
"sync/atomic"
"time"
"unicode/utf8"
)
// SuccessCommand is a Reply Command to indicate success in reply to a C2S Command.
@ -179,6 +180,11 @@ var CloseFirstMessageNotHello = websocket.CloseError{
Code: websocket.ClosePolicyViolation,
}
var CloseNonUTF8Data = websocket.CloseError{
Code: 4001,
Text: "Non UTF8 data recieved. Network corruption likely.",
}
const sendMessageBufferLength = 125
const sendMessageAbortLength = 50
@ -298,6 +304,13 @@ RunLoop:
break RunLoop
}
for _, char := range msg.Command {
if char == utf8.RuneError {
closeReason = CloseNonUTF8Data
break RunLoop
}
}
DispatchC2SCommand(conn, &client, msg)
case msg := <-serverMessageChan: