gameServer/Actions.hs
changeset 9973 7589978c9912
parent 9868 53d1b92db6ce
child 10014 56d2f2d5aad8
--- a/gameServer/Actions.hs	Sun Jan 12 11:07:49 2014 +0400
+++ b/gameServer/Actions.hs	Sun Jan 12 15:15:59 2014 +0400
@@ -569,13 +569,18 @@
         return ci
 
     modify (\s -> s{clientIndex = Just newClId})
-    mapM_ processAction
-        [
-            AnswerClients [sendChan cl] ["CONNECTED", "Hedgewars server http://www.hedgewars.org/", serverVersion]
-            , CheckBanned True
-            , AddIP2Bans (host cl) "Reconnected too fast" (addUTCTime 10 $ connectTime cl)
-        ]
+
+    jm <- gets joinsMonitor
+    pass <- io $ joinsSentry jm (host cl) (connectTime cl)
 
+    if pass then
+        mapM_ processAction
+            [
+                CheckBanned True
+                , AnswerClients [sendChan cl] ["CONNECTED", "Hedgewars server http://www.hedgewars.org/", serverVersion]
+            ]
+        else
+        processAction $ ByeClient $ loc "Reconnected too fast"
 
 processAction (AddNick2Bans n reason expiring) = do
     processAction $ ModifyServerInfo (\s -> s{bans = BanByNick n reason expiring : bans s})
@@ -760,3 +765,11 @@
             , [AnswerClients [c] $ "EM" : roundMsgs']
             , [AnswerClients [c] ["KICKED"]]
             ]
+
+
+processAction Cleanup = do
+    jm <- gets joinsMonitor
+    
+    io $ do
+        t <- getCurrentTime
+        cleanup jm t