checker: define Resolution verdict constants to make the collect/evaluate contract explicit
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
355f2b92eb
commit
62e85a155e
3 changed files with 23 additions and 12 deletions
|
|
@ -76,7 +76,7 @@ func (p *danglingProvider) Collect(ctx context.Context, opts sdk.CheckerOptions)
|
|||
seen[key] = true
|
||||
classifyExternal(&pt, zoneRegistrable)
|
||||
if skipResolution {
|
||||
pt.Resolution = "skipped"
|
||||
pt.Resolution = ResolutionSkipped
|
||||
} else {
|
||||
pt.Resolution, pt.ResolutionDetail = resolveHost(ctx, pt.Target)
|
||||
}
|
||||
|
|
@ -287,7 +287,7 @@ func classifyExternal(pt *Pointer, zoneRegistrable string) {
|
|||
func defaultResolveHost(ctx context.Context, target string) (verdict, detail string) {
|
||||
target = strings.TrimSuffix(target, ".")
|
||||
if target == "" {
|
||||
return "skipped", "empty target"
|
||||
return ResolutionSkipped, "empty target"
|
||||
}
|
||||
cctx, cancel := context.WithTimeout(ctx, resolverTimeout)
|
||||
defer cancel()
|
||||
|
|
@ -295,25 +295,25 @@ func defaultResolveHost(ctx context.Context, target string) (verdict, detail str
|
|||
ips, err := net.DefaultResolver.LookupHost(cctx, target)
|
||||
if err == nil {
|
||||
if len(ips) == 0 {
|
||||
return "no_answer", ""
|
||||
return ResolutionNoAnswer, ""
|
||||
}
|
||||
return "ok", ""
|
||||
return ResolutionOK, ""
|
||||
}
|
||||
|
||||
var dnsErr *net.DNSError
|
||||
if errors.As(err, &dnsErr) {
|
||||
switch {
|
||||
case dnsErr.IsNotFound:
|
||||
return "nxdomain", dnsErr.Err
|
||||
return ResolutionNXDomain, dnsErr.Err
|
||||
case dnsErr.IsTimeout:
|
||||
return "timeout", dnsErr.Err
|
||||
return ResolutionTimeout, dnsErr.Err
|
||||
case strings.Contains(strings.ToLower(dnsErr.Err), "servfail"):
|
||||
return "servfail", dnsErr.Err
|
||||
return ResolutionServFail, dnsErr.Err
|
||||
default:
|
||||
return "error", dnsErr.Err
|
||||
return ResolutionError, dnsErr.Err
|
||||
}
|
||||
}
|
||||
return "error", err.Error()
|
||||
return ResolutionError, err.Error()
|
||||
}
|
||||
|
||||
// ownerFQDN returns the record owner FQDN, preferring the service's _domain field over subdomain+apex.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue