Пример #1
0
        public bool IsWhiteListed(string name, IPAddress address)
        {
            if (!Enabled)
            {
                return(true);
            }
            WhiteListedPlayer wlp = whitelistedPlayers.Find(p => p.Name == name);

            if (wlp == null)
            {
                return(false);
            }
            if (!string.IsNullOrWhiteSpace(wlp.IP))
            {
                if (address.IsIPv4MappedToIPv6 && wlp.IP == address.MapToIPv4NoThrow().ToString())
                {
                    return(true);
                }
                else
                {
                    return(wlp.IP == address.ToString());
                }
            }
            return(true);
        }
Пример #2
0
        public void ServerAdminWrite(IWriteMessage outMsg, Client c)
        {
            if (!c.HasPermission(ClientPermissions.ManageSettings))
            {
                outMsg.Write(false); outMsg.WritePadBits();
                return;
            }
            outMsg.Write(true);
            outMsg.Write(c.Connection == GameMain.Server.OwnerConnection);
            outMsg.Write(Enabled);

            outMsg.WritePadBits();
            outMsg.WriteVariableUInt32((UInt32)whitelistedPlayers.Count);
            for (int i = 0; i < whitelistedPlayers.Count; i++)
            {
                WhiteListedPlayer whitelistedPlayer = whitelistedPlayers[i];

                outMsg.Write(whitelistedPlayer.Name);
                outMsg.Write(whitelistedPlayer.UniqueIdentifier);
                if (c.Connection == GameMain.Server.OwnerConnection)
                {
                    outMsg.Write(whitelistedPlayer.IP);
                    //outMsg.Write(whitelistedPlayer.SteamID); //TODO: add steamid to whitelisted players
                }
            }
        }
Пример #3
0
        private void RemoveFromWhiteList(WhiteListedPlayer wlp)
        {
            GameServer.Log("Removing " + wlp.Name + " from whitelist", ServerLog.MessageType.ServerMessage);

            whitelistedPlayers.Remove(wlp);
            Save();
        }
Пример #4
0
        public bool ServerAdminRead(IReadMessage incMsg, Client c)
        {
            if (!c.HasPermission(ClientPermissions.ManageSettings))
            {
                bool   enabled     = incMsg.ReadBoolean(); incMsg.ReadPadBits();
                UInt16 removeCount = incMsg.ReadUInt16();
                incMsg.BitPosition += removeCount * 4 * 8;
                UInt16 addCount = incMsg.ReadUInt16();
                for (int i = 0; i < addCount; i++)
                {
                    incMsg.ReadString(); //skip name
                    incMsg.ReadString(); //skip ip
                }
                return(false);
            }
            else
            {
                bool prevEnabled = Enabled;
                bool enabled     = incMsg.ReadBoolean(); incMsg.ReadPadBits();
                Enabled = enabled;

                UInt16 removeCount = incMsg.ReadUInt16();
                for (int i = 0; i < removeCount; i++)
                {
                    UInt16            id = incMsg.ReadUInt16();
                    WhiteListedPlayer whitelistedPlayer = whitelistedPlayers.Find(p => p.UniqueIdentifier == id);
                    if (whitelistedPlayer != null)
                    {
                        GameServer.Log(GameServer.ClientLogName(c) + " removed " + whitelistedPlayer.Name + " from whitelist (" + whitelistedPlayer.IP + ")", ServerLog.MessageType.ConsoleUsage);
                        RemoveFromWhiteList(whitelistedPlayer);
                    }
                }

                UInt16 addCount = incMsg.ReadUInt16();
                for (int i = 0; i < addCount; i++)
                {
                    string name = incMsg.ReadString();
                    string ip   = incMsg.ReadString();

                    GameServer.Log(GameServer.ClientLogName(c) + " added " + name + " to whitelist (" + ip + ")", ServerLog.MessageType.ConsoleUsage);
                    AddToWhiteList(name, ip);
                }

                bool changed = removeCount > 0 || addCount > 0 || prevEnabled != enabled;
                if (changed)
                {
                    Save();
                }
                return(changed);
            }
        }
Пример #5
0
        public bool IsWhiteListed(string name, string ip)
        {
            if (!Enabled)
            {
                return(true);
            }
            WhiteListedPlayer wlp = whitelistedPlayers.Find(p => p.Name == name);

            if (wlp == null)
            {
                return(false);
            }
            if (wlp.IP != ip && !string.IsNullOrWhiteSpace(wlp.IP))
            {
                return(false);
            }
            return(true);
        }
Пример #6
0
        private bool RemoveFromWhiteList(GUIButton button, object obj)
        {
            WhiteListedPlayer wlp = obj as WhiteListedPlayer;

            if (wlp == null)
            {
                return(false);
            }

            RemoveFromWhiteList(wlp);

            if (whitelistFrame != null)
            {
                CreateWhiteListFrame(whitelistFrame.Parent);
            }

            return(true);
        }
Пример #7
0
        private bool RemoveFromWhiteList(GUIButton button, object obj)
        {
            WhiteListedPlayer wlp = obj as WhiteListedPlayer;

            if (wlp == null)
            {
                return(false);
            }

            DebugConsole.Log("Removing " + wlp.Name + " from whitelist");
            GameServer.Log("Removing " + wlp.Name + " from whitelist", ServerLog.MessageType.ServerMessage);

            whitelistedPlayers.Remove(wlp);
            Save();

            if (whitelistFrame != null)
            {
                whitelistFrame.Parent.ClearChildren();
                CreateWhiteListFrame(whitelistFrame.Parent);
            }

            return(true);
        }
Пример #8
0
        private bool RemoveFromWhiteList(GUIButton button, object obj)
        {
            if (obj is WhiteListedPlayer)
            {
                WhiteListedPlayer wlp = obj as WhiteListedPlayer;
                if (wlp == null)
                {
                    return(false);
                }

                if (!localRemoved.Contains(wlp.UniqueIdentifier))
                {
                    localRemoved.Add(wlp.UniqueIdentifier);
                }
            }
            else if (obj is LocalAdded)
            {
                LocalAdded lad = obj as LocalAdded;
                if (lad == null)
                {
                    return(false);
                }

                if (localAdded.Contains(lad))
                {
                    localAdded.Remove(lad);
                }
            }

            if (whitelistFrame != null)
            {
                CreateWhiteListFrame(whitelistFrame.Parent);
            }

            return(true);
        }