public virtual void AddIpFailure(string IP) { if (!IPFailure.ContainsKey(IP)) { var list = new List <DateTime>(); list.Add(DateTime.Now); IPFailure[IP] = list; } else { var list = IPFailure[IP]; list.Add(DateTime.Now); } }
public virtual bool IsIpBlocked(string IP) { if (IPFailure.ContainsKey(IP)) { var items = IPFailure[IP]; items.RemoveAll(o => o < DateTime.Now.AddHours(-4)); if (items.Count > MaxFailure) { return(true); } } return(false); }
public void AddLoginOK(string username, string ip) { if (ip != null) { if (IPFailure.ContainsKey(ip)) { IPFailure.Remove(ip); } } if (username != null) { var userid = Lib.Security.Hash.ComputeGuidIgnoreCase(username); UserNameFailure.Remove(userid); } }