Hide last two octets of IP address from usual users
authorunc0rr
Mon, 28 Mar 2011 20:31:01 +0400
changeset 5060 7d0f6e5b1c1c
parent 5059 68a5415ca8ea
child 5061 c90b1da271bc
child 5062 e2d38329b84a
Hide last two octets of IP address from usual users
gameServer/HWProtoCore.hs
gameServer/Utils.hs
--- a/gameServer/HWProtoCore.hs	Mon Mar 28 20:30:15 2011 +0400
+++ b/gameServer/HWProtoCore.hs	Mon Mar 28 20:31:01 2011 +0400
@@ -43,6 +43,7 @@
 handleCmd_loggedin ["INFO", asknick] = do
     (_, rnc) <- ask
     maybeClientId <- clientByNick asknick
+    isAdminAsking <- liftM isAdministrator thisClient
     let noSuchClient = isNothing maybeClientId
     let clientId = fromJust maybeClientId
     let cl = rnc `client` fromJust maybeClientId
@@ -55,13 +56,14 @@
             if teamsInGame cl > 0 then "(playing)" else "(spectating)"
             else
             ""
+    let hostStr = if isAdminAsking then host cl else cutHost $ host cl
     if noSuchClient then
         return []
         else
         answerClient [
             "INFO",
             nick cl,
-            B.concat ["[", host cl, "]"],
+            B.concat ["[", hostStr, "]"],
             protoNumber2ver $ clientProto cl,
             B.concat ["[", roomInfo, "]", roomStatus]
             ]
--- a/gameServer/Utils.hs	Mon Mar 28 20:30:15 2011 +0400
+++ b/gameServer/Utils.hs	Mon Mar 28 20:31:01 2011 +0400
@@ -124,3 +124,6 @@
   case B.readInt str of
        Just (i, t) | B.null t -> fromIntegral i
        _                      -> 0 
+
+cutHost :: B.ByteString -> B.ByteString
+cutHost = B.intercalate "." .  flip (++) ["*","*"] . List.take 2 . B.split '.'