reports

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2026 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ReportsDir    string // Output directory for reports
	HistoryDir    string // Input: stats history directory
	BansLogPath   string // Input: bans.log path
	RetentionDays int    // Days to keep reports
	TopN          int    // Number of items in top lists (default 10)
}

Config holds report generator configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns default configuration

type DailySummary

type DailySummary struct {
	Date        string    `json:"date"` // YYYY-MM-DD
	Host        string    `json:"host"`
	GeneratedAt time.Time `json:"generated_at"`

	Totals struct {
		BansAdded      int `json:"bans_added"`
		BansRemoved    int `json:"bans_removed"`
		BansActiveEnd  int `json:"bans_active_end"`
		WhitelistCount int `json:"whitelist_count"`
	} `json:"totals"`

	BansBySource  map[string]int `json:"bans_by_source"`  // loginmon, portscan, ddos, suricata, feeds, manual
	BansByCountry map[string]int `json:"bans_by_country"` // RU, CN, US, etc.

	Feeds map[string]FeedState `json:"feeds"`

	Watchdog struct {
		PressureMax map[string]float64 `json:"pressure_max"` // cpu, memory, io
		ModeChanges int                `json:"mode_changes"`
	} `json:"watchdog"`

	Health struct {
		UptimePercent float64 `json:"uptime_percent"`
		ErrorsCount   int     `json:"errors_count"`
	} `json:"health"`
}

DailySummary contains aggregated metrics for one day

type DailyTop

type DailyTop struct {
	Date string `json:"date"` // YYYY-MM-DD

	TopBannedIPs  []TopIP        `json:"top_banned_ips"`
	TopCountries  []TopCountry   `json:"top_countries"`
	TopSources    []TopSource    `json:"top_sources"`
	RecidivistIPs []RecidivistIP `json:"recidivist_ips"`
}

DailyTop contains top lists for one day

type FeedState

type FeedState struct {
	IPsLoaded int   `json:"ips_loaded"`
	LastSync  int64 `json:"last_sync"` // Unix timestamp
}

FeedState represents feed status at time of report

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

Generator creates daily reports

func NewGenerator

func NewGenerator(config *Config) *Generator

NewGenerator creates a new report generator

func (*Generator) Cleanup

func (g *Generator) Cleanup() error

Cleanup removes reports older than retention days

func (*Generator) GenerateDaily

func (g *Generator) GenerateDaily(date string) error

GenerateDaily generates summary and top reports for a specific date

type IndexEntry

type IndexEntry struct {
	Date       string `json:"date"`
	Bans       int    `json:"bans"`
	Unbans     int    `json:"unbans"`
	Active     int    `json:"active"`
	TopCountry string `json:"top_country"`
	TopSource  string `json:"top_source"`
}

IndexEntry is one line in reports/index.jsonl for fast search

type RecidivistIP

type RecidivistIP struct {
	IP        string `json:"ip"`
	BanCount  int    `json:"ban_count"`
	FirstSeen string `json:"first_seen"` // YYYY-MM-DD
	LastSeen  string `json:"last_seen"`  // YYYY-MM-DD
}

RecidivistIP represents an IP banned multiple times

type TopCountry

type TopCountry struct {
	Country    string  `json:"country"`
	Bans       int     `json:"bans"`
	Percentage float64 `json:"percentage"`
}

TopCountry represents country ban statistics

type TopIP

type TopIP struct {
	IP      string   `json:"ip"`
	Count   int      `json:"count"`
	Country string   `json:"country"`
	Sources []string `json:"sources"`
}

TopIP represents a frequently banned IP

type TopSource

type TopSource struct {
	Source     string  `json:"source"`
	Bans       int     `json:"bans"`
	Percentage float64 `json:"percentage"`
}

TopSource represents ban source statistics

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL