/// <summary> Removes a given IP address from the ban list (if present). </summary> /// <param name="address"> Address to unban. </param> /// <param name="raiseEvents"> Whether to raise RemovingIPBan and RemovedIPBan events. </param> /// <returns> True if IP was unbanned. /// False if it was not banned in the first place, or if it was canceled by an event callback. </returns> public static bool Remove([NotNull] IPAddress address, bool raiseEvents) { if (address == null) { throw new ArgumentNullException("address"); } lock ( BanListLock ) { if (!Bans.ContainsKey(address.ToString())) { return(false); } IPBanInfo info = Bans[address.ToString()]; if (raiseEvents) { if (!RaiseRemovingIPBanEvent(info)) { return(false); } } if (Bans.Remove(address.ToString())) { if (raiseEvents) { RemovedIPBanEvent.Raise(new IPBanEventArgs(info)); } Save(); return(true); } else { return(false); } } }
public static void RemovedIPBanPriority([NotNull] EventHandler <IPBanEventArgs> callback, Priority priority) { if (callback == null) { throw new ArgumentNullException("callback"); } RemovedIPBanEvent.Add(callback, priority); }