Help us shape the future of Go! Take the 2026 Go Developer Survey

storage

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const MaxReportLimit = 100

MaxReportLimit caps the page size GetReports callers may ask for, so one request cannot buffer the whole table into memory.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthResultStats

type AuthResultStats struct {
	Result string `json:"result"`
	Count  int    `json:"count"`
}

AuthResultStats holds authentication result statistics

type DispositionStats

type DispositionStats struct {
	Disposition string `json:"disposition"`
	Count       int    `json:"count"`
}

DispositionStats holds statistics for a disposition type

type DomainStats

type DomainStats struct {
	Domain            string  `json:"domain"`
	TotalMessages     int     `json:"total_messages"`
	CompliantMessages int     `json:"compliant_messages"`
	ComplianceRate    float64 `json:"compliance_rate"`
}

DomainStats holds statistics for a single domain

type OrgStats

type OrgStats struct {
	OrgName string `json:"org_name"`
	Reports int    `json:"reports"`
}

OrgStats holds statistics for a reporting organization

type ReportSummary

type ReportSummary struct {
	ID                int64  `json:"id"`
	ReportID          string `json:"report_id"`
	OrgName           string `json:"org_name"`
	Domain            string `json:"domain"`
	DateBegin         int64  `json:"date_begin"`
	DateEnd           int64  `json:"date_end"`
	TotalMessages     int    `json:"total_messages"`
	CompliantMessages int    `json:"compliant_messages"`
	// ComplianceRate is null for an RFC 7489 null report (no messages):
	// 0 of 0 is not a 0% pass rate.
	ComplianceRate *float64 `json:"compliance_rate"`
	PolicyP        string   `json:"policy_p"`
	// Status is the backend's verdict for display: empty, pass, warn or fail.
	Status string `json:"status"`
}

type Statistics

type Statistics struct {
	TotalReports      int     `json:"total_reports"`
	TotalMessages     int     `json:"total_messages"`
	CompliantMessages int     `json:"compliant_messages"`
	ComplianceRate    float64 `json:"compliance_rate"`
	// EnforcedMessages counts non-compliant mail the receiver already blocked
	// (disposition reject or quarantine): the published policy working, not
	// an authentication gap.
	EnforcedMessages int `json:"enforced_messages"`
	// DeliveredComplianceRate is the pass rate over mail that was actually
	// delivered (total minus enforced). Null when nothing was delivered.
	DeliveredComplianceRate *float64 `json:"delivered_compliance_rate"`
	// Health is the backend's verdict for the dashboard: nodata, secure,
	// warning or critical.
	Health          string `json:"health"`
	UniqueSourceIPs int    `json:"unique_source_ips"`
	UniqueDomains   int    `json:"unique_domains"`
	HasData         bool   `json:"has_data"`
}

type Storage

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

func NewStorage

func NewStorage(dbPath string) (*Storage, error)

NewStorage creates a new storage instance

func (*Storage) Close

func (s *Storage) Close() error

func (*Storage) GetDKIMStats

func (s *Storage) GetDKIMStats() ([]AuthResultStats, error)

GetDKIMStats returns DKIM authentication result statistics

func (*Storage) GetDispositionStats

func (s *Storage) GetDispositionStats() ([]DispositionStats, error)

GetDispositionStats returns message counts grouped by disposition

func (*Storage) GetDomainStats

func (s *Storage) GetDomainStats() ([]DomainStats, error)

GetDomainStats returns statistics grouped by domain

func (*Storage) GetOrgStats

func (s *Storage) GetOrgStats() ([]OrgStats, error)

GetOrgStats returns statistics grouped by reporting organization

func (*Storage) GetReportByID

func (s *Storage) GetReportByID(id int64) (*parser.Feedback, error)

func (*Storage) GetReports

func (s *Storage) GetReports(limit, offset int) ([]ReportSummary, error)

func (*Storage) GetSPFStats

func (s *Storage) GetSPFStats() ([]AuthResultStats, error)

GetSPFStats returns SPF authentication result statistics

func (*Storage) GetStatistics

func (s *Storage) GetStatistics() (*Statistics, error)

func (*Storage) GetTopSourceIPs

func (s *Storage) GetTopSourceIPs(limit int) ([]TopSourceIP, error)

func (*Storage) SaveReport

func (s *Storage) SaveReport(feedback *parser.Feedback) error

type TopSourceIP

type TopSourceIP struct {
	SourceIP string `json:"source_ip"`
	Count    int    `json:"count"`
	Pass     int    `json:"pass"`
	Fail     int    `json:"fail"`
}

Jump to

Keyboard shortcuts

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