-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
62 lines (48 loc) · 983 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package main
import (
"bufio"
"encoding/xml"
"flag"
"fmt"
"io"
"os"
)
var xmlFile string
func init() {
flag.StringVar(&xmlFile, "fileName", "", "XML file name. If omitted, stdin will be used")
flag.Parse()
}
func fatal(err ...interface{}) {
fmt.Fprintf(os.Stderr, fmt.Sprint(err...))
fmt.Fprintf(os.Stderr, "\n")
os.Exit(1)
}
func main() {
v := Feedback{}
var content []byte
var err error
if xmlFile == "" {
reader := bufio.NewReader(os.Stdin)
content, err = io.ReadAll(reader)
if err != nil {
fatal(err)
}
} else {
content, err = os.ReadFile(xmlFile)
if err != nil {
fatal(err)
}
}
err = xml.Unmarshal(content, &v)
if err != nil {
fatal(err)
}
for _, record := range v.Records {
if record.AuthResults.Dkim.Result != "pass" {
fatal(fmt.Sprintf("dkim %s", record.AuthResults.Dkim.GetStatus()))
}
if record.AuthResults.Spf.Result != "pass" {
fatal(fmt.Sprintf("spf %s", record.AuthResults.Spf.GetStatus()))
}
}
}