Documentation ¶
Overview ¶
Package dmarc contains reader and parser for DMARC xml reports.
Index ¶
- Constants
- type AuthResults
- type DKIMAuthResult
- type DateRange
- type DateTime
- type Identifiers
- type MessagesStats
- type PolicyEvaluated
- type PolicyPublished
- type Record
- type Report
- func Parse(b []byte, lookupAddr bool) (Report, error)
- func ReadParse(r io.Reader, lookupAddr bool) (Report, error)
- func ReadParseGZIP(r io.Reader, lookupAddr bool) (Report, error)
- func ReadParseXML(r io.Reader, lookupAddr bool) (Report, error)
- func ReadParseZIP(r io.Reader, lookupAddr bool) (Report, error)
- type ReportMetadata
- type Row
- type SPFAuthResult
Constants ¶
const ( // MimeTypeGZIP is the mimetype for *.gz files MimeTypeGZIP = "application/x-gzip" // MimeTypeZIP is the mimetype for *.zip files MimeTypeZIP = "application/zip" // MimeTypeXML is the mimetype for *.xml files MimeTypeXML = "text/xml" )
const ReportIDDateTime = "2006-01-02"
ReportIDDateTime is the DateTime format for Report.ID
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthResults ¶
type AuthResults struct { DKIM DKIMAuthResult `xml:"dkim" json:"dkim"` SPF SPFAuthResult `xml:"spf" json:"spf"` }
AuthResults represents feedback>record>auth_results section
type DKIMAuthResult ¶
type DKIMAuthResult struct { Domain string `xml:"domain" json:"domain"` Result string `xml:"result" json:"result"` Selector string `xml:"selector" json:"selector"` }
DKIMAuthResult represnets feedback>record>auth_results>dkim sections
type DateRange ¶
type DateRange struct { Begin DateTime `xml:"begin" json:"begin"` End DateTime `xml:"end" json:"end"` }
DateRange represents feedback>report_metadata>date_range section
type DateTime ¶
DateTime is the custom time for DateRange.Begin and DateRange.End values
func (*DateTime) UnmarshalXML ¶
UnmarshalXML unmarshals unix timestamp to time.Time
type Identifiers ¶
type Identifiers struct { HeaderFrom string `xml:"header_from" json:"header_from"` EnvelopeFrom string `xml:"envelope_from" json:"envelope_from"` }
Identifiers represents feedback>record>identifiers section
type MessagesStats ¶
type MessagesStats struct { // All it is the total amount of email messages All int `json:"all"` // Failed it is the total amount of failed email messages Failed int `json:"failed"` // Passed it is the total amount of passed email messages Passed int `json:"passed"` // PassedPercent it is the percent of passed email messages PassedPercent float64 `json:"passed_percent"` }
MessagesStats includes some statistic calculated from report.
type PolicyEvaluated ¶
type PolicyEvaluated struct { Disposition string `xml:"disposition" json:"disposition"` DKIM string `xml:"dkim" json:"dkim"` SPF string `xml:"spf" json:"spf"` }
PolicyEvaluated represents feedback>record>row>policy_evaluated section
type PolicyPublished ¶
type PolicyPublished struct { Domain string `xml:"domain" json:"domain"` ADKIM string `xml:"adkim" json:"adkim"` ASPF string `xml:"aspf" json:"aspf"` Policy string `xml:"p" json:"p"` SPolicy string `xml:"sp" json:"sp"` Pct string `xml:"pct" json:"pct"` }
PolicyPublished represents feedback>policy_published section
type Record ¶
type Record struct { Row Row `xml:"row"` Identifiers Identifiers `xml:"identifiers"` AuthResults AuthResults `xml:"auth_results"` }
Record represents feedback>record section
func (Record) MarshalJSON ¶
MarshalJSON marshals Record struct to json, adds additional "_is_passed" field.
type Report ¶
type Report struct { XMLName xml.Name `xml:"feedback"` ReportMetadata ReportMetadata `xml:"report_metadata"` PolicyPublished PolicyPublished `xml:"policy_published"` Records []Record `xml:"record"` MessagesStats MessagesStats }
Report represents root of dmarc report struct
func Parse ¶
Parse parses input xml data b to Report struct. If lookupAddr is true, performs a reverse lookups for feedback>record>row>source_ip
func ReadParse ¶ added in v0.6.2
ReadParse reads any data from reader r, detects mimetype, and parses it to Report struct (if mimetype is supported). If lookupAddr is true, performs reverse lookups for feedback>record>row>source_ip
func ReadParseGZIP ¶
ReadParseGZIP reads gzipped xml data from r and parses it to Report struct. If lookupAddr is true, performs a reverse lookups for feedback>record>row>source_ip
func ReadParseXML ¶
ReadParseXML reads xml data from r and parses it to Report struct. If lookupAddr is true, performs a reverse lookups for feedback>record>row>source_ip
func ReadParseZIP ¶
ReadParseZIP reads zipped xml data from r and parses it to Report struct. If lookupAddr is true, performs a reverse lookups for feedback>record>row>source_ip
func (*Report) CalculateStats ¶
func (r *Report) CalculateStats()
CalculateStats calculates messages statistic and updates Records.MessagesStats struct.
func (Report) ID ¶
ID returns report identifier with format YEAR-MONTH-DAY-DOMAIN/EMAIL-ID (can be used in config to calculate filename), where date is the begin date of report.
func (Report) MarshalJSON ¶
MarshalJSON calculates report messages statistic and marshals Report struct to json, adds this statistic as additional fields:
"messages_stats" { "all": 0, "failed": 0, "passed": 0, "passed_percent": 0, }
func (*Report) MergeRecord ¶
MergeRecord merges new record rec to the report r.
func (*Report) MergeReport ¶
MergeReport merges another report rep to the report r. Keeps the earliest Begin date and the oldest End date. Merges all records from report rep to the r. Doesn't touch another r fields.
func (*Report) SortRecords ¶
func (r *Report) SortRecords()
SortRecords sorts records list by Row.Count
type ReportMetadata ¶
type ReportMetadata struct { OrgName string `xml:"org_name" json:"org_name"` Email string `xml:"email" json:"email"` ExtraContactInfo string `xml:"extra_contact_info" json:"extra_contact_info"` ReportID string `xml:"report_id" json:"report_id"` DateRange DateRange `xml:"date_range" json:"date_range"` }
ReportMetadata represents feedback>report_metadata section
type Row ¶
type Row struct { SourceIP string `xml:"source_ip" json:"source_ip"` Count int `xml:"count" json:"count"` PolicyEvaluated PolicyEvaluated `xml:"policy_evaluated" json:"policy_evaluated"` SourceHostname string `json:"source_hostname"` }
Row represents feedback>record>row section
type SPFAuthResult ¶
type SPFAuthResult struct { Domain string `xml:"domain" json:"domain"` Result string `xml:"result" json:"result"` Scope string `xml:"scope" json:"scope"` }
SPFAuthResult represnets feedback>record>auth_results>spf section