package model import "time" type DecisionAction string const ( DecisionActionNone DecisionAction = "none" DecisionActionReview DecisionAction = "review" DecisionActionBlock DecisionAction = "block" DecisionActionAllow DecisionAction = "allow" ) type ManualOverride string const ( ManualOverrideNone ManualOverride = "none" ManualOverrideForceAllow ManualOverride = "force_allow" ManualOverrideForceBlock ManualOverride = "force_block" ) type IPStateStatus string const ( IPStateObserved IPStateStatus = "observed" IPStateReview IPStateStatus = "review" IPStateBlocked IPStateStatus = "blocked" IPStateAllowed IPStateStatus = "allowed" ) type AccessLogRecord struct { OccurredAt time.Time RemoteIP string ClientIP string Host string Method string URI string Path string Status int UserAgent string RawJSON string } type Decision struct { Action DecisionAction Reasons []string } func (d Decision) PrimaryReason() string { if len(d.Reasons) == 0 { return "" } return d.Reasons[0] } 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"` } type IPState struct { IP string `json:"ip"` FirstSeenAt time.Time `json:"first_seen_at"` LastSeenAt time.Time `json:"last_seen_at"` LastSourceName string `json:"last_source_name"` LastUserAgent string `json:"last_user_agent"` LatestStatus int `json:"latest_status"` TotalEvents int64 `json:"total_events"` State IPStateStatus `json:"state"` StateReason string `json:"state_reason"` ManualOverride ManualOverride `json:"manual_override"` LastEventID int64 `json:"last_event_id"` UpdatedAt time.Time `json:"updated_at"` } type DecisionRecord struct { ID int64 `json:"id"` EventID int64 `json:"event_id"` IP string `json:"ip"` SourceName string `json:"source_name"` Kind string `json:"kind"` Action DecisionAction `json:"action"` Reason string `json:"reason"` Actor string `json:"actor"` Enforced bool `json:"enforced"` CreatedAt time.Time `json:"created_at"` } type OPNsenseAction struct { ID int64 `json:"id"` IP string `json:"ip"` Action string `json:"action"` Result string `json:"result"` Message string `json:"message"` CreatedAt time.Time `json:"created_at"` } type BotMatch struct { ProviderID string `json:"provider_id"` Name string `json:"name"` Icon string `json:"icon"` Method string `json:"method"` Verified bool `json:"verified"` } type ReverseDNSInfo struct { PTR string `json:"ptr"` ForwardConfirmed bool `json:"forward_confirmed"` } type RegistrationInfo struct { Source string `json:"source"` Handle string `json:"handle"` Name string `json:"name"` Prefix string `json:"prefix"` Organization string `json:"organization"` Country string `json:"country"` AbuseEmail string `json:"abuse_email"` } type ReputationInfo struct { SpamhausLookup string `json:"spamhaus_lookup"` SpamhausListed bool `json:"spamhaus_listed"` SpamhausCodes []string `json:"spamhaus_codes,omitempty"` Error string `json:"error,omitempty"` } type IPInvestigation struct { IP string `json:"ip"` UpdatedAt time.Time `json:"updated_at"` Error string `json:"error,omitempty"` Bot *BotMatch `json:"bot,omitempty"` ReverseDNS *ReverseDNSInfo `json:"reverse_dns,omitempty"` Registration *RegistrationInfo `json:"registration,omitempty"` Reputation *ReputationInfo `json:"reputation,omitempty"` } type OPNsenseStatus struct { Configured bool `json:"configured"` Present bool `json:"present"` CheckedAt time.Time `json:"checked_at,omitempty"` Error string `json:"error,omitempty"` } type ActionAvailability struct { CanBlock bool `json:"can_block"` CanUnblock bool `json:"can_unblock"` CanClearOverride bool `json:"can_clear_override"` } type RecentIPRow struct { IP string `json:"ip"` SourceName string `json:"source_name"` State IPStateStatus `json:"state"` Events int64 `json:"events"` LastSeenAt time.Time `json:"last_seen_at"` Reason string `json:"reason"` ManualOverride ManualOverride `json:"manual_override"` Bot *BotMatch `json:"bot,omitempty"` Actions ActionAvailability `json:"actions"` } type SourceOffset struct { SourceName string Path string Inode string Offset int64 UpdatedAt time.Time } type IPDetails struct { State IPState `json:"state"` RecentEvents []Event `json:"recent_events"` Decisions []DecisionRecord `json:"decisions"` BackendActions []OPNsenseAction `json:"backend_actions"` Investigation *IPInvestigation `json:"investigation,omitempty"` OPNsense OPNsenseStatus `json:"opnsense"` Actions ActionAvailability `json:"actions"` } 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"` RecentIPs []IPState `json:"recent_ips"` RecentEvents []Event `json:"recent_events"` }