- Start work on flood detector
authorunc0rr
Thu, 30 Jan 2014 00:18:32 +0400
changeset 10090 a471a7bbc339
parent 10089 c6e5ed83fb83
child 10091 213c38232b3d
- Start work on flood detector - More agressive joins flood protection - Also fix some warnings
gameServer/Actions.hs
gameServer/CMakeLists.txt
gameServer/CoreTypes.hs
gameServer/FloodDetection.hs
gameServer/JoinsMonitor.hs
gameServer/Votes.hs
--- a/gameServer/Actions.hs	Wed Jan 29 09:17:25 2014 -0500
+++ b/gameServer/Actions.hs	Thu Jan 30 00:18:32 2014 +0400
@@ -782,3 +782,8 @@
     io $ do
         t <- getCurrentTime
         cleanup jm t
+
+
+processAction (RegisterEvent e) = do
+    actions <- registerEvent e
+    mapM_ processAction actions
--- a/gameServer/CMakeLists.txt	Wed Jan 29 09:17:25 2014 -0500
+++ b/gameServer/CMakeLists.txt	Thu Jan 30 00:18:32 2014 +0400
@@ -11,6 +11,7 @@
     Consts.hs
     CoreTypes.hs
     EngineInteraction.hs
+    FloodDetection.hs
     HWProtoCore.hs
     HWProtoInRoomState.hs
     HWProtoLobbyState.hs
--- a/gameServer/CoreTypes.hs	Wed Jan 29 09:17:25 2014 -0500
+++ b/gameServer/CoreTypes.hs	Thu Jan 30 00:18:32 2014 +0400
@@ -78,6 +78,12 @@
     | QueryReplay B.ByteString
     | ShowReplay B.ByteString
     | Cleanup
+    | RegisterEvent Event
+
+
+data Event = LobbyChatMessage
+           | EngineMessage
+           | RoomJoin
 
 type ClientChan = Chan [B.ByteString]
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gameServer/FloodDetection.hs	Thu Jan 30 00:18:32 2014 +0400
@@ -0,0 +1,6 @@
+module FloodDetection where
+
+import CoreTypes
+
+registerEvent :: Event -> a
+registerEvent e = undefined
--- a/gameServer/JoinsMonitor.hs	Wed Jan 29 09:17:25 2014 -0500
+++ b/gameServer/JoinsMonitor.hs	Thu Jan 30 00:18:32 2014 +0400
@@ -36,7 +36,7 @@
     let last30sec = length $ takeWhile (< 30) lastJoins
     let last2min = length $ takeWhile (< 120) lastJoins
     let last10min = length $ takeWhile (< 600) lastJoins
-    let pass = last30sec < 2 && last2min < 4 && last10min < 6
+    let pass = last30sec < 2 && last2min < 3 && last10min < 5
 
     when pass $ writeIORef ref $ Map.alter (Just . (:) time . fromMaybe []) host m
 
--- a/gameServer/Votes.hs	Wed Jan 29 09:17:25 2014 -0500
+++ b/gameServer/Votes.hs	Thu Jan 30 00:18:32 2014 +0400
@@ -11,7 +11,6 @@
 import Utils
 import CoreTypes
 import HandlerUtils
-import Actions
 
 
 voted :: Bool -> Reader (ClientIndex, IRnC) [Action]
@@ -67,7 +66,7 @@
 startVote :: VoteType -> Reader (ClientIndex, IRnC) [Action]
 startVote vt = do
     (ci, rnc) <- ask
-    cl <- thisClient
+    --cl <- thisClient
     rm <- thisRoom
     chans <- roomClientsChans