public bool ContainsIp(List<string> ipRules, string clientIp)
        {
            var ip = ParseIp(clientIp);
            if (ipRules != null && ipRules.Any())
            {
                foreach (var rule in ipRules)
                {
                    var range = new IPAddressRange(rule);
                    if (range.Contains(ip))
                    {
                        return true;
                    }
                }
            }

            return false;
        }
Beispiel #2
0
        private bool ContainsIp(List<string> ipRules, string clientIp, out string rule)
        {
            rule = null;
            IPAddress ip = null;
            if (IPAddress.TryParse(clientIp, out ip))
                if (ipRules != null && ipRules.Any())
                {
                    foreach (var r in ipRules)
                    {
                        var range = new IPAddressRange(r);
                        if (range.Contains(ip))
                        {
                            rule = r;
                            return true;
                        }
                    }
                }

            return false;
        }