wip: restore transport-failure classification coverage
check / check (push) Failing after 21s

This commit is contained in:
clawbot
2026-09-03 22:51:30 +00:00
parent 62dec447e3
commit 240c1bd393
3 changed files with 274 additions and 10 deletions
+18 -1
View File
@@ -20,6 +20,10 @@ const (
minDomainLabels = 2
)
// defaultDNSPort is the port a nameserver is assumed to listen on
// when its address does not carry one.
const defaultDNSPort = "53"
// ErrRefused is returned when a DNS server refuses a query.
var ErrRefused = errors.New("dns query refused")
@@ -106,6 +110,19 @@ func (r *Resolver) retryTCP(
return resp
}
// nameserverAddr renders a nameserver address for dialling. A bare
// address — the normal case, and what a delegation's glue records
// carry — is given the default DNS port. An address that already
// specifies a port is dialled as written, which is what makes a
// nameserver listening somewhere other than 53 reachable.
func nameserverAddr(nsIP string) string {
if _, _, err := net.SplitHostPort(nsIP); err == nil {
return nsIP
}
return net.JoinHostPort(nsIP, defaultDNSPort)
}
// queryDNS sends a DNS query to a specific server IP.
// Tries non-recursive first, falls back to recursive on
// REFUSED (handles DNS interception environments).
@@ -120,7 +137,7 @@ func (r *Resolver) queryDNS(
}
name = dns.Fqdn(name)
addr := net.JoinHostPort(serverIP, "53")
addr := nameserverAddr(serverIP)
msg := new(dns.Msg)
msg.SetQuestion(name, qtype)