Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: net: add (*Resolver).ResolveIPAddr #30452

Open
iangudger opened this Issue Feb 28, 2019 · 4 comments

Comments

Projects
None yet
5 participants
@iangudger
Copy link
Contributor

iangudger commented Feb 28, 2019

In the net package, there are two classes of DNS functions: LookupXxx and ResolveXxx. The net.Resolver type implements the LookupXxx functions as methods, but not the ResolveXxx functions. The ResolveXxx functions are similar to LookupHost, except they allow specifying a network. Adding the ResolveXxx functions as methods will allow a net.Resolver to fully replace the global DNS functions.

@gopherbot gopherbot added this to the Proposal milestone Feb 28, 2019

@gopherbot gopherbot added the Proposal label Feb 28, 2019

@bcmills

This comment has been minimized.

Copy link
Member

bcmills commented Feb 28, 2019

@bradfitz

This comment has been minimized.

Copy link
Member

bradfitz commented Feb 28, 2019

I'm fine with that on principle. I'd never noticed you couldn't do IPv4- vs IPv6-specific lookups on Resolver before. That is, you can't do the equivalent of this today on Resolver:

func main() {
        fmt.Println(net.ResolveIPAddr("ip4", "google.com"))
        fmt.Println(net.ResolveIPAddr("ip6", "google.com"))
}

The name Resolver.ResolveIPAddr is a bit stuttery but probably best for consistency. But I'd also be fine with Resolver.LookupNetIPAddr or something.

@rsc

This comment has been minimized.

Copy link
Contributor

rsc commented Mar 6, 2019

It's unclear why we should add net.Resolver.ResolveIPAddr; why not just use LookupIPAddr and filter out what you want? ResolveIPAddr is just LookupIPAddr plus client-side filtering anyway. It's not any fewer bits on the wire.

@iangudger

This comment has been minimized.

Copy link
Contributor Author

iangudger commented Mar 6, 2019

Sure, it can be done, but it would be nice to not make everyone who wants it re-implement it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.