func handlePlan9DNSError(err error, name string) error {
if stringsHasSuffix(err.Error(), "dns: name does not exist") ||
stringsHasSuffix(err.Error(), "dns: resource does not exist; negrcode 0") ||
- stringsHasSuffix(err.Error(), "dns: resource does not exist; negrcode") {
- return &DNSError{
- Err: errNoSuchHost.Error(),
- Name: name,
- IsNotFound: true,
- }
- }
- return &DNSError{
- Err: err.Error(),
- Name: name,
+ stringsHasSuffix(err.Error(), "dns: resource does not exist; negrcode") ||
+ stringsHasSuffix(err.Error(), "dns failure") {
+ err = errNoSuchHost
}
+ return newDNSError(err, name, "")
}
// toLower returns a lower-case version of in. Restricting us to
// host names in local network (e.g. from /lib/ndb/local)
lines, err := queryCS(ctx, "net", host, "1")
if err != nil {
- if stringsHasSuffix(err.Error(), "dns failure") {
- err = errNoSuchHost
- }
- return nil, newDNSError(err, host, "")
+ return nil, handlePlan9DNSError(err, host)
}
loop:
for _, line := range lines {
}
func TestDNSErrorUnwrap(t *testing.T) {
+ if runtime.GOOS == "plan9" {
+ // The Plan 9 implementation of the resolver doesn't use the Dial function yet. See https://go.dev/cl/409234
+ t.Skip("skipping on plan9")
+ }
rDeadlineExcceeded := &Resolver{PreferGo: true, Dial: func(ctx context.Context, network, address string) (Conn, error) {
return nil, context.DeadlineExceeded
}}