Skip to content

Commit 9dff879

Browse files
committed
in domain/dns self-check, for unused services, check that port is 0 like how we told users to configure it and fix checking for errors during srv lookups
1 parent 1c4bf89 commit 9dff879

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

webadmin/admin.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,8 @@ func unptr[T any](l []*T) []T {
462462
func checkDomain(ctx context.Context, resolver dns.Resolver, dialer *net.Dialer, domainName string) (r CheckResult) {
463463
log := pkglog.WithContext(ctx)
464464

465-
domain, err := dns.ParseDomain(domainName)
466-
xcheckuserf(ctx, err, "parsing domain")
465+
domain, xerr := dns.ParseDomain(domainName)
466+
xcheckuserf(ctx, xerr, "parsing domain")
467467

468468
domConf, ok := mox.Conf.Domain(domain)
469469
if !ok {
@@ -1416,6 +1416,13 @@ When enabling MTA-STS, or updating a policy, always update the policy first (thr
14161416
{name: "_pop3", port: 110, host: "."},
14171417
{name: "_pop3s", port: 995, host: "."},
14181418
}
1419+
// Host "." indicates the service is not available. We suggested in the DNS records
1420+
// that the port be set to 0, so check for that. ../rfc/6186:242
1421+
for i := range reqs {
1422+
if reqs[i].host == "." {
1423+
reqs[i].port = 0
1424+
}
1425+
}
14191426
var srvwg sync.WaitGroup
14201427
srvwg.Add(len(reqs))
14211428
for i := range reqs {
@@ -1436,8 +1443,8 @@ When enabling MTA-STS, or updating a policy, always update the policy first (thr
14361443
}
14371444
instr += fmt.Sprintf("\t%s._tcp.%-*s SRV 0 %d %d %s\n", req.name, len("_submissions")-len(req.name)+len(domain.ASCII+"."), domain.ASCII+".", weight, req.port, req.host)
14381445
r.SRVConf.SRVs[req.name] = unptr(req.srvs)
1439-
if err != nil {
1440-
addf(&r.SRVConf.Errors, "Looking up SRV record %q: %s", name, err)
1446+
if req.err != nil {
1447+
addf(&r.SRVConf.Errors, "Looking up SRV record %q: %s", name, req.err)
14411448
} else if len(req.srvs) == 0 {
14421449
if req.host == "." {
14431450
addf(&r.SRVConf.Warnings, "Missing optional SRV record %q", name)

0 commit comments

Comments
 (0)