Skip to content

Commit 999f438

Browse files
committed
authres: add support for ARC
1 parent 67505da commit 999f438

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

authres/parse.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package authres
22

33
import (
44
"errors"
5+
"fmt"
6+
"strconv"
57
"strings"
68
"unicode"
79
)
@@ -186,6 +188,42 @@ func (r *DMARCResult) format() (ResultValue, map[string]string) {
186188
}
187189
}
188190

191+
type ARCResult struct {
192+
Value ResultValue
193+
RemoteIP string
194+
OldestPass int
195+
}
196+
197+
func (r *ARCResult) parse(value ResultValue, params map[string]string) error {
198+
var oldestPass int
199+
if s, ok := params["header.oldest-pass"]; ok {
200+
var err error
201+
oldestPass, err = strconv.Atoi(s)
202+
if err != nil {
203+
return fmt.Errorf("invalid header.oldest-pass param: %v", err)
204+
} else if oldestPass <= 0 {
205+
return fmt.Errorf("invalid header.oldest-pass param: must be >= 1")
206+
}
207+
}
208+
209+
r.Value = value
210+
r.RemoteIP = params["smtp.remote-ip"]
211+
r.OldestPass = oldestPass
212+
return nil
213+
}
214+
215+
func (r *ARCResult) format() (ResultValue, map[string]string) {
216+
var oldestPass string
217+
if r.OldestPass > 0 {
218+
oldestPass = strconv.Itoa(r.OldestPass)
219+
}
220+
221+
return r.Value, map[string]string{
222+
"smtp.remote-ip": r.RemoteIP,
223+
"header.oldest-pass": oldestPass,
224+
}
225+
}
226+
189227
type GenericResult struct {
190228
Method string
191229
Value ResultValue
@@ -205,6 +243,9 @@ func (r *GenericResult) format() (ResultValue, map[string]string) {
205243
type newResultFunc func() Result
206244

207245
var results = map[string]newResultFunc{
246+
"arc": func() Result {
247+
return new(ARCResult)
248+
},
208249
"auth": func() Result {
209250
return new(AuthResult)
210251
},

0 commit comments

Comments
 (0)