give delivering to mx targets with underscores in name a chance of succeeding

the underscores aren't valid, but have been seen in the wild, so we have a
workaround for them. there are limitations, it won't work with idna domains.
and if the domain has other policies, like mta-sts, the mx host won't pass
either.

after report from richard g about delivery issue, thanks!
This commit is contained in:
Mechiel Lukkien
2023-10-25 13:01:11 +02:00
parent 682f8a0904
commit d1e93020d8
4 changed files with 68 additions and 13 deletions

View File

@ -444,7 +444,8 @@ func evaluate(ctx context.Context, record *Record, resolver dns.Resolver, args A
if i >= 10 {
return StatusPermerror, d.MechanismString(), "", rauthentic, ErrTooManyDNSRequests
}
mxd, err := dns.ParseDomain(strings.TrimSuffix(mx.Host, "."))
// Parsing lax (unless in pedantic mode) for MX targets with underscores as seen in the wild.
mxd, err := dns.ParseDomainLax(strings.TrimSuffix(mx.Host, "."))
if err != nil {
return StatusPermerror, d.MechanismString(), "", rauthentic, err
}