--- a/gameServer/Actions.hs Sat Oct 01 19:06:12 2016 +0200
+++ b/gameServer/Actions.hs Sat Oct 01 20:56:42 2016 +0300
@@ -40,6 +40,9 @@
import Network.Socket
import System.Random
import qualified Data.Traversable as DT
+import Text.Regex.Base
+import qualified Text.Regex.TDFA as TDFA
+import qualified Text.Regex.TDFA.ByteString as TDFAB
-----------------------------
#if defined(OFFICIAL_SERVER)
import OfficialServer.GameReplayStore
@@ -658,9 +661,13 @@
where
checkNotExpired testTime (BanByIP _ _ time) = testTime `diffUTCTime` time <= 0
checkNotExpired testTime (BanByNick _ _ time) = testTime `diffUTCTime` time <= 0
- checkBan True ip _ (BanByIP bip _ _) = bip `B.isPrefixOf` ip
- checkBan False _ n (BanByNick bn _ _) = caseInsensitiveCompare bn n
+ checkBan True ip _ (BanByIP bip _ _) = isMatch bip ip
+ checkBan False _ n (BanByNick bn _ _) = isMatch bn n
checkBan _ _ _ _ = False
+ isMatch :: B.ByteString -> B.ByteString -> Bool
+ isMatch rexp src = (==) (Just True) $ mrexp rexp >>= flip matchM src
+ mrexp :: B.ByteString -> Maybe TDFAB.Regex
+ mrexp = makeRegexOptsM TDFA.defaultCompOpt{TDFA.caseSensitive = False} TDFA.defaultExecOpt
getBanReason (BanByIP _ msg _) = msg
getBanReason (BanByNick _ msg _) = msg
--- a/gameServer/CMakeLists.txt Sat Oct 01 19:06:12 2016 +0200
+++ b/gameServer/CMakeLists.txt Sat Oct 01 20:56:42 2016 +0300
@@ -20,6 +20,7 @@
check_haskell_module_exists("System.Entropy" openHandle 0 entropy)
check_haskell_module_exists("Codec.Compression.Zlib" decompress 1 zlib)
check_haskell_module_exists("System.Random" getStdGen 0 random)
+check_haskell_module_exists("Text.Regex.TDFA.ByteString" execute 2 regex-tdfa)
# this one needs type signatures to work
# check_haskell_module_exists("Control.DeepSeq" deepseq 2 deepseq)
--- a/gameServer/hedgewars-server.cabal Sat Oct 01 19:06:12 2016 +0200
+++ b/gameServer/hedgewars-server.cabal Sat Oct 01 20:56:42 2016 +0300
@@ -5,7 +5,7 @@
Homepage: http://www.hedgewars.org/
License: GPL-2
Author: unC0Rr
-Maintainer: unC0Rr@hedgewars.org
+Maintainer: a.korotaev@hedgewars.org
Category: Game
Build-type: Simple
Cabal-version: >=1.10
@@ -32,7 +32,8 @@
utf8-string,
SHA,
entropy,
- zlib >= 0.5.3 && < 0.6
+ zlib >= 0.5.3 && < 0.6,
+ regex-tdfa
if !os(windows)
build-depends: unix