You've already forked caddy-opnsense-blocker
Add on-demand IP investigation and richer IP details
This commit is contained in:
@@ -113,4 +113,20 @@ func TestStoreRecordsEventsAndState(t *testing.T) {
|
||||
if len(details.RecentEvents) != 1 || len(details.Decisions) != 1 || len(details.BackendActions) != 1 {
|
||||
t.Fatalf("unexpected ip details: %+v", details)
|
||||
}
|
||||
|
||||
investigation := model.IPInvestigation{
|
||||
IP: event.ClientIP,
|
||||
UpdatedAt: occurredAt,
|
||||
Bot: &model.BotMatch{Name: "Googlebot", ProviderID: "google_official", Icon: "🤖", Method: "published_ranges", Verified: true},
|
||||
}
|
||||
if err := db.SaveInvestigation(ctx, investigation); err != nil {
|
||||
t.Fatalf("save investigation: %v", err)
|
||||
}
|
||||
loadedInvestigation, found, err := db.GetInvestigation(ctx, event.ClientIP)
|
||||
if err != nil {
|
||||
t.Fatalf("get investigation: %v", err)
|
||||
}
|
||||
if !found || loadedInvestigation.Bot == nil || loadedInvestigation.Bot.Name != "Googlebot" {
|
||||
t.Fatalf("unexpected investigation payload: found=%v investigation=%+v", found, loadedInvestigation)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user