Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions internal/dns/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ func (o Outcome) String() string {
return "error"
}

// refusedText is the DNSError.Err that marks a response carrying RCODE
// REFUSED. Socket errors such as "connection refused" must not match.
const refusedText = "server refused the query (REFUSED)"

// Classify maps a resolver error onto a coarse outcome so callers can tell a
// definitive negative (NXDOMAIN) apart from an infrastructure failure.
func Classify(err error) Outcome {
Expand All @@ -98,7 +102,7 @@ func Classify(err error) Outcome {
case de.IsTimeout:
return OutcomeTimeout
}
if strings.Contains(strings.ToLower(de.Err), "refused") {
if de.Err == refusedText {
return OutcomeRefused
}
}
Expand Down Expand Up @@ -222,7 +226,7 @@ func (b *wireBudget) fixErr(err error) error {
cp.Server = s
}
if b.refused.Load() && Classify(err) == OutcomeOther {
cp.Err = "server refused the query (REFUSED)"
cp.Err = refusedText
}
return &cp
}
Expand Down Expand Up @@ -641,4 +645,4 @@ func (l Lookup) checkWildcard(ctx context.Context, domain string, probes int, sa
}
}
return true, fp, nil
}
}