Closed ydnar closed 1 year ago
Thanks for the PR!
Would it make sense to export
lookupAddr
or add aResolver
type to thewasip1
package that can resolve addresses? Given that the underlying syscall is blocking, I’d like to be able to cache DNS lookups and bypass the syscall when opening sockets.At the very least, top-level
LookupIP
andLookupPort
functions that are compatible with the standardnet
package would be useful here. We could also make it so that when you call these functions and thepurego
build tag was specified it just forwards the calls to the standard library.
LookupHost
function that accepts a Context
and returns a slice of stringified IP addresses: https://pkg.go.dev/net#LookupHostpurego
build tag and this package? Does that disable syscalls? (Asking because purego
breaks net.Resolver
entirely, even on gotip.What’s the interaction with the purego build tag and this package? Does that disable syscalls? (Asking because purego breaks net.Resolver entirely, even on gotip.
See https://github.com/stealthrocket/net#name-resolution. It instructs the library to use the non-blocking pure Go resolver rather than the blocking sock_getaddrinfo
system call. Unfortunately the pure Go resolver doesn't work yet, we're waiting on https://go-review.googlesource.com/c/go/+/500579.
This PR makes 3 changes:
hints.flags |= AI_NUMERICHOST
iflookupAddr
is called with an IP address. This allowswasip1.DialContext()
to accept and resolve an IP address.hints.flags |= AI_NUMERICSERV
iflookupAddr
is called with a port number. This optimizes handling of numeric service / port numbers.getaddrinfo
. This allowsgetaddrinfo
to correctly return an IPv6 address.Would it make sense to export
lookupAddr
or add aResolver
type to thewasip1
package that can resolve addresses? Given that the underlying syscall is blocking, I’d like to be able to cache DNS lookups and bypass the syscall when opening sockets.