Dynamic rate limit plugin

This commit is contained in:
Kukks
2023-04-05 18:35:32 +02:00
parent f2f18c3634
commit a90b1e7805
9 changed files with 352 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
using BTCPayServer.Abstractions.Contracts;
using BTCPayServer.Abstractions.Models;
using BTCPayServer.Abstractions.Services;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace BTCPayServer.Plugins.DynamicRateLimits;
public class DynamicRateLimitsPlugin : BaseBTCPayServerPlugin
{
public override IBTCPayServerPlugin.PluginDependency[] Dependencies { get; } =
{
new() { Identifier = nameof(BTCPayServer), Condition = ">=1.8.0" }
};
public override void Execute(IServiceCollection applicationBuilder)
{
applicationBuilder.AddSingleton<DynamicRateLimitsService>();
applicationBuilder.AddSingleton<IHostedService>(provider => provider.GetRequiredService<DynamicRateLimitsService>());
applicationBuilder.AddSingleton<IUIExtension>(new UIExtension("DynamicRateLimitsPlugin/Nav",
"server-nav"));
base.Execute(applicationBuilder);
}
}