public bool?TryAccessGranted()
        {
            var ipList = _repository.ReadAll().Select(x => x.IpNetwork).ToList();

            if (ipList.Any() == false)
            {
                return(null);
            }

            var requestIp = _context.HttpContext.Connection.RemoteIpAddress.MapToIPv4();

            foreach (var cidr in ipList)
            {
                if (_validatorService.IsInRange(requestIp, cidr))
                {
                    return(true);
                }
            }

            return(false);
        }
示例#2
0
 public async Task <IEnumerable <IpNetworkModel> > GetAll()
 {
     return(await Task.FromResult(_repository.ReadAll().ToModels()).ConfigureAwait(false));
 }