equal
deleted
inserted
replaced
38 import Control.Exception as E |
38 import Control.Exception as E |
39 import System.Process |
39 import System.Process |
40 import Network.Socket |
40 import Network.Socket |
41 import System.Random |
41 import System.Random |
42 import qualified Data.Traversable as DT |
42 import qualified Data.Traversable as DT |
|
43 import Text.Regex.Base |
|
44 import qualified Text.Regex.TDFA as TDFA |
|
45 import qualified Text.Regex.TDFA.ByteString as TDFAB |
43 ----------------------------- |
46 ----------------------------- |
44 #if defined(OFFICIAL_SERVER) |
47 #if defined(OFFICIAL_SERVER) |
45 import OfficialServer.GameReplayStore |
48 import OfficialServer.GameReplayStore |
46 #endif |
49 #endif |
47 import CoreTypes |
50 import CoreTypes |
656 [ModifyServerInfo (\s -> s{bans = validBans}) | not $ null expiredBans] |
659 [ModifyServerInfo (\s -> s{bans = validBans}) | not $ null expiredBans] |
657 ++ [ByeClient (getBanReason $ fromJust ban) | isJust ban] |
660 ++ [ByeClient (getBanReason $ fromJust ban) | isJust ban] |
658 where |
661 where |
659 checkNotExpired testTime (BanByIP _ _ time) = testTime `diffUTCTime` time <= 0 |
662 checkNotExpired testTime (BanByIP _ _ time) = testTime `diffUTCTime` time <= 0 |
660 checkNotExpired testTime (BanByNick _ _ time) = testTime `diffUTCTime` time <= 0 |
663 checkNotExpired testTime (BanByNick _ _ time) = testTime `diffUTCTime` time <= 0 |
661 checkBan True ip _ (BanByIP bip _ _) = bip `B.isPrefixOf` ip |
664 checkBan True ip _ (BanByIP bip _ _) = isMatch bip ip |
662 checkBan False _ n (BanByNick bn _ _) = caseInsensitiveCompare bn n |
665 checkBan False _ n (BanByNick bn _ _) = isMatch bn n |
663 checkBan _ _ _ _ = False |
666 checkBan _ _ _ _ = False |
|
667 isMatch :: B.ByteString -> B.ByteString -> Bool |
|
668 isMatch rexp src = (==) (Just True) $ mrexp rexp >>= flip matchM src |
|
669 mrexp :: B.ByteString -> Maybe TDFAB.Regex |
|
670 mrexp = makeRegexOptsM TDFA.defaultCompOpt{TDFA.caseSensitive = False} TDFA.defaultExecOpt |
664 getBanReason (BanByIP _ msg _) = msg |
671 getBanReason (BanByIP _ msg _) = msg |
665 getBanReason (BanByNick _ msg _) = msg |
672 getBanReason (BanByNick _ msg _) = msg |
666 |
673 |
667 |
674 |
668 processAction PingAll = do |
675 processAction PingAll = do |