Validating channel name when connecting.

This commit is contained in:
claudemiro
2015-05-17 09:51:17 -03:00
parent 485bc01abe
commit e2d07e9760
3 changed files with 38 additions and 0 deletions
+5
View File
@@ -118,6 +118,11 @@ func onMessage(conn *websocket.Conn, w http.ResponseWriter, r *http.Request, ses
channelName := strings.TrimSpace(subscribeEvent.Data.Channel)
if !utils.IsChannelNameValid(channelName) {
emitWSError(newGenericError(fmt.Sprintf("This channel name is not valid")), conn)
break
}
isPresence := strings.HasPrefix(channelName, "presence-")
isPrivate := strings.HasPrefix(channelName, "private-")