Beispiel #1
0
        private bool IsClientDeniedAtThisSessionBefore(string clientIp)
        {
            bool   denied = false;
            string key    = Edi.MakeUniqueCacheKey("EDI_DENYLIST");

            HashSet <string> denyHashlist = null;

            lock (lck)
            {
                if (!CacheManager.TryGetCachedResult <HashSet <string> >(
                        key,
                        out denyHashlist)
                    )
                {
                    return(false);
                }
            }

            denied = denyHashlist.Contains(clientIp);

            denyHashlist.Clear();
            denyHashlist = null;

            return(denied);
        }
Beispiel #2
0
        private void CacheDeniedClient(string clientIp)
        {
            string key = Edi.MakeUniqueCacheKey("EDI_DENYLIST");

            HashSet <string> denyHashlist = null;

            lock (lck)
            {
                if (!CacheManager.TryGetCachedResult <HashSet <string> >(
                        key,
                        out denyHashlist)
                    )
                {
                    denyHashlist = new HashSet <string>();
                }


                if (!denyHashlist.Contains(clientIp))
                {
                    denyHashlist.Add(clientIp);
                    CacheManager.CacheObject(key, denyHashlist, TimeSpan.FromHours(3));
                }
            }

            denyHashlist.Clear();
            denyHashlist = null;
        }
Beispiel #3
0
        public bool WipeClientInfos()
        {
            CacheManager.Remove(Edi.MakeUniqueCacheKey("EDI_DENYLIST"));

            SqlServerIo sql = SqlServerIo.Create();

            if (!sql.Ready)
            {
                return(false);
            }

            if (!sql.Execute(true, "DELETE FROM ClientState;"))
            {
                SqlServerIo.Release(sql);
                return(false);
            }

            SqlServerIo.Release(sql);
            return(true);
        }