mirror of
https://github.com/mjl-/mox.git
synced 2025-07-14 16:14:36 +03:00
admin: better handling of disabled mta-sts during self-check
if admin has disabled mta-sts for a domain, we still check for records & policies, but won't mark it as error when they don't exist. we do now keep warning that mta-sts isn't enabled, otherwise we would start showing a green "ok". this also fixes the mta-sts code returning ErrNoPolicy when mtasts.<domain> doesn't exist. the dns lookup is done with the reguler "net" package dns lookup code, not through adns, so we look for two types of DNSError's. noticed a while ago when testing with MTA-STS while debugging TLS connection issues with MS.
This commit is contained in:
10
dns/dns.go
10
dns/dns.go
@ -5,6 +5,7 @@ package dns
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/net/idna"
|
||||
@ -148,7 +149,9 @@ func ParseDomainLax(s string) (Domain, error) {
|
||||
return Domain{ASCII: s}, nil
|
||||
}
|
||||
|
||||
// IsNotFound returns whether an error is an adns.DNSError with IsNotFound set.
|
||||
// IsNotFound returns whether an error is an adns.DNSError or net.DNSError with
|
||||
// IsNotFound set.
|
||||
//
|
||||
// IsNotFound means the requested type does not exist for the given domain (a
|
||||
// nodata or nxdomain response). It doesn't not necessarily mean no other types for
|
||||
// that name exist.
|
||||
@ -158,6 +161,7 @@ func ParseDomainLax(s string) (Domain, error) {
|
||||
// The adns resolver (just like the Go resolver) returns an IsNotFound error for
|
||||
// both cases, there is no need to explicitly check for zero entries.
|
||||
func IsNotFound(err error) bool {
|
||||
var dnsErr *adns.DNSError
|
||||
return err != nil && errors.As(err, &dnsErr) && dnsErr.IsNotFound
|
||||
var adnsErr *adns.DNSError
|
||||
var dnsErr *net.DNSError
|
||||
return err != nil && (errors.As(err, &adnsErr) && adnsErr.IsNotFound || errors.As(err, &dnsErr) && dnsErr.IsNotFound)
|
||||
}
|
||||
|
Reference in New Issue
Block a user