Kenc.AbuseIPDB
1.0.13
See the version list below for details.
dotnet add package Kenc.AbuseIPDB --version 1.0.13
NuGet\Install-Package Kenc.AbuseIPDB -Version 1.0.13
<PackageReference Include="Kenc.AbuseIPDB" Version="1.0.13" />
paket add Kenc.AbuseIPDB --version 1.0.13
#r "nuget: Kenc.AbuseIPDB, 1.0.13"
// Install Kenc.AbuseIPDB as a Cake Addin #addin nuget:?package=Kenc.AbuseIPDB&version=1.0.13 // Install Kenc.AbuseIPDB as a Cake Tool #tool nuget:?package=Kenc.AbuseIPDB&version=1.0.13
About
Kenc.AbuseIPDB is a fully featured client for connecting with the AbuseIPDB.com API v2.
How to use
Kenc.AbuseIPDb is built with dependency-injection as a first-class-citizen. As a result, there's a helper function to register the library including pointing to the configuration section, if IConfiguration is being utilized.
Configuration:
"AbuseIPDB": {
"APIEndpoint": "https://api.abuseipdb.com/api/v2/",
"APIKey": "<apikey>"
}
API key should be loaded from a secure storage, such as keyvault to prevent leaks.
services.AddAbuseIPDBClient(Configuration.GetSection("AbuseIPDB"));
...
public HomeController(ILogger<BlogController> logger, IAbuseIPDBClient abuseIPDBClient, IHttpContextAccessor httpContextAccessor)
To lookup the requester IP of a request in ASP.net and reject IPs with an abuse confidence score of 70 or higher:
var ip = httpContextAccessor.HttpContext.Features.Get<IHttpConnectionFeature>()?.RemoteIpAddress;
try
{
// skip for local loopback
if (!IPAddress.IsLoopback(ip))
{
var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30));
(Check abuseCheck, _) = await abuseIPDBClient.CheckAsync(ip.ToString(), 90, false, cancellationTokenSource.Token);
if (abuseCheck.AbuseConfidenceScore > 70)
{
var error = new ErrorModel
{
Title = "Bad Request.",
Detail = "User IP is blocked due to abuse.",
Instance = $"/action/{Activity.Current?.Id ?? httpContextAccessor.HttpContext.TraceIdentifier}",
Status = 400,
Type = "/action/abusiveip"
};
// return a 400 with the error information
return Unauthorized(error);
}
}
}
catch (OperationCanceledException)
{
// request timed out.
}
catch (ApiException abuseIPException)
{
// abuse ip db threw an exception
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Microsoft.Extensions.Configuration.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Http (>= 6.0.0)
- Microsoft.Extensions.Options (>= 6.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 6.0.0)
- System.Net.Http.Json (>= 6.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Kenc.AbuseIPDB:
Package | Downloads |
---|---|
Kenc.AbuseIPDB.Cache
Cache for Kenc.AbuseIPDB based on LazyCache. |
GitHub repositories
This package is not used by any popular GitHub repositories.