Example #1
0
 public RedisCacheIpPolicyStore(
     IConnectionMultiplexer redis,
     IOptions <IpRateLimitOptions> options   = null,
     IOptions <IpRateLimitPolicies> policies = null) : base(redis)
 {
     _options  = options?.Value;
     _policies = policies?.Value;
 }
 public DistributedCacheIpPolicyStore(
     IDistributedCache cache,
     IOptions <IpRateLimitOptions> options   = null,
     IOptions <IpRateLimitPolicies> policies = null) : base(cache)
 {
     _options  = options?.Value;
     _policies = policies?.Value;
 }
 public MemoryCacheIpPolicyStore(
     IMemoryCache cache,
     IOptions <IpRateLimitOptions> options   = null,
     IOptions <IpRateLimitPolicies> policies = null) : base(cache)
 {
     _options  = options?.Value;
     _policies = policies?.Value;
 }
Example #4
0
 public IpRateLimitProcessor(
     IpRateLimitOptions options,
     IRateLimitCounterStore counterStore,
     IIpPolicyStore policyStore,
     IRateLimitConfiguration config)
     : base(options, counterStore, new IpCounterKeyBuilder(options), config)
 {
     _options     = options;
     _policyStore = policyStore;
 }
Example #5
0
 public IpRateLimitProcessor(
     IpRateLimitOptions options,
     IIpPolicyStore policyStore,
     IProcessingStrategy processingStrategy)
     : base(options)
 {
     _options            = options;
     _policyStore        = policyStore;
     _counterKeyBuilder  = new IpCounterKeyBuilder(options);
     _processingStrategy = processingStrategy;
 }
 public IpRateLimitMiddleware(RequestDelegate next,
                              IOptions <IpRateLimitOptions> options,
                              IRateLimitCounterStore counterStore,
                              IIpPolicyStore policyStore,
                              ILogger <IpRateLimitMiddleware> logger)
 {
     _next      = next;
     _options   = options.Value;
     _logger    = logger;
     _processor = new IpRateLimitProcessor(_options, counterStore, policyStore);
 }
Example #7
0
        public IpRateLimitProcessor(IpRateLimitOptions options,
                                    IRateLimitCounterStore counterStore,
                                    IIpPolicyStore policyStore,
                                    IIpAddressParser ipParser)
        {
            _options      = options;
            _counterStore = counterStore;
            _policyStore  = policyStore;
            _ipParser     = ipParser;

            _core = new RateLimitCore(true, options, _counterStore);
        }
        public IpRateLimitMiddleware(RequestDelegate next,
                                     IOptions <IpRateLimitOptions> options,
                                     IRateLimitCounterStore counterStore,
                                     IIpPolicyStore policyStore,
                                     ILogger <IpRateLimitMiddleware> logger,
                                     IIpAddressParser ipParser = null)
        {
            _next     = next;
            _options  = options.Value;
            _logger   = logger;
            _ipParser = ipParser ?? new ReversProxyIpParser(_options.RealIpHeader);

            _processor = new IpRateLimitProcessor(_options, counterStore, policyStore, _ipParser);
        }