Exemplo n.º 1
0
        /// <summary>
        /// 新增
        /// </summary>
        public static void Freeze(IAppSession session)
        {
            var info = _storage.Get(GetId(session));

            if (info != null)
            {
                _storage.Remove(info.Id);
            }
            else
            {
                info = new BlackInfo
                {
                    Id             = GetId(session),
                    RemoteEndPoint = session.RemoteEndPoint.ToString().Split(':')[0],
                    LocalEndPoint  = session.LocalEndPoint.ToString().Split(':')[0],
                    UnfreezeTime   = DateTime.Now,
                    FfreezeTimes   = 0
                }
            };

            info.FfreezeTimes += 1;
            info.UnfreezeTime.AddMinutes(5 * info.FfreezeTimes);
            _storage.Add(info);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 验证
 /// </summary>
 /// <returns>是否处于冻结中</returns>
 public static bool Verification(IAppSession session, out BlackInfo info)
 {
     info = _storage.Get(GetId(session));
     return(info == null || info.UnfreezeTime > DateTime.Now);
 }