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); }
public VerifyIpResponse(VerifyIpResult result) { Allowed = result.Allowed; BlockingType = result.BlockingType; RedirectionUrl = result.RedirectionUrl; }