Ejemplo n.º 1
0
        private bool RangeBan(GUIButton button, object obj)
        {
            BannedPlayer banned = obj as BannedPlayer;

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

            banned.IP = ToRange(banned.IP);

            BannedPlayer bp;

            while ((bp = bannedPlayers.Find(x => banned.CompareTo(x.IP))) != null)
            {
                //remove all specific bans that are now covered by the rangeban
                bannedPlayers.Remove(bp);
            }

            bannedPlayers.Add(banned);

            Save();

            if (banFrame != null)
            {
                banFrame.Parent.RemoveChild(banFrame);
                CreateBanFrame(banFrame.Parent);
            }

            return(true);
        }
Ejemplo n.º 2
0
        public void ServerAdminWrite(NetBuffer outMsg, Client c)
        {
            if (!c.HasPermission(ClientPermissions.Ban))
            {
                outMsg.Write(false); outMsg.WritePadBits();
                return;
            }
            outMsg.Write(true);
            outMsg.Write(c.Connection == GameMain.Server.OwnerConnection);

            outMsg.WritePadBits();
            outMsg.WriteVariableInt32(bannedPlayers.Count);
            for (int i = 0; i < bannedPlayers.Count; i++)
            {
                BannedPlayer bannedPlayer = bannedPlayers[i];

                outMsg.Write(bannedPlayer.Name);
                outMsg.Write(bannedPlayer.UniqueIdentifier);
                outMsg.Write(bannedPlayer.IsRangeBan); outMsg.WritePadBits();
                if (c.Connection == GameMain.Server.OwnerConnection)
                {
                    outMsg.Write(bannedPlayer.IP);
                    outMsg.Write(bannedPlayer.SteamID);
                }
            }
        }
Ejemplo n.º 3
0
        private void RemoveBan(BannedPlayer banned)
        {
            DebugConsole.Log("Removing ban from " + banned.Name);
            GameServer.Log("Removing ban from " + banned.Name, ServerLog.MessageType.ServerMessage);

            bannedPlayers.Remove(banned);

            Save();
        }
Ejemplo n.º 4
0
        public void ServerAdminWrite(IWriteMessage outMsg, Client c)
        {
            try
            {
                if (outMsg == null)
                {
                    throw new ArgumentException("OutMsg was null");
                }
                if (GameMain.Server == null)
                {
                    throw new Exception("GameMain.Server was null");
                }

                if (!c.HasPermission(ClientPermissions.Ban))
                {
                    outMsg.Write(false); outMsg.WritePadBits();
                    return;
                }

                outMsg.Write(true);
                outMsg.Write(c.Connection == GameMain.Server.OwnerConnection);

                outMsg.WritePadBits();
                outMsg.WriteVariableUInt32((UInt32)bannedPlayers.Count);
                for (int i = 0; i < bannedPlayers.Count; i++)
                {
                    BannedPlayer bannedPlayer = bannedPlayers[i];

                    outMsg.Write(bannedPlayer.Name);
                    outMsg.Write(bannedPlayer.UniqueIdentifier);
                    outMsg.Write(bannedPlayer.IsRangeBan);
                    outMsg.Write(bannedPlayer.ExpirationTime != null);
                    outMsg.WritePadBits();
                    if (bannedPlayer.ExpirationTime != null)
                    {
                        double hoursFromNow = (bannedPlayer.ExpirationTime.Value - DateTime.Now).TotalHours;
                        outMsg.Write(hoursFromNow);
                    }

                    outMsg.Write(bannedPlayer.Reason ?? "");

                    if (c.Connection == GameMain.Server.OwnerConnection)
                    {
                        outMsg.Write(bannedPlayer.EndPoint);
                        outMsg.Write(bannedPlayer.SteamID);
                    }
                }
            }

            catch (Exception e)
            {
                string errorMsg = "Error while writing banlist. {" + e + "}\n" + e.StackTrace.CleanupStackTrace();
                GameAnalyticsManager.AddErrorEventOnce("Banlist.ServerAdminWrite", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
                throw;
            }
        }
Ejemplo n.º 5
0
        private bool RangeBan(GUIButton button, object obj)
        {
            BannedPlayer banned = obj as BannedPlayer;

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

            localRangeBans.Add(banned.UniqueIdentifier);

            RecreateBanFrame();

            return(true);
        }
Ejemplo n.º 6
0
        private void RangeBan(BannedPlayer banned)
        {
            banned.EndPoint = ToRange(banned.EndPoint);

            BannedPlayer bp;

            while ((bp = bannedPlayers.Find(x => banned.CompareTo(x.EndPoint))) != null)
            {
                //remove all specific bans that are now covered by the rangeban
                bannedPlayers.Remove(bp);
            }

            bannedPlayers.Add(banned);

            Save();
        }
Ejemplo n.º 7
0
        private bool RangeBan(GUIButton button, object obj)
        {
            BannedPlayer banned = obj as BannedPlayer;

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

            localRangeBans.Add(banned.UniqueIdentifier);
            RecreateBanFrame();

            GameMain.Client?.ServerSettings?.ClientAdminWrite(ServerSettings.NetFlags.Properties);

            return(true);
        }
Ejemplo n.º 8
0
        private bool RangeBan(GUIButton button, object obj)
        {
            BannedPlayer banned = obj as BannedPlayer;

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

            RangeBan(banned);

            if (banFrame != null)
            {
                banFrame.Parent.RemoveChild(banFrame);
                CreateBanFrame(banFrame.Parent);
            }

            return(true);
        }
Ejemplo n.º 9
0
        private void RemoveBan(BannedPlayer banned)
        {
            load();

            BannedPlayer removetarget;

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

            while ((removetarget = bannedPlayers.Find(x => banned.IP.Equals(x.IP) && banned.Name.Equals(x.Name) && banned.Reason.Equals(x.Reason) && banned.ExpirationTime.Equals(x.ExpirationTime))) != null)
            {
                //remove all specific bans that are now covered by the rangeban
                bannedPlayers.Remove(removetarget);
            }

            bannedPlayers.Remove(banned);

            Save();
        }
Ejemplo n.º 10
0
        public bool ServerAdminRead(IReadMessage incMsg, Client c)
        {
            if (!c.HasPermission(ClientPermissions.Ban))
            {
                UInt16 removeCount = incMsg.ReadUInt16();
                incMsg.BitPosition += removeCount * 4 * 8;
                UInt16 rangeBanCount = incMsg.ReadUInt16();
                incMsg.BitPosition += rangeBanCount * 4 * 8;
                return(false);
            }
            else
            {
                UInt16 removeCount = incMsg.ReadUInt16();
                for (int i = 0; i < removeCount; i++)
                {
                    UInt16       id           = incMsg.ReadUInt16();
                    BannedPlayer bannedPlayer = bannedPlayers.Find(p => p.UniqueIdentifier == id);
                    if (bannedPlayer != null)
                    {
                        GameServer.Log(GameServer.ClientLogName(c) + " unbanned " + bannedPlayer.Name + " (" + bannedPlayer.EndPoint + ")", ServerLog.MessageType.ConsoleUsage);
                        RemoveBan(bannedPlayer);
                    }
                }
                Int16 rangeBanCount = incMsg.ReadInt16();
                for (int i = 0; i < rangeBanCount; i++)
                {
                    UInt16       id           = incMsg.ReadUInt16();
                    BannedPlayer bannedPlayer = bannedPlayers.Find(p => p.UniqueIdentifier == id);
                    if (bannedPlayer != null)
                    {
                        GameServer.Log(GameServer.ClientLogName(c) + " rangebanned " + bannedPlayer.Name + " (" + bannedPlayer.EndPoint + ")", ServerLog.MessageType.ConsoleUsage);
                        RangeBan(bannedPlayer);
                    }
                }

                return(removeCount > 0 || rangeBanCount > 0);
            }
        }
Ejemplo n.º 11
0
        private bool RemoveBan(GUIButton button, object obj)
        {
            BannedPlayer banned = obj as BannedPlayer;

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

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

            bannedPlayers.Remove(banned);

            Save();

            if (banFrame != null)
            {
                banFrame.Parent.RemoveChild(banFrame);
                CreateBanFrame(banFrame.Parent);
            }

            return(true);
        }