Exemple #1
0
            /// <summary>
            /// Compare this object to another object
            /// </summary>
            /// <param name="obj">Object to compare to</param>
            /// <returns>True if the other object is equal to this object</returns>
            public override bool Equals(object obj)
            {
                if (obj == null || !(obj is IPBanEntry))
                {
                    return(false);
                }
                IPBanEntry e = (IPBanEntry)obj;

                return(e.Address == Address && e.NetMask == NetMask && e.IsEmpty == IsEmpty);
            }
Exemple #2
0
        /// <summary>
        /// Remove a ban entry from the list (if a matching entry is found)
        /// </summary>
        /// <param name="address">Address of the entry to remove</param>
        /// <param name="mask">Netmask of the entry to remove</param>
        public void RemoveBan(string address, string mask)
        {
            if (address.ToLower() == "all")
            {
                lock (banListLock)
                {
                    banList.Clear();
                    Save();
                    MasterServer.LogMessage("IP ban list cleared");
                }
            }
            else
            {
                IPAddress parsedAddress;
                IPAddress parsedMask = CIDRToMask(ref address, mask);

                if (IPAddress.TryParse(address, out parsedAddress))
                {
                    IPBanEntry existingEntry = FindBan(parsedAddress, parsedMask);

                    if (existingEntry.IsEmpty)
                    {
                        MasterServer.LogMessage("Add ban failed, the specified ban was not found.");
                        return;
                    }
                    else
                    {
                        lock (banListLock)
                        {
                            banList.Remove(existingEntry);
                            MasterServer.LogMessage("{0}/{1} removed from ban list.", parsedAddress, parsedMask);
                            Save();
                        }
                    }
                }
                else
                {
                    MasterServer.LogMessage("Invalid address specified.");
                }
            }
        }