Exemple #1
0
        /// <summary>
        /// Blocks the IP address.
        /// If the IP address in grant list it will be removed from the grant list.
        /// </summary>
        public void Block(string ip)
        {
            lock (GrantList)
                GrantList.Remove(ip);

            lock (BlockList)
                BlockList.Add(ip);
        }
Exemple #2
0
        /// <summary>
        /// Checks if the IP address is granted.
        /// If granted returns true, otherwise returns false.
        /// </summary>
        public bool EntryAuthority(string ip)
        {
            if (!Enabled)
            {
                return(true);
            }

            switch (Type)
            {
            case FirewallType.AllowOnlyGrantList:
                return(GrantList.Any(x => x == ip));

            case FirewallType.BlockOnlyBlockList:
                if (BlockList.Any(x => x == ip))
                {
                    return(false);
                }

                return(true);

            default:
                return(false);
            }
        }