Class SimpleDosDefender
Class that represents a simple DoS defender that will block addresses but not unblock them (until the application is restarted, since state is not persisted). This is helpful only with high connection attempt counts.
Inheritance
Inherited Members
Namespace: Fibula.Security
Assembly: Fibula.Security.dll
Syntax
public class SimpleDosDefender : IDoSDefender, IHostedService
Constructors
| Improve this Doc View SourceSimpleDosDefender(IOptions<SimpleDosDefenderOptions>)
Initializes a new instance of the SimpleDosDefender class.
Declaration
public SimpleDosDefender(IOptions<SimpleDosDefenderOptions> options)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.Options.IOptions<SimpleDosDefenderOptions> | options | The options for this defender. |
Properties
| Improve this Doc View SourceOptions
Gets the options set for this defender.
Declaration
public SimpleDosDefenderOptions Options { get; }
Property Value
Type | Description |
---|---|
SimpleDosDefenderOptions |
Methods
| Improve this Doc View SourceBlockAddress(String)
Blocks a given address.
Declaration
public void BlockAddress(string addressStr)
Parameters
Type | Name | Description |
---|---|---|
System.String | addressStr | The address to block. |
IsBlocked(String)
Checks if a given address is blocked.
Declaration
public bool IsBlocked(string addressStr)
Parameters
Type | Name | Description |
---|---|---|
System.String | addressStr | The address to check for. |
Returns
Type | Description |
---|---|
System.Boolean | True if the address is blocked, false otherwise. |
LogConnectionAttempt(String)
Logs a connection attempt.
Declaration
public void LogConnectionAttempt(string addressStr)
Parameters
Type | Name | Description |
---|---|---|
System.String | addressStr | The address from which the connection attempt took place. |
StartAsync(CancellationToken)
Starts the defender service.
Declaration
public Task StartAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | cancellationToken | A token to observe for cancellation. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the result of the asynchronous operation. |
StopAsync(CancellationToken)
Stops the defender service.
Declaration
public Task StopAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | cancellationToken | A token to observe for cancellation. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the asynchronous operation. |