@@ -2,6 +2,8 @@ package authres
2
2
3
3
import (
4
4
"errors"
5
+ "fmt"
6
+ "strconv"
5
7
"strings"
6
8
"unicode"
7
9
)
@@ -186,6 +188,42 @@ func (r *DMARCResult) format() (ResultValue, map[string]string) {
186
188
}
187
189
}
188
190
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
+
189
227
type GenericResult struct {
190
228
Method string
191
229
Value ResultValue
@@ -205,6 +243,9 @@ func (r *GenericResult) format() (ResultValue, map[string]string) {
205
243
type newResultFunc func () Result
206
244
207
245
var results = map [string ]newResultFunc {
246
+ "arc" : func () Result {
247
+ return new (ARCResult )
248
+ },
208
249
"auth" : func () Result {
209
250
return new (AuthResult )
210
251
},
0 commit comments