Example #1
0
        public bool AddPermBannedIP(IDatabaseContext db, IPRule ipRule)
        {
            if (ipRule == null)
            {
                throw new ArgumentNullException(nameof(ipRule));
            }

            lock (lockStr) {
                if (permBannedIPs.Contains(ipRule.Address))
                {
                    return(false);
                }

                db.Save(ipRule);

                permBannedIPs.Add(ipRule.Address);
                return(true);
            }
        }
Example #2
0
 /// <summary>
 /// Tests whether a host address is allowed.
 /// Both permanent and temporary rules are checked.
 /// </summary>
 /// <param name="hostAddress">Host address (IP).</param>
 /// <returns>True if the host is allowed access (not banned).</returns>
 public bool IsAllowed(string hostAddress)
 {
     return(!permBannedIPs.Contains(hostAddress) && !tempBannedIPs.Contains(hostAddress));
 }