A Go (golang) module for handling Email DMARC summary reports.
Written by George Starcher
MIT license, check license.txt for more information
All text above must be included in any redistribution
go get github.com/georgestarcher/dmarcgo- Make a Report object
- Set the path to the report file
- Call the LoadReportFile() method. This method will try to load the file as a gzip, zip then zlib compressed file automatically.
In your Go app you can do something like the below. You can use the json.Marshal of the Features() method to send the unspooled summary report file to a system such as Splunk etc for processing.
package main
import (
"dmarc"
"encoding/json"
"fmt"
"log"
"utilities"
)
func main() {
report_directory := "../../reports/dmarc/"
report_files, err := utilities.GetFiles(report_directory)
if err != nil {
log.Fatal(err)
}
dmarcReport := new(dmarc.Report)
for _, file := range report_files {
dmarcReport.FilePath = fmt.Sprintf("%+v%+v", report_directory, file)
fmt.Printf("Called on: %+v\n", dmarcReport.FilePath)
err = dmarcReport.LoadReportFile()
if err != nil {
log.Fatal(err)
}
for _, report := range dmarcReport.Content.Features() {
feature_json, err := json.Marshal(report)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(feature_json))
}
}
}