コード例 #1
0
        public static bool Match(int[] bytes, int[] matchBytes)
        {
            for (int index = 0; index < matchBytes.Length; ++index)
            {
                if (!BanMgr.Matches(bytes[index], matchBytes[index]))
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #2
0
        /// <summary>
        /// Returnes whether the given bytes either match the Localhost address
        /// or only consist of wildcards or zeros.
        /// </summary>
        /// <param name="bytes"></param>
        /// <returns></returns>
        public static bool IsInvalid(int[] bytes)
        {
            if (BanMgr.Match(BanMgr.LocalHostBytes, bytes))
            {
                return(true);
            }
            int num1 = -2;

            foreach (int num2 in bytes)
            {
                if (num2 < -1)
                {
                    return(true);
                }
                if (num2 != -1 && num2 != 0 || num1 != -2 && num2 != num1)
                {
                    return(false);
                }
                num1 = num2;
            }

            return(true);
        }
コード例 #3
0
        public static List <BanEntry> GetBanList(string mask)
        {
            BanMgr.Lock.EnterReadLock();
            try
            {
                List <BanEntry> banEntryList = new List <BanEntry>();
                int[]           bytes        = BanMgr.GetBytes(mask);
                for (int index = 0; index < BanMgr.m_bans.Count; ++index)
                {
                    BanEntry ban = BanMgr.m_bans[index];
                    if (ban.Matches(bytes))
                    {
                        banEntryList.Add(ban);
                    }
                }

                return(banEntryList);
            }
            finally
            {
                BanMgr.Lock.ExitReadLock();
            }
        }
コード例 #4
0
 public static bool IsBanned(long ip)
 {
     return(BanMgr.IsBanned(new IPAddress(ip)));
 }