-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtypes.go
More file actions
112 lines (95 loc) · 2.27 KB
/
types.go
File metadata and controls
112 lines (95 loc) · 2.27 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package anotherspf
import (
"context"
"net"
"sync"
)
type Result string
type Modifier string
type Mechanism string
type Qualifier string
type lookupLimitError struct {
Message string
}
type dnsRecord string
const (
dnsA = dnsRecord("a")
dnsTxt = dnsRecord("txt")
dnsMx = dnsRecord("mx")
)
const (
QPass = Qualifier("+")
QFail = Qualifier("-")
QSoftFail = Qualifier("~")
QNeutral = Qualifier("?")
)
const (
MAll = Mechanism("all")
MInclude = Mechanism("include")
MA = Mechanism("a")
MMx = Mechanism("mx")
MPtr = Mechanism("ptr")
MIp4 = Mechanism("ip4")
MIp6 = Mechanism("ip6")
MExists = Mechanism("exists")
)
const (
ModRedirect = Modifier("redirect")
ModExplanation = Modifier("exp")
ModUnknow = Modifier("unknown-modifier")
)
const (
Pass = Result("pass")
Neutral = Result("neutral")
Fail = Result("fail")
SoftFail = Result("softfail")
TempError = Result("temperror")
PermError = Result("permerror")
None = Result("none")
)
var AllowedDNSLookups = 10
var QualifierResultByStatus = map[Qualifier]Result{
QFail: Fail,
QNeutral: Neutral,
QPass: Pass,
QSoftFail: SoftFail,
}
type SPFInfo struct {
LookupCount int
Lookups map[string]*Lookup
lookedDns map[string]bool
Status Result
PassedRule *Rule
Rule []*Rule
Record string
mu sync.Mutex
resolver DNSResolver
}
type DNSResolver interface {
LookupTXT(ctx context.Context, host string) ([]string, error)
LookupIP(ctx context.Context, host string) ([]net.IP, error)
LookupMX(ctx context.Context, name string) ([]*net.MX, error)
}
type Lookup struct {
A bool
TXT bool
MX bool
}
type Rule struct {
Modifier Modifier
Mechanism Mechanism
Qualifier Qualifier
ContainsMacro bool
Key string
Value string
}
type MacroContext struct {
Sender string // %{s} Sender’s email address (e.g., "user@example.com")
IP string // %{i} IP address of the sending mail server
Helo string // %{h} HELO/EHLO domain used in SMTP
Domain string // %{o} Sender’s domain (part after @ in email address)
Authoritative string // %{d} Authoritative sending domain (SPF record owner)
}
func (le *lookupLimitError) Error() string {
return le.Message
}