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

move ResolveUnspecifiedAddress(es) and FilterAddrs here from libp2p/go-addr-util #168

Merged
merged 5 commits into from
Dec 21, 2021

Conversation

marten-seemann
Copy link
Contributor

These are the only functions in use from libp2p/go-addr-util. By moving them here, we can deprecate that package.

@marten-seemann marten-seemann marked this pull request as ready for review December 14, 2021 13:33
@marten-seemann marten-seemann changed the title move ResolveUnspecifiedAddress(es) here from libp2p/go-addr-util move ResolveUnspecifiedAddress(es) and FilterAddrs here from libp2p/go-addr-util Dec 14, 2021
net/ip.go Outdated
@@ -95,6 +95,18 @@ func IsIPUnspecified(m ma.Multiaddr) bool {
return net.IP(c.RawValue()).IsUnspecified()
}

// AddrOverNonLocalIP returns whether the addr uses a non-local ip link
func AddrOverNonLocalIP(a ma.Multiaddr) bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a strange function. What about IPv4 localhost?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where we use it: https://github.com/libp2p/go-libp2p-swarm/blob/69f15a70a0caa2ad4f94bfc603f63181b13a40fb/swarm_dial.go#L636-L661

Is there any reason we don't want to dial IPv6 link-local addresses, but are ok with dialing IPv4 localhost?
At least the code here is consistent with the comment in the swarm.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason we don't want to dial IPv6 link-local addresses, but are ok with dialing IPv4 localhost?

Because they're almost always useless while localhost can actually be useful (and is usually only one address). NOTE: I don't think we advertise link-local addresses anymore.

Really, this isn't the right place to do things like this, but it's the only place till we get a real address "scope" system.

At least the code here is consistent with the comment in the swarm.

I'd change it to IsIpv6LinkLocal, or something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, I renamed the function. All (the few) users of that functions will need to adjust the path manually anyway, so this doesn't create too much extra hassle.

@marten-seemann marten-seemann merged commit 114704e into master Dec 21, 2021
@marten-seemann marten-seemann deleted the resolve branch December 21, 2021 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants