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

@@ -16,6 +16,23 @@ public sealed class DashboardQueries(IDbContextFactory<FlypaperDbContext> dbCont
var catches = events.Where(e => e.Outcome != TrapOutcome.Rejected);
var since = timeProvider.GetUtcNow().UtcDateTime.AddHours(-24);
var countries = await catches
.Where(e => e.CountryCode != null)
.GroupBy(e => e.CountryCode!)
.Select(g => new { g.Key, Count = g.Count(), DurationMs = g.Sum(e => e.DurationMs), Name = g.Max(e => e.Country) })
.OrderByDescending(x => x.Count)
.ThenByDescending(x => x.DurationMs)
.ToListAsync(ct);
var providers = await catches
.Where(e => e.Asn != null)
.GroupBy(e => e.Asn!.Value)
.Select(g => new { g.Key, Count = g.Count(), DurationMs = g.Sum(e => e.DurationMs), Name = g.Max(e => e.Provider) })
.OrderByDescending(x => x.Count)
.ThenByDescending(x => x.DurationMs)
.Take(TopCount)
.ToListAsync(ct);
return new DashboardData(
await catches.CountAsync(ct),
await catches.CountAsync(e => e.StartedAt >= since, ct),
@@ -24,7 +41,15 @@ public sealed class DashboardQueries(IDbContextFactory<FlypaperDbContext> dbCont
TimeSpan.FromMilliseconds(await catches.SumAsync(e => e.DurationMs, ct)),
await events.OrderByDescending(e => e.Id).Take(RecentCount).ToListAsync(ct),
await TopAsync(catches.GroupBy(e => e.RemoteIp), ct),
await TopAsync(catches.Where(e => e.Target != null).GroupBy(e => e.Target!), ct));
await TopAsync(catches.Where(e => e.Target != null).GroupBy(e => e.Target!), ct),
countries
.Take(TopCount)
.Select(x => new TopEntry(x.Key, x.Count, TimeSpan.FromMilliseconds(x.DurationMs), x.Name))
.ToList(),
providers
.Select(x => new TopEntry($"AS{x.Key}", x.Count, TimeSpan.FromMilliseconds(x.DurationMs), x.Name))
.ToList(),
countries.ToDictionary(x => x.Key, x => x.Count, StringComparer.OrdinalIgnoreCase));
}
private static async Task<IReadOnlyList<TopEntry>> TopAsync(