mirror of
https://github.com/mjl-/mox.git
synced 2024-12-27 08:53:48 +03:00
fix problem with spf where we would generate errors about too many void lookups
the problem was that we only looked up either the ipv4 or ipv6 address when evaluating spf directives, depending on the incoming smtp connection. for example, for spf directive "a", we would lookup the requested domain. if that domain has an ipv4 address but no ipv6 address, and the incoming connection is ipv6, we would count a void lookup. but we shouldn't: there is a record for that name, it just doesn't match the address (family).
This commit is contained in:
parent
1073ca2795
commit
30c79faff2
1 changed files with 3 additions and 15 deletions
18
spf/spf.go
18
spf/spf.go
|
@ -338,11 +338,7 @@ func evaluate(ctx context.Context, record *Record, resolver dns.Resolver, args A
|
||||||
|
|
||||||
// Used for "a" and "mx".
|
// Used for "a" and "mx".
|
||||||
checkHostIP := func(domain dns.Domain, d Directive, args *Args) (bool, Status, error) {
|
checkHostIP := func(domain dns.Domain, d Directive, args *Args) (bool, Status, error) {
|
||||||
network := "ip4"
|
ips, err := resolver.LookupIP(ctx, "ip", domain.ASCII+".")
|
||||||
if remote6 != nil {
|
|
||||||
network = "ip6"
|
|
||||||
}
|
|
||||||
ips, err := resolver.LookupIP(ctx, network, domain.ASCII+".")
|
|
||||||
trackVoidLookup(err, args)
|
trackVoidLookup(err, args)
|
||||||
// If "not found", we must ignore the error and treat as zero records in answer. ../rfc/7208:1116
|
// If "not found", we must ignore the error and treat as zero records in answer. ../rfc/7208:1116
|
||||||
if err != nil && !dns.IsNotFound(err) {
|
if err != nil && !dns.IsNotFound(err) {
|
||||||
|
@ -478,11 +474,7 @@ func evaluate(ctx context.Context, record *Record, resolver dns.Resolver, args A
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
lookups++
|
lookups++
|
||||||
network := "ip4"
|
ips, err := resolver.LookupIP(ctx, "ip", rd.ASCII+".")
|
||||||
if remote6 != nil {
|
|
||||||
network = "ip6"
|
|
||||||
}
|
|
||||||
ips, err := resolver.LookupIP(ctx, network, rd.ASCII+".")
|
|
||||||
trackVoidLookup(err, &args)
|
trackVoidLookup(err, &args)
|
||||||
for _, ip := range ips {
|
for _, ip := range ips {
|
||||||
if checkIP(ip, d) {
|
if checkIP(ip, d) {
|
||||||
|
@ -669,11 +661,7 @@ func expandDomainSpec(ctx context.Context, resolver dns.Resolver, domainSpec str
|
||||||
if !matchfn(name) {
|
if !matchfn(name) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
network := "ip4"
|
ips, err := resolver.LookupIP(ctx, "ip", name)
|
||||||
if args.RemoteIP.To4() == nil {
|
|
||||||
network = "ip6"
|
|
||||||
}
|
|
||||||
ips, err := resolver.LookupIP(ctx, network, name)
|
|
||||||
trackVoidLookup(err, &args)
|
trackVoidLookup(err, &args)
|
||||||
// ../rfc/7208:1714, we don't have to check other errors.
|
// ../rfc/7208:1714, we don't have to check other errors.
|
||||||
for _, ip := range ips {
|
for _, ip := range ips {
|
||||||
|
|
Loading…
Reference in a new issue