1
0
mirror of https://github.com/golang/go synced 2024-11-18 11:55:01 -07:00

also treat _WSAHOST_NOT_FOUND as unknown port

Change-Id: I4a3c716c679d327b893cd670ddee12a51fd922ed
This commit is contained in:
Mateusz Poliwczak 2023-09-28 10:04:25 +02:00
parent 829a996be1
commit 48a13fe5f5

View File

@ -220,9 +220,10 @@ func (r *Resolver) lookupPort(ctx context.Context, network, service string) (int
}
// The _WSATYPE_NOT_FOUND error is returned by GetAddrInfoW
// when the service name is unknown, instead of the _WSAHOST_NOT_FOUND
// used by the winError function.
if e == _WSATYPE_NOT_FOUND {
// when the service name is unknown. We are also checking
// for _WSAHOST_NOT_FOUND here to match the cgo (unix) version
// cgo_unix.go (cgoLookupServicePort).
if e == _WSATYPE_NOT_FOUND || e == _WSAHOST_NOT_FOUND {
return 0, &DNSError{Err: "unknown port", Name: network + "/" + service, IsNotFound: true}
}
err := os.NewSyscallError("getaddrinfow", e)