예제 #1
0
        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);
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
            }
        }