コード例 #1
0
        public static bool ContainsIp(string rule, string clientIp)
        {
            var ip = ParseIp(clientIp);

            var range = new IpAddressRange(rule);

            if (range.Contains(ip))
            {
                return(true);
            }

            return(false);
        }
コード例 #2
0
        public static 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);
        }
コード例 #3
0
        public static bool ContainsIp(List<string> ipRules, string clientIp, out string rule)
        {
            rule = null;
            var ip = ParseIp(clientIp);

            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;
        }