Add IP origin enrichment with DB-IP and world map
Build and deploy / build (push) Successful in 1m46s
Build and deploy / deploy (push) Successful in 22s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
TomandClaude Opus 5.5 committed 2026-11-14 15:44:33 +01:00
1 parent 536aee1f31
commit 3671019e60
47 files changed
+1389 -12

No files matched your search

@@ -0,0 +1,35 @@
using System.Net;
using Flypaper.Core.Models;
using MaxMind.GeoIP2;
using MaxMind.GeoIP2.Responses;
namespace Flypaper.GeoIp;
internal sealed class MaxMindGeoIpDatabase(DatabaseReader? city, DatabaseReader? asn) : IGeoIpDatabase
{
public IpOrigin? Find(IPAddress address)
{
CityResponse? cityResponse = null;
AsnResponse? asnResponse = null;
city?.TryCity(address, out cityResponse);
asn?.TryAsn(address, out asnResponse);
if (cityResponse is null && asnResponse is null)
{
return null;
}
return new IpOrigin(
cityResponse?.Country.IsoCode,
cityResponse?.Country.Name,
cityResponse?.City.Name,
asnResponse?.AutonomousSystemNumber,
asnResponse?.AutonomousSystemOrganization);
}
public void Dispose()
{
city?.Dispose();
asn?.Dispose();
}
}