2

Build a Pi-hole-style dashboard and query log

This commit is contained in:
2026-03-12 17:12:19 +01:00
parent b7943e69db
commit 0a14dd1df9
5 changed files with 1012 additions and 450 deletions

View File

@@ -54,26 +54,28 @@ func (d Decision) PrimaryReason() string {
}
type Event struct {
ID int64 `json:"id"`
SourceName string `json:"source_name"`
ProfileName string `json:"profile_name"`
OccurredAt time.Time `json:"occurred_at"`
RemoteIP string `json:"remote_ip"`
ClientIP string `json:"client_ip"`
Host string `json:"host"`
Method string `json:"method"`
URI string `json:"uri"`
Path string `json:"path"`
Status int `json:"status"`
UserAgent string `json:"user_agent"`
Decision DecisionAction `json:"decision"`
DecisionReason string `json:"decision_reason"`
DecisionReasons []string `json:"decision_reasons,omitempty"`
Enforced bool `json:"enforced"`
RawJSON string `json:"raw_json"`
CreatedAt time.Time `json:"created_at"`
CurrentState IPStateStatus `json:"current_state"`
ManualOverride ManualOverride `json:"manual_override"`
ID int64 `json:"id"`
SourceName string `json:"source_name"`
ProfileName string `json:"profile_name"`
OccurredAt time.Time `json:"occurred_at"`
RemoteIP string `json:"remote_ip"`
ClientIP string `json:"client_ip"`
Host string `json:"host"`
Method string `json:"method"`
URI string `json:"uri"`
Path string `json:"path"`
Status int `json:"status"`
UserAgent string `json:"user_agent"`
Decision DecisionAction `json:"decision"`
DecisionReason string `json:"decision_reason"`
DecisionReasons []string `json:"decision_reasons,omitempty"`
Enforced bool `json:"enforced"`
RawJSON string `json:"raw_json"`
CreatedAt time.Time `json:"created_at"`
CurrentState IPStateStatus `json:"current_state"`
ManualOverride ManualOverride `json:"manual_override"`
Bot *BotMatch `json:"bot,omitempty"`
Actions ActionAvailability `json:"actions"`
}
type IPState struct {
@@ -179,11 +181,11 @@ type RecentIPRow struct {
}
type TopIPRow struct {
IP string `json:"ip"`
Events int64 `json:"events"`
TrafficBytes int64 `json:"traffic_bytes"`
LastSeenAt time.Time `json:"last_seen_at"`
Bot *BotMatch `json:"bot,omitempty"`
IP string `json:"ip"`
Events int64 `json:"events"`
TrafficBytes int64 `json:"traffic_bytes"`
LastSeenAt time.Time `json:"last_seen_at"`
Bot *BotMatch `json:"bot,omitempty"`
}
type TopSourceRow struct {
@@ -201,11 +203,39 @@ type TopURLRow struct {
LastSeenAt time.Time `json:"last_seen_at"`
}
type ActivitySourceCount struct {
SourceName string `json:"source_name"`
Events int64 `json:"events"`
}
type ActivityBucket struct {
BucketStart time.Time `json:"bucket_start"`
TotalEvents int64 `json:"total_events"`
Sources []ActivitySourceCount `json:"sources,omitempty"`
}
type MethodBreakdownRow struct {
Method string `json:"method"`
Events int64 `json:"events"`
}
type BotBreakdownRow struct {
Key string `json:"key"`
Label string `json:"label"`
Events int64 `json:"events"`
}
type OverviewOptions struct {
ShowKnownBots bool
ShowAllowed bool
}
type EventListOptions struct {
ShowKnownBots bool
ShowAllowed bool
ReviewOnly bool
}
type SourceOffset struct {
SourceName string
Path string
@@ -225,17 +255,20 @@ type IPDetails struct {
}
type Overview struct {
TotalEvents int64 `json:"total_events"`
TotalIPs int64 `json:"total_ips"`
BlockedIPs int64 `json:"blocked_ips"`
ReviewIPs int64 `json:"review_ips"`
AllowedIPs int64 `json:"allowed_ips"`
ObservedIPs int64 `json:"observed_ips"`
ActivitySince time.Time `json:"activity_since,omitempty"`
TopIPsByEvents []TopIPRow `json:"top_ips_by_events"`
TopIPsByTraffic []TopIPRow `json:"top_ips_by_traffic"`
TopSources []TopSourceRow `json:"top_sources"`
TopURLs []TopURLRow `json:"top_urls"`
RecentIPs []IPState `json:"recent_ips"`
RecentEvents []Event `json:"recent_events"`
TotalEvents int64 `json:"total_events"`
TotalIPs int64 `json:"total_ips"`
BlockedIPs int64 `json:"blocked_ips"`
ReviewIPs int64 `json:"review_ips"`
AllowedIPs int64 `json:"allowed_ips"`
ObservedIPs int64 `json:"observed_ips"`
ActivitySince time.Time `json:"activity_since,omitempty"`
ActivityBuckets []ActivityBucket `json:"activity_buckets"`
Methods []MethodBreakdownRow `json:"methods"`
Bots []BotBreakdownRow `json:"bots"`
TopIPsByEvents []TopIPRow `json:"top_ips_by_events"`
TopIPsByTraffic []TopIPRow `json:"top_ips_by_traffic"`
TopSources []TopSourceRow `json:"top_sources"`
TopURLs []TopURLRow `json:"top_urls"`
RecentIPs []IPState `json:"recent_ips"`
RecentEvents []Event `json:"recent_events"`
}