--- a/netserver/HWProto.hs Sun Jan 25 18:54:30 2009 +0000
+++ b/netserver/HWProto.hs Sun Jan 25 18:54:39 2009 +0000
@@ -302,6 +302,15 @@
handleCmd_noRoom client _ _ ["CHAT_STRING", msg] =
(noChangeClients, noChangeRooms, answerChatString (nick client) msg)
+handleCmd_noRoom client _ _ ["GLOBALMSG", password, msg] =
+ (noChangeClients, noChangeRooms, [answer])
+ where
+ answer = \serverInfo ->
+ if (not $ null password) && (adminPassword serverInfo == password) then
+ (allClients, ["CHAT_STRING", nick client, msg])
+ else
+ (clientOnly, ["ERROR", "Wrong password"])
+
handleCmd_noRoom _ _ _ _ = (noChangeClients, noChangeRooms, answerBadCmd)
--- a/netserver/Miscutils.hs Sun Jan 25 18:54:30 2009 +0000
+++ b/netserver/Miscutils.hs Sun Jan 25 18:54:39 2009 +0000
@@ -99,6 +99,7 @@
{
isDedicated :: Bool,
serverMessage :: String,
+ adminPassword :: String,
listenPort :: PortNumber,
loginsNumber :: Int,
lastHourUsers :: [UTCTime],
@@ -109,6 +110,7 @@
ServerInfo
True
"<h2><p align=center><a href=\"http://www.hedgewars.org/\">http://www.hedgewars.org/</a></p></h2>"
+ ""
46631
0
[]
--- a/netserver/Opts.hs Sun Jan 25 18:54:30 2009 +0000
+++ b/netserver/Opts.hs Sun Jan 25 18:54:39 2009 +0000
@@ -14,10 +14,11 @@
options :: [OptDescr (ServerInfo -> ServerInfo)]
options = [
Option ['p'] ["port"] (ReqArg readListenPort "PORT") "listen on PORT",
- Option ['d'] ["dedicated"] (ReqArg readDedicated "BOOL") "start as dedicated (True or False)"
+ Option ['d'] ["dedicated"] (ReqArg readDedicated "BOOL") "start as dedicated (True or False)",
+ Option [] ["password"] (ReqArg readPassword "STRING") "admin password"
]
-readListenPort, readDedicated :: String -> ServerInfo -> ServerInfo
+readListenPort, readDedicated, readPassword :: String -> ServerInfo -> ServerInfo
readListenPort str opts = opts{listenPort = readPort}
where
readPort = fromInteger $ fromMaybe 46631 (maybeRead str :: Maybe Integer)
@@ -26,6 +27,8 @@
where
readDedicated = fromMaybe True (maybeRead str :: Maybe Bool)
+readPassword str opts = opts{adminPassword = str}
+
getOpts :: ServerInfo -> IO ServerInfo
getOpts opts = do
args <- getArgs