コード例 #1
0
 public RedisProcessingStrategy(IConnectionMultiplexer connectionMultiplexer, IRateLimitConfiguration config, ILogger <RedisProcessingStrategy> logger)
     : base(config)
 {
     _connectionMultiplexer = connectionMultiplexer ?? throw new ArgumentException("IConnectionMultiplexer was null. Ensure StackExchange.Redis was successfully registered");
     _config = config;
     _logger = logger;
 }
コード例 #2
0
 protected RateLimitMiddleware(RequestDelegate next, RateLimitOptions options, TProcessor processor, IRateLimitConfiguration config)
 {
     _next      = next;
     _options   = options;
     _processor = processor;
     _config    = config;
     _config.RegisterResolvers();
 }
コード例 #3
0
ファイル: ClientRateLimitProcessor.cs プロジェクト: Poepon/JK
 public ClientRateLimitProcessor(
     ClientRateLimitOptions options,
     ICacheManager cacheManager,
     IRateLimitConfiguration config)
     : base(cacheManager, options, new ClientCounterKeyBuilder(), config)
 {
     _options = options;
 }
コード例 #4
0
 public ClientRateLimitMiddleware(RequestDelegate next,
                                  IOptions <ClientRateLimitOptions> options,
                                  ICacheManager cacheManager,
                                  IRateLimitConfiguration config,
                                  ILogger <ClientRateLimitMiddleware> logger)
     : base(next, options?.Value, new ClientRateLimitProcessor(options?.Value, cacheManager, config), config)
 {
     _logger = logger;
 }
コード例 #5
0
 public MyIpRateLimitMiddleware(RequestDelegate next
                                , IOptions <IpRateLimitOptions> options
                                , IRateLimitCounterStore counterStore
                                , IIpPolicyStore policyStore
                                , IRateLimitConfiguration config
                                , ILogger <IpRateLimitMiddleware> logger)
     : base(next, options, counterStore, policyStore, config, logger)
 {
 }
コード例 #6
0
 public ClientRateLimitMiddleware(RequestDelegate next,
                                  IRateLimitLoader Loader,
                                  IRateLimitCounterStore counterStore,
                                  IClientPolicyStore policyStore,
                                  IRateLimitConfiguration config,
                                  ILogger <ClientRateLimitMiddleware> logger)
     : base(next, Loader.GetClientRateLimitOptions(), new ClientRateLimitProcessor(Loader.GetClientRateLimitOptions(), counterStore, policyStore, config), config)
 {
     _logger = logger;
 }
コード例 #7
0
 public ClientRateLimitProcessor(
     ClientRateLimitOptions options,
     IRateLimitCounterStore counterStore,
     IClientPolicyStore policyStore,
     IRateLimitConfiguration config)
     : base(options, counterStore, new ClientCounterKeyBuilder(options), config)
 {
     _options     = options;
     _policyStore = policyStore;
 }
コード例 #8
0
 public IpRateLimitProcessor(
     IpRateLimitOptions options,
     IRateLimitCounterStore counterStore,
     IIpPolicyStore policyStore,
     IRateLimitConfiguration config)
     : base(options, counterStore, new IpCounterKeyBuilder(options), config)
 {
     _options     = options;
     _policyStore = policyStore;
 }
コード例 #9
0
 public ClientRateLimitMiddleware(RequestDelegate next,
                                  IOptions <ClientRateLimitOptions> options,
                                  IRateLimitCounterStore counterStore,
                                  IClientPolicyStore policyStore,
                                  IRateLimitConfiguration config,
                                  ILogger <ClientRateLimitMiddleware> logger)
     : base(next, options?.Value, new ClientRateLimitProcessor(options?.Value, counterStore, policyStore, config), config)
 {
     _logger = logger;
 }
コード例 #10
0
 public MyClientRateLimitMiddleware(RequestDelegate next,
                                    IOptions <ClientRateLimitOptions> options,
                                    IRateLimitCounterStore counterStore,
                                    IClientPolicyStore policyStore,
                                    IRateLimitConfiguration config,
                                    ILogger <ClientRateLimitMiddleware> logger)
     : base(next, options, counterStore, policyStore, config, logger)
 {
     _logger = logger;
 }
コード例 #11
0
 protected RateLimitProcessor(
     ICacheManager cacheManager,
     RateLimitOptions options,
     ICounterKeyBuilder counterKeyBuilder,
     IRateLimitConfiguration config)
 {
     _cacheManager      = cacheManager;
     _options           = options;
     _counterKeyBuilder = counterKeyBuilder;
     _config            = config;
 }
コード例 #12
0
 public IpRateLimitMiddleware(RequestDelegate next,
                              IProcessingStrategy processingStrategy,
                              IOptions <IpRateLimitOptions> options,
                              IIpPolicyStore policyStore,
                              IRateLimitConfiguration config,
                              ILogger <IpRateLimitMiddleware> logger
                              )
     : base(next, options?.Value, new IpRateLimitProcessor(options?.Value, policyStore, processingStrategy), config)
 {
     _logger = logger;
 }
コード例 #13
0
 public CustomRateLimitingMiddleware(RequestDelegate next,
                                     IProcessingStrategy processingStrategy,
                                     IOptions <IpRateLimitOptions> options,
                                     IRateLimitCounterStore counterStore,
                                     IIpPolicyStore policyStore,
                                     IRateLimitConfiguration config,
                                     ILogger <IpRateLimitMiddleware> logger)
     : base(next, processingStrategy, options, counterStore, policyStore, config, logger)
 {
     _rateLimitOptions = options.Value;
 }
コード例 #14
0
 protected RateLimitProcessor(
     RateLimitOptions options,
     IRateLimitCounterStore counterStore,
     ICounterKeyBuilder counterKeyBuilder,
     IRateLimitConfiguration config)
 {
     _options           = options;
     _counterStore      = counterStore;
     _counterKeyBuilder = counterKeyBuilder;
     _config            = config;
 }
コード例 #15
0
 public IpRateLimitProcessor(
     IpRateLimitOptions options,
     IRateLimitCounterStore counterStore,
     IIpPolicyStore policyStore,
     IRateLimitConfiguration config,
     IProcessingStrategy processingStrategy)
     : base(options)
 {
     _options            = options;
     _policyStore        = policyStore;
     _counterKeyBuilder  = new IpCounterKeyBuilder(options);
     _processingStrategy = processingStrategy;
 }
コード例 #16
0
        public IpRateLimitMiddleware(RequestDelegate next,
                                     IOptions <IpRateLimitOptions> options,
                                     IRateLimitCounterStore counterStore,
                                     IIpPolicyStore policyStore,
                                     IRateLimitConfiguration config,
                                     ILogger <IpRateLimitMiddleware> logger)
            : base(next, options?.Value, new IpRateLimitProcessor(options?.Value, counterStore, policyStore, config), config)

        {
            _logger        = logger;
            _ipParser      = ipParser != null ? ipParser : new ReversProxyIpParser(_options.RealIpHeader);
            _ipPolicyStore = policyStore;

            _processor = new IpRateLimitProcessor(_options, counterStore, policyStore, _ipParser);
        }
コード例 #17
0
 public CustomIpRateLimitMiddleware(
     IDistributedCache distributedCache,
     IBlockIpService blockIpService,
     RequestDelegate next,
     IProcessingStrategy processingStrategy,
     IRateLimitConfiguration rateLimitConfiguration,
     IOptions <IpRateLimitOptions> options,
     IIpPolicyStore policyStore,
     ILogger <CustomIpRateLimitMiddleware> logger)
     : base(next, processingStrategy, options, policyStore, rateLimitConfiguration, logger)
 {
     _distributedCache = distributedCache;
     _blockIpService   = blockIpService;
     _options          = options.Value;
     _logger           = logger;
 }
コード例 #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ThrottleMiddleware"/> class.
        /// </summary>
        /// <param name="next">The next.</param>
        /// <param name="options">The options.</param>
        /// <param name="counterStore">The counter store.</param>
        /// <param name="policyStore">The policy store.</param>
        /// <param name="config">The rate limit configuration.</param>
        /// <param name="logger">The logger.</param>
        /// <param name="configuration">The API configuration.</param>
        /// <param name="serializer">The JSON serializer.</param>
        /// <exception cref="ArgumentNullException">configuration</exception>
        public ThrottleMiddleware(
            RequestDelegate next,
            IOptions <IpRateLimitOptions> options,
            IRateLimitCounterStore counterStore,
            IIpPolicyStore policyStore,
            IRateLimitConfiguration config,
            ILogger <IpRateLimitMiddleware> logger,
            IApiConfiguration configuration,
            IDefaultJsonSerializer serializer)
            : base(next, options, counterStore, policyStore, config, logger)
        {
            Ensure.ArgumentNotNull(options, nameof(options));

            if (options.Value == null)
            {
                throw new UnexpectedNullException("The options value is null.");
            }

            this.options       = options.Value;
            this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
            this.serializer    = serializer ?? throw new ArgumentNullException(nameof(serializer));
        }
コード例 #19
0
 public IpRateLimitMiddleware(RequestDelegate next, IProcessingStrategy processingStrategy, Microsoft.Extensions.Options.IOptions <IpRateLimitOptions> options, IRateLimitCounterStore counterStore, IIpPolicyStore policyStore, IRateLimitConfiguration config, ILogger <IpRateLimitMiddleware> logger)
     : base(next, (RateLimitOptions)(options?.Value), new IpRateLimitProcessor(options?.Value, counterStore, policyStore, config, processingStrategy), config)
 {
     _logger = logger;
 }
コード例 #20
0
 protected ProcessingStrategy(IRateLimitConfiguration config)
 {
     _config = config;
 }
コード例 #21
0
 public AsyncKeyLockProcessingStrategy(IRateLimitCounterStore counterStore, IRateLimitConfiguration config)
     : base(config)
 {
     _counterStore = counterStore;
     _config       = config;
 }