gameServer/Actions.hs
changeset 10148 a599593e1dc2
parent 10095 003fc694c0c3
child 10195 d1c23bb73346
equal deleted inserted replaced
10147:9a772dc5dfbe 10148:a599593e1dc2
   606 processAction (CheckBanned byIP) = do
   606 processAction (CheckBanned byIP) = do
   607     clTime <- client's connectTime
   607     clTime <- client's connectTime
   608     clNick <- client's nick
   608     clNick <- client's nick
   609     clHost <- client's host
   609     clHost <- client's host
   610     si <- gets serverInfo
   610     si <- gets serverInfo
   611     let validBans = filter (checkNotExpired clTime) $ bans si
   611     let (validBans, expiredBans) = L.partition (checkNotExpired clTime) $ bans si
   612     let ban = L.find (checkBan byIP clHost clNick) $ validBans
   612     let ban = L.find (checkBan byIP clHost clNick) $ validBans
   613     mapM_ processAction $
   613     mapM_ processAction $
   614         ModifyServerInfo (\s -> s{bans = validBans})
   614         [ModifyServerInfo (\s -> s{bans = validBans}) | not $ null expiredBans]
   615         : [ByeClient (getBanReason $ fromJust ban) | isJust ban]
   615         ++ [ByeClient (getBanReason $ fromJust ban) | isJust ban]
   616     where
   616     where
   617         checkNotExpired testTime (BanByIP _ _ time) = testTime `diffUTCTime` time <= 0
   617         checkNotExpired testTime (BanByIP _ _ time) = testTime `diffUTCTime` time <= 0
   618         checkNotExpired testTime (BanByNick _ _ time) = testTime `diffUTCTime` time <= 0
   618         checkNotExpired testTime (BanByNick _ _ time) = testTime `diffUTCTime` time <= 0
   619         checkBan True ip _ (BanByIP bip _ _) = bip `B.isPrefixOf` ip
   619         checkBan True ip _ (BanByIP bip _ _) = bip `B.isPrefixOf` ip
   620         checkBan False _ n (BanByNick bn _ _) = caseInsensitiveCompare bn n
   620         checkBan False _ n (BanByNick bn _ _) = caseInsensitiveCompare bn n