Skip to content

feature: provide InterfaceMultiaddrsFor #275

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tobil4sk
Copy link

net.InterfaceAddrs calls fail on android. This function allows specifying your own set of addresses, so another api can be used to avoid the issue.

See: #255 (comment)

Closes #255

net.InterfaceAddrs calls fail on android. This function allows
specifying your own set of addresses, so another api can be used to
avoid the issue.
@MarcoPolo
Copy link
Contributor

Is the idea that you'll override these functions with go:linkname?

@tobil4sk
Copy link
Author

The way I'm using it is to always use InterfaceMultiaddrsFor instead of InterfaceMultiaddrs, which allows any api to be used to get the addresses.

I'm quite new to go so I'm not familiar with go:linkname. This is how I've patch a library that relies on go-multiaddr in line with this change: libp2p/go-libp2p#3236

@MarcoPolo
Copy link
Contributor

Can you show me how you'll use this change? I'm having a hard time understanding how exposing InterfaceMultiaddrsFor helps here. Thanks

@tobil4sk
Copy link
Author

Can you show me how you'll use this change? I'm having a hard time understanding how exposing InterfaceMultiaddrsFor helps here. Thanks

Instead of relying on InterfaceMultiaddrs, a slice of net.Addr can be passed into InterfaceMultiaddrsFor which allows the caller to decide how to determine the addresses. See the line:
https://github.com/libp2p/go-libp2p/pull/3236/files#diff-46c1cc328c2b33cbdce1bc123a2d6e06f5afc4758186638f9320673f8595ab0bR523

Additionally, when using manet.ResolveUnspecifiedAddresses, you have to avoid passing nil as the second argument to prevent it from calling InterfaceMultiaddrs internally. E.g.:
https://github.com/libp2p/go-libp2p/pull/3236/files#diff-e544d19687434c7b654de15689302596c5159444ad1db181f7096473eb42e8f3R56-R68

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.

2 participants