예제 #1
0
        public VerifyIpResult VerifyIpAddress(string ipAddress, Guid?brandId = null)
        {
            var result = new VerifyIpResult();

            if (IsLocalhost(ipAddress))
            {
                result.Allowed = true;
                return(result);
            }

            if (!IsIpAddressValid(ipAddress))
            {
                result.Allowed = false;
                return(result);
            }

            var ipRegulation =
                Repository.BrandIpRegulations.ToList().FirstOrDefault(
                    ip =>
                    IsRangesIntersects(ip.IpAddress, ipAddress));

            result.Allowed = !(ipRegulation != null && (!brandId.HasValue || ipRegulation.BrandId == brandId.Value));

            if (result.Allowed)
            {
                return(result);
            }

            result.BlockingType   = ipRegulation.BlockingType;
            result.RedirectionUrl = ipRegulation.RedirectionUrl;

            return(result);
        }
예제 #2
0
 public VerifyIpResponse(VerifyIpResult result)
 {
     Allowed        = result.Allowed;
     BlockingType   = result.BlockingType;
     RedirectionUrl = result.RedirectionUrl;
 }